Actual source code: ex94.c

petsc-3.13.6 2020-09-29
Report Typos and Errors

  2: static char help[] = "Tests sequential and parallel MatMatMult() and MatPtAP(), MatTransposeMatMult(), sequential MatMatTransposeMult(), MatRARt()\n\
  3: Input arguments are:\n\
  4:   -f0 <input_file> -f1 <input_file> -f2 <input_file> -f3 <input_file> : file to load\n\n";
  5: /* Example of usage:
  6:    ./ex94 -f0 <A_binary> -f1 <B_binary> -matmatmult_mat_view ascii::ascii_info -matmatmulttr_mat_view
  7:    mpiexec -n 3 ./ex94 -f0 medium -f1 medium -f2 arco1 -f3 arco1 -matmatmult_mat_view
  8: */

 10:  #include <petscmat.h>

 12: /*
 13:      B = A - B
 14:      norm = norm(B)
 15: */
 16: PetscErrorCode MatNormDifference(Mat A,Mat B,PetscReal *norm)
 17: {

 21:   MatAXPY(B,-1.0,A,DIFFERENT_NONZERO_PATTERN);
 22:   MatNorm(B,NORM_FROBENIUS,norm);
 23:   return(0);
 24: }

 26: int main(int argc,char **args)
 27: {
 28:   Mat            A,A_save,B,AT,ATT,BT,BTT,P,R,C,C1;
 29:   Vec            x,v1,v2,v3,v4;
 30:   PetscViewer    viewer;
 32:   PetscMPIInt    size,rank;
 33:   PetscInt       i,m,n,j,*idxn,M,N,nzp,rstart,rend;
 34:   PetscReal      norm,norm_abs,norm_tmp,fill=4.0;
 35:   PetscRandom    rdm;
 36:   char           file[4][128];
 37:   PetscBool      flg,preload = PETSC_TRUE;
 38:   PetscScalar    *a,rval,alpha,none = -1.0;
 39:   PetscBool      Test_MatMatMult=PETSC_TRUE,Test_MatMatTr=PETSC_TRUE,Test_MatPtAP=PETSC_TRUE,Test_MatRARt=PETSC_TRUE,Test_MatMatMatMult=PETSC_TRUE;
 40:   PetscBool      Test_MatAXPY=PETSC_FALSE,view=PETSC_FALSE;
 41:   PetscInt       pm,pn,pM,pN;
 42:   MatInfo        info;
 43:   PetscBool      seqaij;
 44:   MatType        mattype;
 45:   Mat            Cdensetest,Pdense,Cdense,Adense;

 47:   PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
 48:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 49:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);

 51:   PetscOptionsGetReal(NULL,NULL,"-fill",&fill,NULL);
 52:   PetscOptionsGetBool(NULL,NULL,"-matops_view",&view,NULL);
 53:   if (view) {
 54:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO);
 55:   }

 57:   /*  Load the matrices A_save and B */
 58:   PetscOptionsGetString(NULL,NULL,"-f0",file[0],sizeof(file[0]),&flg);
 59:   if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate a file name for small matrix A with the -f0 option.");
 60:   PetscOptionsGetString(NULL,NULL,"-f1",file[1],sizeof(file[1]),&flg);
 61:   if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate a file name for small matrix B with the -f1 option.");
 62:   PetscOptionsGetString(NULL,NULL,"-f2",file[2],sizeof(file[2]),&flg);
 63:   if (!flg) {
 64:     preload = PETSC_FALSE;
 65:   } else {
 66:     PetscOptionsGetString(NULL,NULL,"-f3",file[3],128,&flg);
 67:     if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate a file name for test matrix B with the -f3 option.");
 68:   }

 70:   PetscPreLoadBegin(preload,"Load system");
 71:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,file[2*PetscPreLoadIt],FILE_MODE_READ,&viewer);
 72:   MatCreate(PETSC_COMM_WORLD,&A_save);
 73:   MatSetFromOptions(A_save);
 74:   MatLoad(A_save,viewer);
 75:   PetscViewerDestroy(&viewer);

 77:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,file[2*PetscPreLoadIt+1],FILE_MODE_READ,&viewer);
 78:   MatCreate(PETSC_COMM_WORLD,&B);
 79:   MatSetFromOptions(B);
 80:   MatLoad(B,viewer);
 81:   PetscViewerDestroy(&viewer);

 83:   MatGetType(B,&mattype);

 85:   MatGetSize(B,&M,&N);
 86:   nzp  = PetscMax((PetscInt)(0.1*M),5);
 87:   PetscMalloc((nzp+1)*(sizeof(PetscInt)+sizeof(PetscScalar)),&idxn);
 88:   a    = (PetscScalar*)(idxn + nzp);

 90:   /* Create vectors v1 and v2 that are compatible with A_save */
 91:   VecCreate(PETSC_COMM_WORLD,&v1);
 92:   MatGetLocalSize(A_save,&m,NULL);
 93:   VecSetSizes(v1,m,PETSC_DECIDE);
 94:   VecSetFromOptions(v1);
 95:   VecDuplicate(v1,&v2);

 97:   PetscRandomCreate(PETSC_COMM_WORLD,&rdm);
 98:   PetscRandomSetFromOptions(rdm);
 99:   PetscOptionsGetReal(NULL,NULL,"-fill",&fill,NULL);

