MCPcopy Create free account
hub / github.com/abess-team/abess / testPascal

Function testPascal

python/include/unsupported/test/matrix_exponential.cpp:74–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73template <typename T>
74void testPascal(double tol)
75{
76 for (int size=1; size<20; size++)
77 {
78 Matrix<T,Dynamic,Dynamic> A(size,size), B(size,size), C(size,size);
79 A.setZero();
80 for (int i=0; i<size-1; i++)
81 A(i+1,i) = static_cast<T>(i+1);
82 B.setZero();
83 for (int i=0; i<size; i++)
84 for (int j=0; j<=i; j++)
85 B(i,j) = static_cast<T>(binom(i,j));
86
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)));
90
91 C = A.exp();
92 std::cout << " error expm = " << relerr(C, B) << "\n";
93 VERIFY(C.isApprox(B, static_cast<T>(tol)));
94 }
95}
96
97template<typename MatrixType>
98void randomTest(const MatrixType& m, double tol)

Callers

nothing calls this directly

Calls 6

binomFunction · 0.85
relerrFunction · 0.85
matrixFunctionMethod · 0.80
setZeroMethod · 0.45
isApproxMethod · 0.45
expMethod · 0.45

Tested by

no test coverage detected