11 #ifndef EIGEN_MATRIX_EXPONENTIAL
12 #define EIGEN_MATRIX_EXPONENTIAL
26 template <
typename RealScalar>
63 template <
typename MatA,
typename MatU,
typename MatV>
70 U.noalias() =
A *
tmp;
71 V =
b[2] * A2 +
b[0] * MatrixType::Identity(
A.
rows(),
A.
cols());
79 template <
typename MatA,
typename MatU,
typename MatV>
83 const RealScalar b[] = {30240.L, 15120.L, 3360.L, 420.L, 30.L, 1.L};
87 U.noalias() =
A *
tmp;
88 V =
b[4] * A4 +
b[2] * A2 +
b[0] * MatrixType::Identity(
A.
rows(),
A.
cols());
96 template <
typename MatA,
typename MatU,
typename MatV>
100 const RealScalar b[] = {17297280.L, 8648640.L, 1995840.L, 277200.L, 25200.L, 1512.L, 56.L, 1.L};
105 U.noalias() =
A *
tmp;
106 V =
b[6] * A6 +
b[4] * A4 +
b[2] * A2 +
b[0] * MatrixType::Identity(
A.
rows(),
A.
cols());
114 template <
typename MatA,
typename MatU,
typename MatV>
116 typedef typename MatA::PlainObject
MatrixType;
118 const RealScalar b[] = {17643225600.L, 8821612800.L, 2075673600.L, 302702400.L, 30270240.L,
119 2162160.L, 110880.L, 3960.L, 90.L, 1.L};
125 b[9] * A8 +
b[7] * A6 +
b[5] * A4 +
b[3] * A2 +
b[1] * MatrixType::Identity(
A.
rows(),
A.
cols());
126 U.noalias() =
A *
tmp;
127 V =
b[8] * A8 +
b[6] * A6 +
b[4] * A4 +
b[2] * A2 +
b[0] * MatrixType::Identity(
A.
rows(),
A.
cols());
135 template <
typename MatA,
typename MatU,
typename MatV>
137 typedef typename MatA::PlainObject
MatrixType;
156 V =
b[13] * A6 +
b[11] * A4 +
b[9] * A2;
158 tmp +=
b[7] * A6 +
b[5] * A4 +
b[3] * A2 +
b[1] * MatrixType::Identity(
A.
rows(),
A.
cols());
159 U.noalias() =
A *
tmp;
160 tmp =
b[12] * A6 +
b[10] * A4 +
b[8] * A2;
161 V.noalias() = A6 *
tmp;
162 V +=
b[6] * A6 +
b[4] * A4 +
b[2] * A2 +
b[0] * MatrixType::Identity(
A.
rows(),
A.
cols());
172 #if LDBL_MANT_DIG > 64
173 template <
typename MatA,
typename MatU,
typename MatV>
174 void matrix_exp_pade17(
const MatA&
A, MatU&
U, MatV&
V) {
175 typedef typename MatA::PlainObject
MatrixType;
177 const RealScalar b[] = {830034394580628357120000.L,
178 415017197290314178560000.L,
179 100610229646136770560000.L,
180 15720348382208870400000.L,
181 1774878043152614400000.L,
182 153822763739893248000.L,
183 10608466464820224000.L,
184 595373117923584000.L,
199 V =
b[17] * A8 +
b[15] * A6 +
b[13] * A4 +
b[11] * A2;
201 tmp +=
b[9] * A8 +
b[7] * A6 +
b[5] * A4 +
b[3] * A2 +
b[1] * MatrixType::Identity(
A.rows(),
A.cols());
202 U.noalias() =
A *
tmp;
203 tmp =
b[16] * A8 +
b[14] * A6 +
b[12] * A4 +
b[10] * A2;
204 V.noalias() =
tmp * A8;
205 V +=
b[8] * A8 +
b[6] * A6 +
b[4] * A4 +
b[2] * A2 +
b[0] * MatrixType::Identity(
A.rows(),
A.cols());
221 template <
typename MatrixType>
223 template <
typename ArgType>
227 const float l1norm = arg.cwiseAbs().colwise().sum().maxCoeff();
229 if (l1norm < 4.258730016922831e-001f) {
231 }
else if (l1norm < 1.880152677804762e+000f) {
234 const float maxnorm = 3.925724783138660f;
235 frexp(l1norm / maxnorm, &squarings);
236 if (squarings < 0) squarings = 0;
243 template <
typename MatrixType>
246 template <
typename ArgType>
250 const RealScalar l1norm = arg.cwiseAbs().colwise().sum().maxCoeff();
252 if (l1norm < 1.495585217958292e-002) {
254 }
else if (l1norm < 2.539398330063230e-001) {
256 }
else if (l1norm < 9.504178996162932e-001) {
258 }
else if (l1norm < 2.097847961257068e+000) {
262 frexp(l1norm / maxnorm, &squarings);
263 if (squarings < 0) squarings = 0;
270 template <
typename MatrixType>
272 template <
typename ArgType>
274 #if LDBL_MANT_DIG == 53
281 const long double l1norm = arg.cwiseAbs().colwise().sum().maxCoeff();
284 #if LDBL_MANT_DIG <= 64
286 if (l1norm < 4.1968497232266989671e-003L) {
288 }
else if (l1norm < 1.1848116734693823091e-001L) {
290 }
else if (l1norm < 5.5170388480686700274e-001L) {
292 }
else if (l1norm < 1.3759868875587845383e+000L) {
295 const long double maxnorm = 4.0246098906697353063L;
296 frexp(l1norm / maxnorm, &squarings);
297 if (squarings < 0) squarings = 0;
302 #elif LDBL_MANT_DIG <= 106
304 if (l1norm < 3.2787892205607026992947488108213e-005L) {
306 }
else if (l1norm < 6.4467025060072760084130906076332e-003L) {
308 }
else if (l1norm < 6.8988028496595374751374122881143e-002L) {
310 }
else if (l1norm < 2.7339737518502231741495857201670e-001L) {
312 }
else if (l1norm < 1.3203382096514474905666448850278e+000L) {
315 const long double maxnorm = 3.2579440895405400856599663723517L;
316 frexp(l1norm / maxnorm, &squarings);
317 if (squarings < 0) squarings = 0;
319 matrix_exp_pade17(
A,
U,
V);
322 #elif LDBL_MANT_DIG <= 113
324 if (l1norm < 1.639394610288918690547467954466970e-005L) {
326 }
else if (l1norm < 4.253237712165275566025884344433009e-003L) {
328 }
else if (l1norm < 5.125804063165764409885122032933142e-002L) {
330 }
else if (l1norm < 2.170000765161155195453205651889853e-001L) {
332 }
else if (l1norm < 1.125358383453143065081397882891878e+000L) {
335 const long double maxnorm = 2.884233277829519311757165057717815L;
336 frexp(l1norm / maxnorm, &squarings);
337 if (squarings < 0) squarings = 0;
339 matrix_exp_pade17(
A,
U,
V);
352 template <
typename T>
358 #if LDBL_MANT_DIG <= 113
363 template <
typename ArgType,
typename ResultType>
366 typedef typename ArgType::PlainObject
MatrixType;
372 result = denom.partialPivLu().solve(numer);
373 for (
int i = 0;
i < squarings;
i++) result *= result;
381 template <
typename ArgType,
typename ResultType>
384 typedef typename ArgType::PlainObject
MatrixType;
387 typedef typename std::complex<RealScalar> ComplexScalar;
388 result = arg.matrixFunction(internal::stem_function_exp<ComplexScalar>);
403 template <
typename Derived>
416 template <
typename ResultType>
417 inline void evalTo(ResultType& result)
const {
430 template <
typename Derived>
436 template <
typename Derived>
int i
Definition: BiCGSTAB_step_by_step.cpp:9
MatrixXcd V
Definition: EigenSolver_EigenSolver_MatrixType.cpp:15
#define eigen_assert(x)
Definition: Macros.h:910
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 100 >, boost::multiprecision::et_on > Real
Definition: boostmultiprec.cpp:77
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:192
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
Definition: ReturnByValue.h:50
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
void matrix_exp_pade7(const MatA &A, MatU &U, MatV &V)
Compute the (7,7)-Padé approximant to the exponential.
Definition: MatrixExponential.h:97
void matrix_exp_pade9(const MatA &A, MatU &U, MatV &V)
Compute the (9,9)-Padé approximant to the exponential.
Definition: MatrixExponential.h:115
void matrix_exp_compute(const ArgType &arg, ResultType &result, true_type)
Definition: MatrixExponential.h:364
void matrix_exp_pade3(const MatA &A, MatU &U, MatV &V)
Compute the (3,3)-Padé approximant to the exponential.
Definition: MatrixExponential.h:64
void matrix_exp_pade13(const MatA &A, MatU &U, MatV &V)
Compute the (13,13)-Padé approximant to the exponential.
Definition: MatrixExponential.h:136
void matrix_exp_pade5(const MatA &A, MatU &U, MatV &V)
Compute the (5,5)-Padé approximant to the exponential.
Definition: MatrixExponential.h:80
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
double U
Swimming speed.
Definition: two_d_variable_diff_adapt.cc:53
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
Proxy for the matrix exponential of some matrix (expression).
Definition: MatrixExponential.h:404
void evalTo(ResultType &result) const
Compute the matrix exponential.
Definition: MatrixExponential.h:417
MatrixExponentialReturnValue(const Derived &src)
Constructor.
Definition: MatrixExponential.h:410
Index rows() const
Definition: MatrixExponential.h:422
const internal::ref_selector< Derived >::type m_src
Definition: MatrixExponential.h:426
Index cols() const
Definition: MatrixExponential.h:423
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Scaling operator.
Definition: MatrixExponential.h:27
const ComplexScalar operator()(const ComplexScalar &x) const
Scale a matrix coefficient.
Definition: MatrixExponential.h:49
int m_squarings
Definition: MatrixExponential.h:55
std::complex< RealScalar > ComplexScalar
Definition: MatrixExponential.h:43
const RealScalar operator()(const RealScalar &x) const
Scale a matrix coefficient.
Definition: MatrixExponential.h:38
MatrixExponentialScalingOp(int squarings)
Constructor.
Definition: MatrixExponential.h:32
Definition: MatrixExponential.h:353
NumTraits< typename traits< MatrixType >::Scalar >::Real RealScalar
Definition: MatrixExponential.h:245
static void run(const ArgType &arg, MatrixType &U, MatrixType &V, int &squarings)
Definition: MatrixExponential.h:247
static void run(const ArgType &arg, MatrixType &U, MatrixType &V, int &squarings)
Definition: MatrixExponential.h:224
static void run(const ArgType &arg, MatrixType &U, MatrixType &V, int &squarings)
Definition: MatrixExponential.h:273
Compute the (17,17)-Padé approximant to the exponential.
Definition: MatrixExponential.h:210
static void run(const MatrixType &arg, MatrixType &U, MatrixType &V, int &squarings)
Compute Padé approximant to the exponential.
std::conditional_t< Evaluate, PlainObject, typename ref_selector< T >::type > type
Definition: XprHelper.h:549
std::conditional_t< bool(traits< T >::Flags &NestByRefBit), T const &, const T > type
Definition: XprHelper.h:507
Derived::PlainObject ReturnType
Definition: MatrixExponential.h:432
Definition: ForwardDeclarations.h:21