66 #ifdef HAVE_TEUCHOS_COMPLEX 67 #define SType std::complex<double> 73 #define OType1 long int 84 #ifdef HAVE_TEUCHOS_COMPLEX 85 #define SCALARMAX SType(10,0) 87 #define SCALARMAX SType(10) 109 template<
typename TYPE>
121 std::complex<T>
GetRandom( std::complex<T>, std::complex<T> );
123 template<
typename TYPE,
typename OTYPE>
124 void PrintVector(TYPE* Vector,
OTYPE Size, std::string Name,
bool Matlab = 0);
126 template<
typename TYPE,
typename OTYPE>
129 template<
typename TYPE>
132 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
135 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
136 bool CompareMatrices(TYPE* Matrix1, OTYPE1 Rows1, OTYPE1 Columns1, OTYPE1 LDM1,
137 TYPE* Matrix2, OTYPE2 Rows2, OTYPE2 Columns2, OTYPE2 LDM2,
141 template<
typename OTYPE1,
typename OTYPE2>
144 return static_cast<OTYPE2
>(T1);
153 int main(
int argc,
char *argv[])
159 bool InvalidCmdLineArgs = 0;
163 for(i = 1; i < argc; i++)
165 if(argv[i][0] ==
'-')
176 InvalidCmdLineArgs = 1;
186 InvalidCmdLineArgs = 1;
196 InvalidCmdLineArgs = 1;
200 InvalidCmdLineArgs = 1;
209 if(InvalidCmdLineArgs || (argc > 4))
211 std::cout <<
"Invalid command line arguments detected. Use the following flags:" << std::endl
212 <<
"\t -v enables verbose mode (reports number of failed/successful tests)" << std::endl
213 <<
"\t -d enables debug mode (same as verbose with output of each test, not recommended for large numbers of tests)" << std::endl
214 <<
"\t -m enables matlab-style output; only has an effect if debug mode is enabled" << std::endl;
222 SType OType1alpha, OType1beta;
223 SType OType2alpha, OType2beta;
224 SType *OType1A, *OType1B, *OType1C, *OType1x, *OType1y;
225 SType *OType2A, *OType2B, *OType2C, *OType2x, *OType2y;
226 SType OType1ASUMresult, OType1DOTresult, OType1NRM2result, OType1SINresult;
227 SType OType2ASUMresult, OType2DOTresult, OType2NRM2result, OType2SINresult;
228 MType OType1COSresult, OType2COSresult;
233 OType1 TotalTestCount = 1, GoodTestSubcount, GoodTestCount = 0, M1, N1, P1, K1, LDA1, LDB1, LDC1, Mx1, My1;
234 OType2 M2, N2, P2, K2, LDA2, LDB2, LDC2, Mx2, My2;
241 std::srand(time(NULL));
248 GoodTestSubcount = 0;
252 OType2alpha = OType1alpha;
254 OType2beta = OType1beta;
256 OType2COSresult = OType1COSresult;
258 OType2SINresult = OType1SINresult;
262 std::cout <<
"Test #" << TotalTestCount <<
" -- ROTG -- " << std::endl;
263 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
264 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
265 std::cout <<
"OType1beta = " << OType1beta << std::endl;
266 std::cout <<
"OType2beta = " << OType2beta << std::endl;
269 OType1BLAS.
ROTG(&OType1alpha, &OType1beta, &OType1COSresult, &OType1SINresult);
270 OType2BLAS.
ROTG(&OType2alpha, &OType2beta, &OType2COSresult, &OType2SINresult);
273 std::cout <<
"OType1 ROTG COS result: " << OType1COSresult << std::endl;
274 std::cout <<
"OType2 ROTG COS result: " << OType2COSresult << std::endl;
275 std::cout <<
"OType1 ROTG SIN result: " << OType1SINresult << std::endl;
276 std::cout <<
"OType2 ROTG SIN result: " << OType2SINresult << std::endl;
279 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
280 GoodTestSubcount += (
CompareScalars(OType1COSresult, OType2COSresult, TOL) &&
283 GoodTestCount += GoodTestSubcount;
284 if(verbose || debug) std::cout <<
"ROTG: " << GoodTestSubcount <<
" of " << ROTGTESTS <<
" tests were successful." << std::endl;
285 if(debug) std::cout << std::endl;
293 GoodTestSubcount = 0;
298 if (incx1 == 0) incx1 = 1;
299 if (incy1 == 0) incy1 = 1;
304 Mx1 = M1*std::abs(incx1);
305 My1 = M1*std::abs(incy1);
306 if (Mx1 == 0) { Mx1 = 1; }
307 if (My1 == 0) { My1 = 1; }
310 OType1x =
new SType[Mx1];
311 OType1y =
new SType[My1];
312 OType2x =
new SType[Mx2];
313 OType2y =
new SType[My2];
314 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
317 OType2x[j2] = OType1x[j1];
319 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
322 OType2y[j2] = OType1y[j1];
330 std::cout <<
"Test #" << TotalTestCount <<
" -- ROT -- " << std::endl;
331 std::cout <<
"c1 = " << c1 <<
", s1 = " << s1 << std::endl;
332 std::cout <<
"c2 = " << c2 <<
", s2 = " << s2 << std::endl;
333 std::cout <<
"incx1 = " << incx1 <<
", incy1 = " << incy1 << std::endl;
334 std::cout <<
"incx2 = " << incx2 <<
", incy2 = " << incy2 << std::endl;
336 PrintVector(OType1y, My1,
"OType1y_before_operation", matlab);
338 PrintVector(OType2y, My2,
"OType2y_before_operation", matlab);
341 OType1BLAS.
ROT(M1, OType1x, incx1, OType1y, incy1, &c1, &s1);
342 OType2BLAS.
ROT(M2, OType2x, incx2, OType2y, incy2, &c2, &s2);
345 PrintVector(OType1y, My1,
"OType1y_after_operation", matlab);
346 PrintVector(OType2y, My2,
"OType2y_after_operation", matlab);
349 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
350 GoodTestSubcount += (
CompareVectors(OType1x, Mx1, OType2x, Mx2, TOL) &&
357 GoodTestCount += GoodTestSubcount;
358 if(verbose || debug) std::cout <<
"ROT: " << GoodTestSubcount <<
" of " << ROTTESTS <<
" tests were successful." << std::endl;
359 if(debug) std::cout << std::endl;
367 GoodTestSubcount = 0;
375 OType1x =
new SType[M1*incx1];
376 OType2x =
new SType[M2*incx2];
377 for(j1 = 0, j2 = 0; j2 < M2*incx2; j1++, j2++)
380 OType2x[j2] = OType1x[j1];
384 std::cout <<
"Test #" << TotalTestCount <<
" -- ASUM -- " << std::endl;
385 std::cout <<
"incx1 = " << incx1 <<
"\t" <<
"incx2 = " << incx2
386 <<
"\t" <<
"M1 = " << M1 <<
"\t" <<
"M2 = " << M2 << std::endl;
391 OType1ASUMresult = OType1BLAS.
ASUM(M1, OType1x, incx1);
392 OType2ASUMresult = OType2BLAS.
ASUM(M2, OType2x, incx2);
395 std::cout <<
"OType1 ASUM result: " << OType1ASUMresult << std::endl;
396 std::cout <<
"OType2 ASUM result: " << OType2ASUMresult << std::endl;
399 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
400 GoodTestSubcount +=
CompareScalars(OType1ASUMresult, OType2ASUMresult, TOL);
405 GoodTestCount += GoodTestSubcount;
406 if(verbose || debug) std::cout <<
"ASUM: " << GoodTestSubcount <<
" of " << ASUMTESTS <<
" tests were successful." << std::endl;
407 if(debug) std::cout << std::endl;
416 GoodTestSubcount = 0;
425 Mx1 = M1*std::abs(incx1);
426 My1 = M1*std::abs(incy1);
427 if (Mx1 == 0) { Mx1 = 1; }
428 if (My1 == 0) { My1 = 1; }
431 OType1x =
new SType[Mx1];
432 OType1y =
new SType[My1];
433 OType2x =
new SType[Mx2];
434 OType2y =
new SType[My2];
435 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
438 OType2x[j2] = OType1x[j1];
440 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
443 OType2y[j2] = OType1y[j1];
446 OType2alpha = OType1alpha;
449 std::cout <<
"Test #" << TotalTestCount <<
" -- AXPY -- " << std::endl;
450 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
451 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
453 PrintVector(OType1y, My1,
"OType1y_before_operation", matlab);
455 PrintVector(OType2y, My2,
"OType2y_before_operation", matlab);
458 OType1BLAS.
AXPY(M1, OType1alpha, OType1x, incx1, OType1y, incy1);
459 OType2BLAS.
AXPY(M2, OType2alpha, OType2x, incx2, OType2y, incy2);
462 PrintVector(OType1y, My1,
"OType1y_after_operation", matlab);
463 PrintVector(OType2y, My2,
"OType2y_after_operation", matlab);
466 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
467 GoodTestSubcount +=
CompareVectors(OType1y, My1, OType2y, My2, TOL);
474 GoodTestCount += GoodTestSubcount;
475 if(verbose || debug) std::cout <<
"AXPY: " << GoodTestSubcount <<
" of " << AXPYTESTS <<
" tests were successful." << std::endl;
476 if(debug) std::cout << std::endl;
484 GoodTestSubcount = 0;
493 Mx1 = M1*std::abs(incx1);
494 My1 = M1*std::abs(incy1);
495 if (Mx1 == 0) { Mx1 = 1; }
496 if (My1 == 0) { My1 = 1; }
499 OType1x =
new SType[Mx1];
500 OType1y =
new SType[My1];
501 OType2x =
new SType[Mx2];
502 OType2y =
new SType[My2];
503 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
506 OType2x[j2] = OType1x[j1];
508 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
511 OType2y[j2] = OType1y[j1];
515 std::cout <<
"Test #" << TotalTestCount <<
" -- COPY -- " << std::endl;
517 PrintVector(OType1y, My1,
"OType1y_before_operation", matlab);
519 PrintVector(OType2y, My2,
"OType2y_before_operation", matlab);
522 OType1BLAS.
COPY(M1, OType1x, incx1, OType1y, incy1);
523 OType2BLAS.
COPY(M2, OType2x, incx2, OType2y, incy2);
526 PrintVector(OType1y, My1,
"OType1y_after_operation", matlab);
527 PrintVector(OType2y, My2,
"OType2y_after_operation", matlab);
530 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
531 GoodTestSubcount +=
CompareVectors(OType1y, My1, OType2y, My2, TOL);
538 GoodTestCount += GoodTestSubcount;
if(verbose || debug) std::cout <<
"COPY: " << GoodTestSubcount <<
" of " << COPYTESTS <<
" tests were successful." << std::endl;
539 if(debug) std::cout << std::endl;
547 GoodTestSubcount = 0;
556 Mx1 = M1*std::abs(incx1);
557 My1 = M1*std::abs(incy1);
558 if (Mx1 == 0) { Mx1 = 1; }
559 if (My1 == 0) { My1 = 1; }
562 OType1x =
new SType[Mx1];
563 OType1y =
new SType[My1];
564 OType2x =
new SType[Mx2];
565 OType2y =
new SType[My2];
566 for(j1 = 0, j2 = 0; j1 < Mx1; j1++, j2++)
569 OType2x[j2] = OType1x[j1];
571 for(j1 = 0, j2 = 0; j1 < My1; j1++, j2++)
574 OType2y[j2] = OType1y[j1];
578 std::cout <<
"Test #" << TotalTestCount <<
" -- DOT -- " << std::endl;
585 OType1DOTresult = OType1BLAS.
DOT(M1, OType1x, incx1, OType1y, incy1);
586 OType2DOTresult = OType2BLAS.
DOT(M2, OType2x, incx2, OType2y, incy2);
589 std::cout <<
"OType1 DOT result: " << OType1DOTresult << std::endl;
590 std::cout <<
"OType2 DOT result: " << OType2DOTresult << std::endl;
593 std::cout <<
"DOT test " << i+1 <<
" of " << DOTTESTS <<
" FAILED! " 595 <<
"The two results are " << OType1DOTresult <<
" and " 596 << OType2DOTresult <<
". incx1 = " << incx1 <<
", incy1 = " 597 << incy1 <<
", incx2 = " << incx2 <<
", and incy2 = " 598 << incy2 << std::endl;
601 GoodTestSubcount +=
CompareScalars(OType1DOTresult, OType2DOTresult, TOL);
608 GoodTestCount += GoodTestSubcount;
609 if(verbose || debug) std::cout <<
"DOT: " << GoodTestSubcount <<
" of " << DOTTESTS <<
" tests were successful." << std::endl;
610 if(debug) std::cout << std::endl;
618 GoodTestSubcount = 0;
625 OType1x =
new SType[M1*incx1];
626 OType2x =
new SType[M2*incx2];
627 for(j1 = 0, j2 = 0; j1 < M1*incx1; j1++, j2++)
630 OType2x[j2] = OType1x[j1];
634 std::cout <<
"Test #" << TotalTestCount <<
" -- NRM2 -- " << std::endl;
639 OType1NRM2result = OType1BLAS.
NRM2(M1, OType1x, incx1);
640 OType2NRM2result = OType2BLAS.
NRM2(M2, OType2x, incx2);
643 std::cout <<
"OType1 NRM2 result: " << OType1NRM2result << std::endl;
644 std::cout <<
"OType2 NRM2 result: " << OType2NRM2result << std::endl;
647 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
648 GoodTestSubcount +=
CompareScalars(OType1NRM2result, OType2NRM2result, TOL);
653 GoodTestCount += GoodTestSubcount;
if(verbose || debug) std::cout <<
"NRM2: " << GoodTestSubcount <<
" of " << NRM2TESTS <<
" tests were successful." << std::endl;
654 if(debug) std::cout << std::endl;
662 GoodTestSubcount = 0;
672 OType1x =
new SType[M1*incx1];
673 OType2x =
new SType[M2*incx2];
674 for(j1 = 0, j2 = 0; j1 < M1*incx1; j1++, j2++)
677 OType2x[j2] = OType1x[j1];
680 OType2alpha = OType1alpha;
683 std::cout <<
"Test #" << TotalTestCount <<
" -- SCAL -- " << std::endl;
684 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
685 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
686 PrintVector(OType1x, M1*incx1,
"OType1x_before_operation", matlab);
687 PrintVector(OType2x, M2*incx2,
"OType2x_before_operation", matlab);
690 OType1BLAS.
SCAL(M1, OType1alpha, OType1x, incx1);
691 OType2BLAS.
SCAL(M2, OType2alpha, OType2x, incx2);
694 PrintVector(OType1x, M1*incx1,
"OType1x_after_operation", matlab);
695 PrintVector(OType2x, M2*incx2,
"OType2x_after_operation", matlab);
698 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
699 GoodTestSubcount +=
CompareVectors(OType1x, M1*incx1, OType2x, M2*incx2, TOL);
704 GoodTestCount += GoodTestSubcount;
705 if(verbose || debug) std::cout <<
"SCAL: " << GoodTestSubcount <<
" of " << SCALTESTS <<
" tests were successful." << std::endl;
706 if(debug) std::cout << std::endl;
714 GoodTestSubcount = 0;
721 OType1x =
new SType[M1*incx1];
722 OType2x =
new SType[M2*incx2];
723 for(j1 = 0, j2 = 0; j1 < M1*incx1; j1++, j2++)
726 OType2x[j2] = OType1x[j1];
730 std::cout <<
"Test #" << TotalTestCount <<
" -- IAMAX -- " << std::endl;
735 OType1IAMAXresult = OType1BLAS.
IAMAX(M1, OType1x, incx1);
736 OType2IAMAXresult = OType2BLAS.
IAMAX(M2, OType2x, incx2);
739 std::cout <<
"OType1 IAMAX result: " << OType1IAMAXresult << std::endl;
740 std::cout <<
"OType2 IAMAX result: " << OType2IAMAXresult << std::endl;
742 if (OType1IAMAXresult != OType2IAMAXresult)
743 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
744 GoodTestSubcount += (OType1IAMAXresult == OType2IAMAXresult);
749 GoodTestCount += GoodTestSubcount;
750 if(verbose || debug) std::cout <<
"IAMAX: " << GoodTestSubcount <<
" of " << IAMAXTESTS <<
" tests were successful." << std::endl;
751 if(debug) std::cout << std::endl;
761 GoodTestSubcount = 0;
782 OType1 M2_1 = 0, N2_1 = 0;
784 M2_1 = M1*std::abs(incy1);
785 N2_1 = N1*std::abs(incx1);
787 M2_1 = N1*std::abs(incy1);
788 N2_1 = M1*std::abs(incx1);
801 OType2alpha = OType1alpha;
802 OType2beta = OType1beta;
804 OType1A =
new SType[LDA1 * N1];
805 OType1x =
new SType[N2_1];
806 OType1y =
new SType[M2_1];
807 OType2A =
new SType[LDA2 * N2];
808 OType2x =
new SType[N2_2];
809 OType2y =
new SType[M2_2];
811 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++)
814 OType2A[j2] = OType1A[j1];
816 for(j1 = 0, j2 = 0; j1 < N2_1; j1++, j2++)
819 OType2x[j2] = OType1x[j1];
821 for(j1 = 0, j2 = 0; j1 < M2_1; j1++, j2++)
824 OType2y[j2] = OType1y[j1];
828 std::cout <<
"Test #" << TotalTestCount <<
" -- GEMV -- " << std::endl;
830 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
831 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
832 std::cout <<
"OType1beta = " << OType1beta << std::endl;
833 std::cout <<
"OType2beta = " << OType2beta << std::endl;
834 PrintMatrix(OType1A, M1, N1, LDA1,
"OType1A", matlab);
836 PrintVector(OType1y, M2_1,
"OType1y_before_operation", matlab);
837 PrintMatrix(OType2A, M2, N2, LDA2,
"OType2A", matlab);
839 PrintVector(OType2y, M2_2,
"OType2y_before_operation", matlab);
842 OType1BLAS.
GEMV(TRANS, M1, N1, OType1alpha, OType1A, LDA1, OType1x, incx1, OType1beta, OType1y, incy1);
843 OType2BLAS.
GEMV(TRANS, M2, N2, OType2alpha, OType2A, LDA2, OType2x, incx2, OType2beta, OType2y, incy2);
846 PrintVector(OType1y, M2_1,
"OType1y_after_operation", matlab);
847 PrintVector(OType2y, M2_2,
"OType2y_after_operation", matlab);
850 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
851 GoodTestSubcount +=
CompareVectors(OType1y, M2_1, OType2y, M2_2, TOL);
860 GoodTestCount += GoodTestSubcount;
861 if(verbose || debug) std::cout <<
"GEMV: " << GoodTestSubcount <<
" of " << GEMVTESTS <<
" tests were successful." << std::endl;
862 if(debug) std::cout << std::endl;
870 GoodTestSubcount = 0;
888 OType1x =
new SType[N1*std::abs(incx1)];
889 OType2x =
new SType[N2*std::abs(incx2)];
891 for(j1 = 0, j2 = 0; j1 < N1*std::abs(incx1); j1++, j2++)
894 OType2x[j2] = OType1x[j1];
902 OType1A =
new SType[LDA1 * N1];
903 OType2A =
new SType[LDA2 * N2];
905 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
910 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
915 OType1A[j1*LDA1+k1] = STypezero;
917 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
921 while (OType1A[j1*LDA1+k1] == STypezero) {
924 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
926 OType1A[j1*LDA1+k1] = STypeone;
927 OType2A[j2*LDA2+k2] = STypeone;
934 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
939 OType1A[j1*LDA1+k1] = STypezero;
941 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
945 while (OType1A[j1*LDA1+k1] == STypezero) {
948 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
950 OType1A[j1*LDA1+k1] = STypeone;
951 OType2A[j2*LDA2+k2] = STypeone;
960 std::cout <<
"Test #" << TotalTestCount <<
" -- TRMV -- " << std::endl;
964 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
965 PrintVector(OType1x, N1*incx1,
"OType1x_before_operation", matlab);
966 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
967 PrintVector(OType2x, N2*incx2,
"OType2x_before_operation", matlab);
970 OType1BLAS.
TRMV(UPLO, TRANSA, DIAG, N1, OType1A, LDA1, OType1x, incx1);
971 OType2BLAS.
TRMV(UPLO, TRANSA, DIAG, N2, OType2A, LDA2, OType2x, incx2);
974 PrintVector(OType1x, N1*incx1,
"OType1x_after_operation", matlab);
975 PrintVector(OType2x, N2*incx2,
"OType2x_after_operation", matlab);
977 if (
CompareVectors(OType1x, std::abs(N1*incx1), OType2x, std::abs(N2*incx2), TOL)==0)
978 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
979 GoodTestSubcount +=
CompareVectors(OType1x, std::abs(N1*incx1), OType2x, std::abs(N2*incx2), TOL);
986 GoodTestCount += GoodTestSubcount;
987 if(verbose || debug) std::cout <<
"TRMV: " << GoodTestSubcount <<
" of " << TRMVTESTS <<
" tests were successful." << std::endl;
988 if(debug) std::cout << std::endl;
996 GoodTestSubcount = 0;
1000 while (incx1 == 0) {
1004 while (incy1 == 0) {
1020 OType1A =
new SType[LDA1 * N1];
1021 OType1x =
new SType[M1*std::abs(incx1)];
1022 OType1y =
new SType[N1*std::abs(incy1)];
1023 OType2A =
new SType[LDA2 * N2];
1024 OType2x =
new SType[M2*std::abs(incx2)];
1025 OType2y =
new SType[N2*std::abs(incy2)];
1027 OType2alpha = OType1alpha;
1028 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++)
1031 OType2A[j2] = OType1A[j1];
1033 for(j1 = 0, j2 = 0; j1 < std::abs(M1*incx1); j1++, j2++)
1036 OType2x[j2] = OType1x[j1];
1038 for(j1 = 0, j2 = 0; j1 < std::abs(N1*incy1); j1++, j2++)
1041 OType2y[j2] = OType1y[j1];
1045 std::cout <<
"Test #" << TotalTestCount <<
" -- GER -- " << std::endl;
1046 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1047 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1048 PrintMatrix(OType1A, M1, N1, LDA1,
"OType1A_before_operation", matlab);
1049 PrintVector(OType1x, std::abs(M1*incx1),
"OType1x", matlab);
1050 PrintVector(OType1y, std::abs(N1*incy1),
"OType1y", matlab);
1051 PrintMatrix(OType2A, M2, N2, LDA2,
"OType2A_before_operation", matlab);
1052 PrintVector(OType2x, std::abs(M2*incx2),
"OType2x", matlab);
1053 PrintVector(OType2y, std::abs(N2*incy2),
"OType2y", matlab);
1056 OType1BLAS.
GER(M1, N1, OType1alpha, OType1x, incx1, OType1y, incy1, OType1A, LDA1);
1057 OType2BLAS.
GER(M2, N2, OType2alpha, OType2x, incx2, OType2y, incy2, OType2A, LDA2);
1060 PrintMatrix(OType1A, M1, N1, LDA1,
"OType1A_after_operation", matlab);
1061 PrintMatrix(OType2A, M2, N2, LDA2,
"OType2A_after_operation", matlab);
1063 if (
CompareMatrices(OType1A, M1, N1, LDA1, OType2A, M2, N2, LDA2, TOL)==0)
1064 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1065 GoodTestSubcount +=
CompareMatrices(OType1A, M1, N1, LDA1, OType2A, M2, N2, LDA2, TOL);
1074 GoodTestCount += GoodTestSubcount;
1075 if(verbose || debug) std::cout <<
"GER: " << GoodTestSubcount <<
" of " << GERTESTS <<
" tests were successful." << std::endl;
1076 if(debug) std::cout << std::endl;
1086 GoodTestSubcount = 0;
1099 std::cout <<
"Test #" << TotalTestCount <<
" -- GEMM -- " << std::endl;
1107 OType1A =
new SType[LDA1 * P1];
1108 OType2A =
new SType[LDA2 * P2];
1109 for(j1 = 0, j2 = 0; j1 < LDA1 * P1; j1++, j2++)
1112 OType2A[j2] = OType1A[j1];
1115 PrintMatrix(OType1A, M1, P1, LDA1,
"OType1A", matlab);
1116 PrintMatrix(OType2A, M2, P2, LDA2,
"OType2A", matlab);
1121 OType1A =
new SType[LDA1 * M1];
1122 OType2A =
new SType[LDA1 * M1];
1123 for(j1 = 0, j2 = 0; j1 < LDA1 * M1; j1++, j2++)
1126 OType2A[j2] = OType1A[j1];
1129 PrintMatrix(OType1A, P1, M1, LDA1,
"OType1A", matlab);
1130 PrintMatrix(OType2A, P2, M2, LDA2,
"OType2A", matlab);
1138 OType1B =
new SType[LDB1 * N1];
1139 OType2B =
new SType[LDB2 * N2];
1140 for(j1 = 0, j2 = 0; j1 < LDB1 * N1; j1++, j2++)
1143 OType2B[j2] = OType1B[j1];
1146 PrintMatrix(OType1B, P1, N1, LDB1,
"OType1B", matlab);
1147 PrintMatrix(OType2B, P2, N2, LDB2,
"OType2B", matlab);
1152 OType1B =
new SType[LDB1 * P1];
1153 OType2B =
new SType[LDB2 * P2];
1154 for(j1 = 0, j2 = 0; j1 < LDB1 * P1; j1++, j2++)
1157 OType2B[j2] = OType1B[j1];
1160 PrintMatrix(OType1B, N1, P1, LDB1,
"OType1B", matlab);
1161 PrintMatrix(OType2B, N2, P2, LDB2,
"OType2B", matlab);
1168 OType1C =
new SType[LDC1 * N1];
1169 OType2C =
new SType[LDC2 * N2];
1170 for(j1 = 0, j2 = 0; j1 < LDC1 * N1; j1++, j2++) {
1172 OType2C[j2] = OType1C[j1];
1176 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_before_operation", matlab);
1177 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_before_operation", matlab);
1182 OType2alpha = OType1alpha;
1183 OType2beta = OType1beta;
1186 OType1BLAS.
GEMM(TRANSA, TRANSB, M1, N1, P1, OType1alpha, OType1A, LDA1, OType1B, LDB1, OType1beta, OType1C, LDC1);
1187 OType2BLAS.
GEMM(TRANSA, TRANSB, M2, N2, P2, OType2alpha, OType2A, LDA2, OType2B, LDB2, OType2beta, OType2C, LDC2);
1190 std::cout <<
"M1="<<M1 <<
"\t" <<
"N1="<<N1 <<
"\t" <<
"P1 = " << P1
1191 <<
"\t" <<
"LDA1="<<LDA1 <<
"\t" <<
"LDB1="<<LDB1 <<
"\t" <<
"LDC1=" << LDC1 << std::endl;
1192 std::cout <<
"M2="<<M2 <<
"\t" <<
"N2="<<N2 <<
"\t" <<
"P2 = " << P2
1193 <<
"\t" <<
"LDA2="<<LDA2 <<
"\t" <<
"LDB2="<<LDB2 <<
"\t" <<
"LDC2=" << LDC2 << std::endl;
1194 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1195 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1196 std::cout <<
"OType1beta = " << OType1beta << std::endl;
1197 std::cout <<
"OType2beta = " << OType2beta << std::endl;
1198 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_after_operation", matlab);
1199 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_after_operation", matlab);
1201 if (
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL)==0)
1202 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1203 GoodTestSubcount +=
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL);
1212 GoodTestCount += GoodTestSubcount;
1213 if(verbose || debug) std::cout <<
"GEMM: " << GoodTestSubcount <<
" of " << GEMMTESTS <<
" tests were successful." << std::endl;
1214 if(debug) std::cout << std::endl;
1222 GoodTestSubcount = 0;
1236 OType1A =
new SType[LDA1 * M1];
1237 OType2A =
new SType[LDA2 * M2];
1238 for(j1 = 0, j2 = 0; j1 < LDA1 * M1; j1++, j2++) {
1240 OType2A[j2] = OType1A[j1];
1245 OType1A =
new SType[LDA1 * N1];
1246 OType2A =
new SType[LDA2 * N2];
1247 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++) {
1249 OType2A[j2] = OType1A[j1];
1256 OType1B =
new SType[LDB1 * N1];
1257 OType2B =
new SType[LDB2 * N2];
1258 for(j1 = 0, j2 = 0; j1 < LDB1 * N1; j1++, j2++) {
1260 OType2B[j2] = OType1B[j1];
1266 OType1C =
new SType[LDC1 * N1];
1267 OType2C =
new SType[LDC2 * N2];
1268 for(j1 = 0, j2 = 0; j1 < LDC1 * N1; j1++, j2++) {
1270 OType2C[j2] = OType1C[j1];
1275 OType2alpha = OType1alpha;
1276 OType2beta = OType1beta;
1279 std::cout <<
"Test #" << TotalTestCount <<
" -- SYMM -- " << std::endl;
1282 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1283 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1284 std::cout <<
"OType1beta = " << OType1beta << std::endl;
1285 std::cout <<
"OType2beta = " << OType2beta << std::endl;
1287 PrintMatrix(OType1A, M1, M1, LDA1,
"OType1A", matlab);
1288 PrintMatrix(OType2A, M2, M2, LDA2,
"OType2A", matlab);
1290 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
1291 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
1293 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B", matlab);
1294 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_before_operation", matlab);
1295 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B", matlab);
1296 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_before_operation", matlab);
1300 OType1BLAS.
SYMM(SIDE, UPLO, M1, N1, OType1alpha, OType1A, LDA1, OType1B, LDB1, OType1beta, OType1C, LDC1);
1301 OType2BLAS.
SYMM(SIDE, UPLO, M2, N2, OType2alpha, OType2A, LDA2, OType2B, LDB2, OType2beta, OType2C, LDC2);
1304 PrintMatrix(OType1C, M1, N1, LDC1,
"OType1C_after_operation", matlab);
1305 PrintMatrix(OType2C, M2, N2, LDC2,
"OType2C_after_operation", matlab);
1307 if (
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL)==0)
1308 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1309 GoodTestSubcount +=
CompareMatrices(OType1C, M1, N1, LDC1, OType2C, M2, N2, LDC2, TOL);
1318 GoodTestCount += GoodTestSubcount;
1319 if(verbose || debug) std::cout <<
"SYMM: " << GoodTestSubcount <<
" of " << SYMMTESTS <<
" tests were successful." << std::endl;
1320 if(debug) std::cout << std::endl;
1328 GoodTestSubcount = 0;
1339 #ifdef HAVE_TEUCHOS_COMPLEX 1347 OType1A =
new SType[LDA1 * K1];
1348 OType2A =
new SType[LDA2 * K2];
1349 for(j1 = 0, j2 = 0; j1 < LDA1 * K1; j1++, j2++) {
1351 OType2A[j2] = OType1A[j1];
1356 OType1A =
new SType[LDA1 * N1];
1357 OType2A =
new SType[LDA2 * N2];
1358 for(j1 = 0, j2 = 0; j1 < LDA1 * N1; j1++, j2++) {
1360 OType2A[j2] = OType1A[j1];
1367 OType1C =
new SType[LDC1 * N1];
1368 OType2C =
new SType[LDC2 * N2];
1369 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++) {
1374 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1379 OType1C[j1*LDC1+k1] = STypezero;
1381 OType2C[j2*LDC2+k2] = OType1C[j1*LDC1+k1];
1385 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1390 OType1C[j1*LDC1+k1] = STypezero;
1392 OType2C[j2*LDC2+k2] = OType1C[j1*LDC1+k1];
1399 OType2alpha = OType1alpha;
1400 OType2beta = OType1beta;
1403 std::cout <<
"Test #" << TotalTestCount <<
" -- SYRK -- " << std::endl;
1406 std::cout <<
"N1="<<N1 <<
"\t" <<
"K1 = " << K1
1407 <<
"\t" <<
"LDA1="<<LDA1 <<
"\t" <<
"LDC1=" << LDC1 << std::endl;
1408 std::cout <<
"N2="<<N2 <<
"\t" <<
"K2 = " << K2
1409 <<
"\t" <<
"LDA2="<<LDA2 <<
"\t" <<
"LDC2=" << LDC2 << std::endl;
1410 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1411 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1412 std::cout <<
"OType1beta = " << OType1beta << std::endl;
1413 std::cout <<
"OType2beta = " << OType2beta << std::endl;
1415 PrintMatrix(OType1A, N1, K1, LDA1,
"OType1A", matlab);
1416 PrintMatrix(OType2A, N2, K2, LDA2,
"OType2A", matlab);
1418 PrintMatrix(OType1A, K1, N1, LDA1,
"OType1A", matlab);
1419 PrintMatrix(OType2A, K2, N2, LDA2,
"OType2A", matlab);
1421 PrintMatrix(OType1C, N1, N1, LDC1,
"OType1C_before_operation", matlab);
1422 PrintMatrix(OType2C, N2, N2, LDC2,
"OType2C_before_operation", matlab);
1426 OType1BLAS.
SYRK(UPLO, TRANS, N1, K1, OType1alpha, OType1A, LDA1, OType1beta, OType1C, LDC1);
1427 OType2BLAS.
SYRK(UPLO, TRANS, N2, K2, OType2alpha, OType2A, LDA2, OType2beta, OType2C, LDC2);
1430 PrintMatrix(OType1C, N1, N1, LDC1,
"OType1C_after_operation", matlab);
1431 PrintMatrix(OType2C, N2, N2, LDC2,
"OType2C_after_operation", matlab);
1433 if (
CompareMatrices(OType1C, N1, N1, LDC1, OType2C, N2, N2, LDC2, TOL)==0)
1434 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1435 GoodTestSubcount +=
CompareMatrices(OType1C, N1, N1, LDC1, OType2C, N2, N2, LDC2, TOL);
1442 GoodTestCount += GoodTestSubcount;
1443 if(verbose || debug) std::cout <<
"SYRK: " << GoodTestSubcount <<
" of " << SYRKTESTS <<
" tests were successful." << std::endl;
1444 if(debug) std::cout << std::endl;
1452 GoodTestSubcount = 0;
1466 OType1B =
new SType[LDB1 * N1];
1467 OType2B =
new SType[LDB2 * N2];
1482 OType1A =
new SType[LDA1 * M1];
1483 OType2A =
new SType[LDA2 * M2];
1485 for(j1 = 0, j2 = 0; j1 < M1; j1++, j2++)
1490 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1495 OType1A[j1*LDA1+k1] = STypezero;
1497 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1501 while (OType1A[j1*LDA1+k1] == STypezero) {
1504 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1506 OType1A[j1*LDA1+k1] = STypeone;
1507 OType2A[j2*LDA2+k2] = STypeone;
1514 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1519 OType1A[j1*LDA1+k1] = STypezero;
1521 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1525 while (OType1A[j1*LDA1+k1] == STypezero) {
1528 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1530 OType1A[j1*LDA1+k1] = STypeone;
1531 OType2A[j2*LDA2+k2] = STypeone;
1546 OType1A =
new SType[LDA1 * N1];
1547 OType2A =
new SType[LDA2 * N2];
1549 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
1554 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1559 OType1A[j1*LDA1+k1] = STypezero;
1561 OType2A[j1*LDA1+k1] = OType1A[j1*LDA1+k1];
1565 while (OType1A[j1*LDA1+k1] == STypezero) {
1568 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1570 OType1A[j1*LDA1+k1] = STypeone;
1571 OType2A[j2*LDA2+k2] = STypeone;
1578 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1583 OType1A[j1*LDA1+k1] = STypezero;
1585 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1589 while (OType1A[j1*LDA1+k1] == STypezero) {
1592 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1594 OType1A[j1*LDA1+k1] = STypeone;
1595 OType2A[j2*LDA2+k2] = STypeone;
1604 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++) {
1605 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++) {
1607 OType2B[j2*LDB2+k2] = OType1B[j1*LDB1+k1];
1611 OType2alpha = OType1alpha;
1614 std::cout <<
"Test #" << TotalTestCount <<
" -- TRMM -- " << std::endl;
1619 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1620 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1622 PrintMatrix(OType1A, M1, M1, LDA1,
"OType1A", matlab);
1623 PrintMatrix(OType2A, M2, M2, LDA2,
"OType2A", matlab);
1625 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
1626 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
1628 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_before_operation", matlab);
1629 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_before_operation", matlab);
1632 OType1BLAS.
TRMM(SIDE, UPLO, TRANSA, DIAG, M1, N1, OType1alpha, OType1A, LDA1, OType1B, LDB1);
1633 OType2BLAS.
TRMM(SIDE, UPLO, TRANSA, DIAG, M2, N2, OType2alpha, OType2A, LDA2, OType2B, LDB2);
1636 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_after_operation", matlab);
1637 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_after_operation", matlab);
1639 if (
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL)==0)
1640 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1641 GoodTestSubcount +=
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL);
1647 GoodTestCount += GoodTestSubcount;
1648 if(verbose || debug) std::cout <<
"TRMM: " << GoodTestSubcount <<
" of " << TRMMTESTS <<
" tests were successful." << std::endl;
1649 if(debug) std::cout << std::endl;
1657 GoodTestSubcount = 0;
1671 OType1B =
new SType[LDB1 * N1];
1672 OType2B =
new SType[LDB2 * N2];
1690 OType1A =
new SType[LDA1 * M1];
1691 OType2A =
new SType[LDA2 * M2];
1693 for(j1 = 0, j2 = 0; j1 < M1; j1++, j2++)
1698 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1703 OType1A[j1*LDA1+k1] = STypezero;
1705 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1709 while (OType1A[j1*LDA1+k1] == STypezero) {
1712 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1714 OType1A[j1*LDA1+k1] = STypeone;
1715 OType2A[j2*LDA2+k2] = STypeone;
1722 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1727 OType1A[j1*LDA1+k1] = STypezero;
1729 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1733 while (OType1A[j1*LDA1+k1] == STypezero) {
1736 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1738 OType1A[j1*LDA1+k1] = STypeone;
1739 OType2A[j2*LDA2+k2] = STypeone;
1754 OType1A =
new SType[LDA1 * N1];
1755 OType2A =
new SType[LDA2 * N2];
1757 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
1762 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1767 OType1A[j1*LDA1+k1] = STypezero;
1769 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1773 while (OType1A[j1*LDA1+k1] == STypezero) {
1776 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1778 OType1A[j1*LDA1+k1] = STypeone;
1779 OType2A[j2*LDA2+k2] = STypeone;
1786 for(k1 = 0, k2 = 0; k1 < N1; k1++, k2++)
1791 OType1A[j1*LDA1+k1] = STypezero;
1793 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1797 while (OType1A[j1*LDA1+k1] == STypezero) {
1800 OType2A[j2*LDA2+k2] = OType1A[j1*LDA1+k1];
1802 OType1A[j1*LDA1+k1] = STypeone;
1803 OType2A[j2*LDA2+k2] = STypeone;
1812 for(j1 = 0, j2 = 0; j1 < N1; j1++, j2++)
1814 for(k1 = 0, k2 = 0; k1 < M1; k1++, k2++)
1817 OType2B[j2*LDB2+k2] = OType1B[j1*LDB1+k1];
1822 OType2alpha = OType1alpha;
1826 std::cout <<
"Test #" << TotalTestCount <<
" -- TRSM -- " << std::endl;
1831 std::cout <<
"M1="<<M1 <<
"\t" <<
"N1="<<N1 <<
"\t" <<
"LDA1="<<LDA1 <<
"\t" <<
"LDB1="<<LDB1 << std::endl;
1832 std::cout <<
"M2="<<M2 <<
"\t" <<
"N2="<<N2 <<
"\t" <<
"LDA2="<<LDA2 <<
"\t" <<
"LDB2="<<LDB2 << std::endl;
1833 std::cout <<
"OType1alpha = " << OType1alpha << std::endl;
1834 std::cout <<
"OType2alpha = " << OType2alpha << std::endl;
1836 PrintMatrix(OType1A, M1, M1, LDA1,
"OType1A", matlab);
1837 PrintMatrix(OType2A, M2, M2, LDA2,
"OType2A", matlab);
1839 PrintMatrix(OType1A, N1, N1, LDA1,
"OType1A", matlab);
1840 PrintMatrix(OType2A, N2, N2, LDA2,
"OType2A", matlab);
1842 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_before_operation", matlab);
1843 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_before_operation", matlab);
1847 OType1BLAS.
TRSM(SIDE, UPLO, TRANSA, DIAG, M1, N1, OType1alpha, OType1A, LDA1, OType1B, LDB1);
1848 OType2BLAS.
TRSM(SIDE, UPLO, TRANSA, DIAG, M2, N2, OType2alpha, OType2A, LDA2, OType2B, LDB2);
1852 PrintMatrix(OType1B, M1, N1, LDB1,
"OType1B_after_operation", matlab);
1853 PrintMatrix(OType2B, M2, N2, LDB2,
"OType2B_after_operation", matlab);
1856 if (
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL)==0)
1857 std::cout <<
"FAILED TEST!!!!!!" << std::endl;
1858 GoodTestSubcount +=
CompareMatrices(OType1B, M1, N1, LDB1, OType2B, M2, N2, LDB2, TOL);
1865 GoodTestCount += GoodTestSubcount;
1866 if(verbose || debug) std::cout <<
"TRSM: " << GoodTestSubcount <<
" of " << TRSMTESTS <<
" tests were successful." << std::endl;
1867 if(debug) std::cout << std::endl;
1872 if((((TotalTestCount - 1) - GoodTestCount) != 0) || (verbose) || (debug))
1874 std::cout << GoodTestCount <<
" of " << (TotalTestCount - 1) <<
" total tests were successful." << std::endl;
1877 if ((TotalTestCount-1) == GoodTestCount) {
1878 std::cout <<
"End Result: TEST PASSED" << std::endl;
1882 std::cout <<
"End Result: TEST FAILED" << std::endl;
1883 return (TotalTestCount-GoodTestCount-1);
1886 template<
typename TYPE>
1892 template<
typename T>
1893 std::complex<T>
GetRandom( std::complex<T> Low, std::complex<T> High)
1895 T lowMag = Low.real();
1896 T highMag = High.real();
1899 return std::complex<T>( real, imag );
1914 template<
typename TYPE,
typename OTYPE>
1917 std::cout << Name <<
" =" << std::endl;
1919 if(Matlab) std::cout <<
"[";
1920 for(i = 0; i < Size; i++)
1922 std::cout << Vector[i] <<
" ";
1924 if(Matlab) std::cout <<
"]";
1927 std::cout << std::endl << std::endl;
1931 std::cout <<
";" << std::endl;
1935 template<
typename TYPE,
typename OTYPE>
1940 std::cout << Name <<
" =" << std::endl;
1942 for(i = 0; i < Rows; i++)
1944 for(j = 0; j < Columns; j++)
1946 std::cout << Matrix[i + (j * LDM)] <<
" ";
1948 std::cout << std::endl;
1950 std::cout << std::endl;
1954 std::cout << Name <<
" = ";
1957 for(i = 0; i < Rows; i++)
1960 for(j = 0; j < Columns; j++)
1962 std::cout << Matrix[i + (j * LDM)] <<
" ";
1966 std::cout <<
"];" << std::endl;
1970 template<
typename TYPE>
1978 return( temp2 < Tolerance );
1985 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
1995 for(i1 = 0, i2 = 0; i1 < Size1; i1++, i2++)
1998 temp = Vector1[i1] - Vector2[i2];
2006 if (temp3 > Tolerance )
2015 template<
typename TYPE,
typename OTYPE1,
typename OTYPE2>
2017 TYPE* Matrix2, OTYPE2 Rows2, OTYPE2 Columns2, OTYPE2 LDM2,
2027 for(j1 = 0, j2 = 0; j1 < Columns1; j1++, j2++)
2029 for(i1 = 0, i2 = 0; i1 < Rows1; i1++, i2++)
2032 temp = Matrix1[j1*LDM1 + i1] - Matrix2[j2*LDM2 + i2];
2041 if (temp3 > Tolerance)
2082 if(r == 1 || r == 2)
OrdinalType IAMAX(const OrdinalType n, const ScalarType *x, const OrdinalType incx) const
Return the index of the element of x with the maximum magnitude.
Templated interface class to BLAS routines.
Basic wall-clock timer class.
bool CompareScalars(TYPE Scalar1, TYPE Scalar2, typename ScalarTraits< TYPE >::magnitudeType Tolerance)
void PrintMatrix(TYPE *Matrix, OTYPE Rows, OTYPE Columns, OTYPE LDM, std::string Name, bool Matlab=0)
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.
Teuchos::EDiag RandomDIAG()
void PrintVector(TYPE *Vector, OTYPE Size, std::string Name, bool Matlab=0)
Teuchos::ETransp RandomTRANS()
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.
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 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, MagnitudeType *c, ScalarType *s) const
Computes a Givens plane rotation.
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 ge...
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.
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char EUploChar[]
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.
TYPE GetRandom(TYPE, TYPE)
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...
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ESideChar[]
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.
std::string Teuchos_Version()
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.
bool CompareMatrices(TYPE *Matrix1, OTYPE1 Rows1, OTYPE1 Columns1, OTYPE1 LDM1, TYPE *Matrix2, OTYPE2 Rows2, OTYPE2 Columns2, OTYPE2 LDM2, typename ScalarTraits< TYPE >::magnitudeType Tolerance)
int main(int argc, char *argv[])
Teuchos::ESide RandomSIDE()
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
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/l...
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.
ScalarTraits< ScalarType >::magnitudeType ASUM(const OrdinalType n, const ScalarType *x, const OrdinalType incx) const
Sum the absolute values of the entries of x.
TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ETranspChar[]
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...
OTYPE2 ConvertType(OTYPE1 T1, OTYPE2 T2)
bool CompareVectors(TYPE *Vector1, OTYPE1 Size1, TYPE *Vector2, OTYPE2 Size2, typename ScalarTraits< TYPE >::magnitudeType Tolerance)
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.
Teuchos::EUplo RandomUPLO()
static std::string name()
ScalarTraits< ScalarType >::magnitudeType NRM2(const OrdinalType n, const ScalarType *x, const OrdinalType incx) const
Compute the 2-norm of the vector x.