1be1d678aSKris Buschelman 283287d42SBarry Smith /* 383287d42SBarry Smith Factorization code for BAIJ format. 483287d42SBarry Smith */ 5c6db04a5SJed Brown #include <../src/mat/impls/baij/seq/baij.h> 6c6db04a5SJed Brown #include <../src/mat/blockinvert.h> 783287d42SBarry Smith /* 883287d42SBarry Smith Version for when blocks are 7 by 7 983287d42SBarry Smith */ 104a2ae208SSatish Balay #undef __FUNCT__ 1106e38f1dSHong Zhang #define __FUNCT__ "MatLUFactorNumeric_SeqBAIJ_7_inplace" 1206e38f1dSHong Zhang PetscErrorCode MatLUFactorNumeric_SeqBAIJ_7_inplace(Mat C,Mat A,const MatFactorInfo *info) 1383287d42SBarry Smith { 1483287d42SBarry Smith Mat_SeqBAIJ *a = (Mat_SeqBAIJ*)A->data,*b = (Mat_SeqBAIJ*)C->data; 1583287d42SBarry Smith IS isrow = b->row,isicol = b->icol; 166849ba73SBarry Smith PetscErrorCode ierr; 175d0c19d7SBarry Smith const PetscInt *r,*ic,*bi = b->i,*bj = b->j,*ajtmp,*diag_offset = b->diag,*ai=a->i,*aj=a->j,*pj,*ajtmpold; 185d0c19d7SBarry Smith PetscInt i,j,n = a->mbs,nz,row,idx; 1983287d42SBarry Smith MatScalar *pv,*v,*rtmp,*pc,*w,*x; 2083287d42SBarry Smith MatScalar p1,p2,p3,p4,m1,m2,m3,m4,m5,m6,m7,m8,m9,x1,x2,x3,x4; 2183287d42SBarry Smith MatScalar p5,p6,p7,p8,p9,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16; 2283287d42SBarry Smith MatScalar x17,x18,x19,x20,x21,x22,x23,x24,x25,p10,p11,p12,p13,p14; 2383287d42SBarry Smith MatScalar p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,m10,m11,m12; 2483287d42SBarry Smith MatScalar m13,m14,m15,m16,m17,m18,m19,m20,m21,m22,m23,m24,m25; 2583287d42SBarry Smith MatScalar p26,p27,p28,p29,p30,p31,p32,p33,p34,p35,p36; 2683287d42SBarry Smith MatScalar p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p47,p48,p49; 2783287d42SBarry Smith MatScalar x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36; 2883287d42SBarry Smith MatScalar x37,x38,x39,x40,x41,x42,x43,x44,x45,x46,x47,x48,x49; 2983287d42SBarry Smith MatScalar m26,m27,m28,m29,m30,m31,m32,m33,m34,m35,m36; 3083287d42SBarry Smith MatScalar m37,m38,m39,m40,m41,m42,m43,m44,m45,m46,m47,m48,m49; 3183287d42SBarry Smith MatScalar *ba = b->a,*aa = a->a; 32182b8fbaSHong Zhang PetscReal shift = info->shiftamount; 3383287d42SBarry Smith 3483287d42SBarry Smith PetscFunctionBegin; 3583287d42SBarry Smith ierr = ISGetIndices(isrow,&r);CHKERRQ(ierr); 3683287d42SBarry Smith ierr = ISGetIndices(isicol,&ic);CHKERRQ(ierr); 37b0a32e0cSBarry Smith ierr = PetscMalloc(49*(n+1)*sizeof(MatScalar),&rtmp);CHKERRQ(ierr); 3883287d42SBarry Smith 3983287d42SBarry Smith for (i=0; i<n; i++) { 4083287d42SBarry Smith nz = bi[i+1] - bi[i]; 4183287d42SBarry Smith ajtmp = bj + bi[i]; 4283287d42SBarry Smith for (j=0; j<nz; j++) { 4383287d42SBarry Smith x = rtmp+49*ajtmp[j]; 4483287d42SBarry Smith x[0] = x[1] = x[2] = x[3] = x[4] = x[5] = x[6] = x[7] = x[8] = x[9] = 0.0; 4583287d42SBarry Smith x[10] = x[11] = x[12] = x[13] = x[14] = x[15] = x[16] = x[17] = 0.0; 4683287d42SBarry Smith x[18] = x[19] = x[20] = x[21] = x[22] = x[23] = x[24] = x[25] = 0.0; 4783287d42SBarry Smith x[26] = x[27] = x[28] = x[29] = x[30] = x[31] = x[32] = x[33] = 0.0; 4883287d42SBarry Smith x[34] = x[35] = x[36] = x[37] = x[38] = x[39] = x[40] = x[41] = 0.0; 4983287d42SBarry Smith x[42] = x[43] = x[44] = x[45] = x[46] = x[47] = x[48] = 0.0; 5083287d42SBarry Smith } 5183287d42SBarry Smith /* load in initial (unfactored row) */ 5283287d42SBarry Smith idx = r[i]; 5383287d42SBarry Smith nz = ai[idx+1] - ai[idx]; 5483287d42SBarry Smith ajtmpold = aj + ai[idx]; 5583287d42SBarry Smith v = aa + 49*ai[idx]; 5683287d42SBarry Smith for (j=0; j<nz; j++) { 5783287d42SBarry Smith x = rtmp+49*ic[ajtmpold[j]]; 5883287d42SBarry Smith x[0] = v[0]; x[1] = v[1]; x[2] = v[2]; x[3] = v[3]; 5983287d42SBarry Smith x[4] = v[4]; x[5] = v[5]; x[6] = v[6]; x[7] = v[7]; 6083287d42SBarry Smith x[8] = v[8]; x[9] = v[9]; x[10] = v[10]; x[11] = v[11]; 6183287d42SBarry Smith x[12] = v[12]; x[13] = v[13]; x[14] = v[14]; x[15] = v[15]; 6283287d42SBarry Smith x[16] = v[16]; x[17] = v[17]; x[18] = v[18]; x[19] = v[19]; 6383287d42SBarry Smith x[20] = v[20]; x[21] = v[21]; x[22] = v[22]; x[23] = v[23]; 6483287d42SBarry Smith x[24] = v[24]; x[25] = v[25]; x[26] = v[26]; x[27] = v[27]; 6583287d42SBarry Smith x[28] = v[28]; x[29] = v[29]; x[30] = v[30]; x[31] = v[31]; 6683287d42SBarry Smith x[32] = v[32]; x[33] = v[33]; x[34] = v[34]; x[35] = v[35]; 6783287d42SBarry Smith x[36] = v[36]; x[37] = v[37]; x[38] = v[38]; x[39] = v[39]; 6883287d42SBarry Smith x[40] = v[40]; x[41] = v[41]; x[42] = v[42]; x[43] = v[43]; 6983287d42SBarry Smith x[44] = v[44]; x[45] = v[45]; x[46] = v[46]; x[47] = v[47]; 7083287d42SBarry Smith x[48] = v[48]; 7183287d42SBarry Smith v += 49; 7283287d42SBarry Smith } 7383287d42SBarry Smith row = *ajtmp++; 7483287d42SBarry Smith while (row < i) { 7583287d42SBarry Smith pc = rtmp + 49*row; 7683287d42SBarry Smith p1 = pc[0]; p2 = pc[1]; p3 = pc[2]; p4 = pc[3]; 7783287d42SBarry Smith p5 = pc[4]; p6 = pc[5]; p7 = pc[6]; p8 = pc[7]; 7883287d42SBarry Smith p9 = pc[8]; p10 = pc[9]; p11 = pc[10]; p12 = pc[11]; 7983287d42SBarry Smith p13 = pc[12]; p14 = pc[13]; p15 = pc[14]; p16 = pc[15]; 8083287d42SBarry Smith p17 = pc[16]; p18 = pc[17]; p19 = pc[18]; p20 = pc[19]; 8183287d42SBarry Smith p21 = pc[20]; p22 = pc[21]; p23 = pc[22]; p24 = pc[23]; 8283287d42SBarry Smith p25 = pc[24]; p26 = pc[25]; p27 = pc[26]; p28 = pc[27]; 8383287d42SBarry Smith p29 = pc[28]; p30 = pc[29]; p31 = pc[30]; p32 = pc[31]; 8483287d42SBarry Smith p33 = pc[32]; p34 = pc[33]; p35 = pc[34]; p36 = pc[35]; 8583287d42SBarry Smith p37 = pc[36]; p38 = pc[37]; p39 = pc[38]; p40 = pc[39]; 8683287d42SBarry Smith p41 = pc[40]; p42 = pc[41]; p43 = pc[42]; p44 = pc[43]; 8783287d42SBarry Smith p45 = pc[44]; p46 = pc[45]; p47 = pc[46]; p48 = pc[47]; 8883287d42SBarry Smith p49 = pc[48]; 8983287d42SBarry Smith if (p1 != 0.0 || p2 != 0.0 || p3 != 0.0 || p4 != 0.0 || 9083287d42SBarry Smith p5 != 0.0 || p6 != 0.0 || p7 != 0.0 || p8 != 0.0 || 9183287d42SBarry Smith p9 != 0.0 || p10 != 0.0 || p11 != 0.0 || p12 != 0.0 || 9283287d42SBarry Smith p13 != 0.0 || p14 != 0.0 || p15 != 0.0 || p16 != 0.0 || 9383287d42SBarry Smith p17 != 0.0 || p18 != 0.0 || p19 != 0.0 || p20 != 0.0 || 9483287d42SBarry Smith p21 != 0.0 || p22 != 0.0 || p23 != 0.0 || p24 != 0.0 || 9583287d42SBarry Smith p25 != 0.0 || p26 != 0.0 || p27 != 0.0 || p28 != 0.0 || 9683287d42SBarry Smith p29 != 0.0 || p30 != 0.0 || p31 != 0.0 || p32 != 0.0 || 9783287d42SBarry Smith p33 != 0.0 || p34 != 0.0 || p35 != 0.0 || p36 != 0.0 || 9883287d42SBarry Smith p37 != 0.0 || p38 != 0.0 || p39 != 0.0 || p40 != 0.0 || 9983287d42SBarry Smith p41 != 0.0 || p42 != 0.0 || p43 != 0.0 || p44 != 0.0 || 10083287d42SBarry Smith p45 != 0.0 || p46 != 0.0 || p47 != 0.0 || p48 != 0.0 || 10183287d42SBarry Smith p49 != 0.0) { 10283287d42SBarry Smith pv = ba + 49*diag_offset[row]; 10383287d42SBarry Smith pj = bj + diag_offset[row] + 1; 10483287d42SBarry Smith x1 = pv[0]; x2 = pv[1]; x3 = pv[2]; x4 = pv[3]; 10583287d42SBarry Smith x5 = pv[4]; x6 = pv[5]; x7 = pv[6]; x8 = pv[7]; 10683287d42SBarry Smith x9 = pv[8]; x10 = pv[9]; x11 = pv[10]; x12 = pv[11]; 10783287d42SBarry Smith x13 = pv[12]; x14 = pv[13]; x15 = pv[14]; x16 = pv[15]; 10883287d42SBarry Smith x17 = pv[16]; x18 = pv[17]; x19 = pv[18]; x20 = pv[19]; 10983287d42SBarry Smith x21 = pv[20]; x22 = pv[21]; x23 = pv[22]; x24 = pv[23]; 11083287d42SBarry Smith x25 = pv[24]; x26 = pv[25]; x27 = pv[26]; x28 = pv[27]; 11183287d42SBarry Smith x29 = pv[28]; x30 = pv[29]; x31 = pv[30]; x32 = pv[31]; 11283287d42SBarry Smith x33 = pv[32]; x34 = pv[33]; x35 = pv[34]; x36 = pv[35]; 11383287d42SBarry Smith x37 = pv[36]; x38 = pv[37]; x39 = pv[38]; x40 = pv[39]; 11483287d42SBarry Smith x41 = pv[40]; x42 = pv[41]; x43 = pv[42]; x44 = pv[43]; 11583287d42SBarry Smith x45 = pv[44]; x46 = pv[45]; x47 = pv[46]; x48 = pv[47]; 11683287d42SBarry Smith x49 = pv[48]; 11783287d42SBarry Smith pc[0] = m1 = p1*x1 + p8*x2 + p15*x3 + p22*x4 + p29*x5 + p36*x6 + p43*x7; 11883287d42SBarry Smith pc[1] = m2 = p2*x1 + p9*x2 + p16*x3 + p23*x4 + p30*x5 + p37*x6 + p44*x7; 11983287d42SBarry Smith pc[2] = m3 = p3*x1 + p10*x2 + p17*x3 + p24*x4 + p31*x5 + p38*x6 + p45*x7; 12083287d42SBarry Smith pc[3] = m4 = p4*x1 + p11*x2 + p18*x3 + p25*x4 + p32*x5 + p39*x6 + p46*x7; 12183287d42SBarry Smith pc[4] = m5 = p5*x1 + p12*x2 + p19*x3 + p26*x4 + p33*x5 + p40*x6 + p47*x7; 12283287d42SBarry Smith pc[5] = m6 = p6*x1 + p13*x2 + p20*x3 + p27*x4 + p34*x5 + p41*x6 + p48*x7; 12383287d42SBarry Smith pc[6] = m7 = p7*x1 + p14*x2 + p21*x3 + p28*x4 + p35*x5 + p42*x6 + p49*x7; 12483287d42SBarry Smith 12583287d42SBarry Smith pc[7] = m8 = p1*x8 + p8*x9 + p15*x10 + p22*x11 + p29*x12 + p36*x13 + p43*x14; 12683287d42SBarry Smith pc[8] = m9 = p2*x8 + p9*x9 + p16*x10 + p23*x11 + p30*x12 + p37*x13 + p44*x14; 12783287d42SBarry Smith pc[9] = m10 = p3*x8 + p10*x9 + p17*x10 + p24*x11 + p31*x12 + p38*x13 + p45*x14; 12883287d42SBarry Smith pc[10] = m11 = p4*x8 + p11*x9 + p18*x10 + p25*x11 + p32*x12 + p39*x13 + p46*x14; 12983287d42SBarry Smith pc[11] = m12 = p5*x8 + p12*x9 + p19*x10 + p26*x11 + p33*x12 + p40*x13 + p47*x14; 13083287d42SBarry Smith pc[12] = m13 = p6*x8 + p13*x9 + p20*x10 + p27*x11 + p34*x12 + p41*x13 + p48*x14; 13183287d42SBarry Smith pc[13] = m14 = p7*x8 + p14*x9 + p21*x10 + p28*x11 + p35*x12 + p42*x13 + p49*x14; 13283287d42SBarry Smith 13383287d42SBarry Smith pc[14] = m15 = p1*x15 + p8*x16 + p15*x17 + p22*x18 + p29*x19 + p36*x20 + p43*x21; 13483287d42SBarry Smith pc[15] = m16 = p2*x15 + p9*x16 + p16*x17 + p23*x18 + p30*x19 + p37*x20 + p44*x21; 13583287d42SBarry Smith pc[16] = m17 = p3*x15 + p10*x16 + p17*x17 + p24*x18 + p31*x19 + p38*x20 + p45*x21; 13683287d42SBarry Smith pc[17] = m18 = p4*x15 + p11*x16 + p18*x17 + p25*x18 + p32*x19 + p39*x20 + p46*x21; 13783287d42SBarry Smith pc[18] = m19 = p5*x15 + p12*x16 + p19*x17 + p26*x18 + p33*x19 + p40*x20 + p47*x21; 13883287d42SBarry Smith pc[19] = m20 = p6*x15 + p13*x16 + p20*x17 + p27*x18 + p34*x19 + p41*x20 + p48*x21; 13983287d42SBarry Smith pc[20] = m21 = p7*x15 + p14*x16 + p21*x17 + p28*x18 + p35*x19 + p42*x20 + p49*x21; 14083287d42SBarry Smith 14183287d42SBarry Smith pc[21] = m22 = p1*x22 + p8*x23 + p15*x24 + p22*x25 + p29*x26 + p36*x27 + p43*x28; 14283287d42SBarry Smith pc[22] = m23 = p2*x22 + p9*x23 + p16*x24 + p23*x25 + p30*x26 + p37*x27 + p44*x28; 14383287d42SBarry Smith pc[23] = m24 = p3*x22 + p10*x23 + p17*x24 + p24*x25 + p31*x26 + p38*x27 + p45*x28; 14483287d42SBarry Smith pc[24] = m25 = p4*x22 + p11*x23 + p18*x24 + p25*x25 + p32*x26 + p39*x27 + p46*x28; 14583287d42SBarry Smith pc[25] = m26 = p5*x22 + p12*x23 + p19*x24 + p26*x25 + p33*x26 + p40*x27 + p47*x28; 14683287d42SBarry Smith pc[26] = m27 = p6*x22 + p13*x23 + p20*x24 + p27*x25 + p34*x26 + p41*x27 + p48*x28; 14783287d42SBarry Smith pc[27] = m28 = p7*x22 + p14*x23 + p21*x24 + p28*x25 + p35*x26 + p42*x27 + p49*x28; 14883287d42SBarry Smith 14983287d42SBarry Smith pc[28] = m29 = p1*x29 + p8*x30 + p15*x31 + p22*x32 + p29*x33 + p36*x34 + p43*x35; 15083287d42SBarry Smith pc[29] = m30 = p2*x29 + p9*x30 + p16*x31 + p23*x32 + p30*x33 + p37*x34 + p44*x35; 15183287d42SBarry Smith pc[30] = m31 = p3*x29 + p10*x30 + p17*x31 + p24*x32 + p31*x33 + p38*x34 + p45*x35; 15283287d42SBarry Smith pc[31] = m32 = p4*x29 + p11*x30 + p18*x31 + p25*x32 + p32*x33 + p39*x34 + p46*x35; 15383287d42SBarry Smith pc[32] = m33 = p5*x29 + p12*x30 + p19*x31 + p26*x32 + p33*x33 + p40*x34 + p47*x35; 15483287d42SBarry Smith pc[33] = m34 = p6*x29 + p13*x30 + p20*x31 + p27*x32 + p34*x33 + p41*x34 + p48*x35; 15583287d42SBarry Smith pc[34] = m35 = p7*x29 + p14*x30 + p21*x31 + p28*x32 + p35*x33 + p42*x34 + p49*x35; 15683287d42SBarry Smith 15783287d42SBarry Smith pc[35] = m36 = p1*x36 + p8*x37 + p15*x38 + p22*x39 + p29*x40 + p36*x41 + p43*x42; 15883287d42SBarry Smith pc[36] = m37 = p2*x36 + p9*x37 + p16*x38 + p23*x39 + p30*x40 + p37*x41 + p44*x42; 15983287d42SBarry Smith pc[37] = m38 = p3*x36 + p10*x37 + p17*x38 + p24*x39 + p31*x40 + p38*x41 + p45*x42; 16083287d42SBarry Smith pc[38] = m39 = p4*x36 + p11*x37 + p18*x38 + p25*x39 + p32*x40 + p39*x41 + p46*x42; 16183287d42SBarry Smith pc[39] = m40 = p5*x36 + p12*x37 + p19*x38 + p26*x39 + p33*x40 + p40*x41 + p47*x42; 16283287d42SBarry Smith pc[40] = m41 = p6*x36 + p13*x37 + p20*x38 + p27*x39 + p34*x40 + p41*x41 + p48*x42; 16383287d42SBarry Smith pc[41] = m42 = p7*x36 + p14*x37 + p21*x38 + p28*x39 + p35*x40 + p42*x41 + p49*x42; 16483287d42SBarry Smith 16583287d42SBarry Smith pc[42] = m43 = p1*x43 + p8*x44 + p15*x45 + p22*x46 + p29*x47 + p36*x48 + p43*x49; 16683287d42SBarry Smith pc[43] = m44 = p2*x43 + p9*x44 + p16*x45 + p23*x46 + p30*x47 + p37*x48 + p44*x49; 16783287d42SBarry Smith pc[44] = m45 = p3*x43 + p10*x44 + p17*x45 + p24*x46 + p31*x47 + p38*x48 + p45*x49; 16883287d42SBarry Smith pc[45] = m46 = p4*x43 + p11*x44 + p18*x45 + p25*x46 + p32*x47 + p39*x48 + p46*x49; 16983287d42SBarry Smith pc[46] = m47 = p5*x43 + p12*x44 + p19*x45 + p26*x46 + p33*x47 + p40*x48 + p47*x49; 17083287d42SBarry Smith pc[47] = m48 = p6*x43 + p13*x44 + p20*x45 + p27*x46 + p34*x47 + p41*x48 + p48*x49; 17183287d42SBarry Smith pc[48] = m49 = p7*x43 + p14*x44 + p21*x45 + p28*x46 + p35*x47 + p42*x48 + p49*x49; 17283287d42SBarry Smith 17383287d42SBarry Smith nz = bi[row+1] - diag_offset[row] - 1; 17483287d42SBarry Smith pv += 49; 17583287d42SBarry Smith for (j=0; j<nz; j++) { 17683287d42SBarry Smith x1 = pv[0]; x2 = pv[1]; x3 = pv[2]; x4 = pv[3]; 17783287d42SBarry Smith x5 = pv[4]; x6 = pv[5]; x7 = pv[6]; x8 = pv[7]; 17883287d42SBarry Smith x9 = pv[8]; x10 = pv[9]; x11 = pv[10]; x12 = pv[11]; 17983287d42SBarry Smith x13 = pv[12]; x14 = pv[13]; x15 = pv[14]; x16 = pv[15]; 18083287d42SBarry Smith x17 = pv[16]; x18 = pv[17]; x19 = pv[18]; x20 = pv[19]; 18183287d42SBarry Smith x21 = pv[20]; x22 = pv[21]; x23 = pv[22]; x24 = pv[23]; 18283287d42SBarry Smith x25 = pv[24]; x26 = pv[25]; x27 = pv[26]; x28 = pv[27]; 18383287d42SBarry Smith x29 = pv[28]; x30 = pv[29]; x31 = pv[30]; x32 = pv[31]; 18483287d42SBarry Smith x33 = pv[32]; x34 = pv[33]; x35 = pv[34]; x36 = pv[35]; 18583287d42SBarry Smith x37 = pv[36]; x38 = pv[37]; x39 = pv[38]; x40 = pv[39]; 18683287d42SBarry Smith x41 = pv[40]; x42 = pv[41]; x43 = pv[42]; x44 = pv[43]; 18783287d42SBarry Smith x45 = pv[44]; x46 = pv[45]; x47 = pv[46]; x48 = pv[47]; 18883287d42SBarry Smith x49 = pv[48]; 18983287d42SBarry Smith x = rtmp + 49*pj[j]; 19083287d42SBarry Smith x[0] -= m1*x1 + m8*x2 + m15*x3 + m22*x4 + m29*x5 + m36*x6 + m43*x7; 19183287d42SBarry Smith x[1] -= m2*x1 + m9*x2 + m16*x3 + m23*x4 + m30*x5 + m37*x6 + m44*x7; 19283287d42SBarry Smith x[2] -= m3*x1 + m10*x2 + m17*x3 + m24*x4 + m31*x5 + m38*x6 + m45*x7; 19383287d42SBarry Smith x[3] -= m4*x1 + m11*x2 + m18*x3 + m25*x4 + m32*x5 + m39*x6 + m46*x7; 19483287d42SBarry Smith x[4] -= m5*x1 + m12*x2 + m19*x3 + m26*x4 + m33*x5 + m40*x6 + m47*x7; 19583287d42SBarry Smith x[5] -= m6*x1 + m13*x2 + m20*x3 + m27*x4 + m34*x5 + m41*x6 + m48*x7; 19683287d42SBarry Smith x[6] -= m7*x1 + m14*x2 + m21*x3 + m28*x4 + m35*x5 + m42*x6 + m49*x7; 19783287d42SBarry Smith 19883287d42SBarry Smith x[7] -= m1*x8 + m8*x9 + m15*x10 + m22*x11 + m29*x12 + m36*x13 + m43*x14; 19983287d42SBarry Smith x[8] -= m2*x8 + m9*x9 + m16*x10 + m23*x11 + m30*x12 + m37*x13 + m44*x14; 20083287d42SBarry Smith x[9] -= m3*x8 + m10*x9 + m17*x10 + m24*x11 + m31*x12 + m38*x13 + m45*x14; 20183287d42SBarry Smith x[10] -= m4*x8 + m11*x9 + m18*x10 + m25*x11 + m32*x12 + m39*x13 + m46*x14; 20283287d42SBarry Smith x[11] -= m5*x8 + m12*x9 + m19*x10 + m26*x11 + m33*x12 + m40*x13 + m47*x14; 20383287d42SBarry Smith x[12] -= m6*x8 + m13*x9 + m20*x10 + m27*x11 + m34*x12 + m41*x13 + m48*x14; 20483287d42SBarry Smith x[13] -= m7*x8 + m14*x9 + m21*x10 + m28*x11 + m35*x12 + m42*x13 + m49*x14; 20583287d42SBarry Smith 20683287d42SBarry Smith x[14] -= m1*x15 + m8*x16 + m15*x17 + m22*x18 + m29*x19 + m36*x20 + m43*x21; 20783287d42SBarry Smith x[15] -= m2*x15 + m9*x16 + m16*x17 + m23*x18 + m30*x19 + m37*x20 + m44*x21; 20883287d42SBarry Smith x[16] -= m3*x15 + m10*x16 + m17*x17 + m24*x18 + m31*x19 + m38*x20 + m45*x21; 20983287d42SBarry Smith x[17] -= m4*x15 + m11*x16 + m18*x17 + m25*x18 + m32*x19 + m39*x20 + m46*x21; 21083287d42SBarry Smith x[18] -= m5*x15 + m12*x16 + m19*x17 + m26*x18 + m33*x19 + m40*x20 + m47*x21; 21183287d42SBarry Smith x[19] -= m6*x15 + m13*x16 + m20*x17 + m27*x18 + m34*x19 + m41*x20 + m48*x21; 21283287d42SBarry Smith x[20] -= m7*x15 + m14*x16 + m21*x17 + m28*x18 + m35*x19 + m42*x20 + m49*x21; 21383287d42SBarry Smith 21483287d42SBarry Smith x[21] -= m1*x22 + m8*x23 + m15*x24 + m22*x25 + m29*x26 + m36*x27 + m43*x28; 21583287d42SBarry Smith x[22] -= m2*x22 + m9*x23 + m16*x24 + m23*x25 + m30*x26 + m37*x27 + m44*x28; 21683287d42SBarry Smith x[23] -= m3*x22 + m10*x23 + m17*x24 + m24*x25 + m31*x26 + m38*x27 + m45*x28; 21783287d42SBarry Smith x[24] -= m4*x22 + m11*x23 + m18*x24 + m25*x25 + m32*x26 + m39*x27 + m46*x28; 21883287d42SBarry Smith x[25] -= m5*x22 + m12*x23 + m19*x24 + m26*x25 + m33*x26 + m40*x27 + m47*x28; 21983287d42SBarry Smith x[26] -= m6*x22 + m13*x23 + m20*x24 + m27*x25 + m34*x26 + m41*x27 + m48*x28; 22083287d42SBarry Smith x[27] -= m7*x22 + m14*x23 + m21*x24 + m28*x25 + m35*x26 + m42*x27 + m49*x28; 22183287d42SBarry Smith 22283287d42SBarry Smith x[28] -= m1*x29 + m8*x30 + m15*x31 + m22*x32 + m29*x33 + m36*x34 + m43*x35; 22383287d42SBarry Smith x[29] -= m2*x29 + m9*x30 + m16*x31 + m23*x32 + m30*x33 + m37*x34 + m44*x35; 22483287d42SBarry Smith x[30] -= m3*x29 + m10*x30 + m17*x31 + m24*x32 + m31*x33 + m38*x34 + m45*x35; 22583287d42SBarry Smith x[31] -= m4*x29 + m11*x30 + m18*x31 + m25*x32 + m32*x33 + m39*x34 + m46*x35; 22683287d42SBarry Smith x[32] -= m5*x29 + m12*x30 + m19*x31 + m26*x32 + m33*x33 + m40*x34 + m47*x35; 22783287d42SBarry Smith x[33] -= m6*x29 + m13*x30 + m20*x31 + m27*x32 + m34*x33 + m41*x34 + m48*x35; 22883287d42SBarry Smith x[34] -= m7*x29 + m14*x30 + m21*x31 + m28*x32 + m35*x33 + m42*x34 + m49*x35; 22983287d42SBarry Smith 23083287d42SBarry Smith x[35] -= m1*x36 + m8*x37 + m15*x38 + m22*x39 + m29*x40 + m36*x41 + m43*x42; 23183287d42SBarry Smith x[36] -= m2*x36 + m9*x37 + m16*x38 + m23*x39 + m30*x40 + m37*x41 + m44*x42; 23283287d42SBarry Smith x[37] -= m3*x36 + m10*x37 + m17*x38 + m24*x39 + m31*x40 + m38*x41 + m45*x42; 23383287d42SBarry Smith x[38] -= m4*x36 + m11*x37 + m18*x38 + m25*x39 + m32*x40 + m39*x41 + m46*x42; 23483287d42SBarry Smith x[39] -= m5*x36 + m12*x37 + m19*x38 + m26*x39 + m33*x40 + m40*x41 + m47*x42; 23583287d42SBarry Smith x[40] -= m6*x36 + m13*x37 + m20*x38 + m27*x39 + m34*x40 + m41*x41 + m48*x42; 23683287d42SBarry Smith x[41] -= m7*x36 + m14*x37 + m21*x38 + m28*x39 + m35*x40 + m42*x41 + m49*x42; 23783287d42SBarry Smith 23883287d42SBarry Smith x[42] -= m1*x43 + m8*x44 + m15*x45 + m22*x46 + m29*x47 + m36*x48 + m43*x49; 23983287d42SBarry Smith x[43] -= m2*x43 + m9*x44 + m16*x45 + m23*x46 + m30*x47 + m37*x48 + m44*x49; 24083287d42SBarry Smith x[44] -= m3*x43 + m10*x44 + m17*x45 + m24*x46 + m31*x47 + m38*x48 + m45*x49; 24183287d42SBarry Smith x[45] -= m4*x43 + m11*x44 + m18*x45 + m25*x46 + m32*x47 + m39*x48 + m46*x49; 24283287d42SBarry Smith x[46] -= m5*x43 + m12*x44 + m19*x45 + m26*x46 + m33*x47 + m40*x48 + m47*x49; 24383287d42SBarry Smith x[47] -= m6*x43 + m13*x44 + m20*x45 + m27*x46 + m34*x47 + m41*x48 + m48*x49; 24483287d42SBarry Smith x[48] -= m7*x43 + m14*x44 + m21*x45 + m28*x46 + m35*x47 + m42*x48 + m49*x49; 24583287d42SBarry Smith pv += 49; 24683287d42SBarry Smith } 247dc0b31edSSatish Balay ierr = PetscLogFlops(686.0*nz+637.0);CHKERRQ(ierr); 24883287d42SBarry Smith } 24983287d42SBarry Smith row = *ajtmp++; 25083287d42SBarry Smith } 25183287d42SBarry Smith /* finished row so stick it into b->a */ 25283287d42SBarry Smith pv = ba + 49*bi[i]; 25383287d42SBarry Smith pj = bj + bi[i]; 25483287d42SBarry Smith nz = bi[i+1] - bi[i]; 25583287d42SBarry Smith for (j=0; j<nz; j++) { 25683287d42SBarry Smith x = rtmp+49*pj[j]; 25783287d42SBarry Smith pv[0] = x[0]; pv[1] = x[1]; pv[2] = x[2]; pv[3] = x[3]; 25883287d42SBarry Smith pv[4] = x[4]; pv[5] = x[5]; pv[6] = x[6]; pv[7] = x[7]; 25983287d42SBarry Smith pv[8] = x[8]; pv[9] = x[9]; pv[10] = x[10]; pv[11] = x[11]; 26083287d42SBarry Smith pv[12] = x[12]; pv[13] = x[13]; pv[14] = x[14]; pv[15] = x[15]; 26183287d42SBarry Smith pv[16] = x[16]; pv[17] = x[17]; pv[18] = x[18]; pv[19] = x[19]; 26283287d42SBarry Smith pv[20] = x[20]; pv[21] = x[21]; pv[22] = x[22]; pv[23] = x[23]; 26383287d42SBarry Smith pv[24] = x[24]; pv[25] = x[25]; pv[26] = x[26]; pv[27] = x[27]; 26483287d42SBarry Smith pv[28] = x[28]; pv[29] = x[29]; pv[30] = x[30]; pv[31] = x[31]; 26583287d42SBarry Smith pv[32] = x[32]; pv[33] = x[33]; pv[34] = x[34]; pv[35] = x[35]; 26683287d42SBarry Smith pv[36] = x[36]; pv[37] = x[37]; pv[38] = x[38]; pv[39] = x[39]; 26783287d42SBarry Smith pv[40] = x[40]; pv[41] = x[41]; pv[42] = x[42]; pv[43] = x[43]; 26883287d42SBarry Smith pv[44] = x[44]; pv[45] = x[45]; pv[46] = x[46]; pv[47] = x[47]; 26983287d42SBarry Smith pv[48] = x[48]; 27083287d42SBarry Smith pv += 49; 27183287d42SBarry Smith } 27283287d42SBarry Smith /* invert diagonal block */ 27383287d42SBarry Smith w = ba + 49*diag_offset[i]; 27496b95a6bSBarry Smith ierr = PetscKernel_A_gets_inverse_A_7(w,shift);CHKERRQ(ierr); 27583287d42SBarry Smith } 27683287d42SBarry Smith 27783287d42SBarry Smith ierr = PetscFree(rtmp);CHKERRQ(ierr); 27883287d42SBarry Smith ierr = ISRestoreIndices(isicol,&ic);CHKERRQ(ierr); 27983287d42SBarry Smith ierr = ISRestoreIndices(isrow,&r);CHKERRQ(ierr); 280*26fbe8dcSKarl Rupp 28106e38f1dSHong Zhang C->ops->solve = MatSolve_SeqBAIJ_7_inplace; 28206e38f1dSHong Zhang C->ops->solvetranspose = MatSolveTranspose_SeqBAIJ_7_inplace; 28383287d42SBarry Smith C->assembled = PETSC_TRUE; 284*26fbe8dcSKarl Rupp 285766f9fbaSBarry Smith ierr = PetscLogFlops(1.333333333333*7*7*7*b->mbs);CHKERRQ(ierr); /* from inverting diagonal blocks */ 28683287d42SBarry Smith PetscFunctionReturn(0); 28783287d42SBarry Smith } 288bef36659SShri Abhyankar 289c0c7eb62SShri Abhyankar 290bef36659SShri Abhyankar #undef __FUNCT__ 2914dd39f65SShri Abhyankar #define __FUNCT__ "MatLUFactorNumeric_SeqBAIJ_7" 2924dd39f65SShri Abhyankar PetscErrorCode MatLUFactorNumeric_SeqBAIJ_7(Mat B,Mat A,const MatFactorInfo *info) 293bef36659SShri Abhyankar { 294bef36659SShri Abhyankar Mat C =B; 295bef36659SShri Abhyankar Mat_SeqBAIJ *a =(Mat_SeqBAIJ*)A->data,*b=(Mat_SeqBAIJ*)C->data; 296bef36659SShri Abhyankar IS isrow = b->row,isicol = b->icol; 297bef36659SShri Abhyankar PetscErrorCode ierr; 2985a586d82SBarry Smith const PetscInt *r,*ic; 299bbd65245SShri Abhyankar PetscInt i,j,k,nz,nzL,row; 300bbd65245SShri Abhyankar const PetscInt n=a->mbs,*ai=a->i,*aj=a->j,*bi=b->i,*bj=b->j; 301bbd65245SShri Abhyankar const PetscInt *ajtmp,*bjtmp,*bdiag=b->diag,*pj,bs2=a->bs2; 302bef36659SShri Abhyankar MatScalar *rtmp,*pc,*mwork,*v,*pv,*aa=a->a; 303bbd65245SShri Abhyankar PetscInt flg; 304182b8fbaSHong Zhang PetscReal shift = info->shiftamount; 305bef36659SShri Abhyankar 306bef36659SShri Abhyankar PetscFunctionBegin; 307bef36659SShri Abhyankar ierr = ISGetIndices(isrow,&r);CHKERRQ(ierr); 308bef36659SShri Abhyankar ierr = ISGetIndices(isicol,&ic);CHKERRQ(ierr); 309bef36659SShri Abhyankar 310bef36659SShri Abhyankar /* generate work space needed by the factorization */ 31174ed9c26SBarry Smith ierr = PetscMalloc2(bs2*n,MatScalar,&rtmp,bs2,MatScalar,&mwork);CHKERRQ(ierr); 312bef36659SShri Abhyankar ierr = PetscMemzero(rtmp,bs2*n*sizeof(MatScalar));CHKERRQ(ierr); 313bef36659SShri Abhyankar 314bef36659SShri Abhyankar for (i=0; i<n; i++) { 315bef36659SShri Abhyankar /* zero rtmp */ 316bef36659SShri Abhyankar /* L part */ 317bef36659SShri Abhyankar nz = bi[i+1] - bi[i]; 318bef36659SShri Abhyankar bjtmp = bj + bi[i]; 319bef36659SShri Abhyankar for (j=0; j<nz; j++) { 320bef36659SShri Abhyankar ierr = PetscMemzero(rtmp+bs2*bjtmp[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 321bef36659SShri Abhyankar } 322bef36659SShri Abhyankar 323bef36659SShri Abhyankar /* U part */ 32435aa4fcfSShri Abhyankar nz = bdiag[i] - bdiag[i+1]; 32535aa4fcfSShri Abhyankar bjtmp = bj + bdiag[i+1]+1; 32635aa4fcfSShri Abhyankar for (j=0; j<nz; j++) { 32735aa4fcfSShri Abhyankar ierr = PetscMemzero(rtmp+bs2*bjtmp[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 32835aa4fcfSShri Abhyankar } 32935aa4fcfSShri Abhyankar 33035aa4fcfSShri Abhyankar /* load in initial (unfactored row) */ 33135aa4fcfSShri Abhyankar nz = ai[r[i]+1] - ai[r[i]]; 33235aa4fcfSShri Abhyankar ajtmp = aj + ai[r[i]]; 33335aa4fcfSShri Abhyankar v = aa + bs2*ai[r[i]]; 33435aa4fcfSShri Abhyankar for (j=0; j<nz; j++) { 33535aa4fcfSShri Abhyankar ierr = PetscMemcpy(rtmp+bs2*ic[ajtmp[j]],v+bs2*j,bs2*sizeof(MatScalar));CHKERRQ(ierr); 33635aa4fcfSShri Abhyankar } 33735aa4fcfSShri Abhyankar 33835aa4fcfSShri Abhyankar /* elimination */ 33935aa4fcfSShri Abhyankar bjtmp = bj + bi[i]; 34035aa4fcfSShri Abhyankar nzL = bi[i+1] - bi[i]; 34135aa4fcfSShri Abhyankar for (k=0; k < nzL; k++) { 34235aa4fcfSShri Abhyankar row = bjtmp[k]; 34335aa4fcfSShri Abhyankar pc = rtmp + bs2*row; 344c35f09e5SBarry Smith for (flg=0,j=0; j<bs2; j++) { 345c35f09e5SBarry Smith if (pc[j]!=0.0) { 346c35f09e5SBarry Smith flg = 1; 347c35f09e5SBarry Smith break; 348c35f09e5SBarry Smith } 349c35f09e5SBarry Smith } 35035aa4fcfSShri Abhyankar if (flg) { 35135aa4fcfSShri Abhyankar pv = b->a + bs2*bdiag[row]; 35296b95a6bSBarry Smith /* PetscKernel_A_gets_A_times_B(bs,pc,pv,mwork); *pc = *pc * (*pv); */ 35396b95a6bSBarry Smith ierr = PetscKernel_A_gets_A_times_B_7(pc,pv,mwork);CHKERRQ(ierr); 35435aa4fcfSShri Abhyankar 35535aa4fcfSShri Abhyankar pj = b->j + bdiag[row+1]+1; /* begining of U(row,:) */ 35635aa4fcfSShri Abhyankar pv = b->a + bs2*(bdiag[row+1]+1); 35735aa4fcfSShri Abhyankar nz = bdiag[row] - bdiag[row+1] - 1; /* num of entries inU(row,:), excluding diag */ 35835aa4fcfSShri Abhyankar for (j=0; j<nz; j++) { 35996b95a6bSBarry Smith /* PetscKernel_A_gets_A_minus_B_times_C(bs,rtmp+bs2*pj[j],pc,pv+bs2*j); */ 36035aa4fcfSShri Abhyankar /* rtmp+bs2*pj[j] = rtmp+bs2*pj[j] - (*pc)*(pv+bs2*j) */ 36135aa4fcfSShri Abhyankar v = rtmp + bs2*pj[j]; 36296b95a6bSBarry Smith ierr = PetscKernel_A_gets_A_minus_B_times_C_7(v,pc,pv);CHKERRQ(ierr); 36335aa4fcfSShri Abhyankar pv += bs2; 36435aa4fcfSShri Abhyankar } 36535aa4fcfSShri Abhyankar ierr = PetscLogFlops(686*nz+637);CHKERRQ(ierr); /* flops = 2*bs^3*nz + 2*bs^3 - bs2) */ 36635aa4fcfSShri Abhyankar } 36735aa4fcfSShri Abhyankar } 36835aa4fcfSShri Abhyankar 36935aa4fcfSShri Abhyankar /* finished row so stick it into b->a */ 37035aa4fcfSShri Abhyankar /* L part */ 37135aa4fcfSShri Abhyankar pv = b->a + bs2*bi[i]; 37235aa4fcfSShri Abhyankar pj = b->j + bi[i]; 37335aa4fcfSShri Abhyankar nz = bi[i+1] - bi[i]; 37435aa4fcfSShri Abhyankar for (j=0; j<nz; j++) { 37535aa4fcfSShri Abhyankar ierr = PetscMemcpy(pv+bs2*j,rtmp+bs2*pj[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 37635aa4fcfSShri Abhyankar } 37735aa4fcfSShri Abhyankar 37835aa4fcfSShri Abhyankar /* Mark diagonal and invert diagonal for simplier triangular solves */ 37935aa4fcfSShri Abhyankar pv = b->a + bs2*bdiag[i]; 38035aa4fcfSShri Abhyankar pj = b->j + bdiag[i]; 38135aa4fcfSShri Abhyankar ierr = PetscMemcpy(pv,rtmp+bs2*pj[0],bs2*sizeof(MatScalar));CHKERRQ(ierr); 38296b95a6bSBarry Smith /* ierr = PetscKernel_A_gets_inverse_A(bs,pv,v_pivots,v_work);CHKERRQ(ierr); */ 38396b95a6bSBarry Smith ierr = PetscKernel_A_gets_inverse_A_7(pv,shift);CHKERRQ(ierr); 38435aa4fcfSShri Abhyankar 38535aa4fcfSShri Abhyankar /* U part */ 38635aa4fcfSShri Abhyankar pv = b->a + bs2*(bdiag[i+1]+1); 38735aa4fcfSShri Abhyankar pj = b->j + bdiag[i+1]+1; 38835aa4fcfSShri Abhyankar nz = bdiag[i] - bdiag[i+1] - 1; 38935aa4fcfSShri Abhyankar for (j=0; j<nz; j++) { 39035aa4fcfSShri Abhyankar ierr = PetscMemcpy(pv+bs2*j,rtmp+bs2*pj[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 39135aa4fcfSShri Abhyankar } 39235aa4fcfSShri Abhyankar } 39335aa4fcfSShri Abhyankar 39474ed9c26SBarry Smith ierr = PetscFree2(rtmp,mwork);CHKERRQ(ierr); 39535aa4fcfSShri Abhyankar ierr = ISRestoreIndices(isicol,&ic);CHKERRQ(ierr); 39635aa4fcfSShri Abhyankar ierr = ISRestoreIndices(isrow,&r);CHKERRQ(ierr); 397*26fbe8dcSKarl Rupp 3984dd39f65SShri Abhyankar C->ops->solve = MatSolve_SeqBAIJ_7; 3994dd39f65SShri Abhyankar C->ops->solvetranspose = MatSolveTranspose_SeqBAIJ_7; 40035aa4fcfSShri Abhyankar C->assembled = PETSC_TRUE; 401*26fbe8dcSKarl Rupp 402766f9fbaSBarry Smith ierr = PetscLogFlops(1.333333333333*7*7*7*n);CHKERRQ(ierr); /* from inverting diagonal blocks */ 40335aa4fcfSShri Abhyankar PetscFunctionReturn(0); 40435aa4fcfSShri Abhyankar } 40535aa4fcfSShri Abhyankar 40635aa4fcfSShri Abhyankar #undef __FUNCT__ 40706e38f1dSHong Zhang #define __FUNCT__ "MatLUFactorNumeric_SeqBAIJ_7_NaturalOrdering_inplace" 40806e38f1dSHong Zhang PetscErrorCode MatLUFactorNumeric_SeqBAIJ_7_NaturalOrdering_inplace(Mat C,Mat A,const MatFactorInfo *info) 409bef36659SShri Abhyankar { 410bef36659SShri Abhyankar Mat_SeqBAIJ *a = (Mat_SeqBAIJ*)A->data,*b = (Mat_SeqBAIJ*)C->data; 411bef36659SShri Abhyankar PetscErrorCode ierr; 412bef36659SShri Abhyankar PetscInt i,j,n = a->mbs,*bi = b->i,*bj = b->j; 413bef36659SShri Abhyankar PetscInt *ajtmpold,*ajtmp,nz,row; 414bef36659SShri Abhyankar PetscInt *diag_offset = b->diag,*ai=a->i,*aj=a->j,*pj; 415bef36659SShri Abhyankar MatScalar *pv,*v,*rtmp,*pc,*w,*x; 416bef36659SShri Abhyankar MatScalar x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15; 417bef36659SShri Abhyankar MatScalar x16,x17,x18,x19,x20,x21,x22,x23,x24,x25; 418bef36659SShri Abhyankar MatScalar p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15; 419bef36659SShri Abhyankar MatScalar p16,p17,p18,p19,p20,p21,p22,p23,p24,p25; 420bef36659SShri Abhyankar MatScalar m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15; 421bef36659SShri Abhyankar MatScalar m16,m17,m18,m19,m20,m21,m22,m23,m24,m25; 422bef36659SShri Abhyankar MatScalar p26,p27,p28,p29,p30,p31,p32,p33,p34,p35,p36; 423bef36659SShri Abhyankar MatScalar p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p47,p48,p49; 424bef36659SShri Abhyankar MatScalar x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36; 425bef36659SShri Abhyankar MatScalar x37,x38,x39,x40,x41,x42,x43,x44,x45,x46,x47,x48,x49; 426bef36659SShri Abhyankar MatScalar m26,m27,m28,m29,m30,m31,m32,m33,m34,m35,m36; 427bef36659SShri Abhyankar MatScalar m37,m38,m39,m40,m41,m42,m43,m44,m45,m46,m47,m48,m49; 428bef36659SShri Abhyankar MatScalar *ba = b->a,*aa = a->a; 429182b8fbaSHong Zhang PetscReal shift = info->shiftamount; 430bef36659SShri Abhyankar 431bef36659SShri Abhyankar PetscFunctionBegin; 432bef36659SShri Abhyankar ierr = PetscMalloc(49*(n+1)*sizeof(MatScalar),&rtmp);CHKERRQ(ierr); 433bef36659SShri Abhyankar for (i=0; i<n; i++) { 434bef36659SShri Abhyankar nz = bi[i+1] - bi[i]; 435bef36659SShri Abhyankar ajtmp = bj + bi[i]; 436bef36659SShri Abhyankar for (j=0; j<nz; j++) { 437bef36659SShri Abhyankar x = rtmp+49*ajtmp[j]; 438bef36659SShri Abhyankar x[0] = x[1] = x[2] = x[3] = x[4] = x[5] = x[6] = x[7] = x[8] = x[9] = 0.0; 439bef36659SShri Abhyankar x[10] = x[11] = x[12] = x[13] = x[14] = x[15] = x[16] = x[17] = 0.0; 440bef36659SShri Abhyankar x[18] = x[19] = x[20] = x[21] = x[22] = x[23] = x[24] = x[25] = 0.0; 441bef36659SShri Abhyankar x[26] = x[27] = x[28] = x[29] = x[30] = x[31] = x[32] = x[33] = 0.0; 442bef36659SShri Abhyankar x[34] = x[35] = x[36] = x[37] = x[38] = x[39] = x[40] = x[41] = 0.0; 443bef36659SShri Abhyankar x[42] = x[43] = x[44] = x[45] = x[46] = x[47] = x[48] = 0.0; 444bef36659SShri Abhyankar } 445bef36659SShri Abhyankar /* load in initial (unfactored row) */ 446bef36659SShri Abhyankar nz = ai[i+1] - ai[i]; 447bef36659SShri Abhyankar ajtmpold = aj + ai[i]; 448bef36659SShri Abhyankar v = aa + 49*ai[i]; 449bef36659SShri Abhyankar for (j=0; j<nz; j++) { 450bef36659SShri Abhyankar x = rtmp+49*ajtmpold[j]; 451bef36659SShri Abhyankar x[0] = v[0]; x[1] = v[1]; x[2] = v[2]; x[3] = v[3]; 452bef36659SShri Abhyankar x[4] = v[4]; x[5] = v[5]; x[6] = v[6]; x[7] = v[7]; 453bef36659SShri Abhyankar x[8] = v[8]; x[9] = v[9]; x[10] = v[10]; x[11] = v[11]; 454bef36659SShri Abhyankar x[12] = v[12]; x[13] = v[13]; x[14] = v[14]; x[15] = v[15]; 455bef36659SShri Abhyankar x[16] = v[16]; x[17] = v[17]; x[18] = v[18]; x[19] = v[19]; 456bef36659SShri Abhyankar x[20] = v[20]; x[21] = v[21]; x[22] = v[22]; x[23] = v[23]; 457bef36659SShri Abhyankar x[24] = v[24]; x[25] = v[25]; x[26] = v[26]; x[27] = v[27]; 458bef36659SShri Abhyankar x[28] = v[28]; x[29] = v[29]; x[30] = v[30]; x[31] = v[31]; 459bef36659SShri Abhyankar x[32] = v[32]; x[33] = v[33]; x[34] = v[34]; x[35] = v[35]; 460bef36659SShri Abhyankar x[36] = v[36]; x[37] = v[37]; x[38] = v[38]; x[39] = v[39]; 461bef36659SShri Abhyankar x[40] = v[40]; x[41] = v[41]; x[42] = v[42]; x[43] = v[43]; 462bef36659SShri Abhyankar x[44] = v[44]; x[45] = v[45]; x[46] = v[46]; x[47] = v[47]; 463bef36659SShri Abhyankar x[48] = v[48]; 464bef36659SShri Abhyankar v += 49; 465bef36659SShri Abhyankar } 466bef36659SShri Abhyankar row = *ajtmp++; 467bef36659SShri Abhyankar while (row < i) { 468bef36659SShri Abhyankar pc = rtmp + 49*row; 469bef36659SShri Abhyankar p1 = pc[0]; p2 = pc[1]; p3 = pc[2]; p4 = pc[3]; 470bef36659SShri Abhyankar p5 = pc[4]; p6 = pc[5]; p7 = pc[6]; p8 = pc[7]; 471bef36659SShri Abhyankar p9 = pc[8]; p10 = pc[9]; p11 = pc[10]; p12 = pc[11]; 472bef36659SShri Abhyankar p13 = pc[12]; p14 = pc[13]; p15 = pc[14]; p16 = pc[15]; 473bef36659SShri Abhyankar p17 = pc[16]; p18 = pc[17]; p19 = pc[18]; p20 = pc[19]; 474bef36659SShri Abhyankar p21 = pc[20]; p22 = pc[21]; p23 = pc[22]; p24 = pc[23]; 475bef36659SShri Abhyankar p25 = pc[24]; p26 = pc[25]; p27 = pc[26]; p28 = pc[27]; 476bef36659SShri Abhyankar p29 = pc[28]; p30 = pc[29]; p31 = pc[30]; p32 = pc[31]; 477bef36659SShri Abhyankar p33 = pc[32]; p34 = pc[33]; p35 = pc[34]; p36 = pc[35]; 478bef36659SShri Abhyankar p37 = pc[36]; p38 = pc[37]; p39 = pc[38]; p40 = pc[39]; 479bef36659SShri Abhyankar p41 = pc[40]; p42 = pc[41]; p43 = pc[42]; p44 = pc[43]; 480bef36659SShri Abhyankar p45 = pc[44]; p46 = pc[45]; p47 = pc[46]; p48 = pc[47]; 481bef36659SShri Abhyankar p49 = pc[48]; 482bef36659SShri Abhyankar if (p1 != 0.0 || p2 != 0.0 || p3 != 0.0 || p4 != 0.0 || 483bef36659SShri Abhyankar p5 != 0.0 || p6 != 0.0 || p7 != 0.0 || p8 != 0.0 || 484bef36659SShri Abhyankar p9 != 0.0 || p10 != 0.0 || p11 != 0.0 || p12 != 0.0 || 485bef36659SShri Abhyankar p13 != 0.0 || p14 != 0.0 || p15 != 0.0 || p16 != 0.0 || 486bef36659SShri Abhyankar p17 != 0.0 || p18 != 0.0 || p19 != 0.0 || p20 != 0.0 || 487bef36659SShri Abhyankar p21 != 0.0 || p22 != 0.0 || p23 != 0.0 || p24 != 0.0 || 488bef36659SShri Abhyankar p25 != 0.0 || p26 != 0.0 || p27 != 0.0 || p28 != 0.0 || 489bef36659SShri Abhyankar p29 != 0.0 || p30 != 0.0 || p31 != 0.0 || p32 != 0.0 || 490bef36659SShri Abhyankar p33 != 0.0 || p34 != 0.0 || p35 != 0.0 || p36 != 0.0 || 491bef36659SShri Abhyankar p37 != 0.0 || p38 != 0.0 || p39 != 0.0 || p40 != 0.0 || 492bef36659SShri Abhyankar p41 != 0.0 || p42 != 0.0 || p43 != 0.0 || p44 != 0.0 || 493bef36659SShri Abhyankar p45 != 0.0 || p46 != 0.0 || p47 != 0.0 || p48 != 0.0 || 494bef36659SShri Abhyankar p49 != 0.0) { 495bef36659SShri Abhyankar pv = ba + 49*diag_offset[row]; 496bef36659SShri Abhyankar pj = bj + diag_offset[row] + 1; 497bef36659SShri Abhyankar x1 = pv[0]; x2 = pv[1]; x3 = pv[2]; x4 = pv[3]; 498bef36659SShri Abhyankar x5 = pv[4]; x6 = pv[5]; x7 = pv[6]; x8 = pv[7]; 499bef36659SShri Abhyankar x9 = pv[8]; x10 = pv[9]; x11 = pv[10]; x12 = pv[11]; 500bef36659SShri Abhyankar x13 = pv[12]; x14 = pv[13]; x15 = pv[14]; x16 = pv[15]; 501bef36659SShri Abhyankar x17 = pv[16]; x18 = pv[17]; x19 = pv[18]; x20 = pv[19]; 502bef36659SShri Abhyankar x21 = pv[20]; x22 = pv[21]; x23 = pv[22]; x24 = pv[23]; 503bef36659SShri Abhyankar x25 = pv[24]; x26 = pv[25]; x27 = pv[26]; x28 = pv[27]; 504bef36659SShri Abhyankar x29 = pv[28]; x30 = pv[29]; x31 = pv[30]; x32 = pv[31]; 505bef36659SShri Abhyankar x33 = pv[32]; x34 = pv[33]; x35 = pv[34]; x36 = pv[35]; 506bef36659SShri Abhyankar x37 = pv[36]; x38 = pv[37]; x39 = pv[38]; x40 = pv[39]; 507bef36659SShri Abhyankar x41 = pv[40]; x42 = pv[41]; x43 = pv[42]; x44 = pv[43]; 508bef36659SShri Abhyankar x45 = pv[44]; x46 = pv[45]; x47 = pv[46]; x48 = pv[47]; 509bef36659SShri Abhyankar x49 = pv[48]; 510bef36659SShri Abhyankar pc[0] = m1 = p1*x1 + p8*x2 + p15*x3 + p22*x4 + p29*x5 + p36*x6 + p43*x7; 511bef36659SShri Abhyankar pc[1] = m2 = p2*x1 + p9*x2 + p16*x3 + p23*x4 + p30*x5 + p37*x6 + p44*x7; 512bef36659SShri Abhyankar pc[2] = m3 = p3*x1 + p10*x2 + p17*x3 + p24*x4 + p31*x5 + p38*x6 + p45*x7; 513bef36659SShri Abhyankar pc[3] = m4 = p4*x1 + p11*x2 + p18*x3 + p25*x4 + p32*x5 + p39*x6 + p46*x7; 514bef36659SShri Abhyankar pc[4] = m5 = p5*x1 + p12*x2 + p19*x3 + p26*x4 + p33*x5 + p40*x6 + p47*x7; 515bef36659SShri Abhyankar pc[5] = m6 = p6*x1 + p13*x2 + p20*x3 + p27*x4 + p34*x5 + p41*x6 + p48*x7; 516bef36659SShri Abhyankar pc[6] = m7 = p7*x1 + p14*x2 + p21*x3 + p28*x4 + p35*x5 + p42*x6 + p49*x7; 517bef36659SShri Abhyankar 518bef36659SShri Abhyankar pc[7] = m8 = p1*x8 + p8*x9 + p15*x10 + p22*x11 + p29*x12 + p36*x13 + p43*x14; 519bef36659SShri Abhyankar pc[8] = m9 = p2*x8 + p9*x9 + p16*x10 + p23*x11 + p30*x12 + p37*x13 + p44*x14; 520bef36659SShri Abhyankar pc[9] = m10 = p3*x8 + p10*x9 + p17*x10 + p24*x11 + p31*x12 + p38*x13 + p45*x14; 521bef36659SShri Abhyankar pc[10] = m11 = p4*x8 + p11*x9 + p18*x10 + p25*x11 + p32*x12 + p39*x13 + p46*x14; 522bef36659SShri Abhyankar pc[11] = m12 = p5*x8 + p12*x9 + p19*x10 + p26*x11 + p33*x12 + p40*x13 + p47*x14; 523bef36659SShri Abhyankar pc[12] = m13 = p6*x8 + p13*x9 + p20*x10 + p27*x11 + p34*x12 + p41*x13 + p48*x14; 524bef36659SShri Abhyankar pc[13] = m14 = p7*x8 + p14*x9 + p21*x10 + p28*x11 + p35*x12 + p42*x13 + p49*x14; 525bef36659SShri Abhyankar 526bef36659SShri Abhyankar pc[14] = m15 = p1*x15 + p8*x16 + p15*x17 + p22*x18 + p29*x19 + p36*x20 + p43*x21; 527bef36659SShri Abhyankar pc[15] = m16 = p2*x15 + p9*x16 + p16*x17 + p23*x18 + p30*x19 + p37*x20 + p44*x21; 528bef36659SShri Abhyankar pc[16] = m17 = p3*x15 + p10*x16 + p17*x17 + p24*x18 + p31*x19 + p38*x20 + p45*x21; 529bef36659SShri Abhyankar pc[17] = m18 = p4*x15 + p11*x16 + p18*x17 + p25*x18 + p32*x19 + p39*x20 + p46*x21; 530bef36659SShri Abhyankar pc[18] = m19 = p5*x15 + p12*x16 + p19*x17 + p26*x18 + p33*x19 + p40*x20 + p47*x21; 531bef36659SShri Abhyankar pc[19] = m20 = p6*x15 + p13*x16 + p20*x17 + p27*x18 + p34*x19 + p41*x20 + p48*x21; 532bef36659SShri Abhyankar pc[20] = m21 = p7*x15 + p14*x16 + p21*x17 + p28*x18 + p35*x19 + p42*x20 + p49*x21; 533bef36659SShri Abhyankar 534bef36659SShri Abhyankar pc[21] = m22 = p1*x22 + p8*x23 + p15*x24 + p22*x25 + p29*x26 + p36*x27 + p43*x28; 535bef36659SShri Abhyankar pc[22] = m23 = p2*x22 + p9*x23 + p16*x24 + p23*x25 + p30*x26 + p37*x27 + p44*x28; 536bef36659SShri Abhyankar pc[23] = m24 = p3*x22 + p10*x23 + p17*x24 + p24*x25 + p31*x26 + p38*x27 + p45*x28; 537bef36659SShri Abhyankar pc[24] = m25 = p4*x22 + p11*x23 + p18*x24 + p25*x25 + p32*x26 + p39*x27 + p46*x28; 538bef36659SShri Abhyankar pc[25] = m26 = p5*x22 + p12*x23 + p19*x24 + p26*x25 + p33*x26 + p40*x27 + p47*x28; 539bef36659SShri Abhyankar pc[26] = m27 = p6*x22 + p13*x23 + p20*x24 + p27*x25 + p34*x26 + p41*x27 + p48*x28; 540bef36659SShri Abhyankar pc[27] = m28 = p7*x22 + p14*x23 + p21*x24 + p28*x25 + p35*x26 + p42*x27 + p49*x28; 541bef36659SShri Abhyankar 542bef36659SShri Abhyankar pc[28] = m29 = p1*x29 + p8*x30 + p15*x31 + p22*x32 + p29*x33 + p36*x34 + p43*x35; 543bef36659SShri Abhyankar pc[29] = m30 = p2*x29 + p9*x30 + p16*x31 + p23*x32 + p30*x33 + p37*x34 + p44*x35; 544bef36659SShri Abhyankar pc[30] = m31 = p3*x29 + p10*x30 + p17*x31 + p24*x32 + p31*x33 + p38*x34 + p45*x35; 545bef36659SShri Abhyankar pc[31] = m32 = p4*x29 + p11*x30 + p18*x31 + p25*x32 + p32*x33 + p39*x34 + p46*x35; 546bef36659SShri Abhyankar pc[32] = m33 = p5*x29 + p12*x30 + p19*x31 + p26*x32 + p33*x33 + p40*x34 + p47*x35; 547bef36659SShri Abhyankar pc[33] = m34 = p6*x29 + p13*x30 + p20*x31 + p27*x32 + p34*x33 + p41*x34 + p48*x35; 548bef36659SShri Abhyankar pc[34] = m35 = p7*x29 + p14*x30 + p21*x31 + p28*x32 + p35*x33 + p42*x34 + p49*x35; 549bef36659SShri Abhyankar 550bef36659SShri Abhyankar pc[35] = m36 = p1*x36 + p8*x37 + p15*x38 + p22*x39 + p29*x40 + p36*x41 + p43*x42; 551bef36659SShri Abhyankar pc[36] = m37 = p2*x36 + p9*x37 + p16*x38 + p23*x39 + p30*x40 + p37*x41 + p44*x42; 552bef36659SShri Abhyankar pc[37] = m38 = p3*x36 + p10*x37 + p17*x38 + p24*x39 + p31*x40 + p38*x41 + p45*x42; 553bef36659SShri Abhyankar pc[38] = m39 = p4*x36 + p11*x37 + p18*x38 + p25*x39 + p32*x40 + p39*x41 + p46*x42; 554bef36659SShri Abhyankar pc[39] = m40 = p5*x36 + p12*x37 + p19*x38 + p26*x39 + p33*x40 + p40*x41 + p47*x42; 555bef36659SShri Abhyankar pc[40] = m41 = p6*x36 + p13*x37 + p20*x38 + p27*x39 + p34*x40 + p41*x41 + p48*x42; 556bef36659SShri Abhyankar pc[41] = m42 = p7*x36 + p14*x37 + p21*x38 + p28*x39 + p35*x40 + p42*x41 + p49*x42; 557bef36659SShri Abhyankar 558bef36659SShri Abhyankar pc[42] = m43 = p1*x43 + p8*x44 + p15*x45 + p22*x46 + p29*x47 + p36*x48 + p43*x49; 559bef36659SShri Abhyankar pc[43] = m44 = p2*x43 + p9*x44 + p16*x45 + p23*x46 + p30*x47 + p37*x48 + p44*x49; 560bef36659SShri Abhyankar pc[44] = m45 = p3*x43 + p10*x44 + p17*x45 + p24*x46 + p31*x47 + p38*x48 + p45*x49; 561bef36659SShri Abhyankar pc[45] = m46 = p4*x43 + p11*x44 + p18*x45 + p25*x46 + p32*x47 + p39*x48 + p46*x49; 562bef36659SShri Abhyankar pc[46] = m47 = p5*x43 + p12*x44 + p19*x45 + p26*x46 + p33*x47 + p40*x48 + p47*x49; 563bef36659SShri Abhyankar pc[47] = m48 = p6*x43 + p13*x44 + p20*x45 + p27*x46 + p34*x47 + p41*x48 + p48*x49; 564bef36659SShri Abhyankar pc[48] = m49 = p7*x43 + p14*x44 + p21*x45 + p28*x46 + p35*x47 + p42*x48 + p49*x49; 565bef36659SShri Abhyankar 566bef36659SShri Abhyankar nz = bi[row+1] - diag_offset[row] - 1; 567bef36659SShri Abhyankar pv += 49; 568bef36659SShri Abhyankar for (j=0; j<nz; j++) { 569bef36659SShri Abhyankar x1 = pv[0]; x2 = pv[1]; x3 = pv[2]; x4 = pv[3]; 570bef36659SShri Abhyankar x5 = pv[4]; x6 = pv[5]; x7 = pv[6]; x8 = pv[7]; 571bef36659SShri Abhyankar x9 = pv[8]; x10 = pv[9]; x11 = pv[10]; x12 = pv[11]; 572bef36659SShri Abhyankar x13 = pv[12]; x14 = pv[13]; x15 = pv[14]; x16 = pv[15]; 573bef36659SShri Abhyankar x17 = pv[16]; x18 = pv[17]; x19 = pv[18]; x20 = pv[19]; 574bef36659SShri Abhyankar x21 = pv[20]; x22 = pv[21]; x23 = pv[22]; x24 = pv[23]; 575bef36659SShri Abhyankar x25 = pv[24]; x26 = pv[25]; x27 = pv[26]; x28 = pv[27]; 576bef36659SShri Abhyankar x29 = pv[28]; x30 = pv[29]; x31 = pv[30]; x32 = pv[31]; 577bef36659SShri Abhyankar x33 = pv[32]; x34 = pv[33]; x35 = pv[34]; x36 = pv[35]; 578bef36659SShri Abhyankar x37 = pv[36]; x38 = pv[37]; x39 = pv[38]; x40 = pv[39]; 579bef36659SShri Abhyankar x41 = pv[40]; x42 = pv[41]; x43 = pv[42]; x44 = pv[43]; 580bef36659SShri Abhyankar x45 = pv[44]; x46 = pv[45]; x47 = pv[46]; x48 = pv[47]; 581bef36659SShri Abhyankar x49 = pv[48]; 582bef36659SShri Abhyankar x = rtmp + 49*pj[j]; 583bef36659SShri Abhyankar x[0] -= m1*x1 + m8*x2 + m15*x3 + m22*x4 + m29*x5 + m36*x6 + m43*x7; 584bef36659SShri Abhyankar x[1] -= m2*x1 + m9*x2 + m16*x3 + m23*x4 + m30*x5 + m37*x6 + m44*x7; 585bef36659SShri Abhyankar x[2] -= m3*x1 + m10*x2 + m17*x3 + m24*x4 + m31*x5 + m38*x6 + m45*x7; 586bef36659SShri Abhyankar x[3] -= m4*x1 + m11*x2 + m18*x3 + m25*x4 + m32*x5 + m39*x6 + m46*x7; 587bef36659SShri Abhyankar x[4] -= m5*x1 + m12*x2 + m19*x3 + m26*x4 + m33*x5 + m40*x6 + m47*x7; 588bef36659SShri Abhyankar x[5] -= m6*x1 + m13*x2 + m20*x3 + m27*x4 + m34*x5 + m41*x6 + m48*x7; 589bef36659SShri Abhyankar x[6] -= m7*x1 + m14*x2 + m21*x3 + m28*x4 + m35*x5 + m42*x6 + m49*x7; 590bef36659SShri Abhyankar 591bef36659SShri Abhyankar x[7] -= m1*x8 + m8*x9 + m15*x10 + m22*x11 + m29*x12 + m36*x13 + m43*x14; 592bef36659SShri Abhyankar x[8] -= m2*x8 + m9*x9 + m16*x10 + m23*x11 + m30*x12 + m37*x13 + m44*x14; 593bef36659SShri Abhyankar x[9] -= m3*x8 + m10*x9 + m17*x10 + m24*x11 + m31*x12 + m38*x13 + m45*x14; 594bef36659SShri Abhyankar x[10] -= m4*x8 + m11*x9 + m18*x10 + m25*x11 + m32*x12 + m39*x13 + m46*x14; 595bef36659SShri Abhyankar x[11] -= m5*x8 + m12*x9 + m19*x10 + m26*x11 + m33*x12 + m40*x13 + m47*x14; 596bef36659SShri Abhyankar x[12] -= m6*x8 + m13*x9 + m20*x10 + m27*x11 + m34*x12 + m41*x13 + m48*x14; 597bef36659SShri Abhyankar x[13] -= m7*x8 + m14*x9 + m21*x10 + m28*x11 + m35*x12 + m42*x13 + m49*x14; 598bef36659SShri Abhyankar 599bef36659SShri Abhyankar x[14] -= m1*x15 + m8*x16 + m15*x17 + m22*x18 + m29*x19 + m36*x20 + m43*x21; 600bef36659SShri Abhyankar x[15] -= m2*x15 + m9*x16 + m16*x17 + m23*x18 + m30*x19 + m37*x20 + m44*x21; 601bef36659SShri Abhyankar x[16] -= m3*x15 + m10*x16 + m17*x17 + m24*x18 + m31*x19 + m38*x20 + m45*x21; 602bef36659SShri Abhyankar x[17] -= m4*x15 + m11*x16 + m18*x17 + m25*x18 + m32*x19 + m39*x20 + m46*x21; 603bef36659SShri Abhyankar x[18] -= m5*x15 + m12*x16 + m19*x17 + m26*x18 + m33*x19 + m40*x20 + m47*x21; 604bef36659SShri Abhyankar x[19] -= m6*x15 + m13*x16 + m20*x17 + m27*x18 + m34*x19 + m41*x20 + m48*x21; 605bef36659SShri Abhyankar x[20] -= m7*x15 + m14*x16 + m21*x17 + m28*x18 + m35*x19 + m42*x20 + m49*x21; 606bef36659SShri Abhyankar 607bef36659SShri Abhyankar x[21] -= m1*x22 + m8*x23 + m15*x24 + m22*x25 + m29*x26 + m36*x27 + m43*x28; 608bef36659SShri Abhyankar x[22] -= m2*x22 + m9*x23 + m16*x24 + m23*x25 + m30*x26 + m37*x27 + m44*x28; 609bef36659SShri Abhyankar x[23] -= m3*x22 + m10*x23 + m17*x24 + m24*x25 + m31*x26 + m38*x27 + m45*x28; 610bef36659SShri Abhyankar x[24] -= m4*x22 + m11*x23 + m18*x24 + m25*x25 + m32*x26 + m39*x27 + m46*x28; 611bef36659SShri Abhyankar x[25] -= m5*x22 + m12*x23 + m19*x24 + m26*x25 + m33*x26 + m40*x27 + m47*x28; 612bef36659SShri Abhyankar x[26] -= m6*x22 + m13*x23 + m20*x24 + m27*x25 + m34*x26 + m41*x27 + m48*x28; 613bef36659SShri Abhyankar x[27] -= m7*x22 + m14*x23 + m21*x24 + m28*x25 + m35*x26 + m42*x27 + m49*x28; 614bef36659SShri Abhyankar 615bef36659SShri Abhyankar x[28] -= m1*x29 + m8*x30 + m15*x31 + m22*x32 + m29*x33 + m36*x34 + m43*x35; 616bef36659SShri Abhyankar x[29] -= m2*x29 + m9*x30 + m16*x31 + m23*x32 + m30*x33 + m37*x34 + m44*x35; 617bef36659SShri Abhyankar x[30] -= m3*x29 + m10*x30 + m17*x31 + m24*x32 + m31*x33 + m38*x34 + m45*x35; 618bef36659SShri Abhyankar x[31] -= m4*x29 + m11*x30 + m18*x31 + m25*x32 + m32*x33 + m39*x34 + m46*x35; 619bef36659SShri Abhyankar x[32] -= m5*x29 + m12*x30 + m19*x31 + m26*x32 + m33*x33 + m40*x34 + m47*x35; 620bef36659SShri Abhyankar x[33] -= m6*x29 + m13*x30 + m20*x31 + m27*x32 + m34*x33 + m41*x34 + m48*x35; 621bef36659SShri Abhyankar x[34] -= m7*x29 + m14*x30 + m21*x31 + m28*x32 + m35*x33 + m42*x34 + m49*x35; 622bef36659SShri Abhyankar 623bef36659SShri Abhyankar x[35] -= m1*x36 + m8*x37 + m15*x38 + m22*x39 + m29*x40 + m36*x41 + m43*x42; 624bef36659SShri Abhyankar x[36] -= m2*x36 + m9*x37 + m16*x38 + m23*x39 + m30*x40 + m37*x41 + m44*x42; 625bef36659SShri Abhyankar x[37] -= m3*x36 + m10*x37 + m17*x38 + m24*x39 + m31*x40 + m38*x41 + m45*x42; 626bef36659SShri Abhyankar x[38] -= m4*x36 + m11*x37 + m18*x38 + m25*x39 + m32*x40 + m39*x41 + m46*x42; 627bef36659SShri Abhyankar x[39] -= m5*x36 + m12*x37 + m19*x38 + m26*x39 + m33*x40 + m40*x41 + m47*x42; 628bef36659SShri Abhyankar x[40] -= m6*x36 + m13*x37 + m20*x38 + m27*x39 + m34*x40 + m41*x41 + m48*x42; 629bef36659SShri Abhyankar x[41] -= m7*x36 + m14*x37 + m21*x38 + m28*x39 + m35*x40 + m42*x41 + m49*x42; 630bef36659SShri Abhyankar 631bef36659SShri Abhyankar x[42] -= m1*x43 + m8*x44 + m15*x45 + m22*x46 + m29*x47 + m36*x48 + m43*x49; 632bef36659SShri Abhyankar x[43] -= m2*x43 + m9*x44 + m16*x45 + m23*x46 + m30*x47 + m37*x48 + m44*x49; 633bef36659SShri Abhyankar x[44] -= m3*x43 + m10*x44 + m17*x45 + m24*x46 + m31*x47 + m38*x48 + m45*x49; 634bef36659SShri Abhyankar x[45] -= m4*x43 + m11*x44 + m18*x45 + m25*x46 + m32*x47 + m39*x48 + m46*x49; 635bef36659SShri Abhyankar x[46] -= m5*x43 + m12*x44 + m19*x45 + m26*x46 + m33*x47 + m40*x48 + m47*x49; 636bef36659SShri Abhyankar x[47] -= m6*x43 + m13*x44 + m20*x45 + m27*x46 + m34*x47 + m41*x48 + m48*x49; 637bef36659SShri Abhyankar x[48] -= m7*x43 + m14*x44 + m21*x45 + m28*x46 + m35*x47 + m42*x48 + m49*x49; 638bef36659SShri Abhyankar pv += 49; 639bef36659SShri Abhyankar } 640bef36659SShri Abhyankar ierr = PetscLogFlops(686.0*nz+637.0);CHKERRQ(ierr); 641bef36659SShri Abhyankar } 642bef36659SShri Abhyankar row = *ajtmp++; 643bef36659SShri Abhyankar } 644bef36659SShri Abhyankar /* finished row so stick it into b->a */ 645bef36659SShri Abhyankar pv = ba + 49*bi[i]; 646bef36659SShri Abhyankar pj = bj + bi[i]; 647bef36659SShri Abhyankar nz = bi[i+1] - bi[i]; 648bef36659SShri Abhyankar for (j=0; j<nz; j++) { 649bef36659SShri Abhyankar x = rtmp+49*pj[j]; 650bef36659SShri Abhyankar pv[0] = x[0]; pv[1] = x[1]; pv[2] = x[2]; pv[3] = x[3]; 651bef36659SShri Abhyankar pv[4] = x[4]; pv[5] = x[5]; pv[6] = x[6]; pv[7] = x[7]; 652bef36659SShri Abhyankar pv[8] = x[8]; pv[9] = x[9]; pv[10] = x[10]; pv[11] = x[11]; 653bef36659SShri Abhyankar pv[12] = x[12]; pv[13] = x[13]; pv[14] = x[14]; pv[15] = x[15]; 654bef36659SShri Abhyankar pv[16] = x[16]; pv[17] = x[17]; pv[18] = x[18]; pv[19] = x[19]; 655bef36659SShri Abhyankar pv[20] = x[20]; pv[21] = x[21]; pv[22] = x[22]; pv[23] = x[23]; 656bef36659SShri Abhyankar pv[24] = x[24]; pv[25] = x[25]; pv[26] = x[26]; pv[27] = x[27]; 657bef36659SShri Abhyankar pv[28] = x[28]; pv[29] = x[29]; pv[30] = x[30]; pv[31] = x[31]; 658bef36659SShri Abhyankar pv[32] = x[32]; pv[33] = x[33]; pv[34] = x[34]; pv[35] = x[35]; 659bef36659SShri Abhyankar pv[36] = x[36]; pv[37] = x[37]; pv[38] = x[38]; pv[39] = x[39]; 660bef36659SShri Abhyankar pv[40] = x[40]; pv[41] = x[41]; pv[42] = x[42]; pv[43] = x[43]; 661bef36659SShri Abhyankar pv[44] = x[44]; pv[45] = x[45]; pv[46] = x[46]; pv[47] = x[47]; 662bef36659SShri Abhyankar pv[48] = x[48]; 663bef36659SShri Abhyankar pv += 49; 664bef36659SShri Abhyankar } 665bef36659SShri Abhyankar /* invert diagonal block */ 666bef36659SShri Abhyankar w = ba + 49*diag_offset[i]; 66796b95a6bSBarry Smith ierr = PetscKernel_A_gets_inverse_A_7(w,shift);CHKERRQ(ierr); 668bef36659SShri Abhyankar } 669bef36659SShri Abhyankar 670bef36659SShri Abhyankar ierr = PetscFree(rtmp);CHKERRQ(ierr); 671*26fbe8dcSKarl Rupp 67206e38f1dSHong Zhang C->ops->solve = MatSolve_SeqBAIJ_7_NaturalOrdering_inplace; 67306e38f1dSHong Zhang C->ops->solvetranspose = MatSolveTranspose_SeqBAIJ_7_NaturalOrdering_inplace; 674bef36659SShri Abhyankar C->assembled = PETSC_TRUE; 675*26fbe8dcSKarl Rupp 676766f9fbaSBarry Smith ierr = PetscLogFlops(1.333333333333*7*7*7*b->mbs);CHKERRQ(ierr); /* from inverting diagonal blocks */ 677bef36659SShri Abhyankar PetscFunctionReturn(0); 678bef36659SShri Abhyankar } 679bef36659SShri Abhyankar 680bef36659SShri Abhyankar #undef __FUNCT__ 6814dd39f65SShri Abhyankar #define __FUNCT__ "MatLUFactorNumeric_SeqBAIJ_7_NaturalOrdering" 6824dd39f65SShri Abhyankar PetscErrorCode MatLUFactorNumeric_SeqBAIJ_7_NaturalOrdering(Mat B,Mat A,const MatFactorInfo *info) 683bef36659SShri Abhyankar { 684bef36659SShri Abhyankar Mat C =B; 685bef36659SShri Abhyankar Mat_SeqBAIJ *a=(Mat_SeqBAIJ*)A->data,*b=(Mat_SeqBAIJ*)C->data; 686bef36659SShri Abhyankar PetscErrorCode ierr; 687bbd65245SShri Abhyankar PetscInt i,j,k,nz,nzL,row; 688bbd65245SShri Abhyankar const PetscInt n=a->mbs,*ai=a->i,*aj=a->j,*bi=b->i,*bj=b->j; 689bbd65245SShri Abhyankar const PetscInt *ajtmp,*bjtmp,*bdiag=b->diag,*pj,bs2=a->bs2; 690bef36659SShri Abhyankar MatScalar *rtmp,*pc,*mwork,*v,*pv,*aa=a->a; 691bbd65245SShri Abhyankar PetscInt flg; 692182b8fbaSHong Zhang PetscReal shift = info->shiftamount; 693bef36659SShri Abhyankar 694bef36659SShri Abhyankar PetscFunctionBegin; 695bef36659SShri Abhyankar /* generate work space needed by the factorization */ 69674ed9c26SBarry Smith ierr = PetscMalloc2(bs2*n,MatScalar,&rtmp,bs2,MatScalar,&mwork);CHKERRQ(ierr); 697bef36659SShri Abhyankar ierr = PetscMemzero(rtmp,bs2*n*sizeof(MatScalar));CHKERRQ(ierr); 698bef36659SShri Abhyankar 699bef36659SShri Abhyankar for (i=0; i<n; i++) { 700bef36659SShri Abhyankar /* zero rtmp */ 701bef36659SShri Abhyankar /* L part */ 702bef36659SShri Abhyankar nz = bi[i+1] - bi[i]; 703bef36659SShri Abhyankar bjtmp = bj + bi[i]; 704bef36659SShri Abhyankar for (j=0; j<nz; j++) { 705bef36659SShri Abhyankar ierr = PetscMemzero(rtmp+bs2*bjtmp[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 706bef36659SShri Abhyankar } 707bef36659SShri Abhyankar 708bef36659SShri Abhyankar /* U part */ 70953cca76cSShri Abhyankar nz = bdiag[i] - bdiag[i+1]; 71053cca76cSShri Abhyankar bjtmp = bj + bdiag[i+1]+1; 71153cca76cSShri Abhyankar for (j=0; j<nz; j++) { 71253cca76cSShri Abhyankar ierr = PetscMemzero(rtmp+bs2*bjtmp[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 71353cca76cSShri Abhyankar } 71453cca76cSShri Abhyankar 71553cca76cSShri Abhyankar /* load in initial (unfactored row) */ 71653cca76cSShri Abhyankar nz = ai[i+1] - ai[i]; 71753cca76cSShri Abhyankar ajtmp = aj + ai[i]; 71853cca76cSShri Abhyankar v = aa + bs2*ai[i]; 71953cca76cSShri Abhyankar for (j=0; j<nz; j++) { 72053cca76cSShri Abhyankar ierr = PetscMemcpy(rtmp+bs2*ajtmp[j],v+bs2*j,bs2*sizeof(MatScalar));CHKERRQ(ierr); 72153cca76cSShri Abhyankar } 72253cca76cSShri Abhyankar 72353cca76cSShri Abhyankar /* elimination */ 72453cca76cSShri Abhyankar bjtmp = bj + bi[i]; 72553cca76cSShri Abhyankar nzL = bi[i+1] - bi[i]; 72653cca76cSShri Abhyankar for (k=0; k < nzL; k++) { 72753cca76cSShri Abhyankar row = bjtmp[k]; 72853cca76cSShri Abhyankar pc = rtmp + bs2*row; 729c35f09e5SBarry Smith for (flg=0,j=0; j<bs2; j++) { 730c35f09e5SBarry Smith if (pc[j]!=0.0) { 731c35f09e5SBarry Smith flg = 1; 732c35f09e5SBarry Smith break; 733c35f09e5SBarry Smith } 734c35f09e5SBarry Smith } 73553cca76cSShri Abhyankar if (flg) { 73653cca76cSShri Abhyankar pv = b->a + bs2*bdiag[row]; 73796b95a6bSBarry Smith /* PetscKernel_A_gets_A_times_B(bs,pc,pv,mwork); *pc = *pc * (*pv); */ 73896b95a6bSBarry Smith ierr = PetscKernel_A_gets_A_times_B_7(pc,pv,mwork);CHKERRQ(ierr); 73953cca76cSShri Abhyankar 74053cca76cSShri Abhyankar pj = b->j + bdiag[row+1]+1; /* begining of U(row,:) */ 74153cca76cSShri Abhyankar pv = b->a + bs2*(bdiag[row+1]+1); 74253cca76cSShri Abhyankar nz = bdiag[row] - bdiag[row+1] - 1; /* num of entries inU(row,:), excluding diag */ 74353cca76cSShri Abhyankar for (j=0; j<nz; j++) { 74496b95a6bSBarry Smith /* PetscKernel_A_gets_A_minus_B_times_C(bs,rtmp+bs2*pj[j],pc,pv+bs2*j); */ 74553cca76cSShri Abhyankar /* rtmp+bs2*pj[j] = rtmp+bs2*pj[j] - (*pc)*(pv+bs2*j) */ 74653cca76cSShri Abhyankar v = rtmp + bs2*pj[j]; 74796b95a6bSBarry Smith ierr = PetscKernel_A_gets_A_minus_B_times_C_7(v,pc,pv);CHKERRQ(ierr); 74853cca76cSShri Abhyankar pv += bs2; 74953cca76cSShri Abhyankar } 75053cca76cSShri Abhyankar ierr = PetscLogFlops(686*nz+637);CHKERRQ(ierr); /* flops = 2*bs^3*nz + 2*bs^3 - bs2) */ 75153cca76cSShri Abhyankar } 75253cca76cSShri Abhyankar } 75353cca76cSShri Abhyankar 75453cca76cSShri Abhyankar /* finished row so stick it into b->a */ 75553cca76cSShri Abhyankar /* L part */ 75653cca76cSShri Abhyankar pv = b->a + bs2*bi[i]; 75753cca76cSShri Abhyankar pj = b->j + bi[i]; 75853cca76cSShri Abhyankar nz = bi[i+1] - bi[i]; 75953cca76cSShri Abhyankar for (j=0; j<nz; j++) { 76053cca76cSShri Abhyankar ierr = PetscMemcpy(pv+bs2*j,rtmp+bs2*pj[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 76153cca76cSShri Abhyankar } 76253cca76cSShri Abhyankar 76353cca76cSShri Abhyankar /* Mark diagonal and invert diagonal for simplier triangular solves */ 76453cca76cSShri Abhyankar pv = b->a + bs2*bdiag[i]; 76553cca76cSShri Abhyankar pj = b->j + bdiag[i]; 76653cca76cSShri Abhyankar ierr = PetscMemcpy(pv,rtmp+bs2*pj[0],bs2*sizeof(MatScalar));CHKERRQ(ierr); 76796b95a6bSBarry Smith /* ierr = PetscKernel_A_gets_inverse_A(bs,pv,v_pivots,v_work);CHKERRQ(ierr); */ 76896b95a6bSBarry Smith ierr = PetscKernel_A_gets_inverse_A_7(pv,shift);CHKERRQ(ierr); 76953cca76cSShri Abhyankar 77053cca76cSShri Abhyankar /* U part */ 77153cca76cSShri Abhyankar pv = b->a + bs2*(bdiag[i+1]+1); 77253cca76cSShri Abhyankar pj = b->j + bdiag[i+1]+1; 77353cca76cSShri Abhyankar nz = bdiag[i] - bdiag[i+1] - 1; 77453cca76cSShri Abhyankar for (j=0; j<nz; j++) { 77553cca76cSShri Abhyankar ierr = PetscMemcpy(pv+bs2*j,rtmp+bs2*pj[j],bs2*sizeof(MatScalar));CHKERRQ(ierr); 77653cca76cSShri Abhyankar } 77753cca76cSShri Abhyankar } 77874ed9c26SBarry Smith ierr = PetscFree2(rtmp,mwork);CHKERRQ(ierr); 779*26fbe8dcSKarl Rupp 7804dd39f65SShri Abhyankar C->ops->solve = MatSolve_SeqBAIJ_7_NaturalOrdering; 7814dd39f65SShri Abhyankar C->ops->solvetranspose = MatSolveTranspose_SeqBAIJ_7_NaturalOrdering; 78253cca76cSShri Abhyankar C->assembled = PETSC_TRUE; 783*26fbe8dcSKarl Rupp 784766f9fbaSBarry Smith ierr = PetscLogFlops(1.333333333333*7*7*7*n);CHKERRQ(ierr); /* from inverting diagonal blocks */ 78553cca76cSShri Abhyankar PetscFunctionReturn(0); 78653cca76cSShri Abhyankar } 78753cca76cSShri Abhyankar 788