103 #include "Trilinos_Util.h"
104 #ifdef HAVE_COMM_ASSERT_EQUAL
105 #include "Comm_assert_equal.h"
114 int main(
int argc,
char *argv[]) {
120 MPI_Init(&argc,&argv);
128 bool verbose =
false;
129 bool veryVerbose =
false;
132 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
136 if (verbose) cout << comm << endl << flush;
138 bool verbose1 = verbose;
139 if (verbose) verbose = (comm.
MyPID()==0);
152 int xoff[] = {-1, 0, 1, -1, 0, 1, 0};
153 int yoff[] = {-1, -1, -1, 0, 0, 0, 1};
159 Trilinos_Util_GenerateCrsProblem(nx, ny, npoints, xoff, yoff, comm, map,
A, x, b, xexact);
162 cout <<
"npoints = " << npoints <<
" nx = " << nx <<
" ny = " << ny << endl ;
164 if (verbose && nx<6 ) {
166 cout <<
"B = " << endl << *b << endl;
179 if (verbose) cout <<
"\nTime to construct redistor = "
182 bool ConstructTranspose =
true;
183 bool MakeDataContiguous =
true;
186 redistor.CreateRedistProblem(ConstructTranspose, MakeDataContiguous, redistProblem);
187 if (verbose) cout <<
"\nTime to create redistributed problem = "
194 ierr +=
checkResults( ConstructTranspose, &redistor, &origProblem,
195 redistProblem, verbose);
205 redistor.UpdateRedistRHS(b);
206 if (verbose) cout <<
"\nTime to update redistributed RHS = "
210 &origProblem, redistProblem, verbose);
214 #define CREATE_CONST_MATRIX
215 #ifdef CREATE_CONST_MATRIX
224 for (i=0; i<
A->NumMyRows(); i++) {
226 cout <<
" i = " << i ;
227 A->SumIntoMyValues(i, 1, &Value, &i);
233 redistor.UpdateRedistProblemValues(&origProblem);
234 if (verbose) cout <<
"\nTime to update redistributed problem = "
237 ierr +=
checkResults(ConstructTranspose, &redistor, &origProblem, redistProblem, verbose);
268 int m =
A->GetRHS()->MyLength();
269 int n =
A->GetLHS()->MyLength();
277 assert( matrixA != 0 ) ;
287 double *val, *rhs, *lhs;
288 int Nrhs, ldrhs, ldlhs;
291 val, Nrhs, rhs, ldrhs,
296 cout <<
" iam = " << iam
297 <<
" m = " << m <<
" n = " <<
n <<
" M = " << M << endl ;
299 cout <<
" iam = " << iam <<
" ptr = " << ptr[0] <<
" " << ptr[1] <<
" " << ptr[2] <<
" " << ptr[3] <<
" " << ptr[4] <<
" " << ptr[5] << endl ;
301 cout <<
" iam = " << iam <<
" ind = " << ind[0] <<
" " << ind[1] <<
" " << ind[2] <<
" " << ind[3] <<
" " << ind[4] <<
" " << ind[5] << endl ;
303 cout <<
" iam = " << iam <<
" val = " << val[0] <<
" " << val[1] <<
" " << val[2] <<
" " << val[3] <<
" " << val[4] <<
" " << val[5] << endl ;
308 int NumMyElements_ = 0 ;
309 if (matrixA->
Comm().
MyPID()==0) NumMyElements_ =
n;
323 for (
int k = 0 ; k < Nrhs; k ++ ) {
324 for (
int i = 0 ; i < M ; i ++ ) {
325 lhs[ i + k * ldlhs ] = 0.0;
327 for (
int i = 0 ; i < M ; i++ ) {
328 for (
int l = ptr[i]; l < ptr[i+1]; l++ ) {
330 if ( verbose && N < 40 ) {
331 cout <<
" i = " << i <<
" j = " << j ;
332 cout <<
" l = " << l <<
" val[l] = " << val[l] ;
333 cout <<
" rhs = " << rhs[ j + k * ldrhs ] << endl ;
335 lhs[ i + k * ldrhs ] += val[l] * rhs[ j + k * ldrhs ] ;
339 if ( verbose && N < 40 ) {
341 for (
int j = 0 ; j < N ; j++ ) cout <<
" " << lhs[j] ;
344 for (
int j = 0 ; j < N ; j++ ) cout <<
" " << rhs[j] ;
349 #ifdef HAVE_COMM_ASSERT_EQUAL
354 for (
int j = 0 ; j < N ; j++ ) {
355 assert( Comm_assert_equal( &comm, lhs[ j + k * ldrhs ] ) ) ;
356 assert( Comm_assert_equal( &comm, rhs[ j + k * ldrhs ] ) ) ;
371 double Norm_x1, Norm_diff ;
377 x1.
Update( -1.0, *x, 1.0 ) ;
385 cout <<
" Norm_diff = " << Norm_diff << endl ;
386 cout <<
" Norm_x1 = " << Norm_x1 << endl ;
391 if (ierr!=0 && verbose) cerr <<
"Status: Test failed" << endl;
392 else if (verbose) cerr <<
"Status: Test passed" << endl;