Linear solver. More...
#include <linsol.hpp>
Create a solver for linear systems of equations Solves the linear system A*X = B or A^T*X = B for X with A square and non-singular
If A is structurally singular, an error will be thrown during init. If A is numerically singular, the prepare step will fail.
- csparse
- ma27
- lapacklu
- lapackqr
- mumps
- ldl
- qr
- tridiag
Note: some of the plugins in this list might not be available on your system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Linsol.doc("myextraplugin")
Linsol with CSparseCholesky Interface
Extra doc: https://github.com/casadi/casadi/wiki/L_21u
Linsol with CSparse Interface
Extra doc: https://github.com/casadi/casadi/wiki/L_21t
Interface to the sparse direct linear solver MA27 Works for symmetric indefinite systems Partly adopted from qpOASES 3.2
Extra doc: https://github.com/casadi/casadi/wiki/L_229
This class solves the linear system A.x=b
by making an LU factorization of A:
A = L.U
, with L lower and U upper triangular
Extra doc: https://github.com/casadi/casadi/wiki/L_22h
Id | Type | Description |
---|---|---|
allow_equilibration_failure | OT_BOOL | Non-fatal error when equilibration fails |
equilibration | OT_BOOL | Equilibrate the matrix |
This class solves the linear system A.x=b
by making an QR factorization of A:
A = Q.R
, with Q orthogonal and R upper triangular
Extra doc: https://github.com/casadi/casadi/wiki/L_22g
Id | Type | Description |
---|---|---|
max_nrhs | OT_INT | Maximum number of right-hand-sides that get processed in a single pass [default:10]. |
Interface to the sparse direct linear solver MUMPS Works for symmetric indefinite systems
Extra doc: https://github.com/casadi/casadi/wiki/L_22t
Id | Type | Description |
---|---|---|
posdef | OT_BOOL | Positive definite |
symmetric | OT_BOOL | Symmetric matrix |
Linear solver using sparse direct LDL factorization
Extra doc: https://github.com/casadi/casadi/wiki/L_233
Id | Type | Description |
---|---|---|
incomplete | OT_BOOL | Incomplete factorization, without any fill-in |
preordering | OT_BOOL | Approximate minimal degree (AMD) preordering |
Linear solver using sparse direct QR factorization
Extra doc: https://github.com/casadi/casadi/wiki/L_22z
Id | Type | Description |
---|---|---|
cache | OT_DOUBLE | Amount of factorisations to remember (thread-local) [0] |
eps | OT_DOUBLE | Minimum R entry before singularity is declared [1e-12] |
Linear solver for tridiagonal matrices
Extra doc: https://github.com/casadi/casadi/wiki/L_22v
Linear solver for sparse least-squares problems Inspired from https://github.com/scipy/scipy/blob/v0.14.0/scipy/sparse/linalg/isolve/lsqr.py#L96
Extra doc: https://github.com/casadi/casadi/wiki/L_230
Linsol based on QR factorization with sparsity pattern based reordering without partial pivoting
Extra doc: https://github.com/casadi/casadi/wiki/L_231
Id | Type | Description |
---|---|---|
fopts | OT_DICT | Options to be passed to generated function objects |
Extra doc: https://github.com/casadi/casadi/wiki/L_1kh
Definition at line 53 of file linsol.hpp.
Public Types | |
using | internal_base_type = SharedObjectInternal |
using | base_type = SharedObject |
Public Member Functions | |
Linsol () | |
Default constructor. More... | |
Linsol (const std::string &name, const std::string &solver, const Sparsity &sp, const Dict &opts=Dict()) | |
Constructor. More... | |
LinsolInternal * | operator-> () |
Access functions of the node. More... | |
const LinsolInternal * | operator-> () const |
std::string | plugin_name () const |
Query plugin name. More... | |
const Sparsity & | sparsity () const |
Get linear system sparsity. More... | |
void | sfact (const DM &A) const |
Symbolic factorization of the linear system, e.g. selecting pivots. More... | |
void | nfact (const DM &A) const |
Numeric factorization of the linear system. More... | |
casadi_int | neig (const DM &A) const |
Number of negative eigenvalues. More... | |
casadi_int | rank (const DM &A) const |
Matrix rank. More... | |
Dict | stats (int mem=1) const |
Get all statistics obtained at the end of the last evaluate call. More... | |
casadi_int | checkout () const |
Checkout a memory object. More... | |
void | release (int mem) const |
Release a memory object. More... | |
void | serialize (SerializingStream &s) const |
Serialize an object. More... | |
std::string | class_name () const |
Get class name. More... | |
void | disp (std::ostream &stream, bool more=false) const |
Print a description of the object. More... | |
std::string | get_str (bool more=false) const |
Get string representation. More... | |
void | print_ptr (std::ostream &stream=casadi::uout()) const |
void | own (SharedObjectInternal *node) |
void | assign (SharedObjectInternal *node) |
Assign the node to a node class pointer without reference counting. More... | |
SharedObjectInternal * | get () const |
Get a const pointer to the node. More... | |
casadi_int | getCount () const |
Get the reference count. More... | |
void | swap (GenericShared &other) |
Swap content with another instance. More... | |
std::string | debug_repr () const |
bool | is_null () const |
Is a null pointer? More... | |
casadi_int | __hash__ () const |
Returns a number that is unique for a given Node. More... | |
GenericWeakRef< SharedObject, SharedObjectInternal > * | weak () |
Get a weak reference to the object. More... | |
DM | solve (const DM &A, const DM &B, bool tr=false) const |
MX | solve (const MX &A, const MX &B, bool tr=false) const |
int | sfact (const double *A, int mem=0) const |
int | nfact (const double *A, int mem=0) const |
int | solve (const double *A, double *x, casadi_int nrhs=1, bool tr=false, int mem=0) const |
casadi_int | neig (const double *A, int mem=0) const |
casadi_int | rank (const double *A, int mem=0) const |
Static Public Member Functions | |
static std::string | type_name () |
Get type name. More... | |
static bool | test_cast (const SharedObjectInternal *ptr) |
Check if a particular cast is allowed. More... | |
static Linsol | create (LinsolInternal *node) |
Create from node. More... | |
static bool | has_plugin (const std::string &name) |
Check if a plugin is available. More... | |
static void | load_plugin (const std::string &name) |
Explicitly load a plugin dynamically. More... | |
static std::string | doc (const std::string &name) |
Get solver specific documentation. More... | |
static Linsol | deserialize (DeserializingStream &s) |
Deserialize with type disambiguation. More... | |
Protected Member Functions | |
void | count_up () |
void | count_down () |
|
inherited |
Definition at line 103 of file shared_object.hpp.
|
inherited |
Definition at line 102 of file shared_object.hpp.
casadi::Linsol::Linsol | ( | ) |
Definition at line 32 of file linsol.cpp.
|
explicit |
Definition at line 35 of file linsol.cpp.
References casadi::PluginInterface< LinsolInternal >::getPlugin(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::own().
|
inherited |
If the Object does not point to any node, "0" is returned.
Extra doc: https://github.com/casadi/casadi/wiki/L_av
Definition at line 124 of file generic_shared_impl.hpp.
|
inherited |
improper use will cause memory leaks!
Extra doc: https://github.com/casadi/casadi/wiki/L_at
Definition at line 97 of file generic_shared_impl.hpp.
casadi_int casadi::Linsol::checkout | ( | ) | const |
Definition at line 197 of file linsol.cpp.
Referenced by casadi::SundialsInterface::init_mem(), and casadi::Ipqp::solve().
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_au
Definition at line 31 of file shared_object.cpp.
Referenced by casadi::FmuFunction::check_mem_count(), casadi::MXFunction::export_code_body(), and casadi::BlazingSplineFunction::merge().
|
protectedinherited |
Definition at line 134 of file generic_shared_impl.hpp.
|
protectedinherited |
Definition at line 133 of file generic_shared_impl.hpp.
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_1kj
Definition at line 236 of file linsol.cpp.
References casadi::GenericShared< Shared, Internal >::own().
|
inherited |
Definition at line 113 of file generic_shared_impl.hpp.
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_1kn
Definition at line 229 of file linsol.cpp.
References casadi::LinsolInternal::deserialize(), casadi::ProtoFunction::finalize(), and casadi::GenericShared< Shared, Internal >::own().
|
inherited |
Definition at line 35 of file shared_object.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().
Referenced by casadi::Nlpsol::disp_more(), and casadi::CsparseInterface::nfact().
|
static |
Definition at line 61 of file linsol.cpp.
References casadi::PluginInterface< LinsolInternal >::getPlugin().
Referenced by casadi::doc_linsol().
|
inherited |
Definition at line 100 of file generic_shared_impl.hpp.
|
inlineinherited |
Definition at line 91 of file shared_object.hpp.
|
inherited |
Definition at line 103 of file generic_shared_impl.hpp.
|
static |
Definition at line 53 of file linsol.cpp.
References casadi::PluginInterface< LinsolInternal >::has_plugin().
Referenced by casadi::has_linsol().
|
inherited |
Definition at line 117 of file generic_shared_impl.hpp.
|
static |
Definition at line 57 of file linsol.cpp.
References casadi::PluginInterface< LinsolInternal >::load_plugin().
Referenced by casadi::load_linsol().
casadi_int casadi::Linsol::neig | ( | const DM & | A | ) | const |
Not available for all solvers
Extra doc: https://github.com/casadi/casadi/wiki/L_1kk
Definition at line 166 of file linsol.cpp.
References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().
Referenced by casadi::QpoasesInterface::qpoases_nfact().
casadi_int casadi::Linsol::neig | ( | const double * | A, |
int | mem = 0 |
||
) | const |
Low-level API
Definition at line 173 of file linsol.cpp.
void casadi::Linsol::nfact | ( | const DM & | A | ) | const |
Definition at line 127 of file linsol.cpp.
References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().
Referenced by casadi::SlicotDple::eval(), casadi::KinsolInterface::psetup(), casadi::QpoasesInterface::qpoases_nfact(), solve(), casadi::Ipqp::solve(), and casadi::Newton::solve().
int casadi::Linsol::nfact | ( | const double * | A, |
int | mem = 0 |
||
) | const |
Low-level API
Definition at line 132 of file linsol.cpp.
References casadi::Sparsity::export_code(), casadi::LinsolMemory::is_nfact, casadi::Filesystem::open(), sfact(), and sparsity().
LinsolInternal * casadi::Linsol::operator-> | ( | ) |
Definition at line 41 of file linsol.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().
const LinsolInternal * casadi::Linsol::operator-> | ( | ) | const |
Definition at line 45 of file linsol.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().
|
inherited |
Assign the node to a node class pointer (or null)
Definition at line 90 of file generic_shared_impl.hpp.
std::string casadi::Linsol::plugin_name | ( | ) | const |
Definition at line 65 of file linsol.cpp.
|
inherited |
Print the pointer to the internal class
Definition at line 43 of file shared_object.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().
casadi_int casadi::Linsol::rank | ( | const DM & | A | ) | const |
Not available for all solvers
Extra doc: https://github.com/casadi/casadi/wiki/L_1kl
Definition at line 177 of file linsol.cpp.
References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().
Referenced by casadi::QpoasesInterface::qpoases_nfact().
casadi_int casadi::Linsol::rank | ( | const double * | A, |
int | mem = 0 |
||
) | const |
Low-level API
Definition at line 184 of file linsol.cpp.
void casadi::Linsol::release | ( | int | mem | ) | const |
Definition at line 201 of file linsol.cpp.
Referenced by casadi::Ipqp::solve().
void casadi::Linsol::serialize | ( | SerializingStream & | s | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_1km
Definition at line 224 of file linsol.cpp.
void casadi::Linsol::sfact | ( | const DM & | A | ) | const |
Definition at line 105 of file linsol.cpp.
References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().
Referenced by casadi::SlicotDple::eval(), nfact(), casadi::QpoasesInterface::qpoases_sfact(), and solve().
int casadi::Linsol::sfact | ( | const double * | A, |
int | mem = 0 |
||
) | const |
Solve linear system of equations
Definition at line 73 of file linsol.cpp.
References casadi::GenericMatrix< MatType >::dim(), nfact(), casadi::Matrix< Scalar >::ptr(), sfact(), casadi::GenericMatrix< MatType >::size1(), casadi::GenericMatrix< MatType >::size2(), casadi::ProtoFunctionMemory::t_total, and casadi::FStats::tic().
Referenced by casadi::SlicotDple::eval(), casadi::KinsolInterface::psolve(), casadi::QpoasesInterface::qpoases_solve(), casadi::Ipqp::solve(), casadi::LinsolCall< Tr >::solve(), casadi::MX::solve(), casadi::Newton::solve(), and casadi::IdasInterface::solve_transposed().
int casadi::Linsol::solve | ( | const double * | A, |
double * | x, | ||
casadi_int | nrhs = 1 , |
||
bool | tr = false , |
||
int | mem = 0 |
||
) | const |
Solve linear system of equations
Definition at line 101 of file linsol.cpp.
References casadi::MXNode::get_solve().
const Sparsity & casadi::Linsol::sparsity | ( | ) | const |
Definition at line 69 of file linsol.cpp.
Referenced by casadi::SundialsInterface::init(), neig(), nfact(), rank(), casadi::SundialsInterface::set_work(), and sfact().
Dict casadi::Linsol::stats | ( | int | mem = 1 | ) | const |
Definition at line 218 of file linsol.cpp.
|
inherited |
Definition at line 106 of file generic_shared_impl.hpp.
|
static |
Definition at line 49 of file linsol.cpp.
|
inlinestatic |
Extra doc: https://github.com/casadi/casadi/wiki/L_1ki
Definition at line 60 of file linsol.hpp.
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_aw
Definition at line 131 of file generic_shared_impl.hpp.