101:   /* Test MatAXPY()    */
102:   /*-------------------*/
103:   PetscOptionsHasName(NULL,NULL,"-test_MatAXPY",&Test_MatAXPY);
104:   if (Test_MatAXPY) {
105:     Mat Btmp;
106:     MatDuplicate(A_save,MAT_COPY_VALUES,&A);
107:     MatDuplicate(B,MAT_COPY_VALUES,&Btmp);
108:     MatAXPY(A,-1.0,B,DIFFERENT_NONZERO_PATTERN); /* A = -B + A_save */

110:     MatScale(A,-1.0); /* A = -A = B - A_save */
111:     MatAXPY(Btmp,-1.0,A,DIFFERENT_NONZERO_PATTERN); /* Btmp = -A + B = A_save */
112:     MatMultEqual(A_save,Btmp,10,&flg);
113:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"MatAXPY() is incorrect\n");
114:     MatDestroy(&A);
115:     MatDestroy(&Btmp);

117:     Test_MatMatMult    = PETSC_FALSE;
118:     Test_MatMatTr      = PETSC_FALSE;
119:     Test_MatPtAP       = PETSC_FALSE;
120:     Test_MatRARt       = PETSC_FALSE;
121:     Test_MatMatMatMult = PETSC_FALSE;
122:   }

