MyraMath
zherkLower


Source: tests/dense/herk3.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
13 #include <myramath/dense/Matrix.h>
16 
17 // Algorithms.
19 #include <myramath/dense/gemm.h>
20 #include <myramath/dense/herk.h>
25 #include <myramath/dense/tril.h>
26 #include <myramath/dense/triu.h>
28 
29 // Reporting.
30 #include <tests/myratest.h>
31 
32 using namespace myra;
33 
34 namespace {
35 
36 template<class Precision> void test(int I, int J, Precision tolerance)
37  {
38  // Useful typedef.
39  typedef std::complex<Precision> Number;
40  myra::out() << typestring<Number>() << std::endl;
41 
42  // Make random nonsquare matrix A.
43  auto A = Matrix<Number>::random(I,J);
44 
45  // Compare herk(A,'N') to gemm(A,'N',A,'H')
46  {
47  LowerMatrix<Number> B1(gemm(A,'N',A,'H'));
48  LowerMatrix<Number> B2 = herk(A,'N');
49  Precision error = frobenius(B2-B1);
50  myra::out() << " |herk('N')-gemm('N','H')| = " << error << std::endl;
51  REQUIRE(error < tolerance);
52  }
53 
54  // Compare herk(A,'T') to gemm(A,'T',A,'C')
55  {
56  LowerMatrix<Number> C1(gemm(A,'T',A,'C'));
57  LowerMatrix<Number> C2 = herk(A,'T');
58  Precision error = frobenius(C2-C1);
59  myra::out() << " |herk('T')-gemm('T','C')| = " << error << std::endl;
60  REQUIRE(error < tolerance);
61  }
62 
63  // Compare herk(A,'H') to gemm(A,'H',A,'N')
64  {
65  LowerMatrix<Number> C1(gemm(A,'H',A,'N'));
66  LowerMatrix<Number> C2 = herk(A,'H');
67  Precision error = frobenius(C2-C1);
68  myra::out() << " |herk('H')-gemm('H','N')| = " << error << std::endl;
69  REQUIRE(error < tolerance);
70  }
71 
72  // Compare herk(A,'C') to gemm(A,'C',A,'T')
73  {
74  LowerMatrix<Number> C1(gemm(A,'C',A,'T'));
75  LowerMatrix<Number> C2 = herk(A,'C');
76  Precision error = frobenius(C2-C1);
77  myra::out() << " |herk('C')-gemm('C','T')| = " << error << std::endl;
78  REQUIRE(error < tolerance);
79  }
80 
81  }
82 
83 } // namespace
84 
85 ADD_TEST("cherkLower","[dense][blas]")
86  { test<float>(54,37,1.0e-4f); }
87 
88 ADD_TEST("zherkLower","[dense][blas]")
89  { test<double>(54,37,1.0e-8); }
90 
Returns a conjugated copy of a Matrix or Vector. Or, conjugate one inplace.
Routines for hermitian rank-k updates, a specialized form of Matrix*Matrix multiplication.
Routines for computing Frobenius norms of various algebraic containers.
static Matrix< Number > random(int I, int J)
Generates a random Matrix of specified size.
Definition: Matrix.cpp:353
Replaces small values with explicit zeros.
Range construct for a lower triangular matrix stored in rectangular packed format.
Definition: syntax.dox:1
Specialized container for a lower triangular matrix, O(N^2/2) storage. Used by symmetry exploiting ma...
Returns a transposed copy of a Matrix. The inplace version only works on a square operand...
Returns the lower triangle of a dense Matrix.
Returns the upper triangle of a dense Matrix.
Various utility functions/classes related to scalar Number types.
General purpose dense matrix container, O(i*j) storage.
Returns a hermitian copy of a Matrix. The inplace version only works on a square operand.
Simplistic random number functions.
Stores a lower triangular matrix in rectangular packed format.
Definition: conjugate.h:22
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.


Results: [PASS]

std::complex<double>
|herk('N')-gemm('N','H')| = 0
|herk('T')-gemm('T','C')| = 0
|herk('H')-gemm('H','N')| = 0
|herk('C')-gemm('C','T')| = 0


Go back to Summary of /test programs.