56 #include "../epetra_test_err.h"
68 int * xoff,
int * yoff,
int nrhs,
77 int nsizes,
int * sizes,
int nrhs,
85 int main(
int argc,
char *argv[]) {
93 MPI_Init(&argc,&argv);
103 bool verbose =
false;
106 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
108 int verbose_int = verbose ? 1 : 0;
110 verbose = verbose_int==1 ? true :
false;
119 int MyPID = Comm.
MyPID();
122 if(verbose && MyPID==0)
136 int xoff[] = {-1, 0, 1, -1, 0, 1, 0};
137 int yoff[] = {-1, -1, -1, 0, 0, 0, 1};
143 GenerateCrsProblem(nx, ny, npoints, xoff, yoff, 1, Comm, map,
A, x, b, xexact);
147 cout <<
"X exact = " << endl << *xexact << endl;
148 cout <<
"B = " << endl << *b << endl;
156 if (verbose) cout <<
"\nTime to construct transposer = "
159 bool MakeDataContiguous =
true;
164 if (verbose) cout <<
"\nTime to create transpose matrix = "
176 for (i=0; i<
A->NumMyRows(); i++)
177 A->SumIntoMyValues(i, 1, &Value, &i);
182 if (verbose) cout <<
"\nTime to update transpose matrix = "
194 if (verbose) cout << endl <<
"Checking transposer for VbrMatrix objects" << endl<< endl;
197 int sizes[] = {4, 6, 5, 3};
203 1, Comm, bmap, Avbr, x, b, xexact);
206 cout << *Avbr << endl;
207 cout <<
"X exact = " << endl << *xexact << endl;
208 cout <<
"B = " << endl << *b << endl;
213 if (verbose) cout <<
"\nTime to construct transposer = "
218 if (verbose) cout <<
"\nTime to create transpose matrix = "
235 if (verbose) cout <<
"\nTime to update transpose matrix = "
257 int n =
A->NumGlobalRows();
259 if (
n<100) cout <<
"A transpose = " << endl << *transA << endl;
264 A->SetUseTranspose(
true);
269 if (verbose) cout <<
"\nTime to compute b1: matvec with original matrix using transpose flag = " << timer.ElapsedTime() - start << endl;
271 if (
n<100) cout <<
"b1 = " << endl << b1 << endl;
274 start = timer.ElapsedTime();
276 if (verbose) cout <<
"\nTime to compute b2: matvec with transpose matrix = " << timer.ElapsedTime() - start << endl;
278 if (
n<100) cout <<
"b1 = " << endl << b1 << endl;
283 resid.
Update(1.0, b1, -1.0, b2, 0.0);
284 int ierr0 = resid.Norm2(&residual);
286 if (verbose) cout <<
"Norm of b1 - b2 = " << residual << endl;
290 if (residual > 1.0e-10) ierr++;
292 if (ierr!=0 && verbose) {
293 cerr <<
"Status: Test failed" << endl;
295 else if (verbose) cerr <<
"Status: Test passed" << endl;
301 int * xoff,
int * yoff,
int nrhs,
310 int numGlobalEquations = nx*ny;
311 map =
new Epetra_Map(numGlobalEquations, 0, comm);
317 int * indices =
new int[npoints];
318 double * values =
new double[npoints];
320 double dnpoints = (double) npoints;
322 for (
int i=0; i<numMyEquations; i++) {
324 int rowID = map->
GID(i);
327 for (
int j=0; j<npoints; j++) {
328 int colID = rowID + xoff[j] + nx*yoff[j];
329 if (colID>-1 && colID<numGlobalEquations) {
330 indices[numIndices] = colID;
331 double value = - ((double) rand())/ ((
double) RAND_MAX);
333 values[numIndices++] = dnpoints - value;
335 values[numIndices++] = -value;
339 A->InsertGlobalValues(rowID, numIndices, values, indices);
360 A->Multiply(
false, *xexact, *b);
366 int nsizes,
int * sizes,
int nrhs,
377 int numGlobalEquations = nx*ny;
378 Epetra_Map ptMap(numGlobalEquations, 0, comm);
383 for (i=0; i<numMyElements; i++)
384 elementSizes[i] = sizes[ptMap.
GID(i)%nsizes];
391 int * indices =
new int[npoints];
396 int maxElementSize = 0;
397 for (i=0; i< nsizes; i++) maxElementSize =
EPETRA_MAX(maxElementSize, sizes[i]);
405 for (i=0; i<numMyElements; i++) {
406 int rowID = map->
GID(i);
408 int rowDim = sizes[rowID%nsizes];
409 for (j=0; j<npoints; j++) {
410 int colID = rowID + xoff[j] + nx*yoff[j];
411 if (colID>-1 && colID<numGlobalEquations)
412 indices[numIndices++] = colID;
415 A->BeginInsertGlobalValues(rowID, numIndices, indices);
417 for (j=0; j < numIndices; j++) {
418 int colDim = sizes[indices[j]%nsizes];
419 A->SubmitBlockEntry(&(randvec[0]), rowDim, rowDim, colDim);
421 A->EndSubmitEntries();
431 A->InvRowSums(invRowSums);
432 rowSums.Reciprocal(invRowSums);
435 int numBlockDiagonalEntries;
438 A->BeginExtractBlockDiagonalView(numBlockDiagonalEntries, rowColDims);
439 for (i=0; i< numBlockDiagonalEntries; i++) {
442 A->ExtractBlockDiagonalEntryView(diagVals, diagLDA);
444 for (j=0; j<rowDim; j++) diagVals[j+j*diagLDA] = rowSums[diagoffsets[i]+j];
460 A->Multiply(
false, *xexact, *b);