/* Factorization code for BAIJ format. */ #include <../src/mat/impls/baij/seq/baij.h> #include /* ----------------------------------------------------------- */ PetscErrorCode MatLUFactorNumeric_SeqBAIJ_N_inplace(Mat C,Mat A,const MatFactorInfo *info) { Mat_SeqBAIJ *a = (Mat_SeqBAIJ*)A->data,*b = (Mat_SeqBAIJ*)C->data; IS isrow = b->row,isicol = b->icol; const PetscInt *r,*ic; PetscInt i,j,n = a->mbs,*bi = b->i,*bj = b->j; PetscInt *ajtmpold,*ajtmp,nz,row,*ai=a->i,*aj=a->j,k,flg; PetscInt *diag_offset=b->diag,diag,bs=A->rmap->bs,bs2 = a->bs2,*pj,*v_pivots; MatScalar *ba = b->a,*aa = a->a,*pv,*v,*rtmp,*multiplier,*v_work,*pc,*w; PetscBool allowzeropivot,zeropivotdetected; PetscFunctionBegin; PetscCall(ISGetIndices(isrow,&r)); PetscCall(ISGetIndices(isicol,&ic)); allowzeropivot = PetscNot(A->erroriffailure); PetscCall(PetscCalloc1(bs2*(n+1),&rtmp)); /* generate work space needed by dense LU factorization */ PetscCall(PetscMalloc3(bs,&v_work,bs2,&multiplier,bs,&v_pivots)); for (i=0; ia */ pv = ba + bs2*bi[i]; pj = bj + bi[i]; nz = bi[i+1] - bi[i]; for (j=0; jfactorerrortype = MAT_FACTOR_NUMERIC_ZEROPIVOT; } PetscCall(PetscFree(rtmp)); PetscCall(PetscFree3(v_work,multiplier,v_pivots)); PetscCall(ISRestoreIndices(isicol,&ic)); PetscCall(ISRestoreIndices(isrow,&r)); C->ops->solve = MatSolve_SeqBAIJ_N_inplace; C->ops->solvetranspose = MatSolveTranspose_SeqBAIJ_N_inplace; C->assembled = PETSC_TRUE; PetscCall(PetscLogFlops(1.333333333333*bs*bs2*b->mbs)); /* from inverting diagonal blocks */ PetscFunctionReturn(0); }