MyraMath
expr_generators


Source: tests/expression/generators.cpp

1 
2 // ========================================================================= //
3 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
4 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
5 // ========================================================================= //
6 
19 
20 // Reporting.
21 #include <tests/myratest.h>
22 
23 using namespace myra;
24 
25 #ifdef MYRAMATH_ENABLE_CPP11
26 
27 ADD_TEST("expr_generators","[expression]")
28  {
29  double tol = 1.0e-12;
30  REQUIRE( frobenius(make_LinspaceExpression(0.0,4.0,5) - expr({0.0,1.0,2.0,3.0,4.0})) < tol );
31  REQUIRE( frobenius(make_LogspaceExpression(0.0,4.0,5) - expr({1.0,10.0,100.0,1000.0,10000.0})) < tol );
32  REQUIRE( frobenius(make_ConstantExpression(5,2.0) - expr({2.0,2.0,2.0,2.0,2.0})) < tol );
33  REQUIRE( frobenius(make_ConstantExpression(3,5,2.0) - reshape(make_ConstantExpression(15,2.0),3,5)) < tol );
34  myra::out() << make_RandomExpression< std::complex<double> >(5) << std::endl;
35  myra::out() << make_RandomExpression<double>(3,3) << std::endl;
36  }
37 
38 #endif
39 
Reshapes an Expression (for instance, reinterpret an arity-1 Expression of size 25 into an arity-2 Ex...
Overloads expr() for std::vector<Number> and (C++11 only) std::initializer_list<Number> ...
Generators for basic Expression&#39;s (constant, random, linspace, etc).
An interface used to fill containers from Expression&#39;s (see Matrix::evaluate(), for example)...
Definition: syntax.dox:1
Arithmetic operators (+,-,*,/) for Expression&#39;s.
Routines for computing Frobenius norms of Expression&#39;s.


Results: [PASS]

size 5 arity-1 Expression of std::complex<double>:
[ (0.856348,0.179825) (-0.221386,-0.962504) (0.854009,-0.303818) (-0.138069,0.970514) (0.0403698,0.133254) ]
size 3 by 3 arity-2 Expression of double:
[ 0.436496 -0.392947 0.152213 ]
[ -0.420534 -0.292403 0.929914 ]
[ 0.516054 0.175849 -0.723981 ]


Go back to Summary of /test programs.