1 /* 2 Defines projective product routines where A is a SeqAIJ matrix 3 C = P^T * A * P 4 */ 5 6 #include "src/mat/impls/aij/seq/aij.h" 7 #include "src/mat/utils/freespace.h" 8 9 int MatSeqAIJPtAP(Mat,Mat,Mat*); 10 int MatSeqAIJPtAPSymbolic(Mat,Mat,Mat*); 11 int MatSeqAIJPtAPNumeric(Mat,Mat,Mat); 12 13 static int MATSeqAIJ_PtAP = 0; 14 static int MATSeqAIJ_PtAPSymbolic = 0; 15 static int MATSeqAIJ_PtAPNumeric = 0; 16 17 /* 18 MatSeqAIJPtAP - Creates the SeqAIJ matrix product, C, 19 of SeqAIJ matrix A and matrix P: 20 C = P^T * A * P; 21 22 Note: C is assumed to be uncreated. 23 If this is not the case, Destroy C before calling this routine. 24 */ 25 #undef __FUNCT__ 26 #define __FUNCT__ "MatSeqAIJPtAP" 27 int MatSeqAIJPtAP(Mat A,Mat P,Mat *C) { 28 int ierr; 29 char funct[80]; 30 31 PetscFunctionBegin; 32 33 ierr = PetscLogEventBegin(MATSeqAIJ_PtAP,A,P,0,0);CHKERRQ(ierr); 34 35 ierr = MatSeqAIJPtAPSymbolic(A,P,C);CHKERRQ(ierr); 36 37 /* Avoid additional error checking included in */ 38 /* ierr = MatSeqAIJApplyPtAPNumeric(A,P,*C);CHKERRQ(ierr); */ 39 40 /* Query A for ApplyPtAPNumeric implementation based on types of P */ 41 ierr = PetscStrcpy(funct,"MatApplyPtAPNumeric_seqaij_");CHKERRQ(ierr); 42 ierr = PetscStrcat(funct,P->type_name);CHKERRQ(ierr); 43 ierr = PetscTryMethod(A,funct,(Mat,Mat,Mat),(A,P,*C));CHKERRQ(ierr); 44 45 ierr = PetscLogEventEnd(MATSeqAIJ_PtAP,A,P,0,0);CHKERRQ(ierr); 46 47 PetscFunctionReturn(0); 48 } 49 50 /* 51 MatSeqAIJPtAPSymbolic - Creates the (i,j) structure of the SeqAIJ matrix product, C, 52 of SeqAIJ matrix A and matrix P, according to: 53 C = P^T * A * P; 54 55 Note: C is assumed to be uncreated. 56 If this is not the case, Destroy C before calling this routine. 57 */ 58 #undef __FUNCT__ 59 #define __FUNCT__ "MatSeqAIJPtAPSymbolic" 60 int MatSeqAIJPtAPSymbolic(Mat A,Mat P,Mat *C) { 61 int ierr; 62 char funct[80]; 63 64 PetscFunctionBegin; 65 66 PetscValidPointer(C); 67 68 PetscValidHeaderSpecific(A,MAT_COOKIE); 69 PetscValidType(A); 70 MatPreallocated(A); 71 if (!A->assembled) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for unassembled matrix"); 72 if (A->factor) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for factored matrix"); 73 74 PetscValidHeaderSpecific(P,MAT_COOKIE); 75 PetscValidType(P); 76 MatPreallocated(P); 77 if (!P->assembled) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for unassembled matrix"); 78 if (P->factor) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for factored matrix"); 79 80 if (P->M!=A->N) SETERRQ2(PETSC_ERR_ARG_SIZ,"Matrix dimensions are incompatible, %d != %d",P->M,A->N); 81 if (A->M!=A->N) SETERRQ2(PETSC_ERR_ARG_SIZ,"Matrix 'A' must be square, %d != %d",A->M,A->N); 82 83 /* Query A for ApplyPtAP implementation based on types of P */ 84 ierr = PetscStrcpy(funct,"MatApplyPtAPSymbolic_seqaij_");CHKERRQ(ierr); 85 ierr = PetscStrcat(funct,P->type_name);CHKERRQ(ierr); 86 ierr = PetscTryMethod(A,funct,(Mat,Mat,Mat*),(A,P,C));CHKERRQ(ierr); 87 88 PetscFunctionReturn(0); 89 } 90 91 EXTERN_C_BEGIN 92 #undef __FUNCT__ 93 #define __FUNCT__ "MatApplyPtAPSymbolic_SeqAIJ_SeqAIJ" 94 int MatApplyPtAPSymbolic_SeqAIJ_SeqAIJ(Mat A,Mat P,Mat *C) { 95 int ierr; 96 FreeSpaceList free_space=PETSC_NULL,current_space=PETSC_NULL; 97 Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data,*p=(Mat_SeqAIJ*)P->data,*c; 98 int aishift=a->indexshift,pishift=p->indexshift; 99 int *pti,*ptj,*ptJ,*ai=a->i,*aj=a->j,*ajj,*pi=p->i,*pj=p->j,*pjj; 100 int *ci,*cj,*denserow,*sparserow,*ptadenserow,*ptasparserow,*ptaj; 101 int an=A->N,am=A->M,pn=P->N,pm=P->M; 102 int i,j,k,ptnzi,arow,anzj,ptanzi,prow,pnzj,cnzi; 103 MatScalar *ca; 104 105 PetscFunctionBegin; 106 107 /* some error checking which could be moved into interface layer */ 108 if (aishift || pishift) SETERRQ(PETSC_ERR_SUP,"Shifted matrix indices are not supported."); 109 110 /* Start timer */ 111 ierr = PetscLogEventBegin(MATSeqAIJ_PtAPSymbolic,A,P,0,0);CHKERRQ(ierr); 112 113 /* Get ij structure of P^T */ 114 ierr = MatGetSymbolicTranspose_SeqAIJ(P,&pti,&ptj);CHKERRQ(ierr); 115 ptJ=ptj; 116 117 /* Allocate ci array, arrays for fill computation and */ 118 /* free space for accumulating nonzero column info */ 119 ierr = PetscMalloc(((pn+1)*1)*sizeof(int),&ci);CHKERRQ(ierr); 120 ci[0] = 0; 121 122 ierr = PetscMalloc((2*pn+2*an+1)*sizeof(int),&ptadenserow);CHKERRQ(ierr); 123 ierr = PetscMemzero(ptadenserow,(2*pn+2*an+1)*sizeof(int));CHKERRQ(ierr); 124 ptasparserow = ptadenserow + an; 125 denserow = ptasparserow + an; 126 sparserow = denserow + pn; 127 128 /* Set initial free space to be nnz(A) scaled by aspect ratio of P. */ 129 /* This should be reasonable if sparsity of PtAP is similar to that of A. */ 130 ierr = GetMoreSpace((ai[am]/pm)*pn,&free_space); 131 current_space = free_space; 132 133 /* Determine symbolic info for each row of C: */ 134 for (i=0;i<pn;i++) { 135 ptnzi = pti[i+1] - pti[i]; 136 ptanzi = 0; 137 /* Determine symbolic row of PtA: */ 138 for (j=0;j<ptnzi;j++) { 139 arow = *ptJ++; 140 anzj = ai[arow+1] - ai[arow]; 141 ajj = aj + ai[arow]; 142 for (k=0;k<anzj;k++) { 143 if (!ptadenserow[ajj[k]]) { 144 ptadenserow[ajj[k]] = -1; 145 ptasparserow[ptanzi++] = ajj[k]; 146 } 147 } 148 } 149 /* Using symbolic info for row of PtA, determine symbolic info for row of C: */ 150 ptaj = ptasparserow; 151 cnzi = 0; 152 for (j=0;j<ptanzi;j++) { 153 prow = *ptaj++; 154 pnzj = pi[prow+1] - pi[prow]; 155 pjj = pj + pi[prow]; 156 for (k=0;k<pnzj;k++) { 157 if (!denserow[pjj[k]]) { 158 denserow[pjj[k]] = -1; 159 sparserow[cnzi++] = pjj[k]; 160 } 161 } 162 } 163 164 /* sort sparserow */ 165 ierr = PetscSortInt(cnzi,sparserow);CHKERRQ(ierr); 166 167 /* If free space is not available, make more free space */ 168 /* Double the amount of total space in the list */ 169 if (current_space->local_remaining<cnzi) { 170 ierr = GetMoreSpace(current_space->total_array_size,¤t_space);CHKERRQ(ierr); 171 } 172 173 /* Copy data into free space, and zero out denserows */ 174 ierr = PetscMemcpy(current_space->array,sparserow,cnzi*sizeof(int));CHKERRQ(ierr); 175 current_space->array += cnzi; 176 current_space->local_used += cnzi; 177 current_space->local_remaining -= cnzi; 178 179 for (j=0;j<ptanzi;j++) { 180 ptadenserow[ptasparserow[j]] = 0; 181 } 182 for (j=0;j<cnzi;j++) { 183 denserow[sparserow[j]] = 0; 184 } 185 /* Aside: Perhaps we should save the pta info for the numerical factorization. */ 186 /* For now, we will recompute what is needed. */ 187 ci[i+1] = ci[i] + cnzi; 188 } 189 /* nnz is now stored in ci[ptm], column indices are in the list of free space */ 190 /* Allocate space for cj, initialize cj, and */ 191 /* destroy list of free space and other temporary array(s) */ 192 ierr = PetscMalloc((ci[pn]+1)*sizeof(int),&cj);CHKERRQ(ierr); 193 ierr = MakeSpaceContiguous(&free_space,cj);CHKERRQ(ierr); 194 ierr = PetscFree(ptadenserow);CHKERRQ(ierr); 195 196 /* Allocate space for ca */ 197 ierr = PetscMalloc((ci[pn]+1)*sizeof(MatScalar),&ca);CHKERRQ(ierr); 198 ierr = PetscMemzero(ca,(ci[pn]+1)*sizeof(MatScalar));CHKERRQ(ierr); 199 200 /* put together the new matrix */ 201 ierr = MatCreateSeqAIJWithArrays(A->comm,pn,pn,ci,cj,ca,C);CHKERRQ(ierr); 202 203 /* MatCreateSeqAIJWithArrays flags matrix so PETSc doesn't free the user's arrays. */ 204 /* Since these are PETSc arrays, change flags to free them as necessary. */ 205 c = (Mat_SeqAIJ *)((*C)->data); 206 c->freedata = PETSC_TRUE; 207 c->nonew = 0; 208 209 /* Clean up. */ 210 ierr = MatRestoreSymbolicTranspose_SeqAIJ(P,&pti,&ptj);CHKERRQ(ierr); 211 212 ierr = PetscLogEventEnd(MATSeqAIJ_PtAPSymbolic,A,P,0,0);CHKERRQ(ierr); 213 PetscFunctionReturn(0); 214 } 215 EXTERN_C_END 216 217 #include "src/mat/impls/maij/maij.h" 218 EXTERN_C_BEGIN 219 #undef __FUNCT__ 220 #define __FUNCT__ "MatApplyPtAPSymbolic_SeqAIJ_SeqMAIJ" 221 int MatApplyPtAPSymbolic_SeqAIJ_SeqAIJ(Mat A,Mat PP,Mat *C) { 222 int ierr; 223 FreeSpaceList free_space=PETSC_NULL,current_space=PETSC_NULL; 224 Mat_SeqMAIJ *pp=(Mat_SeqMAIJ*)PP->data; 225 Mat P=pp->AIJ; 226 Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data,*p=(Mat_SeqAIJ*)P->data,*c; 227 int aishift=a->indexshift,pishift=p->indexshift; 228 int *pti,*ptj,*ptJ,*ai=a->i,*aj=a->j,*ajj,*pi=p->i,*pj=p->j,*pjj; 229 int *ci,*cj,*denserow,*sparserow,*ptadenserow,*ptasparserow,*ptaj; 230 int an=A->N,am=A->M,pn=P->N,pm=P->M; 231 int i,j,k,ptnzi,arow,anzj,ptanzi,prow,pnzj,cnzi; 232 MatScalar *ca; 233 234 PetscFunctionBegin; 235 236 /* some error checking which could be moved into interface layer */ 237 if (aishift || pishift) SETERRQ(PETSC_ERR_SUP,"Shifted matrix indices are not supported."); 238 239 /* Start timer */ 240 ierr = PetscLogEventBegin(MATSeqAIJ_PtAPSymbolic,A,PP,0,0);CHKERRQ(ierr); 241 242 /* Get ij structure of P^T */ 243 ierr = MatGetSymbolicTranspose_SeqAIJ(P,&pti,&ptj);CHKERRQ(ierr); 244 ptJ=ptj; 245 246 /* Allocate ci array, arrays for fill computation and */ 247 /* free space for accumulating nonzero column info */ 248 ierr = PetscMalloc(((pn+1)*1)*sizeof(int),&ci);CHKERRQ(ierr); 249 ci[0] = 0; 250 251 ierr = PetscMalloc((2*pn+2*an+1)*sizeof(int),&ptadenserow);CHKERRQ(ierr); 252 ierr = PetscMemzero(ptadenserow,(2*pn+2*an+1)*sizeof(int));CHKERRQ(ierr); 253 ptasparserow = ptadenserow + an; 254 denserow = ptasparserow + an; 255 sparserow = denserow + pn; 256 257 /* Set initial free space to be nnz(A) scaled by aspect ratio of P. */ 258 /* This should be reasonable if sparsity of PtAP is similar to that of A. */ 259 ierr = GetMoreSpace((ai[am]/pm)*pn,&free_space); 260 current_space = free_space; 261 262 /* Determine symbolic info for each row of C: */ 263 for (i=0;i<pn;i++) { 264 ptnzi = pti[i+1] - pti[i]; 265 ptanzi = 0; 266 /* Determine symbolic row of PtA: */ 267 for (j=0;j<ptnzi;j++) { 268 arow = *ptJ++; 269 anzj = ai[arow+1] - ai[arow]; 270 ajj = aj + ai[arow]; 271 for (k=0;k<anzj;k++) { 272 if (!ptadenserow[ajj[k]]) { 273 ptadenserow[ajj[k]] = -1; 274 ptasparserow[ptanzi++] = ajj[k]; 275 } 276 } 277 } 278 /* Using symbolic info for row of PtA, determine symbolic info for row of C: */ 279 ptaj = ptasparserow; 280 cnzi = 0; 281 for (j=0;j<ptanzi;j++) { 282 prow = *ptaj++; 283 pnzj = pi[prow+1] - pi[prow]; 284 pjj = pj + pi[prow]; 285 for (k=0;k<pnzj;k++) { 286 if (!denserow[pjj[k]]) { 287 denserow[pjj[k]] = -1; 288 sparserow[cnzi++] = pjj[k]; 289 } 290 } 291 } 292 293 /* sort sparserow */ 294 ierr = PetscSortInt(cnzi,sparserow);CHKERRQ(ierr); 295 296 /* If free space is not available, make more free space */ 297 /* Double the amount of total space in the list */ 298 if (current_space->local_remaining<cnzi) { 299 ierr = GetMoreSpace(current_space->total_array_size,¤t_space);CHKERRQ(ierr); 300 } 301 302 /* Copy data into free space, and zero out denserows */ 303 ierr = PetscMemcpy(current_space->array,sparserow,cnzi*sizeof(int));CHKERRQ(ierr); 304 current_space->array += cnzi; 305 current_space->local_used += cnzi; 306 current_space->local_remaining -= cnzi; 307 308 for (j=0;j<ptanzi;j++) { 309 ptadenserow[ptasparserow[j]] = 0; 310 } 311 for (j=0;j<cnzi;j++) { 312 denserow[sparserow[j]] = 0; 313 } 314 /* Aside: Perhaps we should save the pta info for the numerical factorization. */ 315 /* For now, we will recompute what is needed. */ 316 ci[i+1] = ci[i] + cnzi; 317 } 318 /* nnz is now stored in ci[ptm], column indices are in the list of free space */ 319 /* Allocate space for cj, initialize cj, and */ 320 /* destroy list of free space and other temporary array(s) */ 321 ierr = PetscMalloc((ci[pn]+1)*sizeof(int),&cj);CHKERRQ(ierr); 322 ierr = MakeSpaceContiguous(&free_space,cj);CHKERRQ(ierr); 323 ierr = PetscFree(ptadenserow);CHKERRQ(ierr); 324 325 /* Allocate space for ca */ 326 ierr = PetscMalloc((ci[pn]+1)*sizeof(MatScalar),&ca);CHKERRQ(ierr); 327 ierr = PetscMemzero(ca,(ci[pn]+1)*sizeof(MatScalar));CHKERRQ(ierr); 328 329 /* put together the new matrix */ 330 ierr = MatCreateSeqAIJWithArrays(A->comm,pn,pn,ci,cj,ca,C);CHKERRQ(ierr); 331 332 /* MatCreateSeqAIJWithArrays flags matrix so PETSc doesn't free the user's arrays. */ 333 /* Since these are PETSc arrays, change flags to free them as necessary. */ 334 c = (Mat_SeqAIJ *)((*C)->data); 335 c->freedata = PETSC_TRUE; 336 c->nonew = 0; 337 338 /* Clean up. */ 339 ierr = MatRestoreSymbolicTranspose_SeqAIJ(P,&pti,&ptj);CHKERRQ(ierr); 340 341 ierr = PetscLogEventEnd(MATSeqAIJ_PtAPSymbolic,A,PP,0,0);CHKERRQ(ierr); 342 PetscFunctionReturn(0); 343 } 344 EXTERN_C_END 345 346 /* 347 MatSeqAIJPtAPNumeric - Computes the SeqAIJ matrix product, C, 348 of SeqAIJ matrix A and matrix P, according to: 349 C = P^T * A * P 350 Note: C must have been created by calling MatSeqAIJApplyPtAPSymbolic. 351 */ 352 #undef __FUNCT__ 353 #define __FUNCT__ "MatSeqAIJPtAPNumeric" 354 int MatSeqAIJPtAPNumeric(Mat A,Mat P,Mat C) { 355 int ierr; 356 char funct[80]; 357 358 PetscFunctionBegin; 359 360 PetscValidHeaderSpecific(A,MAT_COOKIE); 361 PetscValidType(A); 362 MatPreallocated(A); 363 if (!A->assembled) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for unassembled matrix"); 364 if (A->factor) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for factored matrix"); 365 366 PetscValidHeaderSpecific(P,MAT_COOKIE); 367 PetscValidType(P); 368 MatPreallocated(P); 369 if (!P->assembled) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for unassembled matrix"); 370 if (P->factor) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for factored matrix"); 371 372 PetscValidHeaderSpecific(C,MAT_COOKIE); 373 PetscValidType(C); 374 MatPreallocated(C); 375 if (!C->assembled) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for unassembled matrix"); 376 if (C->factor) SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"Not for factored matrix"); 377 378 if (P->N!=C->M) SETERRQ2(PETSC_ERR_ARG_SIZ,"Matrix dimensions are incompatible, %d != %d",P->N,C->M); 379 if (P->M!=A->N) SETERRQ2(PETSC_ERR_ARG_SIZ,"Matrix dimensions are incompatible, %d != %d",P->M,A->N); 380 if (A->M!=A->N) SETERRQ2(PETSC_ERR_ARG_SIZ,"Matrix 'A' must be square, %d != %d",A->M,A->N); 381 if (P->N!=C->N) SETERRQ2(PETSC_ERR_ARG_SIZ,"Matrix dimensions are incompatible, %d != %d",P->N,C->N); 382 383 /* Query A for ApplyPtAP implementation based on types of P */ 384 ierr = PetscStrcpy(funct,"MatApplyPtAPNumeric_seqaij_");CHKERRQ(ierr); 385 ierr = PetscStrcat(funct,P->type_name);CHKERRQ(ierr); 386 ierr = PetscTryMethod(A,funct,(Mat,Mat,Mat),(A,P,C));CHKERRQ(ierr); 387 388 PetscFunctionReturn(0); 389 } 390 391 EXTERN_C_BEGIN 392 #undef __FUNCT__ 393 #define __FUNCT__ "MatApplyPtAPNumeric_SeqAIJ_SeqAIJ" 394 int MatApplyPtAPNumeric_SeqAIJ_SeqAIJ(Mat A,Mat P,Mat C) { 395 int ierr,flops=0; 396 Mat_SeqAIJ *a = (Mat_SeqAIJ *) A->data; 397 Mat_SeqAIJ *p = (Mat_SeqAIJ *) P->data; 398 Mat_SeqAIJ *c = (Mat_SeqAIJ *) C->data; 399 int aishift=a->indexshift,pishift=p->indexshift,cishift=c->indexshift; 400 int *ai=a->i,*aj=a->j,*apj,*apjdense,*pi=p->i,*pj=p->j,*pJ=p->j,*pjj; 401 int *ci=c->i,*cj=c->j,*cjj; 402 int am=A->M,cn=C->N,cm=C->M; 403 int i,j,k,anzi,pnzi,apnzj,nextap,pnzj,prow,crow; 404 MatScalar *aa=a->a,*apa,*pa=p->a,*pA=p->a,*paj,*ca=c->a,*caj; 405 406 PetscFunctionBegin; 407 408 /* Currently not for shifted matrices! */ 409 if (aishift || pishift || cishift) SETERRQ(PETSC_ERR_SUP,"Shifted matrix indices are not supported."); 410 411 ierr = PetscLogEventBegin(MATSeqAIJ_PtAPNumeric,A,P,C,0);CHKERRQ(ierr); 412 413 /* Allocate temporary array for storage of one row of A*P */ 414 ierr = PetscMalloc(cn*(sizeof(MatScalar)+2*sizeof(int)),&apa);CHKERRQ(ierr); 415 ierr = PetscMemzero(apa,cn*(sizeof(MatScalar)+2*sizeof(int)));CHKERRQ(ierr); 416 417 apj = (int *)(apa + cn); 418 apjdense = apj + cn; 419 420 /* Clear old values in C */ 421 ierr = PetscMemzero(ca,ci[cm]*sizeof(MatScalar));CHKERRQ(ierr); 422 423 for (i=0;i<am;i++) { 424 /* Form sparse row of A*P */ 425 anzi = ai[i+1] - ai[i]; 426 apnzj = 0; 427 for (j=0;j<anzi;j++) { 428 prow = *aj++; 429 pnzj = pi[prow+1] - pi[prow]; 430 pjj = pj + pi[prow]; 431 paj = pa + pi[prow]; 432 for (k=0;k<pnzj;k++) { 433 if (!apjdense[pjj[k]]) { 434 apjdense[pjj[k]] = -1; 435 apj[apnzj++] = pjj[k]; 436 } 437 apa[pjj[k]] += (*aa)*paj[k]; 438 } 439 flops += 2*pnzj; 440 aa++; 441 } 442 443 /* Sort the j index array for quick sparse axpy. */ 444 ierr = PetscSortInt(apnzj,apj);CHKERRQ(ierr); 445 446 /* Compute P^T*A*P using outer product (P^T)[:,j]*(A*P)[j,:]. */ 447 pnzi = pi[i+1] - pi[i]; 448 for (j=0;j<pnzi;j++) { 449 nextap = 0; 450 crow = *pJ++; 451 cjj = cj + ci[crow]; 452 caj = ca + ci[crow]; 453 /* Perform sparse axpy operation. Note cjj includes apj. */ 454 for (k=0;nextap<apnzj;k++) { 455 if (cjj[k]==apj[nextap]) { 456 caj[k] += (*pA)*apa[apj[nextap++]]; 457 } 458 } 459 flops += 2*apnzj; 460 pA++; 461 } 462 463 /* Zero the current row info for A*P */ 464 for (j=0;j<apnzj;j++) { 465 apa[apj[j]] = 0.; 466 apjdense[apj[j]] = 0; 467 } 468 } 469 470 /* Assemble the final matrix and clean up */ 471 ierr = MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); 472 ierr = MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); 473 ierr = PetscFree(apa);CHKERRQ(ierr); 474 ierr = PetscLogFlops(flops);CHKERRQ(ierr); 475 ierr = PetscLogEventEnd(MATSeqAIJ_PtAPNumeric,A,P,C,0);CHKERRQ(ierr); 476 477 PetscFunctionReturn(0); 478 } 479 EXTERN_C_END 480 481 #undef __FUNCT__ 482 #define __FUNCT__ "RegisterApplyPtAPRoutines_Private" 483 int RegisterApplyPtAPRoutines_Private(Mat A) { 484 int ierr; 485 486 PetscFunctionBegin; 487 488 if (!MATSeqAIJ_PtAP) { 489 ierr = PetscLogEventRegister(&MATSeqAIJ_PtAP,"MatSeqAIJApplyPtAP",MAT_COOKIE);CHKERRQ(ierr); 490 } 491 492 if (!MATSeqAIJ_PtAPSymbolic) { 493 ierr = PetscLogEventRegister(&MATSeqAIJ_PtAPSymbolic,"MatSeqAIJApplyPtAPSymbolic",MAT_COOKIE);CHKERRQ(ierr); 494 } 495 ierr = PetscObjectComposeFunctionDynamic((PetscObject)A,"MatApplyPtAPSymbolic_seqaij_seqaij", 496 "MatApplyPtAPSymbolic_SeqAIJ_SeqAIJ", 497 MatApplyPtAPSymbolic_SeqAIJ_SeqAIJ);CHKERRQ(ierr); 498 499 if (!MATSeqAIJ_PtAPNumeric) { 500 ierr = PetscLogEventRegister(&MATSeqAIJ_PtAPNumeric,"MatSeqAIJApplyPtAPNumeric",MAT_COOKIE);CHKERRQ(ierr); 501 } 502 ierr = PetscObjectComposeFunctionDynamic((PetscObject)A,"MatApplyPtAPNumeric_seqaij_seqaij", 503 "MatApplyPtAPNumeric_SeqAIJ_SeqAIJ", 504 MatApplyPtAPNumeric_SeqAIJ_SeqAIJ);CHKERRQ(ierr); 505 PetscFunctionReturn(0); 506 } 507