MyraMath
expr_reshape


Source: tests/expression/reshape.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 
15 
16 // Reporting.
17 #include <tests/myratest.h>
18 
19 using namespace myra;
20 
21 #ifdef MYRAMATH_ENABLE_CPP11
22 
23 ADD_TEST("expr_reshape","[expression]")
24  {
25  auto E1 = expr({1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0});
26  auto E2 = reshape(E1,3,3);
27  REQUIRE( E2.evaluate({0,0}) == 1.0 );
28  REQUIRE( E2.evaluate({1,0}) == 2.0 );
29  REQUIRE( E2.evaluate({2,0}) == 3.0 );
30  REQUIRE( E2.evaluate({0,1}) == 4.0 );
31  REQUIRE( E2.evaluate({1,1}) == 5.0 );
32  REQUIRE( E2.evaluate({2,1}) == 6.0 );
33  REQUIRE( E2.evaluate({0,2}) == 7.0 );
34  REQUIRE( E2.evaluate({1,2}) == 8.0 );
35  REQUIRE( E2.evaluate({2,2}) == 9.0 );
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> ...
An interface used to fill containers from Expression&#39;s (see Matrix::evaluate(), for example)...
Definition: syntax.dox:1


Results: [PASS]


Go back to Summary of /test programs.