MyraMath
expr_logical


Source: tests/expression/logical.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 
17 
18 // Reporting.
19 #include <tests/myratest.h>
20 
21 using namespace myra;
22 
23 #ifdef MYRAMATH_ENABLE_CPP11
24 
25 ADD_TEST("expr_logical","[expression]")
26  {
27  auto A = expr({1.0,-4.0,7.0,10.0});
28  auto B = expr({0.0,5.0,6.0,11.0});
29  REQUIRE( equals( A<B, expr({false,true,false,true}) ) );
30  REQUIRE( equals( A>B, expr({true,false,true,false}) ) );
31  REQUIRE( equals( (A<B) && (A>B), expr({false,false,false,false}) ) );
32  REQUIRE( equals( (A<B) || (A>B), expr({true,true,true,true}) ) );
33  REQUIRE( equals( (A<B)&&(A<0.0), expr({false,true,false,false}) ) );
34  REQUIRE( equals( !expr({false,true}), expr({true,false}) ) );
35  double tol = 1.0e-12;
36  REQUIRE( frobenius( ternary(A<B,A,B) - expr({0.0,-4.0,6.0,10.0}) ) < tol );
37  }
38 
39 #endif
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
Arithmetic operators (+,-,*,/) for Expression&#39;s.
Routines for computing Frobenius norms of Expression&#39;s.
Comparison operators (<,>) and logical operators (&&,||,!) for Expression&#39;s.


Results: [PASS]


Go back to Summary of /test programs.