124:   /* 1) Test MatMatMult() */
125:   /* ---------------------*/
126:   if (Test_MatMatMult) {
127:     MatDuplicate(A_save,MAT_COPY_VALUES,&A);
128:     MatCreateTranspose(A,&AT);
129:     MatCreateTranspose(AT,&ATT);
130:     MatCreateTranspose(B,&BT);
131:     MatCreateTranspose(BT,&BTT);

133:     MatMatMult(AT,B,MAT_INITIAL_MATRIX,fill,&C);
134:     MatMatMultEqual(AT,B,C,10,&flg);
135:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatMatMult() for C=AT*B");
136:     MatDestroy(&C);

138:     MatMatMult(ATT,B,MAT_INITIAL_MATRIX,fill,&C);
139:     MatMatMultEqual(ATT,B,C,10,&flg);
140:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatMatMult() for C=ATT*B");
141:     MatDestroy(&C);

143:     MatMatMult(A,B,MAT_INITIAL_MATRIX,fill,&C);
144:     MatMatMultEqual(A,B,C,10,&flg);
145:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatMatMult() for reuse C=A*B");
146:     /* ATT has different matrix type as A (although they have same internal data structure),
147:        we cannot call MatProductReplaceMats(ATT,NULL,NULL,C) and MatMatMult(ATT,B,MAT_REUSE_MATRIX,fill,&C) */
148:     MatDestroy(&C);

150:     MatMatMult(A,BTT,MAT_INITIAL_MATRIX,fill,&C);
151:     MatMatMultEqual(A,BTT,C,10,&flg);
152:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatMatMult() for C=A*BTT");
153:     MatDestroy(&C);

155:     MatMatMult(ATT,BTT,MAT_INITIAL_MATRIX,fill,&C);
156:     MatMatMultEqual(A,B,C,10,&flg);
157:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatMatMult()\n");
158:     MatDestroy(&C);

160:     MatDestroy(&BTT);
161:     MatDestroy(&BT);
162:     MatDestroy(&ATT);
163:     MatDestroy(&AT);

165:     MatMatMult(A,B,MAT_INITIAL_MATRIX,fill,&C);
166:     MatSetOptionsPrefix(C,"matmatmult_"); /* enable option '-matmatmult_' for matrix C */
167:     MatGetInfo(C,MAT_GLOBAL_SUM,&info);

169:     /* Test MAT_REUSE_MATRIX - reuse symbolic C */
170:     alpha=1.0;
171:     for (i=0; i<2; i++) {
172:       alpha -=0.1;
173:       MatScale(A,alpha);
174:       MatMatMult(A,B,MAT_REUSE_MATRIX,fill,&C);
175:     }
176:     MatMatMultEqual(A,B,C,10,&flg);
177:     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatMatMult()\n");
178:     MatDestroy(&A);

180:     /* Test MatDuplicate() of C=A*B */
181:     MatDuplicate(C,MAT_COPY_VALUES,&C1);
182:     MatDestroy(&C1);
183:     MatDestroy(&C);
184:   } /* if (Test_MatMatMult) */

186:   /* 2) Test MatTransposeMatMult() and MatMatTransposeMult() */
187:   /* ------------------------------------------------------- */
188:   if (Test_MatMatTr) {
189:     /* Create P */
190:     PetscInt PN,rstart,rend;
191:     PN   = M/2;
192:     nzp  = 5; /* num of nonzeros in each row of P */
193:     MatCreate(PETSC_COMM_WORLD,&P);
194:     MatSetSizes(P,PETSC_DECIDE,PETSC_DECIDE,M,PN);
195:     MatSetType(P,mattype);
196:     MatSeqAIJSetPreallocation(P,nzp,NULL);
197:     MatMPIAIJSetPreallocation(P,nzp,NULL,nzp,NULL);
198:     MatGetOwnershipRange(P,&rstart,&rend);
199:     for (i=0; i<nzp; i++) {
200:       PetscRandomGetValue(rdm,&a[i]);
201:     }
202:     for (i=rstart; i<rend; i++) {
203:       for (j=0; j<nzp; j++) {
204:         PetscRandomGetValue(rdm,&rval);
205:         idxn[j] = (PetscInt)(PetscRealPart(rval)*PN);
206:       }
207:       MatSetValues(P,1,&i,nzp,idxn,a,ADD_VALUES);
208:     }
209:     MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);
210:     MatAssemblyEnd(P,MAT_FINAL_ASSEMBLY);

212:     /* Create R = P^T */
213:     MatTranspose(P,MAT_INITIAL_MATRIX,&R);

215:     { /* Test R = P^T, C1 = R*B */
216:       MatMatMult(R,B,MAT_INITIAL_MATRIX,fill,&C1);
217:       MatTranspose(P,MAT_REUSE_MATRIX,&R);
218:       MatMatMult(R,B,MAT_REUSE_MATRIX,fill,&C1);
219:       MatDestroy(&C1);
220:     }

222:     /* C = P^T*B */
223:     MatTransposeMatMult(P,B,MAT_INITIAL_MATRIX,fill,&C);
224:     MatGetInfo(C,MAT_GLOBAL_SUM,&info);

