1 #define PETSCMAT_DLL 2 3 /* 4 Factorization code for BAIJ format. 5 */ 6 #include "../src/mat/impls/baij/seq/baij.h" 7 #include "../src/mat/blockinvert.h" 8 9 #undef __FUNCT__ 10 #define __FUNCT__ "MatSeqBAIJSetNumericFactorization" 11 /* 12 This is used to set the numeric factorization for both LU and ILU symbolic factorization 13 */ 14 PetscErrorCode MatSeqBAIJSetNumericFactorization(Mat inA,PetscTruth natural) 15 { 16 PetscFunctionBegin; 17 if (natural) { 18 switch (inA->rmap->bs) { 19 case 1: 20 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_1; 21 break; 22 case 2: 23 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_2_NaturalOrdering; 24 break; 25 case 3: 26 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_3_NaturalOrdering; 27 break; 28 case 4: 29 #if defined(PETSC_USE_MAT_SINGLE) 30 { 31 PetscTruth sse_enabled_local; 32 PetscErrorCode ierr; 33 ierr = PetscSSEIsEnabled(inA->comm,&sse_enabled_local,PETSC_NULL);CHKERRQ(ierr); 34 if (sse_enabled_local) { 35 # if defined(PETSC_HAVE_SSE) 36 int i,*AJ=a->j,nz=a->nz,n=a->mbs; 37 if (n==(unsigned short)n) { 38 unsigned short *aj=(unsigned short *)AJ; 39 for (i=0;i<nz;i++) { 40 aj[i] = (unsigned short)AJ[i]; 41 } 42 inA->ops->setunfactored = MatSetUnfactored_SeqBAIJ_4_NaturalOrdering_SSE_usj; 43 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4_NaturalOrdering_SSE_usj; 44 ierr = PetscInfo(inA,"Using special SSE, in-place natural ordering, ushort j index factor BS=4\n");CHKERRQ(ierr); 45 } else { 46 /* Scale the column indices for easier indexing in MatSolve. */ 47 /* for (i=0;i<nz;i++) { */ 48 /* AJ[i] = AJ[i]*4; */ 49 /* } */ 50 inA->ops->setunfactored = MatSetUnfactored_SeqBAIJ_4_NaturalOrdering_SSE; 51 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4_NaturalOrdering_SSE; 52 ierr = PetscInfo(inA,"Using special SSE, in-place natural ordering, int j index factor BS=4\n");CHKERRQ(ierr); 53 } 54 # else 55 /* This should never be reached. If so, problem in PetscSSEIsEnabled. */ 56 SETERRQ(PETSC_ERR_SUP,"SSE Hardware unavailable"); 57 # endif 58 } else { 59 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4_NaturalOrdering; 60 } 61 } 62 #else 63 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4_NaturalOrdering; 64 #endif 65 break; 66 case 5: 67 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_5_NaturalOrdering; 68 break; 69 case 6: 70 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_6_NaturalOrdering; 71 break; 72 case 7: 73 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_7_NaturalOrdering; 74 break; 75 default: 76 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_N; 77 break; 78 } 79 } else { 80 switch (inA->rmap->bs) { 81 case 1: 82 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_1; 83 break; 84 case 2: 85 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_2; 86 break; 87 case 3: 88 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_3; 89 break; 90 case 4: 91 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4; 92 break; 93 case 5: 94 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_5; 95 break; 96 case 6: 97 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_6; 98 break; 99 case 7: 100 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_7; 101 break; 102 default: 103 inA->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_N; 104 break; 105 } 106 } 107 PetscFunctionReturn(0); 108 } 109 110 /* 111 The symbolic factorization code is identical to that for AIJ format, 112 except for very small changes since this is now a SeqBAIJ datastructure. 113 NOT good code reuse. 114 */ 115 #include "petscbt.h" 116 #include "../src/mat/utils/freespace.h" 117 118 #undef __FUNCT__ 119 #define __FUNCT__ "MatLUFactorSymbolic_SeqBAIJ_newdatastruct" 120 PetscErrorCode MatLUFactorSymbolic_SeqBAIJ_newdatastruct(Mat B,Mat A,IS isrow,IS iscol,const MatFactorInfo *info) 121 { 122 Mat_SeqBAIJ *a = (Mat_SeqBAIJ*)A->data,*b; 123 PetscInt n=a->mbs,bs = A->rmap->bs,bs2=a->bs2; 124 PetscTruth row_identity,col_identity,both_identity; 125 IS isicol; 126 PetscErrorCode ierr; 127 const PetscInt *r,*ic; 128 PetscInt i,*ai=a->i,*aj=a->j; 129 PetscInt *bi,*bj,*ajtmp; 130 PetscInt *bdiag,row,nnz,nzi,reallocs=0,nzbd,*im; 131 PetscReal f; 132 PetscInt nlnk,*lnk,k,**bi_ptr; 133 PetscFreeSpaceList free_space=PETSC_NULL,current_space=PETSC_NULL; 134 PetscBT lnkbt; 135 136 PetscFunctionBegin; 137 if (A->rmap->N != A->cmap->N) SETERRQ(PETSC_ERR_ARG_WRONG,"matrix must be square"); 138 ierr = ISInvertPermutation(iscol,PETSC_DECIDE,&isicol);CHKERRQ(ierr); 139 ierr = ISGetIndices(isrow,&r);CHKERRQ(ierr); 140 ierr = ISGetIndices(isicol,&ic);CHKERRQ(ierr); 141 142 /* get new row pointers */ 143 ierr = PetscMalloc((2*n+2)*sizeof(PetscInt),&bi);CHKERRQ(ierr); 144 bi[0] = 0; 145 146 /* bdiag is location of diagonal in factor */ 147 ierr = PetscMalloc((n+1)*sizeof(PetscInt),&bdiag);CHKERRQ(ierr); 148 bdiag[0] = 0; 149 150 /* linked list for storing column indices of the active row */ 151 nlnk = n + 1; 152 ierr = PetscLLCreate(n,n,nlnk,lnk,lnkbt);CHKERRQ(ierr); 153 154 ierr = PetscMalloc2(n+1,PetscInt**,&bi_ptr,n+1,PetscInt,&im);CHKERRQ(ierr); 155 156 /* initial FreeSpace size is f*(ai[n]+1) */ 157 f = info->fill; 158 ierr = PetscFreeSpaceGet((PetscInt)(f*(ai[n]+1)),&free_space);CHKERRQ(ierr); 159 current_space = free_space; 160 161 for (i=0; i<n; i++) { 162 /* copy previous fill into linked list */ 163 nzi = 0; 164 nnz = ai[r[i]+1] - ai[r[i]]; 165 if (!nnz) SETERRQ2(PETSC_ERR_MAT_LU_ZRPVT,"Empty row in matrix: row in original ordering %D in permuted ordering %D",r[i],i); 166 ajtmp = aj + ai[r[i]]; 167 ierr = PetscLLAddPerm(nnz,ajtmp,ic,n,nlnk,lnk,lnkbt);CHKERRQ(ierr); 168 nzi += nlnk; 169 170 /* add pivot rows into linked list */ 171 row = lnk[n]; 172 while (row < i) { 173 nzbd = bdiag[row] + 1; /* num of entries in the row with column index <= row */ 174 ajtmp = bi_ptr[row] + nzbd; /* points to the entry next to the diagonal */ 175 ierr = PetscLLAddSortedLU(ajtmp,row,nlnk,lnk,lnkbt,i,nzbd,im);CHKERRQ(ierr); 176 nzi += nlnk; 177 row = lnk[row]; 178 } 179 bi[i+1] = bi[i] + nzi; 180 im[i] = nzi; 181 182 /* mark bdiag */ 183 nzbd = 0; 184 nnz = nzi; 185 k = lnk[n]; 186 while (nnz-- && k < i){ 187 nzbd++; 188 k = lnk[k]; 189 } 190 bdiag[i] = nzbd; /* note : bdaig[i] = nnzL as input for PetscFreeSpaceContiguous_LU() */ 191 192 /* if free space is not available, make more free space */ 193 if (current_space->local_remaining<nzi) { 194 nnz = 2*(n - i)*nzi; /* estimated and max additional space needed */ 195 ierr = PetscFreeSpaceGet(nnz,¤t_space);CHKERRQ(ierr); 196 reallocs++; 197 } 198 199 /* copy data into free space, then initialize lnk */ 200 ierr = PetscLLClean(n,n,nzi,lnk,current_space->array,lnkbt);CHKERRQ(ierr); 201 bi_ptr[i] = current_space->array; 202 current_space->array += nzi; 203 current_space->local_used += nzi; 204 current_space->local_remaining -= nzi; 205 } 206 #if defined(PETSC_USE_INFO) 207 if (ai[n] != 0) { 208 PetscReal af = ((PetscReal)bi[n])/((PetscReal)ai[n]); 209 ierr = PetscInfo3(A,"Reallocs %D Fill ratio:given %G needed %G\n",reallocs,f,af);CHKERRQ(ierr); 210 ierr = PetscInfo1(A,"Run with -pc_factor_fill %G or use \n",af);CHKERRQ(ierr); 211 ierr = PetscInfo1(A,"PCFactorSetFill(pc,%G);\n",af);CHKERRQ(ierr); 212 ierr = PetscInfo(A,"for best performance.\n");CHKERRQ(ierr); 213 } else { 214 ierr = PetscInfo(A,"Empty matrix\n");CHKERRQ(ierr); 215 } 216 #endif 217 218 ierr = ISRestoreIndices(isrow,&r);CHKERRQ(ierr); 219 ierr = ISRestoreIndices(isicol,&ic);CHKERRQ(ierr); 220 221 /* destroy list of free space and other temporary array(s) */ 222 ierr = PetscMalloc((bi[n]+1)*sizeof(PetscInt),&bj);CHKERRQ(ierr); 223 ierr = PetscFreeSpaceContiguous_LU(&free_space,bj,n,bi,bdiag);CHKERRQ(ierr); 224 ierr = PetscLLDestroy(lnk,lnkbt);CHKERRQ(ierr); 225 ierr = PetscFree2(bi_ptr,im);CHKERRQ(ierr); 226 227 /* put together the new matrix */ 228 ierr = MatSeqBAIJSetPreallocation_SeqBAIJ(B,bs,MAT_SKIP_ALLOCATION,PETSC_NULL);CHKERRQ(ierr); 229 ierr = PetscLogObjectParent(B,isicol);CHKERRQ(ierr); 230 b = (Mat_SeqBAIJ*)(B)->data; 231 b->free_a = PETSC_TRUE; 232 b->free_ij = PETSC_TRUE; 233 b->singlemalloc = PETSC_FALSE; 234 ierr = PetscMalloc((bi[2*n+1])*sizeof(MatScalar)*bs2,&b->a);CHKERRQ(ierr); 235 b->j = bj; 236 b->i = bi; 237 b->diag = bdiag; 238 b->free_diag = PETSC_TRUE; 239 b->ilen = 0; 240 b->imax = 0; 241 b->row = isrow; 242 b->col = iscol; 243 b->pivotinblocks = (info->pivotinblocks) ? PETSC_TRUE : PETSC_FALSE; 244 ierr = PetscObjectReference((PetscObject)isrow);CHKERRQ(ierr); 245 ierr = PetscObjectReference((PetscObject)iscol);CHKERRQ(ierr); 246 b->icol = isicol; 247 ierr = PetscMalloc((bs*n+bs)*sizeof(PetscScalar),&b->solve_work);CHKERRQ(ierr); 248 ierr = PetscLogObjectMemory(B,(bi[2*n+1])*(sizeof(PetscInt)+sizeof(PetscScalar)*bs2));CHKERRQ(ierr); 249 250 b->maxnz = b->nz = bi[2*n+1]; 251 B->factor = MAT_FACTOR_LU; 252 B->info.factor_mallocs = reallocs; 253 B->info.fill_ratio_given = f; 254 255 if (ai[n] != 0) { 256 B->info.fill_ratio_needed = ((PetscReal)bi[2*n+1])/((PetscReal)ai[n]); 257 } else { 258 B->info.fill_ratio_needed = 0.0; 259 } 260 261 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_N_newdatastruct; 262 263 ierr = ISIdentity(isrow,&row_identity);CHKERRQ(ierr); 264 ierr = ISIdentity(iscol,&col_identity);CHKERRQ(ierr); 265 both_identity = (PetscTruth) (row_identity && col_identity); 266 if(both_identity){ 267 switch(bs){ 268 case 2: 269 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_2_NaturalOrdering_newdatastruct; 270 B->ops->solve = MatSolve_SeqBAIJ_2_NaturalOrdering_newdatastruct; 271 break; 272 case 3: 273 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_3_NaturalOrdering_newdatastruct; 274 B->ops->solve = MatSolve_SeqBAIJ_3_NaturalOrdering_newdatastruct; 275 break; 276 case 4: 277 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4_NaturalOrdering_newdatastruct; 278 B->ops->solve = MatSolve_SeqBAIJ_4_NaturalOrdering_newdatastruct; 279 break; 280 case 5: 281 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_5_NaturalOrdering_newdatastruct; 282 B->ops->solve = MatSolve_SeqBAIJ_5_NaturalOrdering_newdatastruct; 283 break; 284 case 6: 285 B->ops->solve = MatSolve_SeqBAIJ_6_NaturalOrdering_newdatastruct; 286 break; 287 case 7: 288 B->ops->solve = MatSolve_SeqBAIJ_7_NaturalOrdering_newdatastruct; 289 break; 290 default: 291 B->ops->solve = MatSolve_SeqBAIJ_N_NaturalOrdering_newdatastruct; 292 } 293 } 294 else { 295 switch(bs){ 296 case 2: 297 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_2_newdatastruct; 298 B->ops->solve = MatSolve_SeqBAIJ_2_newdatastruct; 299 break; 300 case 3: 301 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_3_newdatastruct; 302 B->ops->solve = MatSolve_SeqBAIJ_3_newdatastruct; 303 break; 304 case 4: 305 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_4_newdatastruct; 306 B->ops->solve = MatSolve_SeqBAIJ_4_newdatastruct; 307 break; 308 case 5: 309 B->ops->lufactornumeric = MatLUFactorNumeric_SeqBAIJ_5_newdatastruct; 310 B->ops->solve = MatSolve_SeqBAIJ_5_newdatastruct; 311 break; 312 case 6: 313 B->ops->solve = MatSolve_SeqBAIJ_6_newdatastruct; 314 break; 315 case 7: 316 B->ops->solve = MatSolve_SeqBAIJ_7_newdatastruct; 317 break; 318 default: 319 B->ops->solve = MatSolve_SeqBAIJ_N_newdatastruct; 320 } 321 } 322 /* ierr = MatSeqBAIJSetNumericFactorization(B,both_identity);CHKERRQ(ierr); */ 323 PetscFunctionReturn(0); 324 } 325 326 #undef __FUNCT__ 327 #define __FUNCT__ "MatLUFactorSymbolic_SeqBAIJ" 328 PetscErrorCode MatLUFactorSymbolic_SeqBAIJ(Mat B,Mat A,IS isrow,IS iscol,const MatFactorInfo *info) 329 { 330 Mat_SeqBAIJ *a = (Mat_SeqBAIJ*)A->data,*b; 331 PetscInt n=a->mbs,bs = A->rmap->bs,bs2=a->bs2; 332 PetscTruth row_identity,col_identity,both_identity; 333 IS isicol; 334 PetscErrorCode ierr; 335 const PetscInt *r,*ic; 336 PetscInt i,*ai=a->i,*aj=a->j; 337 PetscInt *bi,*bj,*ajtmp; 338 PetscInt *bdiag,row,nnz,nzi,reallocs=0,nzbd,*im; 339 PetscReal f; 340 PetscInt nlnk,*lnk,k,**bi_ptr; 341 PetscFreeSpaceList free_space=PETSC_NULL,current_space=PETSC_NULL; 342 PetscBT lnkbt; 343 PetscTruth newdatastruct=PETSC_FALSE; 344 345 PetscFunctionBegin; 346 ierr = PetscOptionsGetTruth(PETSC_NULL,"-lu_new",&newdatastruct,PETSC_NULL);CHKERRQ(ierr); 347 if(newdatastruct){ 348 ierr = MatLUFactorSymbolic_SeqBAIJ_newdatastruct(B,A,isrow,iscol,info);CHKERRQ(ierr); 349 PetscFunctionReturn(0); 350 } 351 352 if (A->rmap->N != A->cmap->N) SETERRQ(PETSC_ERR_ARG_WRONG,"matrix must be square"); 353 ierr = ISInvertPermutation(iscol,PETSC_DECIDE,&isicol);CHKERRQ(ierr); 354 ierr = ISGetIndices(isrow,&r);CHKERRQ(ierr); 355 ierr = ISGetIndices(isicol,&ic);CHKERRQ(ierr); 356 357 /* get new row pointers */ 358 ierr = PetscMalloc((n+1)*sizeof(PetscInt),&bi);CHKERRQ(ierr); 359 bi[0] = 0; 360 361 /* bdiag is location of diagonal in factor */ 362 ierr = PetscMalloc((n+1)*sizeof(PetscInt),&bdiag);CHKERRQ(ierr); 363 bdiag[0] = 0; 364 365 /* linked list for storing column indices of the active row */ 366 nlnk = n + 1; 367 ierr = PetscLLCreate(n,n,nlnk,lnk,lnkbt);CHKERRQ(ierr); 368 369 ierr = PetscMalloc2(n+1,PetscInt**,&bi_ptr,n+1,PetscInt,&im);CHKERRQ(ierr); 370 371 /* initial FreeSpace size is f*(ai[n]+1) */ 372 f = info->fill; 373 ierr = PetscFreeSpaceGet((PetscInt)(f*(ai[n]+1)),&free_space);CHKERRQ(ierr); 374 current_space = free_space; 375 376 for (i=0; i<n; i++) { 377 /* copy previous fill into linked list */ 378 nzi = 0; 379 nnz = ai[r[i]+1] - ai[r[i]]; 380 if (!nnz) SETERRQ2(PETSC_ERR_MAT_LU_ZRPVT,"Empty row in matrix: row in original ordering %D in permuted ordering %D",r[i],i); 381 ajtmp = aj + ai[r[i]]; 382 ierr = PetscLLAddPerm(nnz,ajtmp,ic,n,nlnk,lnk,lnkbt);CHKERRQ(ierr); 383 nzi += nlnk; 384 385 /* add pivot rows into linked list */ 386 row = lnk[n]; 387 while (row < i) { 388 nzbd = bdiag[row] - bi[row] + 1; /* num of entries in the row with column index <= row */ 389 ajtmp = bi_ptr[row] + nzbd; /* points to the entry next to the diagonal */ 390 ierr = PetscLLAddSortedLU(ajtmp,row,nlnk,lnk,lnkbt,i,nzbd,im);CHKERRQ(ierr); 391 nzi += nlnk; 392 row = lnk[row]; 393 } 394 bi[i+1] = bi[i] + nzi; 395 im[i] = nzi; 396 397 /* mark bdiag */ 398 nzbd = 0; 399 nnz = nzi; 400 k = lnk[n]; 401 while (nnz-- && k < i){ 402 nzbd++; 403 k = lnk[k]; 404 } 405 bdiag[i] = bi[i] + nzbd; 406 407 /* if free space is not available, make more free space */ 408 if (current_space->local_remaining<nzi) { 409 nnz = (n - i)*nzi; /* estimated and max additional space needed */ 410 ierr = PetscFreeSpaceGet(nnz,¤t_space);CHKERRQ(ierr); 411 reallocs++; 412 } 413 414 /* copy data into free space, then initialize lnk */ 415 ierr = PetscLLClean(n,n,nzi,lnk,current_space->array,lnkbt);CHKERRQ(ierr); 416 bi_ptr[i] = current_space->array; 417 current_space->array += nzi; 418 current_space->local_used += nzi; 419 current_space->local_remaining -= nzi; 420 } 421 #if defined(PETSC_USE_INFO) 422 if (ai[n] != 0) { 423 PetscReal af = ((PetscReal)bi[n])/((PetscReal)ai[n]); 424 ierr = PetscInfo3(A,"Reallocs %D Fill ratio:given %G needed %G\n",reallocs,f,af);CHKERRQ(ierr); 425 ierr = PetscInfo1(A,"Run with -pc_factor_fill %G or use \n",af);CHKERRQ(ierr); 426 ierr = PetscInfo1(A,"PCFactorSetFill(pc,%G);\n",af);CHKERRQ(ierr); 427 ierr = PetscInfo(A,"for best performance.\n");CHKERRQ(ierr); 428 } else { 429 ierr = PetscInfo(A,"Empty matrix\n");CHKERRQ(ierr); 430 } 431 #endif 432 433 ierr = ISRestoreIndices(isrow,&r);CHKERRQ(ierr); 434 ierr = ISRestoreIndices(isicol,&ic);CHKERRQ(ierr); 435 436 /* destroy list of free space and other temporary array(s) */ 437 ierr = PetscMalloc((bi[n]+1)*sizeof(PetscInt),&bj);CHKERRQ(ierr); 438 ierr = PetscFreeSpaceContiguous(&free_space,bj);CHKERRQ(ierr); 439 ierr = PetscLLDestroy(lnk,lnkbt);CHKERRQ(ierr); 440 ierr = PetscFree2(bi_ptr,im);CHKERRQ(ierr); 441 442 /* put together the new matrix */ 443 ierr = MatSeqBAIJSetPreallocation_SeqBAIJ(B,bs,MAT_SKIP_ALLOCATION,PETSC_NULL);CHKERRQ(ierr); 444 ierr = PetscLogObjectParent(B,isicol);CHKERRQ(ierr); 445 b = (Mat_SeqBAIJ*)(B)->data; 446 b->free_a = PETSC_TRUE; 447 b->free_ij = PETSC_TRUE; 448 b->singlemalloc = PETSC_FALSE; 449 ierr = PetscMalloc((bi[n]+1)*sizeof(MatScalar)*bs2,&b->a);CHKERRQ(ierr); 450 b->j = bj; 451 b->i = bi; 452 b->diag = bdiag; 453 b->free_diag = PETSC_TRUE; 454 b->ilen = 0; 455 b->imax = 0; 456 b->row = isrow; 457 b->col = iscol; 458 b->pivotinblocks = (info->pivotinblocks) ? PETSC_TRUE : PETSC_FALSE; 459 ierr = PetscObjectReference((PetscObject)isrow);CHKERRQ(ierr); 460 ierr = PetscObjectReference((PetscObject)iscol);CHKERRQ(ierr); 461 b->icol = isicol; 462 ierr = PetscMalloc((bs*n+bs)*sizeof(PetscScalar),&b->solve_work);CHKERRQ(ierr); 463 ierr = PetscLogObjectMemory(B,(bi[n]-n)*(sizeof(PetscInt)+sizeof(PetscScalar)*bs2));CHKERRQ(ierr); 464 465 b->maxnz = b->nz = bi[n] ; 466 (B)->factor = MAT_FACTOR_LU; 467 (B)->info.factor_mallocs = reallocs; 468 (B)->info.fill_ratio_given = f; 469 470 if (ai[n] != 0) { 471 (B)->info.fill_ratio_needed = ((PetscReal)bi[n])/((PetscReal)ai[n]); 472 } else { 473 (B)->info.fill_ratio_needed = 0.0; 474 } 475 476 ierr = ISIdentity(isrow,&row_identity);CHKERRQ(ierr); 477 ierr = ISIdentity(iscol,&col_identity);CHKERRQ(ierr); 478 both_identity = (PetscTruth) (row_identity && col_identity); 479 ierr = MatSeqBAIJSetNumericFactorization(B,both_identity);CHKERRQ(ierr); 480 PetscFunctionReturn(0); 481 } 482 483