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)));
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
#define CALL_SUBTEST_9(FUNC)
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
Jet< T, N > cos(const Jet< T, N > &f)
#define CALL_SUBTEST_3(FUNC)
void test2dRotation(double tol)
#define CALL_SUBTEST_7(FUNC)
Jet< T, N > sin(const Jet< T, N > &f)
void testPascal(double tol)
double binom(int n, int k)
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar, typename ExponentDerived::Scalar >, const Derived, const ExponentDerived > pow(const Eigen::ArrayBase< Derived > &x, const Eigen::ArrayBase< ExponentDerived > &exponents)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
EIGEN_DECLARE_TEST(matrix_exponential)
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
void test2dHyperbolicRotation(double tol)
#define CALL_SUBTEST_1(FUNC)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define CALL_SUBTEST_8(FUNC)
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
#define CALL_SUBTEST_5(FUNC)
#define CALL_SUBTEST_2(FUNC)
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
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