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;
395 for (i = 0; i<A_nrows; i++) {
398 sqrtAp[i] = std::sqrt(Ap[i]);
402 for (i = 0; i<A_nrows; i++) {
403 fi = A_MyGlobalElements[i]+1;
405 sqrtAp[i] = std::sqrt(Ap[i]);
412 for (i = 0; i<B_nrows; i++) {
414 Bp[i] = 1.0/((fi*sfinv));
418 for (i = 0; i<B_nrows; i++) {
419 fi = B_MyGlobalElements[i]+1;
420 Bp[i] = 1.0/((fi*sfinv));
426 for (i = 0; i<A_nrows; i++) C_alphaAp[i] = alpha * Ap[i];
430 for (i = 0; i<A_nrows; i++) C_alphaAplusBp[i] = alpha * Ap[i] + Bp[i];
434 for (i = 0; i<A_nrows; i++) C_plusBp[i] = Cp[i] + Bp[i];
453 norm1_A[i] = result * ((
double) (i+1));
459 norm2_sqrtA[i] = std::sqrt(result * ((
double) (i+1)));
465 norminf_A[i] = (double) (i+1);
466 minval_A[i] = (double) (i+1)/ (double) A.
GlobalLength();
467 maxval_A[i] = (double) (i+1);
468 meanval_A[i] = norm1_A[i]/((double) (A.
GlobalLength()));
473 for (j=0; j<A_nrows; j++) Weightsp[j] = Ap[j];
477 delete [] A_MyGlobalElements;
478 delete [] B_MyGlobalElements;
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.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
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 BuildVectorTests(Epetra_Vector &C, const double alpha, Epetra_Vector &A, Epetra_Vector &sqrtA, Epetra_Vector &B, Epetra_Vector &C_alphaA, Epetra_Vector &C_alphaAplusB, Epetra_Vector &C_plusB, double *const dotvec_AB, double *const norm1_A, double *const norm2_sqrtA, double *const norminf_A, double *const normw_A, Epetra_Vector &Weights, double *const minval_A, double *const maxval_A, double *const meanval_A)
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 ExtractView(double **V) const
Set user-provided address of V.
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.