MyraMath
alias_Pattern


Source: tests/sparse/alias.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.
15 
16 // Ranges.
19 
20 // Algorithms.
22 #include <myramath/sparse/expr.h>
25 
26 // Reporting.
27 #include <tests/myratest.h>
28 
29 using namespace myra;
30 
31 namespace {
32 
33 // Alias test for SparseMatrix.
34 template<class Number> void test1(typename ReflectPrecision<Number>::type tolerance)
35  {
36  auto A = SparseMatrix<Number>::random(10,10,40);
37  SparseMatrix<Number> B(A.top(5));
38  A = A.top(5);
39  REQUIRE( frobenius(A-B) < tolerance);
40  }
41 
42 // Alias test for Pattern.
43 void test2()
44  {
45  auto A = Pattern::random(10,10,40);
46  Pattern B(A.top(5));
47  A = A.top(5);
48  REQUIRE( equals(expr(A),expr(B)) );
49  }
50 
51 } // namespace
52 
53 ADD_TEST("alias_SparseMatrix","[sparse]")
54  {
55  test1<NumberS>(1.0e-4f);
56  test1<NumberD>(1.0e-8);
57  test1<NumberC>(1.0e-4f);
58  test1<NumberZ>(1.0e-8);
59  }
60 
61 ADD_TEST("alias_Pattern","[sparse]")
62  {
63  test2();
64  }
static SparseMatrix< Number > random(int I, int J, int N)
Generates a random SparseMatrix with size IxJ and (approximately) N nonzeros.
Definition: SparseMatrix.cpp:493
An interface used to fill containers from Expression&#39;s (see Matrix::evaluate(), for example)...
General purpose compressed-sparse-column (CSC) container.
Definition: syntax.dox:1
Various utility functions/classes related to scalar Number types.
static Pattern random(int I, int J, int N)
Generates a random Pattern with size IxJ and (approximately) N nonzeros.
Definition: Pattern.cpp:300
Comparison operators (<,>) and logical operators (&&,||,!) for Expression&#39;s.
Range/Iterator types associated with Pattern.
Holds the nonzero pattern of a sparse matrix.
Definition: Pattern.h:55
CSparseMatrixRange< Number > top(int i) const
Returns a SparseMatrixRange over the i topmost rows, this(0:i,:)
Definition: SparseMatrix.cpp:361
Reflects Precision trait for a Number, scalar Number types should specialize it.
Definition: Number.h:33
Container class for a sparse nonzero pattern, used in reordering/symbolic analysis.
Returns frobenius norm of a SparseMatrix.
Stores an IxJ matrix A in compressed sparse column format.
Definition: bothcat.h:23
Overloads expr() for SparseMatrix<Number> and Pattern.
Range/Iterator types associated with SparseMatrix.


Results: [PASS]


Go back to Summary of /test programs.