226:     /* Test MAT_REUSE_MATRIX - reuse symbolic C */
227:     MatTransposeMatMult(P,B,MAT_REUSE_MATRIX,fill,&C);
228:     if (view) {
229:       PetscPrintf(PETSC_COMM_WORLD,"C = P^T * B:\n");
230:       MatView(C,PETSC_VIEWER_STDOUT_WORLD);
231:     }
232:     MatFreeIntermediateDataStructures(C);
233:     if (view) {
234:       PetscPrintf(PETSC_COMM_WORLD,"\nC = P^T * B after MatFreeIntermediateDataStructures():\n");
235:       MatView(C,PETSC_VIEWER_STDOUT_WORLD);
236:     }

238:     /* Compare P^T*B and R*B */
239:     MatMatMult(R,B,MAT_INITIAL_MATRIX,fill,&C1);
240:     MatNormDifference(C,C1,&norm);
241:     if (norm > PETSC_SMALL) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Error in MatTransposeMatMult(): %g\n",(double)norm);
242:     MatDestroy(&C1);

244:     /* Test MatDuplicate() of C=P^T*B */
245:     MatDuplicate(C,MAT_COPY_VALUES,&C1);
246:     MatDestroy(&C1);
247:     MatDestroy(&C);

249:     /* C = B*R^T */
250:     PetscObjectTypeCompare((PetscObject)B,MATSEQAIJ,&seqaij);
251:     if (size == 1 && seqaij) {
252:       MatMatTransposeMult(B,R,MAT_INITIAL_MATRIX,fill,&C);
253:       MatSetOptionsPrefix(C,"matmatmulttr_"); /* enable '-matmatmulttr_' for matrix C */
254:       MatGetInfo(C,MAT_GLOBAL_SUM,&info);

256:       /* Test MAT_REUSE_MATRIX - reuse symbolic C */
257:       MatMatTransposeMult(B,R,MAT_REUSE_MATRIX,fill,&C);

259:       /* Check */
260:       MatMatMult(B,P,MAT_INITIAL_MATRIX,fill,&C1);
261:       MatNormDifference(C,C1,&norm);
262:       if (norm > PETSC_SMALL) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Error in MatMatTransposeMult() %g\n",(double)norm);
263:       MatDestroy(&C1);
264:       MatDestroy(&C);
265:     }
266:     MatDestroy(&P);
267:     MatDestroy(&R);
268:   }

270:   /* 3) Test MatPtAP() */
271:   /*-------------------*/
272:   if (Test_MatPtAP) {
273:     PetscInt  PN;
274:     Mat       Cdup;

276:     MatDuplicate(A_save,MAT_COPY_VALUES,&A);
277:     MatGetSize(A,&M,&N);
278:     MatGetLocalSize(A,&m,&n);

280:     PN   = M/2;
281:     nzp  = (PetscInt)(0.1*PN+1); /* num of nozeros in each row of P */
282:     MatCreate(PETSC_COMM_WORLD,&P);
283:     MatSetSizes(P,PETSC_DECIDE,PETSC_DECIDE,N,PN);
284:     MatSetType(P,mattype);
285:     MatSeqAIJSetPreallocation(P,nzp,NULL);
286:     MatMPIAIJSetPreallocation(P,nzp,NULL,nzp,NULL);
287:     for (i=0; i<nzp; i++) {
288:       PetscRandomGetValue(rdm,&a[i]);
289:     }
290:     MatGetOwnershipRange(P,&rstart,&rend);
291:     for (i=rstart; i<rend; i++) {
292:       for (j=0; j<nzp; j++) {
293:         PetscRandomGetValue(rdm,&rval);
294:         idxn[j] = (PetscInt)(PetscRealPart(rval)*PN);
295:       }
296:       MatSetValues(P,1,&i,nzp,idxn,a,ADD_VALUES);
297:     }
298:     MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);
299:     MatAssemblyEnd(P,MAT_FINAL_ASSEMBLY);

