PetscErrorCode MatSolve_LUSOL(Mat A,Vec b,Vec x) { Mat_LUSOL *lusol=(Mat_LUSOL*)A->spptr; double *xx; const double *bb; int mode=5; PetscErrorCode ierr; int i,m,n,nnz,status; PetscFunctionBegin; ierr = VecGetArray(x, &xx);CHKERRQ(ierr); ierr = VecGetArrayRead(b, &bb);CHKERRQ(ierr); m = n = lusol->n; nnz = lusol->nnz; for (i = 0; i < m; i++) lusol->mnsv[i] = bb[i]; LU6SOL(&mode, &m, &n, lusol->mnsv, xx, &nnz, lusol->luparm, lusol->parmlu, lusol->data, lusol->indc, lusol->indr, lusol->ip, lusol->iq, lusol->lenc, lusol->lenr, lusol->locc, lusol->locr, &status); if (status) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"solve failed, error code %d",status); ierr = VecRestoreArray(x, &xx);CHKERRQ(ierr); ierr = VecRestoreArrayRead(b, &bb);CHKERRQ(ierr); PetscFunctionReturn(0); }
int LUSOL_btran(LUSOLrec *LUSOL, REAL b[], int NZidx[]) { int inform; /* Copy RHS vector, but make adjustment for offset since this can create a memory error when the calling program uses a 0-base vector offset back to comply with LUSOL. */ MEMCOPY(LUSOL->w+1, b+1, LUSOL->m); if (LUSOL->w != NULL) LUSOL->w[0] = 0; LU6SOL(LUSOL, LUSOL_SOLVE_Atv_w, b, LUSOL->w, NZidx, &inform); LUSOL->luparm[LUSOL_IP_BTRANCOUNT]++; return(inform); }
int LUSOL_ftran(LUSOLrec *LUSOL, REAL b[], int NZidx[], MYBOOL prepareupdate) { int inform; REAL *vector; if(prepareupdate) vector = LUSOL->vLU6L; else vector = LUSOL->w; /* Copy RHS vector, but make adjustment for offset since this can create a memory error when the calling program uses a 0-base vector offset back to comply with LUSOL. */ MEMCOPY(vector+1, b+1, LUSOL->n); if (vector != NULL) vector[0] = 0; LU6SOL(LUSOL, LUSOL_SOLVE_Aw_v, vector, b, NZidx, &inform); LUSOL->luparm[LUSOL_IP_FTRANCOUNT]++; return(inform); }