12 template <
class scalartype,
int dim>
14 typedef Matrix<scalartype,dim,dim> matrix;
15 typedef Matrix<std::complex<scalartype> ,dim,dim> cmatrix;
16 typedef Matrix<std::complex<scalartype> ,dim,1> cvector;
20 EigenSolver< matrix > eigensolver;
23 eigensolver.compute(A_);
24 V=eigensolver.eigenvectors();
25 lambda=eigensolver.eigenvalues();
28 matrix operator()(scalartype t){
32 for(
int i=0;i<dim;i++)tmp(i,i)=exp(lambda(i)*t);
34 tmp=tmp.operator*(iV);
37 for(
int i=0;i<dim;i++)
38 for(
int j=0;j<dim;j++)
39 ans(i,j)=std::real(tmp(i,j));
45 template <
class scalartype>
47 typedef std::complex<scalartype> complex;
48 typedef Matrix<scalartype,2,2> matrix;
49 typedef Matrix<complex ,2,2> cmatrix;
50 typedef Matrix<complex ,2,1> cvector;
56 complex T=scalartype(0.5)*A_.trace();
57 complex D=A_.determinant();
58 lambda << T+sqrt(T*T-D) , T-sqrt(T*T-D);
61 V << b, b, lambda(0)-a, lambda(1)-a;
64 matrix operator()(scalartype t){
69 for(
int i=0;i<dim;i++)tmp(i,i)=exp(lambda(i)*t);
71 tmp=tmp.operator*(iV);
74 for(
int i=0;i<dim;i++)
75 for(
int j=0;j<dim;j++)
76 ans(i,j)=std::real(tmp(i,j));
Matrix exponential: matrix of arbitrary dimension.
Utility functions for TMB (automatically included)