301:     /* MatView(P,PETSC_VIEWER_STDOUT_WORLD); */
302:     MatGetSize(P,&pM,&pN);
303:     MatGetLocalSize(P,&pm,&pn);
304:     MatPtAP(A,P,MAT_INITIAL_MATRIX,fill,&C);

306:     /* Test MAT_REUSE_MATRIX - reuse symbolic C */
307:     alpha=1.0;
308:     for (i=0; i<2; i++) {
309:       alpha -=0.1;
310:       MatScale(A,alpha);
311:       MatPtAP(A,P,MAT_REUSE_MATRIX,fill,&C);
312:     }

314:     /* Test PtAP ops with P Dense and A either AIJ or SeqDense (it assumes MatPtAP_XAIJ_XAIJ is fine) */
315:     PetscObjectTypeCompare((PetscObject)A,MATSEQAIJ,&seqaij);
316:     if (seqaij) {
317:       MatConvert(C,MATSEQDENSE,MAT_INITIAL_MATRIX,&Cdensetest);
318:       MatConvert(P,MATSEQDENSE,MAT_INITIAL_MATRIX,&Pdense);
319:     } else {
320:       MatConvert(C,MATMPIDENSE,MAT_INITIAL_MATRIX,&Cdensetest);
321:       MatConvert(P,MATMPIDENSE,MAT_INITIAL_MATRIX,&Pdense);
322:     }

324:     /* test with A(AIJ), Pdense -- call MatPtAP_Basic() when np>1 */
325:     MatPtAP(A,Pdense,MAT_INITIAL_MATRIX,fill,&Cdense);
326:     MatPtAP(A,Pdense,MAT_REUSE_MATRIX,fill,&Cdense);
327:     MatPtAPMultEqual(A,Pdense,Cdense,10,&flg);
328:     if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Error in MatPtAP with A AIJ and P Dense");
329:     MatDestroy(&Cdense);

331:     /* test with A SeqDense */
332:     if (seqaij) {
333:       MatConvert(A,MATSEQDENSE,MAT_INITIAL_MATRIX,&Adense);
334:       MatPtAP(Adense,Pdense,MAT_INITIAL_MATRIX,fill,&Cdense);
335:       MatPtAP(Adense,Pdense,MAT_REUSE_MATRIX,fill,&Cdense);
336:       MatPtAPMultEqual(Adense,Pdense,Cdense,10,&flg);
337:       if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error in MatPtAP with A SeqDense and P SeqDense");
338:       MatDestroy(&Cdense);
339:       MatDestroy(&Adense);
340:     }
341:     MatDestroy(&Cdensetest);
342:     MatDestroy(&Pdense);

344:     /* Test MatDuplicate() of C=PtAP and MatView(Cdup,...) */
345:     MatDuplicate(C,MAT_COPY_VALUES,&Cdup);
346:     if (view) {
347:       PetscPrintf(PETSC_COMM_WORLD,"\nC = P^T * A * P:\n");
348:       MatView(C,PETSC_VIEWER_STDOUT_WORLD);

350:       MatFreeIntermediateDataStructures(C);
351:       PetscPrintf(PETSC_COMM_WORLD,"\nC = P^T * A * P after MatFreeIntermediateDataStructures():\n");
352:       MatView(C,PETSC_VIEWER_STDOUT_WORLD);

354:       PetscPrintf(PETSC_COMM_WORLD,"\nCdup:\n");
355:       MatView(Cdup,PETSC_VIEWER_STDOUT_WORLD);
356:     }
357:     MatDestroy(&Cdup);

