12#ifndef SANDALS_LINEAR_SYSTEM_HH
13#define SANDALS_LINEAR_SYSTEM_HH
39 template <
typename Real, Integer N, Integer M = 0>
46 using Pointer = std::shared_ptr<SemiExplicit<Real, N, M>>;
55 Eigen::FullPivLU<MatrixE>
m_lu;
84 return this->
E(t)*x_dot - this->
A(t)*x - this->
b(t);
134 this->m_lu.compute(this->
E(t));
135 SANDALS_ASSERT(this->m_lu.rank() == N,
"Sandals:Linear::f(...): singular mass matrix E(t) detected.");
136 return this->m_lu.solve(this->
A(t)*x + this->
b(t));
154 this->m_lu.compute(this->
E(t));
155 SANDALS_ASSERT(this->m_lu.rank() == N,
"Sandals:Linear::Jf_x(...): singular mass matrix E(t) detected.");
156 return this->m_lu.solve(this->
A(t));
201 template <
typename Real, Integer N, Integer M = 0>
343 return this->
m_h(x, t);
361 return this->
m_Jh_x(x, t);
#define SANDALS_BASIC_CONSTANTS(Real)
Definition Sandals.hh:70
#define SANDALS_ASSERT(COND, MSG)
Definition Sandals.hh:44
Class container for the system of explicit ODEs.
Definition Explicit.hh:42
Explicit(Type t_type, std::string t_name)
Definition Explicit.hh:57
typename Implicit< Real, N, M >::Type Type
Definition Explicit.hh:49
typename Implicit< Real, N, M >::MatrixJF MatrixJF
Definition Explicit.hh:48
typename Implicit< Real, N, M >::VectorF VectorF
Definition Explicit.hh:47
typename Explicit< Real, N, M >::Type Type
Definition Linear.hh:52
Eigen::FullPivLU< MatrixE > m_lu
Definition Linear.hh:55
virtual VectorB b(Real t) const =0
typename Explicit< Real, N, M >::VectorF VectorF
Definition Linear.hh:47
typename Explicit< Real, N, M >::MatrixJF MatrixA
Definition Linear.hh:50
MatrixJF JF_x_dot(VectorF const &, VectorF const &, Real t) const override
Definition Linear.hh:119
VectorF f(VectorF const &x, Real t) const override
Definition Linear.hh:132
typename Explicit< Real, N, M >::MatrixJF MatrixE
Definition Linear.hh:49
virtual MatrixE E(Real t) const =0
VectorF F(VectorF const &x, VectorF const &x_dot, Real t) const override
Definition Linear.hh:82
Linear()
Definition Linear.hh:61
typename Explicit< Real, N, M >::MatrixJF MatrixJF
Definition Linear.hh:48
typename Explicit< Real, N, M >::VectorF VectorB
Definition Linear.hh:51
std::shared_ptr< SemiExplicit< Real, N, M > > Pointer
Definition Linear.hh:46
const Real SQRT_EPSILON
Definition Linear.hh:44
MatrixJF Jf_x(VectorF const &, Real t) const override
Definition Linear.hh:152
virtual MatrixA A(Real t) const =0
MatrixJF JF_x(VectorF const &, VectorF const &, Real t) const override
Definition Linear.hh:102
Linear(std::string t_name)
Definition Linear.hh:67
std::function< MatrixJH(VectorF const &, Real)> FunctionJH
Definition Linear.hh:219
LinearWrapper(FunctionE t_E, FunctionA t_A, FunctionB t_b, FunctionH t_h=DefaultH, FunctionJH t_Jh_x=DefaultJH, FunctionID t_in_domain=DefaultID)
Definition Linear.hh:244
std::function< VectorB(Real)> FunctionB
Definition Linear.hh:217
bool in_domain(VectorF const &x, Real t) const override
Definition Linear.hh:371
FunctionH & h()
Definition Linear.hh:291
typename Explicit< Real, N, M >::VectorH VectorH
Definition Linear.hh:213
~LinearWrapper()
Definition Linear.hh:267
static const FunctionH DefaultH
Definition Linear.hh:222
std::function< bool(VectorF const &, Real)> FunctionID
Definition Linear.hh:220
FunctionH m_h
Definition Linear.hh:230
FunctionB m_b
Definition Linear.hh:229
FunctionID & in_domain()
Definition Linear.hh:303
static const FunctionJH DefaultJH
Definition Linear.hh:223
LinearWrapper(std::string t_name, FunctionE t_E, FunctionA t_A, FunctionB t_b, FunctionH t_h=DefaultH, FunctionJH t_Jh_x=DefaultJH, FunctionID t_in_domain=DefaultID)
Definition Linear.hh:259
FunctionB & b()
Definition Linear.hh:285
std::function< MatrixA(Real)> FunctionA
Definition Linear.hh:216
FunctionE & E()
Definition Linear.hh:273
FunctionE m_E
Definition Linear.hh:227
std::function< VectorH(VectorF const &, Real)> FunctionH
Definition Linear.hh:218
typename Explicit< Real, N, M >::MatrixJH MatrixJH
Definition Linear.hh:214
FunctionA m_A
Definition Linear.hh:228
FunctionID m_in_domain
Definition Linear.hh:232
static const FunctionID DefaultID
Definition Linear.hh:224
typename Linear< Real, N, M >::VectorF VectorF
Definition Linear.hh:208
typename Linear< Real, N, M >::MatrixJF MatrixJF
Definition Linear.hh:209
MatrixJH Jh_x(VectorF const &x, Real t) const override
Definition Linear.hh:359
FunctionJH & Jh_x()
Definition Linear.hh:297
typename Linear< Real, N, M >::MatrixJF MatrixA
Definition Linear.hh:211
std::function< MatrixE(Real)> FunctionE
Definition Linear.hh:215
std::shared_ptr< LinearWrapper< Real, N, M > > Pointer
Definition Linear.hh:207
MatrixE E(Real t) const override
Definition Linear.hh:310
VectorB b(Real t) const override
Definition Linear.hh:330
FunctionA & A()
Definition Linear.hh:279
VectorH h(VectorF const &x, Real t) const override
Definition Linear.hh:341
typename Linear< Real, N, M >::MatrixJF MatrixE
Definition Linear.hh:210
MatrixA A(Real t) const override
Definition Linear.hh:320
typename Linear< Real, N, M >::VectorF VectorB
Definition Linear.hh:212
FunctionJH m_Jh_x
Definition Linear.hh:231
The namespace for the Sandals library.
Definition Sandals.hh:89