#include <../src/mat/impls/baij/seq/baij.h> #include PetscErrorCode MatSolveTranspose_SeqBAIJ_6_inplace(Mat A,Vec bb,Vec xx) { Mat_SeqBAIJ *a =(Mat_SeqBAIJ*)A->data; IS iscol=a->col,isrow=a->row; PetscErrorCode ierr; const PetscInt *r,*c,*rout,*cout; const PetscInt *diag=a->diag,n=a->mbs,*vi,*ai=a->i,*aj=a->j; PetscInt i,nz,idx,idt,ii,ic,ir,oidx; const MatScalar *aa=a->a,*v; PetscScalar s1,s2,s3,s4,s5,s6,x1,x2,x3,x4,x5,x6,*x,*t; const PetscScalar *b; PetscFunctionBegin; ierr = VecGetArrayRead(bb,&b);CHKERRQ(ierr); ierr = VecGetArray(xx,&x);CHKERRQ(ierr); t = a->solve_work; ierr = ISGetIndices(isrow,&rout);CHKERRQ(ierr); r = rout; ierr = ISGetIndices(iscol,&cout);CHKERRQ(ierr); c = cout; /* copy the b into temp work space according to permutation */ ii = 0; for (i=0; i=0; i--) { v = aa + 36*diag[i] - 36; vi = aj + diag[i] - 1; nz = diag[i] - ai[i]; idt = 6*i; s1 = t[idt]; s2 = t[1+idt]; s3 = t[2+idt];s4 = t[3+idt]; s5 = t[4+idt]; s6 = t[5+idt]; while (nz--) { idx = 6*(*vi--); t[idx] -= v[0]*s1 + v[1]*s2 + v[2]*s3 + v[3]*s4 + v[4]*s5 + v[5]*s6; t[idx+1] -= v[6]*s1 + v[7]*s2 + v[8]*s3 + v[9]*s4 + v[10]*s5 + v[11]*s6; t[idx+2] -= v[12]*s1 + v[13]*s2 + v[14]*s3 + v[15]*s4 + v[16]*s5 + v[17]*s6; t[idx+3] -= v[18]*s1 + v[19]*s2 + v[20]*s3 + v[21]*s4 + v[22]*s5 + v[23]*s6; t[idx+4] -= v[24]*s1 + v[25]*s2 + v[26]*s3 + v[27]*s4 + v[28]*s5 + v[29]*s6; t[idx+5] -= v[30]*s1 + v[31]*s2 + v[32]*s3 + v[33]*s4 + v[34]*s5 + v[35]*s6; v -= 36; } } /* copy t into x according to permutation */ ii = 0; for (i=0; inz) - 6.0*A->cmap->n);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode MatSolveTranspose_SeqBAIJ_6(Mat A,Vec bb,Vec xx) { Mat_SeqBAIJ *a=(Mat_SeqBAIJ*)A->data; PetscErrorCode ierr; IS iscol=a->col,isrow=a->row; const PetscInt n =a->mbs,*vi,*ai=a->i,*aj=a->j,*diag=a->diag; const PetscInt *r,*c,*rout,*cout; PetscInt nz,idx,idt,j,i,oidx,ii,ic,ir; const PetscInt bs =A->rmap->bs,bs2=a->bs2; const MatScalar *aa=a->a,*v; PetscScalar s1,s2,s3,s4,s5,s6,x1,x2,x3,x4,x5,x6,*x,*t; const PetscScalar *b; PetscFunctionBegin; ierr = VecGetArrayRead(bb,&b);CHKERRQ(ierr); ierr = VecGetArray(xx,&x);CHKERRQ(ierr); t = a->solve_work; ierr = ISGetIndices(isrow,&rout);CHKERRQ(ierr); r = rout; ierr = ISGetIndices(iscol,&cout);CHKERRQ(ierr); c = cout; /* copy b into temp work space according to permutation */ for (i=0; i-nz; j--) { oidx = bs*vi[j]; t[oidx] -= v[0]*s1 + v[1]*s2 + v[2]*s3 + v[3]*s4 + v[4]*s5 + v[5]*s6; t[oidx+1] -= v[6]*s1 + v[7]*s2 + v[8]*s3 + v[9]*s4 + v[10]*s5 + v[11]*s6; t[oidx+2] -= v[12]*s1 + v[13]*s2 + v[14]*s3 + v[15]*s4 + v[16]*s5 + v[17]*s6; t[oidx+3] -= v[18]*s1 + v[19]*s2 + v[20]*s3 + v[21]*s4 + v[22]*s5 + v[23]*s6; t[oidx+4] -= v[24]*s1 + v[25]*s2 + v[26]*s3 + v[27]*s4 + v[28]*s5 + v[29]*s6; t[oidx+5] -= v[30]*s1 + v[31]*s2 + v[32]*s3 + v[33]*s4 + v[34]*s5 + v[35]*s6; v -= bs2; } t[idx] = s1;t[1+idx] = s2; t[2+idx] = s3; t[3+idx] = s4; t[4+idx] =s5; t[5+idx] = s6; idx += bs; } /* backward solve the L^T */ for (i=n-1; i>=0; i--) { v = aa + bs2*ai[i]; vi = aj + ai[i]; nz = ai[i+1] - ai[i]; idt = bs*i; s1 = t[idt]; s2 = t[1+idt]; s3 = t[2+idt]; s4 = t[3+idt]; s5 = t[4+idt]; s6 = t[5+idt]; for (j=0; jnz) - bs*A->cmap->n);CHKERRQ(ierr); PetscFunctionReturn(0); }