359:     if (size>1 || !seqaij) Test_MatRARt = PETSC_FALSE;
360:     /* 4) Test MatRARt() */
361:     /* ----------------- */
362:     if (Test_MatRARt) {
363:       Mat R, RARt, Rdense, RARtdense;
364:       MatTranspose(P,MAT_INITIAL_MATRIX,&R);

366:       /* Test MatRARt_Basic(), MatMatMatMult_Basic() */
367:       MatConvert(R,MATDENSE,MAT_INITIAL_MATRIX,&Rdense);
368:       MatRARt(A,Rdense,MAT_INITIAL_MATRIX,2.0,&RARtdense);
369:       MatRARt(A,Rdense,MAT_REUSE_MATRIX,2.0,&RARtdense);

371:       MatConvert(RARtdense,MATAIJ,MAT_INITIAL_MATRIX,&RARt);
372:       MatNormDifference(C,RARt,&norm);
373:       if (norm > PETSC_SMALL) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"|PtAP - RARtdense| = %g",(double)norm);
374:       MatDestroy(&Rdense);
375:       MatDestroy(&RARtdense);
376:       MatDestroy(&RARt);

378:       /* Test MatRARt() for aij matrices */
379:       MatRARt(A,R,MAT_INITIAL_MATRIX,2.0,&RARt);
380:       MatRARt(A,R,MAT_REUSE_MATRIX,2.0,&RARt);
381:       MatNormDifference(C,RARt,&norm);
382:       if (norm > PETSC_SMALL) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"|PtAP - RARt| = %g",(double)norm);
383:       MatDestroy(&R);
384:       MatDestroy(&RARt);
385:     }

387:     if (Test_MatMatMatMult && size == 1) {
388:       Mat       R, RAP;
389:       MatTranspose(P,MAT_INITIAL_MATRIX,&R);
390:       MatMatMatMult(R,A,P,MAT_INITIAL_MATRIX,2.0,&RAP);
391:       MatMatMatMult(R,A,P,MAT_REUSE_MATRIX,2.0,&RAP);
392:       MatNormDifference(C,RAP,&norm);
393:       if (norm > PETSC_SMALL) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"PtAP != RAP %g",(double)norm);
394:       MatDestroy(&R);
395:       MatDestroy(&RAP);
396:     }

398:     /* Create vector x that is compatible with P */
399:     VecCreate(PETSC_COMM_WORLD,&x);
400:     MatGetLocalSize(P,&m,&n);
401:     VecSetSizes(x,n,PETSC_DECIDE);
402:     VecSetFromOptions(x);

404:     VecCreate(PETSC_COMM_WORLD,&v3);
405:     VecSetSizes(v3,n,PETSC_DECIDE);
406:     VecSetFromOptions(v3);
407:     VecDuplicate(v3,&v4);

409:     norm = 0.0;
410:     for (i=0; i<10; i++) {
411:       VecSetRandom(x,rdm);
412:       MatMult(P,x,v1);
413:       MatMult(A,v1,v2);  /* v2 = A*P*x */

415:       MatMultTranspose(P,v2,v3); /* v3 = Pt*A*P*x */
416:       MatMult(C,x,v4);           /* v3 = C*x   */
417:       VecNorm(v4,NORM_2,&norm_abs);
418:       VecAXPY(v4,none,v3);
419:       VecNorm(v4,NORM_2,&norm_tmp);

421:       norm_tmp /= norm_abs;
422:       if (norm_tmp > norm) norm = norm_tmp;
423:     }
424:     if (norm >= PETSC_SMALL) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Error: MatPtAP(), |v1 - v2|: %g\n",(double)norm);

426:     MatDestroy(&A);
427:     MatDestroy(&P);
428:     MatDestroy(&C);
429:     VecDestroy(&v3);
430:     VecDestroy(&v4);
431:     VecDestroy(&x);
432:   }

434:   /* Destroy objects */
435:   VecDestroy(&v1);
436:   VecDestroy(&v2);
437:   PetscRandomDestroy(&rdm);
438:   PetscFree(idxn);

440:   MatDestroy(&A_save);
441:   MatDestroy(&B);

443:   PetscPreLoadEnd();
444:   PetscFinalize();
445:   return ierr;
446: }



