15 for (
int i=0;
i<k;
i++)
16 res = res * (n-k+
i+1) / (
i+1);
33 for (
int i=0;
i<=20;
i++)
35 angle =
static_cast<T>(
pow(10,
i / 5. - 2));
38 C = (angle*
A).matrixFunction(
expfn);
39 std::cout <<
"test2dRotation: i = " <<
i <<
" error funm = " <<
relerr(C, B);
40 VERIFY(C.isApprox(B, static_cast<T>(tol)));
43 std::cout <<
" error expm = " <<
relerr(C, B) <<
"\n";
44 VERIFY(C.isApprox(B, static_cast<T>(tol)));
52 std::complex<T> imagUnit(0,1);
55 for (
int i=0;
i<=20;
i++)
57 angle =
static_cast<T>((
i-10) / 2.0);
60 A << 0, angle*imagUnit, -angle*imagUnit, 0;
61 B << ch, sh*imagUnit, -sh*imagUnit, ch;
63 C = A.matrixFunction(
expfn);
64 std::cout <<
"test2dHyperbolicRotation: i = " <<
i <<
" error funm = " <<
relerr(C, B);
65 VERIFY(C.isApprox(B, static_cast<T>(tol)));
68 std::cout <<
" error expm = " <<
relerr(C, B) <<
"\n";
69 VERIFY(C.isApprox(B, static_cast<T>(tol)));
81 A(
i+1,
i) =
static_cast<T>(
i+1);
84 for (
int j=0;
j<=
i;
j++)
87 C =
A.matrixFunction(
expfn);
88 std::cout <<
"testPascal: size = " << size <<
" error funm = " <<
relerr(C,
B);
89 VERIFY(C.isApprox(
B, static_cast<T>(tol)));
92 std::cout <<
" error expm = " <<
relerr(C,
B) <<
"\n";
93 VERIFY(C.isApprox(
B, static_cast<T>(tol)));
97 template<
typename MatrixType>
105 MatrixType m1(rows, cols),
m2(rows, cols), identity = MatrixType::Identity(rows, cols);
110 m1 = MatrixType::Random(rows, cols);
113 std::cout <<
"randomTest: error funm = " <<
relerr(identity,
m2);
114 VERIFY(identity.isApprox(
m2, static_cast<RealScalar>(tol)));
117 std::cout <<
" error expm = " <<
relerr(identity, m2) <<
"\n";
118 VERIFY(identity.isApprox(m2, static_cast<RealScalar>(tol)));
124 CALL_SUBTEST_2(test2dRotation<double>(1
e-13));
125 CALL_SUBTEST_1(test2dRotation<float>(2
e-5));
126 CALL_SUBTEST_8(test2dRotation<long double>(1
e-13));
127 CALL_SUBTEST_2(test2dHyperbolicRotation<double>(1
e-14));
128 CALL_SUBTEST_1(test2dHyperbolicRotation<float>(1
e-5));
129 CALL_SUBTEST_8(test2dHyperbolicRotation<long double>(1
e-14));
130 CALL_SUBTEST_6(testPascal<float>(1
e-6));
131 CALL_SUBTEST_5(testPascal<double>(1
e-15));
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
void test2dRotation(double tol)
void testPascal(double tol)
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
double binom(int n, int k)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic > A
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
Matrix< SCALARB, Dynamic, Dynamic > B
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
EIGEN_DEVICE_FUNC const CosReturnType cos() const
void test2dHyperbolicRotation(double tol)
internal::enable_if< !(internal::is_same< typename Derived::Scalar, ScalarExponent >::value)&&EIGEN_SCALAR_BINARY_SUPPORTED(pow, typename Derived::Scalar, ScalarExponent), const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived, ScalarExponent, pow) >::type pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void randomTest(const MatrixType &m, double tol)
NumTraits< Scalar >::Real RealScalar
Matrix< Scalar, Dynamic, Dynamic > C
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
EIGEN_DEVICE_FUNC const SinReturnType sin() const
The matrix class, also used for vectors and row-vectors.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
void test_matrix_exponential()