MyraMath
ProductAction


Source: tests/iterative/ProductAction.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>
15 
16 // Algorithms.
17 #include <myramath/dense/gemm.h>
19 
20 // Iterative solve/action stuff.
24 
25 // Reporting.
26 #include <tests/myratest.h>
27 
28 using namespace myra;
29 
30 namespace {
31 
32 template<class Number> void test(typename ReflectPrecision<Number>::type tolerance)
33  {
34  typedef typename ReflectPrecision<Number>::type Precision;
35  auto A = Matrix<Number>::random(3,10);
36  auto B = Matrix<Number>::random(10,3);
37  auto C1 = A*B;
38  auto C2 = make_GemmAction(A)*make_GemmAction(B);
39  Precision error = frobenius(C1-C2.make_Matrix());
40  myra::out() << "|(A*B)[dense] - (A*B)[action]| = " << error << std::endl;
41  REQUIRE(error < tolerance);
42  }
43 
44 } // namespace
45 
46 ADD_TEST("ProductAction","[iterative]")
47  {
48  test<NumberS>(1.0e-4f);
49  test<NumberD>(1.0e-12);
50  test<NumberC>(1.0e-4f);
51  test<NumberZ>(1.0e-12);
52  }
Interface class for representing subranges of dense Matrix&#39;s.
Applies the "Action" of a linear operator, b := A*x, used in iterative solution algorithms.
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
Definition: syntax.dox:1
Various utility functions/classes related to scalar Number types.
Composes two Action&#39;s A and B, yielding an Action that cascades A*(B*X)
General purpose dense matrix container, O(i*j) storage.
Reflects Precision trait for a Number, scalar Number types should specialize it.
Definition: Number.h:33
An Action for multiplying by a dense Matrix or SparseMatrix using gemm().
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.


Results: [PASS]

|(A*B)[dense] - (A*B)[action]| = 0
|(A*B)[dense] - (A*B)[action]| = 0
|(A*B)[dense] - (A*B)[action]| = 0
|(A*B)[dense] - (A*B)[action]| = 0


Go back to Summary of /test programs.