19 #include <tests/myratest.h> 23 #ifdef MYRAMATH_ENABLE_CPP11 25 ADD_TEST(
"expr_functions_trig",
"[expression]")
28 double pi = std::acos(-1.0);
29 auto E = expr({0.0,pi/6.0,pi/4.0,pi/3.0,pi/2.0});
30 REQUIRE( frobenius(
sin(E) - expr({0.0,0.5,
sqrt(2.0)/2.0,
sqrt(3.0)/2.0,1.0}) ) < tol );
31 REQUIRE( frobenius(
cos(E) - expr({1.0,
sqrt(3.0)/2.0,
sqrt(2.0)/2.0,0.5,0.0}) ) < tol );
34 REQUIRE( frobenius(
atan2(Y,X) - E ) < tol );
37 ADD_TEST(
"expr_functions_exponential",
"[expression]")
40 auto E = expr({0.0,1.0,2.0,3.0});
41 REQUIRE( frobenius(
log(
exp(E)) - E ) < tol );
42 REQUIRE( frobenius(
log10(
pow(10.0,E)) - E ) < tol );
45 ADD_TEST(
"expr_functions_power",
"[expression]")
48 auto E = expr({0.0,1.0,2.0,3.0});
49 auto E2 = expr({0.0,1.0,4.0,9.0});
50 REQUIRE( frobenius(
pow(E,2.0) - E2 ) < tol );
51 REQUIRE( frobenius(
sqrt(E2) - E ) < tol );
54 ADD_TEST(
"expr_functions_complex",
"[expression]")
57 double pi = std::acos(-1.0);
58 std::complex<double> j(0.0,1.0);
59 auto P = expr({0.0,pi/6.0,pi/4.0,pi/3.0,pi/2.0});
63 REQUIRE( frobenius( R - realpart(Z) ) < tol );
64 REQUIRE( frobenius( I - imagpart(Z) ) < tol );
65 REQUIRE( frobenius( P - argument(Z) ) < tol );
66 REQUIRE( frobenius( P + argument(conjugate(Z)) ) < tol );
69 ADD_TEST(
"expr_functions_measure",
"[expression]")
72 std::vector<double> r {3.0, 5.0, 8.0, 7.0};
73 std::vector<double> i {4.0,12.0,15.0,24.0};
74 std::vector<double> a {5.0,13.0,17.0,25.0};
79 REQUIRE( frobenius(
abs(Z) - A ) < tol );
Expression< 1, NumberS > abs(const Expression< 1, NumberS > &A)
Returns the std::abs() of an Expression.
Definition: functions_measure.cpp:29
Expression< 1, NumberS > exp(const Expression< 1, NumberS > &A)
Returns the std::exp() of an Expression.
Definition: functions_exponential.cpp:29
Overloads expr() for std::vector<Number> and (C++11 only) std::initializer_list<Number> ...
Expression< 1, NumberS > pow(const Expression< 1, NumberS > &A, const Expression< 1, NumberS > &B)
Returns A^B, an Expression base raised to an Expression power.
Definition: functions_power.cpp:53
Expression< 1, NumberS > sin(const Expression< 1, NumberS > &A)
Returns the std::sin() of an Expression.
Definition: functions_trig.cpp:30
An interface used to fill containers from Expression's (see Matrix::evaluate(), for example)...
Expression< 1, NumberS > cos(const Expression< 1, NumberS > &A)
Returns the std::cos() of an Expression.
Definition: functions_trig.cpp:60
Arithmetic operators (+,-,*,/) for Expression's.
Routines for computing Frobenius norms of Expression's.
Expression< 1, NumberS > sqrt(const Expression< 1, NumberS > &A)
Returns the std::sqrt() of an Expression.
Definition: functions_power.cpp:30
Function overloads (sin, exp, etc) for Expression's.
Expression< 1, NumberS > log10(const Expression< 1, NumberS > &A)
Returns the std::log10() of an Expression.
Definition: functions_exponential.cpp:89
Expression< 1, NumberS > atan2(const Expression< 1, NumberS > &Y, const Expression< 1, NumberS > &X)
Returns the std::atan2(y,x) of a real Expression.
Definition: functions_trig.cpp:212
Expression< 1, NumberC > make_complex(const Expression< 1, NumberS > &A)
Promotes a real Expression into a complex one.
Definition: functions_complex.cpp:122
Expression< 1, NumberS > log(const Expression< 1, NumberS > &A)
Returns the std::log() of an Expression.
Definition: functions_exponential.cpp:59