46 const char TransA,
const char TransB,
86 int C_GEMM_Stride = 0;
113 int* A_MyGlobalElements =
new int[A_nrows];
115 int* B_MyGlobalElements =
new int[B_nrows];
116 B_Map->MyGlobalElements(B_MyGlobalElements);
121 opA_ncols != opB_nrows ||
127 delete [] A_MyGlobalElements;
128 delete [] B_MyGlobalElements;
132 bool Case1 = ( A_is_local && B_is_local && C_is_local);
133 bool Case2 = (!A_is_local && !B_is_local && C_is_local && TransA==
'T' );
134 bool Case3 = (!A_is_local && B_is_local && !C_is_local && TransA==
'N');
138 if (!(Case1 || Case2 || Case3)) {
141 delete [] A_MyGlobalElements;
142 delete [] B_MyGlobalElements;
178 double sf = C_global_inner_dim;
179 double sfinv = 1.0/sf;
185 for (j = 0; j <A_ncols ; j++)
186 for (i = 0; i<A_nrows; i++)
190 Ap[i + A_Stride*j] = (fi*sfinv)*fj;
195 for (j = 0; j <A_ncols ; j++)
196 for (i = 0; i<A_nrows; i++)
198 fi = A_MyGlobalElements[i]+1;
200 Ap[i + A_Stride*j] = (fi*sfinv)*fj;
208 for (j = 0; j <B_ncols ; j++)
209 for (i = 0; i<B_nrows; i++)
213 Bp[i + B_Stride*j] = 1.0/((fi*sfinv)*fj);
218 for (j = 0; j <B_ncols ; j++)
219 for (i = 0; i<B_nrows; i++)
221 fi = B_MyGlobalElements[i]+1;
223 Bp[i + B_Stride*j] = 1.0/((fi*sfinv)*fj);
233 for (j = 0; j <C_ncols ; j++)
234 for (i = 0; i<C_nrows; i++)
237 fi = (i+1)*C_global_inner_dim;
239 C_GEMMp[i + C_GEMM_Stride*j] = alpha * (fi/fj)
240 + beta * Cp[i + C_Stride*j];
245 for (j = 0; j <C_ncols ; j++)
246 for (i = 0; i<C_nrows; i++)
249 fi = (i+1)*C_global_inner_dim;
251 C_GEMMp[i + C_GEMM_Stride*j] = alpha * (fi/fj)
252 + beta * Cp[i + C_Stride*j];
257 for (j = 0; j <C_ncols ; j++)
258 for (i = 0; i<C_nrows; i++)
261 fi = (A_MyGlobalElements[i]+1)*C_global_inner_dim;
263 C_GEMMp[i + C_GEMM_Stride*j] = alpha * (fi/fj)
264 + beta * Cp[i + C_Stride*j];
269 delete [] A_MyGlobalElements;
270 delete [] B_MyGlobalElements;
281 double*
const dotvec_AB,
282 double*
const norm1_A,
283 double*
const norm2_sqrtA,
284 double*
const norminf_A,
285 double*
const normw_A,
287 double*
const minval_A,
288 double*
const maxval_A,
289 double*
const meanval_A ) {
316 double **C_alphaAp = 0;
317 double **C_alphaAplusBp = 0;
318 double **C_plusBp = 0;
319 double **Weightsp = 0;
341 int* A_MyGlobalElements =
new int[A_nrows];
343 int* B_MyGlobalElements =
new int[B_nrows];
344 B_Map->MyGlobalElements(B_MyGlobalElements);
349 A_nrows != B_nrows ||
351 A_ncols != B_ncols ||
352 sqrtA_nrows != A_nrows ||
353 sqrtA_ncols != A_ncols ||
362 bool Case1 = ( A_is_local && B_is_local && C_is_local);
363 bool Case2 = (!A_is_local && !B_is_local && !C_is_local);
367 if (!(Case1 || Case2))
return(-3);
390 double sfinv = 1.0/sf;
396 for (j = 0; j <A_ncols ; j++)
398 for (i = 0; i<A_nrows; i++)
402 Ap[j][i] = (fi*sfinv)*fj;
403 sqrtAp[j][i] = std::sqrt(Ap[j][i]);
409 for (j = 0; j <A_ncols ; j++)
411 for (i = 0; i<A_nrows; i++)
413 fi = A_MyGlobalElements[i]+1;
415 Ap[j][i] = (fi*sfinv)*fj;
416 sqrtAp[j][i] = std::sqrt(Ap[j][i]);
425 for (j = 0; j <B_ncols ; j++)
427 for (i = 0; i<B_nrows; i++)
431 Bp[j][i] = 1.0/((fi*sfinv)*fj);
437 for (j = 0; j <B_ncols ; j++)
439 for (i = 0; i<B_nrows; i++)
441 fi = B_MyGlobalElements[i]+1;
443 Bp[j][i] = 1.0/((fi*sfinv)*fj);
450 for (j = 0; j <A_ncols ; j++)
451 for (i = 0; i<A_nrows; i++)
452 C_alphaAp[j][i] = alpha * Ap[j][i];
456 for (j = 0; j <A_ncols ; j++)
457 for (i = 0; i<A_nrows; i++)
458 C_alphaAplusBp[j][i] = alpha * Ap[j][i] + Bp[j][i];
462 for (j = 0; j <A_ncols ; j++)
463 for (i = 0; i<A_nrows; i++)
464 C_plusBp[j][i] = Cp[j][i] + Bp[j][i];
483 norm1_A[i] = result * ((
double) (i+1));
489 norm2_sqrtA[i] = std::sqrt(result * ((
double) (i+1)));
495 norminf_A[i] = (double) (i+1);
496 minval_A[i] = (double) (i+1)/ (double) A.
GlobalLength();
497 maxval_A[i] = (double) (i+1);
498 meanval_A[i] = norm1_A[i]/((double) (A.
GlobalLength()));
504 double ip1 = (double) i+1;
506 for (j=0; j<A_nrows; j++) Weightsp[i][j] = Ap[i][j]/ip1;
512 delete [] A_MyGlobalElements;
513 delete [] B_MyGlobalElements;
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int GlobalLength() const
Returns the global vector length of vectors in the multi-vector.
bool DistributedGlobal() const
Returns true if this multi-vector is distributed global, i.e., not local replicated.
Epetra_Map: A class for partitioning vectors and matrices.
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
int NumVectors() const
Returns the number of vectors in the multi-vector.
int BuildMatrixTests(Epetra_MultiVector &C, const char TransA, const char TransB, const double alpha, Epetra_MultiVector &A, Epetra_MultiVector &B, const double beta, Epetra_MultiVector &C_GEMM)
int IndexBase() const
Index base for this map.
int ExtractView(double **A, int *MyLDA) const
Set user-provided addresses of A and MyLDA.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
bool ConstantStride() const
Returns true if this multi-vector has constant stride between vectors.
int BuildMultiVectorTests(Epetra_MultiVector &C, const double alpha, Epetra_MultiVector &A, Epetra_MultiVector &sqrtA, Epetra_MultiVector &B, Epetra_MultiVector &C_alphaA, Epetra_MultiVector &C_alphaAplusB, Epetra_MultiVector &C_plusB, double *const dotvec_AB, double *const norm1_A, double *const norm2_sqrtA, double *const norminf_A, double *const normw_A, Epetra_MultiVector &Weights, double *const minval_A, double *const maxval_A, double *const meanval_A)
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.