450: /*TEST

452:    test:
453:       suffix: 2_mattransposematmult_matmatmult
454:       nsize: 3
455:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
456:       args: -f0 ${DATAFILESPATH}/matrices/medium -f1 ${DATAFILESPATH}/matrices/medium -mattransposematmult_via at*b> ex94_2.tmp 2>&1

458:    test:
459:       suffix: 2_mattransposematmult_scalable
460:       nsize: 3
461:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
462:       args: -f0 ${DATAFILESPATH}/matrices/medium -f1 ${DATAFILESPATH}/matrices/medium -mattransposematmult_via scalable> ex94_2.tmp 2>&1
463:       output_file: output/ex94_1.out

465:    test:
466:       suffix: axpy_mpiaij
467:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
468:       nsize: 8
469:       args: -f0 ${DATAFILESPATH}/matrices/poisson_2d5p -f1 ${DATAFILESPATH}/matrices/poisson_2d13p -test_MatAXPY
470:       output_file: output/ex94_1.out

472:    test:
473:       suffix: axpy_mpibaij
474:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
475:       nsize: 8
476:       args: -f0 ${DATAFILESPATH}/matrices/poisson_2d5p -f1 ${DATAFILESPATH}/matrices/poisson_2d13p -test_MatAXPY -mat_type baij
477:       output_file: output/ex94_1.out

479:    test:
480:       suffix: axpy_mpisbaij
481:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
482:       nsize: 8
483:       args: -f0 ${DATAFILESPATH}/matrices/poisson_2d5p -f1 ${DATAFILESPATH}/matrices/poisson_2d13p -test_MatAXPY -mat_type sbaij
484:       output_file: output/ex94_1.out

486:    test:
487:       suffix: matmatmult
488:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
489:       args: -f0 ${DATAFILESPATH}/matrices/arco1 -f1 ${DATAFILESPATH}/matrices/arco1 -viewer_binary_skip_info
490:       output_file: output/ex94_1.out

492:    test:
493:       suffix: matmatmult_2
494:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
495:       args: -f0 ${DATAFILESPATH}/matrices/arco1 -f1 ${DATAFILESPATH}/matrices/arco1 -mat_type mpiaij -viewer_binary_skip_info
496:       output_file: output/ex94_1.out

498:    test:
499:       suffix: matmatmult_scalable
500:       nsize: 4
501:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
502:       args: -f0 ${DATAFILESPATH}/matrices/arco1 -f1 ${DATAFILESPATH}/matrices/arco1 -matmatmult_via scalable
503:       output_file: output/ex94_1.out

505:    test:
506:       suffix: ptap
507:       nsize: 3
508:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
509:       args: -f0 ${DATAFILESPATH}/matrices/medium -f1 ${DATAFILESPATH}/matrices/medium -matptap_via scalable
510:       output_file: output/ex94_1.out

512:    test:
513:       suffix: rap
514:       nsize: 3
515:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
516:       args: -f0 ${DATAFILESPATH}/matrices/medium -f1 ${DATAFILESPATH}/matrices/medium
517:       output_file: output/ex94_1.out

519:    test:
520:       suffix: scalable0
521:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
522:       args: -f0 ${DATAFILESPATH}/matrices/arco1 -f1 ${DATAFILESPATH}/matrices/arco1 -viewer_binary_skip_info
523:       output_file: output/ex94_1.out

525:    test:
526:       suffix: scalable1
527:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
528:       args: -f0 ${DATAFILESPATH}/matrices/arco1 -f1 ${DATAFILESPATH}/matrices/arco1 -viewer_binary_skip_info -matptap_via scalable
529:       output_file: output/ex94_1.out

531:    test:
532:       suffix: view
533:       nsize: 2
534:       requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
535:       args: -f0 ${DATAFILESPATH}/matrices/tiny -f1 ${DATAFILESPATH}/matrices/tiny -viewer_binary_skip_info -matops_view
536:       output_file: output/ex94_2.out

538: TEST*/