34 #ifdef HAVE_TEUCHOS_COMPLEX
35 #define SType std::complex<double>
41 #define OType1 long int
52 #ifdef HAVE_TEUCHOS_COMPLEX
53 #define SCALARMAX SType(10,0)
55 #define SCALARMAX SType(10)
77 template<
typename TYPE>
89 std::complex<T>
GetRandom( std::complex<T>, std::complex<T> );
91 template<
typename TYPE,
typename OTYPE>
92 void PrintVector(TYPE* Vector,
OTYPE Size, std::string Name,
bool Matlab = 0);
94 template<
typename TYPE,
typename OTYPE>
97 template<
typename TYPE>
100 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
103 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
104 bool CompareMatrices(TYPE* Matrix1, OTYPE1 Rows1, OTYPE1 Columns1, OTYPE1 LDM1,
105 TYPE* Matrix2, OTYPE2 Rows2, OTYPE2 Columns2, OTYPE2 LDM2,
109 template<
typename OTYPE1,
typename OTYPE2>
112 return static_cast<OTYPE2
>(T1);
121 int main(
int argc,
char *argv[])
127 bool InvalidCmdLineArgs = 0;
131 for(i = 1; i < argc; i++)
133 if(argv[i][0] ==
'-')
144 InvalidCmdLineArgs = 1;
154 InvalidCmdLineArgs = 1;
164 InvalidCmdLineArgs = 1;
168 InvalidCmdLineArgs = 1;
177 if(InvalidCmdLineArgs || (argc > 4))
179 std::cout <<
"Invalid command line arguments detected. Use the following flags:" << std::endl
180 <<
"\t -v enables verbose mode (reports number of failed/successful tests)" << std::endl
181 <<
"\t -d enables debug mode (same as verbose with output of each test, not recommended for large numbers of tests)" << std::endl
182 <<
"\t -m enables matlab-style output; only has an effect if debug mode is enabled" << std::endl;
190 SType OType1alpha, OType1beta;
191 SType OType2alpha, OType2beta;
192 SType *OType1A, *OType1B, *OType1C, *OType1x, *OType1y;
193 SType *OType2A, *OType2B, *OType2C, *OType2x, *OType2y;
194 SType OType1ASUMresult, OType1DOTresult, OType1NRM2result, OType1SINresult;
195 SType OType2ASUMresult, OType2DOTresult, OType2NRM2result, OType2SINresult;
196 MType OType1COSresult, OType2COSresult;
201 OType1 TotalTestCount = 1, GoodTestSubcount, GoodTestCount = 0, M1, N1, P1, K1, LDA1, LDB1, LDC1, Mx1, My1;
202 OType2 M2, N2, P2, K2, LDA2, LDB2, LDC2, Mx2, My2;
209 std::srand(time(NULL));
216 GoodTestSubcount = 0;
220 OType2alpha = OType1alpha;
222 OType2beta = OType1beta;
224 OType2COSresult = OType1COSresult;
226 OType2SINresult = OType1SINresult;
230 std::cout <<
"Test #" << TotalTestCount <<
" -- ROTG -- " << std::endl;
231 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
232 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
233 std::cout <<
"OType1beta = " << OType1beta << std::endl;
234 std::cout <<
"OType2beta = " << OType2beta << std::endl;
237 OType1BLAS.
ROTG(&OType1alpha, &OType1beta, &OType1COSresult, &OType1SINresult);
238 OType2BLAS.
ROTG(&OType2alpha, &OType2beta, &OType2COSresult, &OType2SINresult);
241 std::cout <<
"OType1 ROTG COS result: " << OType1COSresult << std::endl;
242 std::cout <<
"OType2 ROTG COS result: " << OType2COSresult << std::endl;
243 std::cout <<
"OType1 ROTG SIN result: " << OType1SINresult << std::endl;
244 std::cout <<
"OType2 ROTG SIN result: " << OType2SINresult << std::endl;
247 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
248 GoodTestSubcount += (
CompareScalars(OType1COSresult, OType2COSresult, TOL) &&
251 GoodTestCount += GoodTestSubcount;
252 if(verbose || debug) std::cout <<
"ROTG: " << GoodTestSubcount <<
" of " << ROTGTESTS <<
" tests were successful." << std::endl;
253 if(debug) std::cout << std::endl;
261 GoodTestSubcount = 0;
266 if (incx1 == 0) incx1 = 1;
267 if (incy1 == 0) incy1 = 1;
272 Mx1 = M1*std::abs(incx1);
273 My1 = M1*std::abs(incy1);
274 if (Mx1 == 0) { Mx1 = 1; }
275 if (My1 == 0) { My1 = 1; }
278 OType1x =
new SType[Mx1];
279 OType1y =
new SType[My1];
280 OType2x =
new SType[Mx2];
281 OType2y =
new SType[My2];
282 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
285 OType2x[j2] = OType1x[j1];
287 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
290 OType2y[j2] = OType1y[j1];
298 std::cout <<
"Test #" << TotalTestCount <<
" -- ROT -- " << std::endl;
299 std::cout <<
"c1 = " << c1 <<
", s1 = " << s1 << std::endl;
300 std::cout <<
"c2 = " << c2 <<
", s2 = " << s2 << std::endl;
301 std::cout <<
"incx1 = " << incx1 <<
", incy1 = " << incy1 << std::endl;
302 std::cout <<
"incx2 = " << incx2 <<
", incy2 = " << incy2 << std::endl;
304 PrintVector(OType1y, My1,
"OType1y_before_operation", matlab);
306 PrintVector(OType2y, My2,
"OType2y_before_operation", matlab);
309 OType1BLAS.
ROT(M1, OType1x, incx1, OType1y, incy1, &c1, &s1);
310 OType2BLAS.
ROT(M2, OType2x, incx2, OType2y, incy2, &c2, &s2);
313 PrintVector(OType1y, My1,
"OType1y_after_operation", matlab);
314 PrintVector(OType2y, My2,
"OType2y_after_operation", matlab);
317 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
318 GoodTestSubcount += (
CompareVectors(OType1x, Mx1, OType2x, Mx2, TOL) &&
325 GoodTestCount += GoodTestSubcount;
326 if(verbose || debug) std::cout <<
"ROT: " << GoodTestSubcount <<
" of " << ROTTESTS <<
" tests were successful." << std::endl;
327 if(debug) std::cout << std::endl;
335 GoodTestSubcount = 0;
343 OType1x =
new SType[M1*incx1];
344 OType2x =
new SType[M2*incx2];
345 for(j1 = 0, j2 = 0; j2 < M2*incx2; j1++, j2++)
348 OType2x[j2] = OType1x[j1];
352 std::cout <<
"Test #" << TotalTestCount <<
" -- ASUM -- " << std::endl;
353 std::cout <<
"incx1 = " << incx1 <<
"\t" <<
"incx2 = " << incx2
354 <<
"\t" <<
"M1 = " << M1 <<
"\t" <<
"M2 = " << M2 << std::endl;
359 OType1ASUMresult = OType1BLAS.
ASUM(M1, OType1x, incx1);
360 OType2ASUMresult = OType2BLAS.
ASUM(M2, OType2x, incx2);
363 std::cout <<
"OType1 ASUM result: " << OType1ASUMresult << std::endl;
364 std::cout <<
"OType2 ASUM result: " << OType2ASUMresult << std::endl;
367 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
368 GoodTestSubcount +=
CompareScalars(OType1ASUMresult, OType2ASUMresult, TOL);
373 GoodTestCount += GoodTestSubcount;
374 if(verbose || debug) std::cout <<
"ASUM: " << GoodTestSubcount <<
" of " << ASUMTESTS <<
" tests were successful." << std::endl;
375 if(debug) std::cout << std::endl;
384 GoodTestSubcount = 0;
393 Mx1 = M1*std::abs(incx1);
394 My1 = M1*std::abs(incy1);
395 if (Mx1 == 0) { Mx1 = 1; }
396 if (My1 == 0) { My1 = 1; }
399 OType1x =
new SType[Mx1];
400 OType1y =
new SType[My1];
401 OType2x =
new SType[Mx2];
402 OType2y =
new SType[My2];
403 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
406 OType2x[j2] = OType1x[j1];
408 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
411 OType2y[j2] = OType1y[j1];
414 OType2alpha = OType1alpha;
417 std::cout <<
"Test #" << TotalTestCount <<
" -- AXPY -- " << std::endl;
418 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
419 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
421 PrintVector(OType1y, My1,
"OType1y_before_operation", matlab);
423 PrintVector(OType2y, My2,
"OType2y_before_operation", matlab);
426 OType1BLAS.
AXPY(M1, OType1alpha, OType1x, incx1, OType1y, incy1);
427 OType2BLAS.
AXPY(M2, OType2alpha, OType2x, incx2, OType2y, incy2);
430 PrintVector(OType1y, My1,
"OType1y_after_operation", matlab);
431 PrintVector(OType2y, My2,
"OType2y_after_operation", matlab);
434 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
435 GoodTestSubcount +=
CompareVectors(OType1y, My1, OType2y, My2, TOL);
442 GoodTestCount += GoodTestSubcount;
443 if(verbose || debug) std::cout <<
"AXPY: " << GoodTestSubcount <<
" of " << AXPYTESTS <<
" tests were successful." << std::endl;
444 if(debug) std::cout << std::endl;
452 GoodTestSubcount = 0;
461 Mx1 = M1*std::abs(incx1);
462 My1 = M1*std::abs(incy1);
463 if (Mx1 == 0) { Mx1 = 1; }
464 if (My1 == 0) { My1 = 1; }
467 OType1x =
new SType[Mx1];
468 OType1y =
new SType[My1];
469 OType2x =
new SType[Mx2];
470 OType2y =
new SType[My2];
471 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
474 OType2x[j2] = OType1x[j1];
476 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
479 OType2y[j2] = OType1y[j1];
483 std::cout <<
"Test #" << TotalTestCount <<
" -- COPY -- " << std::endl;
485 PrintVector(OType1y, My1,
"OType1y_before_operation", matlab);
487 PrintVector(OType2y, My2,
"OType2y_before_operation", matlab);
490 OType1BLAS.
COPY(M1, OType1x, incx1, OType1y, incy1);
491 OType2BLAS.
COPY(M2, OType2x, incx2, OType2y, incy2);
494 PrintVector(OType1y, My1,
"OType1y_after_operation", matlab);
495 PrintVector(OType2y, My2,
"OType2y_after_operation", matlab);
498 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
499 GoodTestSubcount +=
CompareVectors(OType1y, My1, OType2y, My2, TOL);
506 GoodTestCount += GoodTestSubcount;
if(verbose || debug) std::cout <<
"COPY: " << GoodTestSubcount <<
" of " << COPYTESTS <<
" tests were successful." << std::endl;
507 if(debug) std::cout << std::endl;
515 GoodTestSubcount = 0;
524 Mx1 = M1*std::abs(incx1);
525 My1 = M1*std::abs(incy1);
526 if (Mx1 == 0) { Mx1 = 1; }
527 if (My1 == 0) { My1 = 1; }
530 OType1x =
new SType[Mx1];
531 OType1y =
new SType[My1];
532 OType2x =
new SType[Mx2];
533 OType2y =
new SType[My2];
534 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
537 OType2x[j2] = OType1x[j1];
539 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
542 OType2y[j2] = OType1y[j1];
546 std::cout <<
"Test #" << TotalTestCount <<
" -- DOT -- " << std::endl;
553 OType1DOTresult = OType1BLAS.
DOT(M1, OType1x, incx1, OType1y, incy1);
554 OType2DOTresult = OType2BLAS.
DOT(M2, OType2x, incx2, OType2y, incy2);
557 std::cout <<
"OType1 DOT result: " << OType1DOTresult << std::endl;
558 std::cout <<
"OType2 DOT result: " << OType2DOTresult << std::endl;
561 std::cout <<
"DOT test " << i+1 <<
" of " << DOTTESTS <<
" FAILED! "
563 <<
"The two results are " << OType1DOTresult <<
" and "
564 << OType2DOTresult <<
". incx1 = " << incx1 <<
", incy1 = "
565 << incy1 <<
", incx2 = " << incx2 <<
", and incy2 = "
566 << incy2 << std::endl;
569 GoodTestSubcount +=
CompareScalars(OType1DOTresult, OType2DOTresult, TOL);
576 GoodTestCount += GoodTestSubcount;
577 if(verbose || debug) std::cout <<
"DOT: " << GoodTestSubcount <<
" of " << DOTTESTS <<
" tests were successful." << std::endl;
578 if(debug) std::cout << std::endl;
586 GoodTestSubcount = 0;
593 OType1x =
new SType[M1*incx1];
594 OType2x =
new SType[M2*incx2];
595 for(j1 = 0, j2 = 0; j1 < M1*incx1; j1++, j2++)
598 OType2x[j2] = OType1x[j1];
602 std::cout <<
"Test #" << TotalTestCount <<
" -- NRM2 -- " << std::endl;
607 OType1NRM2result = OType1BLAS.
NRM2(M1, OType1x, incx1);
608 OType2NRM2result = OType2BLAS.
NRM2(M2, OType2x, incx2);
611 std::cout <<
"OType1 NRM2 result: " << OType1NRM2result << std::endl;
612 std::cout <<
"OType2 NRM2 result: " << OType2NRM2result << std::endl;
615 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
616 GoodTestSubcount +=
CompareScalars(OType1NRM2result, OType2NRM2result, TOL);
621 GoodTestCount += GoodTestSubcount;
if(verbose || debug) std::cout <<
"NRM2: " << GoodTestSubcount <<
" of " << NRM2TESTS <<
" tests were successful." << std::endl;
622 if(debug) std::cout << std::endl;
630 GoodTestSubcount = 0;
640 OType1x =
new SType[M1*incx1];
641 OType2x =
new SType[M2*incx2];
642 for(j1 = 0, j2 = 0; j1 < M1*incx1; j1++, j2++)
645 OType2x[j2] = OType1x[j1];
648 OType2alpha = OType1alpha;
651 std::cout <<
"Test #" << TotalTestCount <<
" -- SCAL -- " << std::endl;
652 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
653 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
654 PrintVector(OType1x, M1*incx1,
"OType1x_before_operation", matlab);
655 PrintVector(OType2x, M2*incx2,
"OType2x_before_operation", matlab);
658 OType1BLAS.
SCAL(M1, OType1alpha, OType1x, incx1);
659 OType2BLAS.
SCAL(M2, OType2alpha, OType2x, incx2);
662 PrintVector(OType1x, M1*incx1,
"OType1x_after_operation", matlab);
663 PrintVector(OType2x, M2*incx2,
"OType2x_after_operation", matlab);
666 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
667 GoodTestSubcount +=
CompareVectors(OType1x, M1*incx1, OType2x, M2*incx2, TOL);
672 GoodTestCount += GoodTestSubcount;
673 if(verbose || debug) std::cout <<
"SCAL: " << GoodTestSubcount <<
" of " << SCALTESTS <<
" tests were successful." << std::endl;
674 if(debug) std::cout << std::endl;
682 GoodTestSubcount = 0;
689 OType1x =
new SType[M1*incx1];
690 OType2x =
new SType[M2*incx2];
691 for(j1 = 0, j2 = 0; j1 < M1*incx1; j1++, j2++)
694 OType2x[j2] = OType1x[j1];
698 std::cout <<
"Test #" << TotalTestCount <<
" -- IAMAX -- " << std::endl;
703 OType1IAMAXresult = OType1BLAS.
IAMAX(M1, OType1x, incx1);
704 OType2IAMAXresult = OType2BLAS.
IAMAX(M2, OType2x, incx2);
707 std::cout <<
"OType1 IAMAX result: " << OType1IAMAXresult << std::endl;
708 std::cout <<
"OType2 IAMAX result: " << OType2IAMAXresult << std::endl;
710 if (OType1IAMAXresult != OType2IAMAXresult)
711 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
712 GoodTestSubcount += (OType1IAMAXresult == OType2IAMAXresult);
717 GoodTestCount += GoodTestSubcount;
718 if(verbose || debug) std::cout <<
"IAMAX: " << GoodTestSubcount <<
" of " << IAMAXTESTS <<
" tests were successful." << std::endl;
719 if(debug) std::cout << std::endl;
729 GoodTestSubcount = 0;
750 OType1 M2_1 = 0, N2_1 = 0;
752 M2_1 = M1*std::abs(incy1);
753 N2_1 = N1*std::abs(incx1);
755 M2_1 = N1*std::abs(incy1);
756 N2_1 = M1*std::abs(incx1);
771 OType2alpha = OType1alpha;
772 OType2beta = OType1beta;
774 OType1A =
new SType[LDA1 * N1];
775 OType1x =
new SType[N2_1];
776 OType1y =
new SType[M2_1];
777 OType2A =
new SType[LDA2 * N2];
778 OType2x =
new SType[N2_2];
779 OType2y =
new SType[M2_2];
781 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++)
784 OType2A[j2] = OType1A[j1];
786 for(j1 = 0, j2 = 0; j1 < N2_1; j1++, j2++)
789 OType2x[j2] = OType1x[j1];
791 for(j1 = 0, j2 = 0; j1 < M2_1; j1++, j2++)
794 OType2y[j2] = OType1y[j1];
798 std::cout <<
"Test #" << TotalTestCount <<
" -- GEMV -- " << std::endl;
800 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
801 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
802 std::cout <<
"OType1beta = " << OType1beta << std::endl;
803 std::cout <<
"OType2beta = " << OType2beta << std::endl;
804 PrintMatrix(OType1A, M1, N1, LDA1,
"OType1A", matlab);
806 PrintVector(OType1y, M2_1,
"OType1y_before_operation", matlab);
807 PrintMatrix(OType2A, M2, N2, LDA2,
"OType2A", matlab);
809 PrintVector(OType2y, M2_2,
"OType2y_before_operation", matlab);
812 OType1BLAS.
GEMV(TRANS, M1, N1, OType1alpha, OType1A, LDA1, OType1x, incx1, OType1beta, OType1y, incy1);
813 OType2BLAS.
GEMV(TRANS, M2, N2, OType2alpha, OType2A, LDA2, OType2x, incx2, OType2beta, OType2y, incy2);
816 PrintVector(OType1y, M2_1,
"OType1y_after_operation", matlab);
817 PrintVector(OType2y, M2_2,
"OType2y_after_operation", matlab);
820 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
821 GoodTestSubcount +=
CompareVectors(OType1y, M2_1, OType2y, M2_2, TOL);
830 GoodTestCount += GoodTestSubcount;
831 if(verbose || debug) std::cout <<
"GEMV: " << GoodTestSubcount <<
" of " << GEMVTESTS <<
" tests were successful." << std::endl;
832 if(debug) std::cout << std::endl;
840 GoodTestSubcount = 0;
858 OType1x =
new SType[N1*std::abs(incx1)];
859 OType2x =
new SType[N2*std::abs(incx2)];
861 for(j1 = 0, j2 = 0; j1 < N1*std::abs(incx1); j1++, j2++)
864 OType2x[j2] = OType1x[j1];
872 OType1A =
new SType[LDA1 * N1];
873 OType2A =
new SType[LDA2 * N2];
875 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
880 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
885 OType1A[j1*LDA1+k1] = STypezero;
887 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
891 while (OType1A[j1*LDA1+k1] == STypezero) {
894 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
896 OType1A[j1*LDA1+k1] = STypeone;
897 OType2A[j2*LDA2+k2] = STypeone;
904 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
909 OType1A[j1*LDA1+k1] = STypezero;
911 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
915 while (OType1A[j1*LDA1+k1] == STypezero) {
918 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
920 OType1A[j1*LDA1+k1] = STypeone;
921 OType2A[j2*LDA2+k2] = STypeone;
930 std::cout <<
"Test #" << TotalTestCount <<
" -- TRMV -- " << std::endl;
934 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
935 PrintVector(OType1x, N1*incx1,
"OType1x_before_operation", matlab);
936 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
937 PrintVector(OType2x, N2*incx2,
"OType2x_before_operation", matlab);
940 OType1BLAS.
TRMV(UPLO, TRANSA, DIAG, N1, OType1A, LDA1, OType1x, incx1);
941 OType2BLAS.
TRMV(UPLO, TRANSA, DIAG, N2, OType2A, LDA2, OType2x, incx2);
944 PrintVector(OType1x, N1*incx1,
"OType1x_after_operation", matlab);
945 PrintVector(OType2x, N2*incx2,
"OType2x_after_operation", matlab);
947 if (
CompareVectors(OType1x, std::abs(N1*incx1), OType2x, std::abs(N2*incx2), TOL)==0)
948 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
949 GoodTestSubcount +=
CompareVectors(OType1x, std::abs(N1*incx1), OType2x, std::abs(N2*incx2), TOL);
956 GoodTestCount += GoodTestSubcount;
957 if(verbose || debug) std::cout <<
"TRMV: " << GoodTestSubcount <<
" of " << TRMVTESTS <<
" tests were successful." << std::endl;
958 if(debug) std::cout << std::endl;
966 GoodTestSubcount = 0;
990 OType1A =
new SType[LDA1 * N1];
991 OType1x =
new SType[M1*std::abs(incx1)];
992 OType1y =
new SType[N1*std::abs(incy1)];
993 OType2A =
new SType[LDA2 * N2];
994 OType2x =
new SType[M2*std::abs(incx2)];
995 OType2y =
new SType[N2*std::abs(incy2)];
997 OType2alpha = OType1alpha;
998 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++)
1001 OType2A[j2] = OType1A[j1];
1003 for(j1 = 0, j2 = 0; j1 < std::abs(M1*incx1); j1++, j2++)
1006 OType2x[j2] = OType1x[j1];
1008 for(j1 = 0, j2 = 0; j1 < std::abs(N1*incy1); j1++, j2++)
1011 OType2y[j2] = OType1y[j1];
1015 std::cout <<
"Test #" << TotalTestCount <<
" -- GER -- " << std::endl;
1016 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1017 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1018 PrintMatrix(OType1A, M1, N1, LDA1,
"OType1A_before_operation", matlab);
1019 PrintVector(OType1x, std::abs(M1*incx1),
"OType1x", matlab);
1020 PrintVector(OType1y, std::abs(N1*incy1),
"OType1y", matlab);
1021 PrintMatrix(OType2A, M2, N2, LDA2,
"OType2A_before_operation", matlab);
1022 PrintVector(OType2x, std::abs(M2*incx2),
"OType2x", matlab);
1023 PrintVector(OType2y, std::abs(N2*incy2),
"OType2y", matlab);
1026 OType1BLAS.
GER(M1, N1, OType1alpha, OType1x, incx1, OType1y, incy1, OType1A, LDA1);
1027 OType2BLAS.
GER(M2, N2, OType2alpha, OType2x, incx2, OType2y, incy2, OType2A, LDA2);
1030 PrintMatrix(OType1A, M1, N1, LDA1,
"OType1A_after_operation", matlab);
1031 PrintMatrix(OType2A, M2, N2, LDA2,
"OType2A_after_operation", matlab);
1033 if (
CompareMatrices(OType1A, M1, N1, LDA1, OType2A, M2, N2, LDA2, TOL)==0)
1034 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1035 GoodTestSubcount +=
CompareMatrices(OType1A, M1, N1, LDA1, OType2A, M2, N2, LDA2, TOL);
1044 GoodTestCount += GoodTestSubcount;
1045 if(verbose || debug) std::cout <<
"GER: " << GoodTestSubcount <<
" of " << GERTESTS <<
" tests were successful." << std::endl;
1046 if(debug) std::cout << std::endl;
1056 GoodTestSubcount = 0;
1069 std::cout <<
"Test #" << TotalTestCount <<
" -- GEMM -- " << std::endl;
1077 OType1A =
new SType[LDA1 * P1];
1078 OType2A =
new SType[LDA2 * P2];
1079 for(j1 = 0, j2 = 0; j1 < LDA1 * P1; j1++, j2++)
1082 OType2A[j2] = OType1A[j1];
1085 PrintMatrix(OType1A, M1, P1, LDA1,
"OType1A", matlab);
1086 PrintMatrix(OType2A, M2, P2, LDA2,
"OType2A", matlab);
1091 OType1A =
new SType[LDA1 * M1];
1092 OType2A =
new SType[LDA1 * M1];
1093 for(j1 = 0, j2 = 0; j1 < LDA1 * M1; j1++, j2++)
1096 OType2A[j2] = OType1A[j1];
1099 PrintMatrix(OType1A, P1, M1, LDA1,
"OType1A", matlab);
1100 PrintMatrix(OType2A, P2, M2, LDA2,
"OType2A", matlab);
1108 OType1B =
new SType[LDB1 * N1];
1109 OType2B =
new SType[LDB2 * N2];
1110 for(j1 = 0, j2 = 0; j1 < LDB1 * N1; j1++, j2++)
1113 OType2B[j2] = OType1B[j1];
1116 PrintMatrix(OType1B, P1, N1, LDB1,
"OType1B", matlab);
1117 PrintMatrix(OType2B, P2, N2, LDB2,
"OType2B", matlab);
1122 OType1B =
new SType[LDB1 * P1];
1123 OType2B =
new SType[LDB2 * P2];
1124 for(j1 = 0, j2 = 0; j1 < LDB1 * P1; j1++, j2++)
1127 OType2B[j2] = OType1B[j1];
1130 PrintMatrix(OType1B, N1, P1, LDB1,
"OType1B", matlab);
1131 PrintMatrix(OType2B, N2, P2, LDB2,
"OType2B", matlab);
1138 OType1C =
new SType[LDC1 * N1];
1139 OType2C =
new SType[LDC2 * N2];
1140 for(j1 = 0, j2 = 0; j1 < LDC1 * N1; j1++, j2++) {
1142 OType2C[j2] = OType1C[j1];
1146 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_before_operation", matlab);
1147 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_before_operation", matlab);
1152 OType2alpha = OType1alpha;
1153 OType2beta = OType1beta;
1156 OType1BLAS.
GEMM(TRANSA, TRANSB, M1, N1, P1, OType1alpha, OType1A, LDA1, OType1B, LDB1, OType1beta, OType1C, LDC1);
1157 OType2BLAS.
GEMM(TRANSA, TRANSB, M2, N2, P2, OType2alpha, OType2A, LDA2, OType2B, LDB2, OType2beta, OType2C, LDC2);
1160 std::cout <<
"M1="<<M1 <<
"\t" <<
"N1="<<N1 <<
"\t" <<
"P1 = " << P1
1161 <<
"\t" <<
"LDA1="<<LDA1 <<
"\t" <<
"LDB1="<<LDB1 <<
"\t" <<
"LDC1=" << LDC1 << std::endl;
1162 std::cout <<
"M2="<<M2 <<
"\t" <<
"N2="<<N2 <<
"\t" <<
"P2 = " << P2
1163 <<
"\t" <<
"LDA2="<<LDA2 <<
"\t" <<
"LDB2="<<LDB2 <<
"\t" <<
"LDC2=" << LDC2 << std::endl;
1164 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1165 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1166 std::cout <<
"OType1beta = " << OType1beta << std::endl;
1167 std::cout <<
"OType2beta = " << OType2beta << std::endl;
1168 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_after_operation", matlab);
1169 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_after_operation", matlab);
1171 if (
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL)==0)
1172 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1173 GoodTestSubcount +=
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL);
1182 GoodTestCount += GoodTestSubcount;
1183 if(verbose || debug) std::cout <<
"GEMM: " << GoodTestSubcount <<
" of " << GEMMTESTS <<
" tests were successful." << std::endl;
1184 if(debug) std::cout << std::endl;
1192 GoodTestSubcount = 0;
1206 OType1A =
new SType[LDA1 * M1];
1207 OType2A =
new SType[LDA2 * M2];
1208 for(j1 = 0, j2 = 0; j1 < LDA1 * M1; j1++, j2++) {
1210 OType2A[j2] = OType1A[j1];
1215 OType1A =
new SType[LDA1 * N1];
1216 OType2A =
new SType[LDA2 * N2];
1217 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++) {
1219 OType2A[j2] = OType1A[j1];
1226 OType1B =
new SType[LDB1 * N1];
1227 OType2B =
new SType[LDB2 * N2];
1228 for(j1 = 0, j2 = 0; j1 < LDB1 * N1; j1++, j2++) {
1230 OType2B[j2] = OType1B[j1];
1236 OType1C =
new SType[LDC1 * N1];
1237 OType2C =
new SType[LDC2 * N2];
1238 for(j1 = 0, j2 = 0; j1 < LDC1 * N1; j1++, j2++) {
1240 OType2C[j2] = OType1C[j1];
1245 OType2alpha = OType1alpha;
1246 OType2beta = OType1beta;
1249 std::cout <<
"Test #" << TotalTestCount <<
" -- SYMM -- " << std::endl;
1252 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1253 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1254 std::cout <<
"OType1beta = " << OType1beta << std::endl;
1255 std::cout <<
"OType2beta = " << OType2beta << std::endl;
1257 PrintMatrix(OType1A, M1, M1, LDA1,
"OType1A", matlab);
1258 PrintMatrix(OType2A, M2, M2, LDA2,
"OType2A", matlab);
1260 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
1261 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
1263 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B", matlab);
1264 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_before_operation", matlab);
1265 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B", matlab);
1266 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_before_operation", matlab);
1270 OType1BLAS.
SYMM(SIDE, UPLO, M1, N1, OType1alpha, OType1A, LDA1, OType1B, LDB1, OType1beta, OType1C, LDC1);
1271 OType2BLAS.
SYMM(SIDE, UPLO, M2, N2, OType2alpha, OType2A, LDA2, OType2B, LDB2, OType2beta, OType2C, LDC2);
1274 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_after_operation", matlab);
1275 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_after_operation", matlab);
1277 if (
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL)==0)
1278 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1279 GoodTestSubcount +=
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL);
1288 GoodTestCount += GoodTestSubcount;
1289 if(verbose || debug) std::cout <<
"SYMM: " << GoodTestSubcount <<
" of " << SYMMTESTS <<
" tests were successful." << std::endl;
1290 if(debug) std::cout << std::endl;
1298 GoodTestSubcount = 0;
1309 #ifdef HAVE_TEUCHOS_COMPLEX
1317 OType1A =
new SType[LDA1 * K1];
1318 OType2A =
new SType[LDA2 * K2];
1319 for(j1 = 0, j2 = 0; j1 < LDA1 * K1; j1++, j2++) {
1321 OType2A[j2] = OType1A[j1];
1326 OType1A =
new SType[LDA1 * N1];
1327 OType2A =
new SType[LDA2 * N2];
1328 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++) {
1330 OType2A[j2] = OType1A[j1];
1337 OType1C =
new SType[LDC1 * N1];
1338 OType2C =
new SType[LDC2 * N2];
1339 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++) {
1344 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1349 OType1C[j1*LDC1+k1] = STypezero;
1351 OType2C[j2*LDC2+k2] = OType1C[j1*LDC1+k1];
1355 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1360 OType1C[j1*LDC1+k1] = STypezero;
1362 OType2C[j2*LDC2+k2] = OType1C[j1*LDC1+k1];
1369 OType2alpha = OType1alpha;
1370 OType2beta = OType1beta;
1373 std::cout <<
"Test #" << TotalTestCount <<
" -- SYRK -- " << std::endl;
1376 std::cout <<
"N1="<<N1 <<
"\t" <<
"K1 = " << K1
1377 <<
"\t" <<
"LDA1="<<LDA1 <<
"\t" <<
"LDC1=" << LDC1 << std::endl;
1378 std::cout <<
"N2="<<N2 <<
"\t" <<
"K2 = " << K2
1379 <<
"\t" <<
"LDA2="<<LDA2 <<
"\t" <<
"LDC2=" << LDC2 << std::endl;
1380 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1381 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1382 std::cout <<
"OType1beta = " << OType1beta << std::endl;
1383 std::cout <<
"OType2beta = " << OType2beta << std::endl;
1385 PrintMatrix(OType1A, N1, K1, LDA1,
"OType1A", matlab);
1386 PrintMatrix(OType2A, N2, K2, LDA2,
"OType2A", matlab);
1388 PrintMatrix(OType1A, K1, N1, LDA1,
"OType1A", matlab);
1389 PrintMatrix(OType2A, K2, N2, LDA2,
"OType2A", matlab);
1391 PrintMatrix(OType1C, N1, N1, LDC1,
"OType1C_before_operation", matlab);
1392 PrintMatrix(OType2C, N2, N2, LDC2,
"OType2C_before_operation", matlab);
1396 OType1BLAS.
SYRK(UPLO, TRANS, N1, K1, OType1alpha, OType1A, LDA1, OType1beta, OType1C, LDC1);
1397 OType2BLAS.
SYRK(UPLO, TRANS, N2, K2, OType2alpha, OType2A, LDA2, OType2beta, OType2C, LDC2);
1400 PrintMatrix(OType1C, N1, N1, LDC1,
"OType1C_after_operation", matlab);
1401 PrintMatrix(OType2C, N2, N2, LDC2,
"OType2C_after_operation", matlab);
1403 if (
CompareMatrices(OType1C, N1, N1, LDC1, OType2C, N2, N2, LDC2, TOL)==0)
1404 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1405 GoodTestSubcount +=
CompareMatrices(OType1C, N1, N1, LDC1, OType2C, N2, N2, LDC2, TOL);
1412 GoodTestCount += GoodTestSubcount;
1413 if(verbose || debug) std::cout <<
"SYRK: " << GoodTestSubcount <<
" of " << SYRKTESTS <<
" tests were successful." << std::endl;
1414 if(debug) std::cout << std::endl;
1422 GoodTestSubcount = 0;
1436 OType1B =
new SType[LDB1 * N1];
1437 OType2B =
new SType[LDB2 * N2];
1452 OType1A =
new SType[LDA1 * M1];
1453 OType2A =
new SType[LDA2 * M2];
1455 for(j1 = 0, j2 = 0; j1 < M1; j1++, j2++)
1460 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1465 OType1A[j1*LDA1+k1] = STypezero;
1467 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1471 while (OType1A[j1*LDA1+k1] == STypezero) {
1474 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1476 OType1A[j1*LDA1+k1] = STypeone;
1477 OType2A[j2*LDA2+k2] = STypeone;
1484 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1489 OType1A[j1*LDA1+k1] = STypezero;
1491 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1495 while (OType1A[j1*LDA1+k1] == STypezero) {
1498 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1500 OType1A[j1*LDA1+k1] = STypeone;
1501 OType2A[j2*LDA2+k2] = STypeone;
1516 OType1A =
new SType[LDA1 * N1];
1517 OType2A =
new SType[LDA2 * N2];
1519 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
1524 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1529 OType1A[j1*LDA1+k1] = STypezero;
1531 OType2A[j1*LDA1+k1] = OType1A[j1*LDA1+k1];
1535 while (OType1A[j1*LDA1+k1] == STypezero) {
1538 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1540 OType1A[j1*LDA1+k1] = STypeone;
1541 OType2A[j2*LDA2+k2] = STypeone;
1548 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1553 OType1A[j1*LDA1+k1] = STypezero;
1555 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1559 while (OType1A[j1*LDA1+k1] == STypezero) {
1562 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1564 OType1A[j1*LDA1+k1] = STypeone;
1565 OType2A[j2*LDA2+k2] = STypeone;
1574 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++) {
1575 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++) {
1577 OType2B[j2*LDB2+k2] = OType1B[j1*LDB1+k1];
1581 OType2alpha = OType1alpha;
1584 std::cout <<
"Test #" << TotalTestCount <<
" -- TRMM -- " << std::endl;
1589 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1590 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1592 PrintMatrix(OType1A, M1, M1, LDA1,
"OType1A", matlab);
1593 PrintMatrix(OType2A, M2, M2, LDA2,
"OType2A", matlab);
1595 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
1596 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
1598 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_before_operation", matlab);
1599 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_before_operation", matlab);
1602 OType1BLAS.
TRMM(SIDE, UPLO, TRANSA, DIAG, M1, N1, OType1alpha, OType1A, LDA1, OType1B, LDB1);
1603 OType2BLAS.
TRMM(SIDE, UPLO, TRANSA, DIAG, M2, N2, OType2alpha, OType2A, LDA2, OType2B, LDB2);
1606 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_after_operation", matlab);
1607 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_after_operation", matlab);
1609 if (
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL)==0)
1610 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1611 GoodTestSubcount +=
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL);
1617 GoodTestCount += GoodTestSubcount;
1618 if(verbose || debug) std::cout <<
"TRMM: " << GoodTestSubcount <<
" of " << TRMMTESTS <<
" tests were successful." << std::endl;
1619 if(debug) std::cout << std::endl;
1627 GoodTestSubcount = 0;
1641 OType1B =
new SType[LDB1 * N1];
1642 OType2B =
new SType[LDB2 * N2];
1660 OType1A =
new SType[LDA1 * M1];
1661 OType2A =
new SType[LDA2 * M2];
1663 for(j1 = 0, j2 = 0; j1 < M1; j1++, j2++)
1668 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1673 OType1A[j1*LDA1+k1] = STypezero;
1675 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1679 while (OType1A[j1*LDA1+k1] == STypezero) {
1682 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1684 OType1A[j1*LDA1+k1] = STypeone;
1685 OType2A[j2*LDA2+k2] = STypeone;
1692 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1697 OType1A[j1*LDA1+k1] = STypezero;
1699 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1703 while (OType1A[j1*LDA1+k1] == STypezero) {
1706 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1708 OType1A[j1*LDA1+k1] = STypeone;
1709 OType2A[j2*LDA2+k2] = STypeone;
1724 OType1A =
new SType[LDA1 * N1];
1725 OType2A =
new SType[LDA2 * N2];
1727 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
1732 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1737 OType1A[j1*LDA1+k1] = STypezero;
1739 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1743 while (OType1A[j1*LDA1+k1] == STypezero) {
1746 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1748 OType1A[j1*LDA1+k1] = STypeone;
1749 OType2A[j2*LDA2+k2] = STypeone;
1756 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1761 OType1A[j1*LDA1+k1] = STypezero;
1763 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1767 while (OType1A[j1*LDA1+k1] == STypezero) {
1770 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1772 OType1A[j1*LDA1+k1] = STypeone;
1773 OType2A[j2*LDA2+k2] = STypeone;
1782 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
1784 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1787 OType2B[j2*LDB2+k2] = OType1B[j1*LDB1+k1];
1792 OType2alpha = OType1alpha;
1796 std::cout <<
"Test #" << TotalTestCount <<
" -- TRSM -- " << std::endl;
1801 std::cout <<
"M1="<<M1 <<
"\t" <<
"N1="<<N1 <<
"\t" <<
"LDA1="<<LDA1 <<
"\t" <<
"LDB1="<<LDB1 << std::endl;
1802 std::cout <<
"M2="<<M2 <<
"\t" <<
"N2="<<N2 <<
"\t" <<
"LDA2="<<LDA2 <<
"\t" <<
"LDB2="<<LDB2 << std::endl;
1803 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1804 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1806 PrintMatrix(OType1A, M1, M1, LDA1,
"OType1A", matlab);
1807 PrintMatrix(OType2A, M2, M2, LDA2,
"OType2A", matlab);
1809 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
1810 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
1812 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_before_operation", matlab);
1813 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_before_operation", matlab);
1817 OType1BLAS.
TRSM(SIDE, UPLO, TRANSA, DIAG, M1, N1, OType1alpha, OType1A, LDA1, OType1B, LDB1);
1818 OType2BLAS.
TRSM(SIDE, UPLO, TRANSA, DIAG, M2, N2, OType2alpha, OType2A, LDA2, OType2B, LDB2);
1822 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_after_operation", matlab);
1823 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_after_operation", matlab);
1826 if (
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL)==0)
1827 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1828 GoodTestSubcount +=
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL);
1835 GoodTestCount += GoodTestSubcount;
1836 if(verbose || debug) std::cout <<
"TRSM: " << GoodTestSubcount <<
" of " << TRSMTESTS <<
" tests were successful." << std::endl;
1837 if(debug) std::cout << std::endl;
1842 if((((TotalTestCount - 1) - GoodTestCount) != 0) || (verbose) || (debug))
1844 std::cout << GoodTestCount <<
" of " << (TotalTestCount - 1) <<
" total tests were successful." << std::endl;
1847 if ((TotalTestCount-1) == GoodTestCount) {
1848 std::cout <<
"End Result: TEST PASSED" << std::endl;
1852 std::cout <<
"End Result: TEST FAILED" << std::endl;
1853 return (TotalTestCount-GoodTestCount-1);
1856 template<
typename TYPE>
1862 template<
typename T>
1863 std::complex<T>
GetRandom( std::complex<T> Low, std::complex<T> High)
1865 T lowMag = Low.real();
1866 T highMag = High.real();
1869 return std::complex<T>( real, imag );
1879 double GetRandom(
double Low,
double High)
1884 template<
typename TYPE,
typename OTYPE>
1887 std::cout << Name <<
" =" << std::endl;
1889 if(Matlab) std::cout <<
"[";
1890 for(i = 0; i < Size; i++)
1892 std::cout << Vector[i] <<
" ";
1894 if(Matlab) std::cout <<
"]";
1897 std::cout << std::endl << std::endl;
1901 std::cout <<
";" << std::endl;
1905 template<
typename TYPE,
typename OTYPE>
1910 std::cout << Name <<
" =" << std::endl;
1912 for(i = 0; i < Rows; i++)
1914 for(j = 0; j < Columns; j++)
1916 std::cout << Matrix[i + (j * LDM)] <<
" ";
1918 std::cout << std::endl;
1920 std::cout << std::endl;
1924 std::cout << Name <<
" = ";
1927 for(i = 0; i < Rows; i++)
1930 for(j = 0; j < Columns; j++)
1932 std::cout << Matrix[i + (j * LDM)] <<
" ";
1936 std::cout <<
"];" << std::endl;
1940 template<
typename TYPE>
1948 return( temp2 < Tolerance );
1955 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
1965 for(i1 = 0, i2 = 0; i1 < Size1; i1++, i2++)
1968 temp = Vector1[i1] - Vector2[i2];
1976 if (temp3 > Tolerance )
1985 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
1987 TYPE* Matrix2, OTYPE2 Rows2, OTYPE2 Columns2, OTYPE2 LDM2,
1997 for(j1 = 0, j2 = 0; j1 < Columns1; j1++, j2++)
1999 for(i1 = 0, i2 = 0; i1 < Rows1; i1++, i2++)
2002 temp = Matrix1[j1*LDM1 + i1] - Matrix2[j2*LDM2 + i2];
2011 if (temp3 > Tolerance)
2052 if(r == 1 || r == 2)
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, ScalarType *B, const OrdinalType &ldb) const
Solves the matrix equations: op(A)*X=alpha*B or X*op(A)=alpha*B where X and B are m by n matrices...
void GER(const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const x_type *x, const OrdinalType &incx, const y_type *y, const OrdinalType &incy, ScalarType *A, const OrdinalType &lda) const
Performs the rank 1 operation: A <- alpha*x*y'+A.
void AXPY(const OrdinalType &n, const alpha_type alpha, const x_type *x, const OrdinalType &incx, ScalarType *y, const OrdinalType &incy) const
Perform the operation: y <- y+alpha*x.
void TRMV(EUplo uplo, ETransp trans, EDiag diag, const OrdinalType &n, const A_type *A, const OrdinalType &lda, ScalarType *x, const OrdinalType &incx) const
Performs the matrix-vector operation: x <- A*x or x <- A'*x where A is a unit/non-unit n by n upper/low...
Templated interface class to BLAS routines.
void GEMV(ETransp trans, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const x_type *x, const OrdinalType &incx, const beta_type beta, ScalarType *y, const OrdinalType &incy) const
Performs the matrix-vector operation: y <- alpha*A*x+beta*y or y <- alpha*A'*x+beta*y where A is a gene...
void ROT(const OrdinalType &n, ScalarType *dx, const OrdinalType &incx, ScalarType *dy, const OrdinalType &incy, MagnitudeType *c, ScalarType *s) const
Applies a Givens plane rotation.
Basic wall-clock timer class.
ScalarTraits< ScalarType >::magnitudeType NRM2(const OrdinalType &n, const ScalarType *x, const OrdinalType &incx) const
Compute the 2-norm of the vector x.
OrdinalType IAMAX(const OrdinalType &n, const ScalarType *x, const OrdinalType &incx) const
Return the index of the element of x with the maximum magnitude.
void GEMM(ETransp transa, ETransp transb, const OrdinalType &m, const OrdinalType &n, const OrdinalType &k, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const B_type *B, const OrdinalType &ldb, const beta_type beta, ScalarType *C, const OrdinalType &ldc) const
General matrix-matrix multiply.
void PrintMatrix(TYPE *Matrix, OType Rows, OType Columns, OType LDM, std::string Name, bool Matlab=0)
Initialize, finalize, and query the global MPI session.
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char EDiagChar[]
This structure defines some basic traits for a scalar field type.
ScalarTraits< ScalarType >::magnitudeType ASUM(const OrdinalType &n, const ScalarType *x, const OrdinalType &incx) const
Sum the absolute values of the entries of x.
Teuchos::EUplo RandomUPLO()
void COPY(const OrdinalType &n, const ScalarType *x, const OrdinalType &incx, ScalarType *y, const OrdinalType &incy) const
Copy the vector x to the vector y.
TYPE GetRandom(TYPE, TYPE)
Teuchos::ESide RandomSIDE()
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char EUploChar[]
Teuchos::EDiag RandomDIAG()
ScalarType DOT(const OrdinalType &n, const x_type *x, const OrdinalType &incx, const y_type *y, const OrdinalType &incy) const
Form the dot product of the vectors x and y.
bool CompareVectors(TYPE1 *Vector1, TYPE2 *Vector2, OType Size, TYPE2 Tolerance)
bool CompareScalars(TYPE1 Scalar1, TYPE2 Scalar2, TYPE2 Tolerance)
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ESideChar[]
std::string Teuchos_Version()
void PrintVector(TYPE *Vector, OType Size, std::string Name, bool Matlab=0)
int main(int argc, char *argv[])
bool CompareMatrices(TYPE1 *Matrix1, TYPE2 *Matrix2, OType Rows, OType Columns, OType LDM, TYPE2 Tolerance)
TYPE2 ConvertType(TYPE1, TYPE2)
void SYMM(ESide side, EUplo uplo, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const B_type *B, const OrdinalType &ldb, const beta_type beta, ScalarType *C, const OrdinalType &ldc) const
Performs the matrix-matrix operation: C <- alpha*A*B+beta*C or C <- alpha*B*A+beta*C where A is an m ...
void TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, ScalarType *B, const OrdinalType &ldb) const
Performs the matrix-matrix operation: B <- alpha*op(A)*B or B <- alpha*B*op(A) where op(A) is an unit...
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
void SCAL(const OrdinalType &n, const ScalarType &alpha, ScalarType *x, const OrdinalType &incx) const
Scale the vector x by the constant alpha.
void ROTG(ScalarType *da, ScalarType *db, rotg_c_type *c, ScalarType *s) const
Computes a Givens plane rotation.
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ETranspChar[]
void SYRK(EUplo uplo, ETransp trans, const OrdinalType &n, const OrdinalType &k, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const beta_type beta, ScalarType *C, const OrdinalType &ldc) const
Performs the symmetric rank k operation: C <- alpha*A*A'+beta*C or C <- alpha*A'*A+beta*C, where alpha and beta are scalars, C is an n by n symmetric matrix and A is an n by k matrix in the first case or k by n matrix in the second case.
Teuchos::ETransp RandomTRANS()
static std::string name()