2 #ifndef vnl_matrix_exp_hxx_ 3 #define vnl_matrix_exp_hxx_ 12 # include <vcl_msvc_warnings.h> 16 template <
class Matrix>
19 assert(X.rows() == X.cols());
20 assert(X.rows() == expX.rows());
21 assert(X.cols() == expX.cols());
24 double norm_X = X.operator_inf_norm();
26 std::cerr <<
"norm_X = " << norm_X << std::endl;
32 double norm_acc_bound = norm_X;
33 for (
unsigned n=1;
true; ++n) {
36 std::cerr <<
"n=" << n << std::endl;
40 double err_bound = norm_acc_bound / (1 - norm_X/n);
42 std::cerr <<
"err_bound = " << err_bound << std::endl;
44 if (err_bound < max_err)
51 norm_acc_bound *= norm_X/(n+1);
58 template <
class Matrix>
61 Matrix expX(X.rows(), X.cols());
73 #undef VNL_MATRIX_EXP_INSTANTIATE 74 #define VNL_MATRIX_EXP_INSTANTIATE(Matrix) \ 75 template VNL_EXPORT bool vnl_matrix_exp(Matrix const&, Matrix &, double); \ 76 template VNL_EXPORT Matrix vnl_matrix_exp(Matrix const&) 78 #endif // vnl_matrix_exp_hxx_ VNL_EXPORT bool vnl_matrix_exp(SquareMatrix const &X, SquareMatrix &expX, double max_err)
Compute the exponential of a square matrix - fiddly form.
Compute the exponential of a square matrix.