List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
casadi::Linsol Class Reference

Linear solver. More...

#include <linsol.hpp>

Detailed Description

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.

General information

List of plugins

- csparsecholesky

- csparse

- ma27

- lapacklu

- lapackqr

- mumps

- ldl

- qr

- tridiag

- symbolicqr

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")


csparsecholesky

Linsol with CSparseCholesky Interface

Extra doc: https://github.com/casadi/casadi/wiki/L_21u


csparse

Linsol with CSparse Interface

Extra doc: https://github.com/casadi/casadi/wiki/L_21t


ma27

Interface to the sparse direct linear solver MA27 Works for symmetric indefinite systems Partly adopted from qpOASES 3.2

Author
Joel Andersson
Date
2016

Extra doc: https://github.com/casadi/casadi/wiki/L_229


lapacklu

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


List of available options
IdTypeDescription
allow_equilibration_failureOT_BOOLNon-fatal error when equilibration fails
equilibrationOT_BOOLEquilibrate the matrix

lapackqr

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


List of available options
IdTypeDescription
max_nrhsOT_INTMaximum number of right-hand-sides that get processed in a single pass [default:10].

mumps

Interface to the sparse direct linear solver MUMPS Works for symmetric indefinite systems

Author
Joel Andersson
Date
2019

Extra doc: https://github.com/casadi/casadi/wiki/L_22t


List of available options
IdTypeDescription
posdefOT_BOOLPositive definite
symmetricOT_BOOLSymmetric matrix

ldl

Linear solver using sparse direct LDL factorization

Extra doc: https://github.com/casadi/casadi/wiki/L_233


List of available options
IdTypeDescription
incompleteOT_BOOLIncomplete factorization, without any fill-in
preorderingOT_BOOLApproximate minimal degree (AMD) preordering

qr

Linear solver using sparse direct QR factorization

Extra doc: https://github.com/casadi/casadi/wiki/L_22z


List of available options
IdTypeDescription
cacheOT_DOUBLEAmount of factorisations to remember (thread-local) [0]
epsOT_DOUBLEMinimum R entry before singularity is declared [1e-12]

tridiag

Linear solver for tridiagonal matrices

Extra doc: https://github.com/casadi/casadi/wiki/L_22v


symbolicqr

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


List of available options
IdTypeDescription
foptsOT_DICTOptions to be passed to generated function objects
Author
Joel Andersson
Date
2011-2016

Extra doc: https://github.com/casadi/casadi/wiki/L_1kh

Definition at line 53 of file linsol.hpp.

Inheritance diagram for casadi::Linsol:
Inheritance graph
[legend]
Collaboration diagram for casadi::Linsol:
Collaboration graph
[legend]

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...
 
LinsolInternaloperator-> ()
 Access functions of the node. More...
 
const LinsolInternaloperator-> () const
 
std::string plugin_name () const
 Query plugin name. More...
 
const Sparsitysparsity () 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...
 
SharedObjectInternalget () 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 ()
 

Member Typedef Documentation

◆ base_type

Definition at line 103 of file shared_object.hpp.

◆ internal_base_type

Definition at line 102 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ Linsol() [1/2]

casadi::Linsol::Linsol ( )

Definition at line 32 of file linsol.cpp.

32  {
33  }

◆ Linsol() [2/2]

casadi::Linsol::Linsol ( const std::string &  name,
const std::string &  solver,
const Sparsity sp,
const Dict opts = Dict() 
)
explicit

Definition at line 35 of file linsol.cpp.

36  {
37  own(LinsolInternal::getPlugin(solver).creator(name, sp));
38  (*this)->construct(opts);
39  }
static Plugin & getPlugin(const std::string &pname)
Load and get the creator function.

References casadi::PluginInterface< LinsolInternal >::getPlugin(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::own().

Member Function Documentation

◆ __hash__()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::__hash__
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 123 of file generic_shared_impl.hpp.

141  {
142  return reinterpret_cast<casadi_int>(get());
143  }

◆ assign()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::assign ( Internal *  node)
inherited

improper use will cause memory leaks!

Extra doc: https://github.com/casadi/casadi/wiki/L_at

Definition at line 96 of file generic_shared_impl.hpp.

79  {
80  node = node_;
81  }

◆ checkout()

casadi_int casadi::Linsol::checkout ( ) const

Definition at line 196 of file linsol.cpp.

196  {
197  return (*this)->checkout();
198  }

Referenced by casadi::SundialsInterface::init_mem(), and casadi::Ipqp::solve().

◆ class_name()

std::string casadi::SharedObject::class_name ( ) const
inherited

◆ count_down()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_down
protectedinherited

Definition at line 133 of file generic_shared_impl.hpp.

46  {
47 #ifdef WITH_EXTRA_CHECKS
48  casadi_assert_dev(Function::call_depth_==0);
49 #endif // WITH_EXTRA_CHECKS
50  if (!node) return;
51  if (node->weak_ref_) {
52 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
53  auto mutex = node->weak_ref_->get_mutex();
54  // Avoid triggering a delete while a weak_ref.shared_if_alive is being called
55  std::lock_guard<std::mutex> lock(*mutex);
56  // Could it be that this mutex is destroyed when the lock goes out of scope?
57 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
58 
59  if (--static_cast<Internal*>(node)->count == 0) {
60  delete node;
61  node = nullptr;
62  }
63  } else {
64  if (--static_cast<Internal*>(node)->count == 0) {
65  delete node;
66  node = nullptr;
67  }
68  }
69  }

◆ count_up()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_up
protectedinherited

Definition at line 132 of file generic_shared_impl.hpp.

36  {
37 #ifdef WITH_EXTRA_CHECKS
38  casadi_assert_dev(Function::call_depth_==0);
39 #endif // WITH_EXTRA_CHECKS
40 
41  if (node) static_cast<Internal*>(node)->count++;
42 
43  }

◆ create()

Linsol casadi::Linsol::create ( LinsolInternal node)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1kj

Definition at line 235 of file linsol.cpp.

235  {
236  Linsol ret;
237  ret.own(node);
238  return ret;
239  }
Linsol()
Default constructor.
Definition: linsol.cpp:32

References casadi::GenericShared< Shared, Internal >::own().

◆ debug_repr()

std::string casadi::GenericShared< SharedObject , SharedObjectInternal >::debug_repr
inherited

Definition at line 112 of file generic_shared_impl.hpp.

84  {
85  if (node) {
86  return node->debug_repr(node);
87  } else {
88  return "NULL";
89  }
90  }
std::string debug_repr(const Internal *) const

◆ deserialize()

Linsol casadi::Linsol::deserialize ( DeserializingStream s)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1kn

Definition at line 228 of file linsol.cpp.

228  {
229  Linsol linsol;
230  linsol.own(LinsolInternal::deserialize(s));
231  linsol->finalize();
232  return linsol;
233  }
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize with type disambiguation.

References casadi::LinsolInternal::deserialize(), casadi::ProtoFunction::finalize(), and casadi::GenericShared< Shared, Internal >::own().

◆ disp()

void casadi::SharedObject::disp ( std::ostream &  stream,
bool  more = false 
) const
inherited

Definition at line 35 of file shared_object.cpp.

35  {
36  if (is_null()) {
37  stream << "NULL";
38  } else {
39  (*this)->disp(stream, more);
40  }
41  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

Referenced by casadi::Nlpsol::disp_more(), and casadi::CsparseInterface::nfact().

◆ doc()

std::string casadi::Linsol::doc ( const std::string &  name)
static

Definition at line 61 of file linsol.cpp.

61  {
62  return LinsolInternal::getPlugin(name).doc;
63  }

References casadi::PluginInterface< LinsolInternal >::getPlugin().

Referenced by casadi::doc_linsol().

◆ get()

Definition at line 99 of file generic_shared_impl.hpp.

108  {
109  return node;
110  }

◆ get_str()

std::string casadi::SharedObject::get_str ( bool  more = false) const
inlineinherited

Definition at line 91 of file shared_object.hpp.

91  {
92  std::stringstream ss;
93  disp(ss, more);
94  return ss.str();
95  }
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.

◆ getCount()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::getCount
inherited

Definition at line 102 of file generic_shared_impl.hpp.

131  {
132  return (*this)->getCount();
133  }

◆ has_plugin()

bool casadi::Linsol::has_plugin ( const std::string &  name)
static

Definition at line 53 of file linsol.cpp.

53  {
54  return LinsolInternal::has_plugin(name);
55  }
static bool has_plugin(const std::string &pname, bool verbose=false)
Check if a plugin is available or can be loaded.

References casadi::PluginInterface< LinsolInternal >::has_plugin().

Referenced by casadi::has_linsol().

◆ is_null()

Definition at line 116 of file generic_shared_impl.hpp.

113  {
114  return node==nullptr;
115  }

◆ load_plugin()

void casadi::Linsol::load_plugin ( const std::string &  name)
static

Definition at line 57 of file linsol.cpp.

57  {
59  }
static Plugin load_plugin(const std::string &pname, bool register_plugin=true, bool needs_lock=true)
Load a plugin dynamically.

References casadi::PluginInterface< LinsolInternal >::load_plugin().

Referenced by casadi::load_linsol().

◆ neig() [1/2]

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 165 of file linsol.cpp.

165  {
166  if (A.sparsity()!=sparsity()) return neig(project(A, sparsity()));
167  casadi_int n = neig(A.ptr());
168  casadi_assert(n>=0, "'neig' failed");
169  return n;
170  }
const Sparsity & sparsity() const
Get linear system sparsity.
Definition: linsol.cpp:69
casadi_int neig(const DM &A) const
Number of negative eigenvalues.
Definition: linsol.cpp:165

References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().

Referenced by casadi::QpoasesInterface::qpoases_nfact().

◆ neig() [2/2]

casadi_int casadi::Linsol::neig ( const double *  A,
int  mem = 0 
) const

Low-level API

Definition at line 172 of file linsol.cpp.

172  {
173  return (*this)->neig((*this)->memory(mem), A);
174  }

◆ nfact() [1/2]

void casadi::Linsol::nfact ( const DM A) const

Definition at line 127 of file linsol.cpp.

127  {
128  if (A.sparsity()!=sparsity()) return nfact(project(A, sparsity()));
129  if (nfact(A.ptr())) casadi_error("'nfact' failed");
130  }
void nfact(const DM &A) const
Numeric factorization of the linear system.
Definition: linsol.cpp:127

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().

◆ nfact() [2/2]

int casadi::Linsol::nfact ( const double *  A,
int  mem = 0 
) const

Low-level API

Definition at line 132 of file linsol.cpp.

132  {
133  if (A==nullptr) return 1;
134  auto m = static_cast<LinsolMemory*>((*this)->memory(mem));
135 
136  // Perform pivoting, if required
137  if (!m->is_sfact) {
138  if (sfact(A, mem)) return 1;
139  }
140 
141  m->is_nfact = false;
142  if (m->t_total) m->fstats.at("nfact").tic();
143  int flag = (*this)->nfact(m, A);
144  if (m->t_total) m->fstats.at("nfact").toc();
145  if (flag && (*this)->regularity_check_) {
146  // Collect nonzeros
147  std::vector<std::string> nonzeros(sparsity().nnz());
148  for (size_t nz = 0; nz < nonzeros.size(); ++nz)
149  nonzeros[nz] = std::to_string(A[nz]);
150  // Create .m file
151  std::string fname = (*this)->class_name() + "_" + (*this)->name_ + "_debug.m";
152  auto mfile_ptr = Filesystem::ofstream_ptr(fname);
153  std::ostream& mfile = *mfile_ptr;
154  Dict opts;
155  opts["name"] = "A";
156  opts["nonzeros"] = nonzeros;
157  sparsity().export_code("matlab", mfile, opts);
158  casadi_error("Numerical factorization failed for " + (*this)->name_
159  + "[" + (*this)->class_name() + "]. Linear system saved to '" + fname + "'");
160  }
161  m->is_nfact = true;
162  return flag;
163  }
static std::unique_ptr< std::ostream > ofstream_ptr(const std::string &path, std::ios_base::openmode mode=std::ios_base::out)
Definition: filesystem.cpp:115
void sfact(const DM &A) const
Symbolic factorization of the linear system, e.g. selecting pivots.
Definition: linsol.cpp:105
void export_code(const std::string &lang, std::ostream &stream=casadi::uout(), const Dict &options=Dict()) const
Export matrix in specific language.
Definition: sparsity.cpp:778
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References casadi::Sparsity::export_code(), casadi::LinsolMemory::is_nfact, casadi::Filesystem::ofstream_ptr(), sfact(), and sparsity().

◆ operator->() [1/2]

LinsolInternal * casadi::Linsol::operator-> ( )

Definition at line 41 of file linsol.cpp.

41  {
42  return static_cast<LinsolInternal*>(SharedObject::operator->());
43  }
SharedObjectInternal * operator->() const
Access a member function or object.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ operator->() [2/2]

const LinsolInternal * casadi::Linsol::operator-> ( ) const

Definition at line 45 of file linsol.cpp.

45  {
46  return static_cast<const LinsolInternal*>(SharedObject::operator->());
47  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ own()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::own ( Internal *  node)
inherited

Assign the node to a node class pointer (or null)

Definition at line 89 of file generic_shared_impl.hpp.

◆ plugin_name()

std::string casadi::Linsol::plugin_name ( ) const

Definition at line 65 of file linsol.cpp.

65  {
66  return (*this)->plugin_name();
67  }

◆ print_ptr()

void casadi::SharedObject::print_ptr ( std::ostream &  stream = casadi::uout()) const
inherited

Print the pointer to the internal class

Definition at line 43 of file shared_object.cpp.

43  {
44  stream << get();
45  }
SharedObjectInternal * get() const
Get a const pointer to the node.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().

◆ rank() [1/2]

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 176 of file linsol.cpp.

176  {
177  if (A.sparsity()!=sparsity()) return rank(project(A, sparsity()));
178  casadi_int n = rank(A.ptr());
179  casadi_assert(n>=0, "'rank' failed");
180  return n;
181  }
casadi_int rank(const DM &A) const
Matrix rank.
Definition: linsol.cpp:176

References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().

Referenced by casadi::QpoasesInterface::qpoases_nfact().

◆ rank() [2/2]

casadi_int casadi::Linsol::rank ( const double *  A,
int  mem = 0 
) const

Low-level API

Definition at line 183 of file linsol.cpp.

183  {
184  return (*this)->rank((*this)->memory(mem), A);
185  }

◆ release()

void casadi::Linsol::release ( int  mem) const

Definition at line 200 of file linsol.cpp.

200  {
201  (*this)->release(mem);
202  }

Referenced by casadi::Ipqp::solve().

◆ serialize()

void casadi::Linsol::serialize ( SerializingStream s) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1km

Definition at line 223 of file linsol.cpp.

223  {
224  // TODO(jgillis): I don't get why LinsolInternal:: this is necessary
225  return (*this)->LinsolInternal::serialize(s);
226  }

◆ sfact() [1/2]

void casadi::Linsol::sfact ( const DM A) const

Definition at line 105 of file linsol.cpp.

105  {
106  if (A.sparsity()!=sparsity()) return sfact(project(A, sparsity()));
107  if (sfact(A.ptr())) casadi_error("'sfact' failed");
108  }

References casadi::Matrix< Scalar >::ptr(), sparsity(), and casadi::Matrix< Scalar >::sparsity().

Referenced by casadi::SlicotDple::eval(), nfact(), casadi::QpoasesInterface::qpoases_sfact(), and solve().

◆ sfact() [2/2]

int casadi::Linsol::sfact ( const double *  A,
int  mem = 0 
) const

Low-level API

Definition at line 110 of file linsol.cpp.

110  {
111  if (A==nullptr) return 1;
112  auto m = static_cast<LinsolMemory*>((*this)->memory(mem));
113 
114  // Factorization will be needed after this step
115  m->is_sfact = m->is_nfact = false;
116 
117  if (m->t_total) m->fstats.at("sfact").tic();
118  // Perform pivoting
119  if ((*this)->sfact(m, A)) return 1;
120  if (m->t_total) m->fstats.at("sfact").toc();
121 
122  // Mark as (successfully) pivoted
123  m->is_sfact = true;
124  return 0;
125  }

References casadi::LinsolMemory::is_sfact.

◆ solve() [1/3]

DM casadi::Linsol::solve ( const DM A,
const DM B,
bool  tr = false 
) const

Solve linear system of equations

Definition at line 73 of file linsol.cpp.

73  {
74  casadi_assert(A.size1()==B.size1(),
75  "Linsol::solve: Dimension mismatch. A and b must have matching row count. "
76  "Got " + A.dim() + " and " + B.dim() + ".");
77 
78  scoped_checkout<Linsol> mem(*this);
79  auto m = static_cast<LinsolMemory*>((*this)->memory(mem));
80 
81  // Reset statistics
82  for (auto&& s : m->fstats) s.second.reset();
83  if (m->t_total) m->t_total->tic();
84  // Symbolic factorization
85  if (sfact(A.ptr(), mem)) casadi_error("Linsol::solve: 'sfact' failed");
86 
87  // Numeric factorization
88  if (nfact(A.ptr(), mem)) casadi_error("Linsol::solve: 'nfact' failed");
89 
90  // Solve
91  DM x = densify(B);
92  if (solve(A.ptr(), x.ptr(), x.size2(), false, mem))
93  casadi_error("Linsol::solve: 'solve' failed");
94  // Show statistics
95  if (m->t_total) m->t_total->toc();
96 
97  (*this)->print_time(m->fstats);
98  return x;
99  }
DM solve(const DM &A, const DM &B, bool tr=false) const
Definition: linsol.cpp:73
Matrix< double > DM
Definition: dm_fwd.hpp:33

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().

◆ solve() [2/3]

int casadi::Linsol::solve ( const double *  A,
double *  x,
casadi_int  nrhs = 1,
bool  tr = false,
int  mem = 0 
) const

Low-level API

Definition at line 187 of file linsol.cpp.

187  {
188  auto m = static_cast<LinsolMemory*>((*this)->memory(mem));
189  casadi_assert(m->is_nfact, "Linear system has not been factorized");
190  if (m->t_total) m->fstats.at("solve").tic();
191  int ret = (*this)->solve(m, A, x, nrhs, tr);
192  if (m->t_total) m->fstats.at("solve").toc();
193  return ret;
194  }

◆ solve() [3/3]

MX casadi::Linsol::solve ( const MX A,
const MX B,
bool  tr = false 
) const

Solve linear system of equations

Definition at line 101 of file linsol.cpp.

101  {
102  return A->get_solve(B, tr, *this);
103  }

References casadi::MXNode::get_solve().

◆ sparsity()

const Sparsity & casadi::Linsol::sparsity ( ) const

Definition at line 69 of file linsol.cpp.

69  {
70  return (*this)->sp_;
71  }

Referenced by casadi::SundialsInterface::init(), neig(), nfact(), rank(), casadi::SundialsInterface::set_work(), and sfact().

◆ stats()

Dict casadi::Linsol::stats ( int  mem = 1) const

Definition at line 217 of file linsol.cpp.

217  {
218  casadi_assert((*this)->has_memory(mem),
219  "No stats available since Linsol did not solve a problem yet.");
220  return (*this)->get_stats((*this)->memory(mem));
221  }

◆ swap()

Definition at line 105 of file generic_shared_impl.hpp.

124  {
125  GenericShared<Shared, Internal> temp = *this;
126  *this = other;
127  other = temp;
128  }

◆ test_cast()

bool casadi::Linsol::test_cast ( const SharedObjectInternal ptr)
static

Definition at line 49 of file linsol.cpp.

49  {
50  return dynamic_cast<const LinsolInternal*>(ptr)!=nullptr;
51  }

◆ type_name()

static std::string casadi::Linsol::type_name ( )
inlinestatic

Extra doc: https://github.com/casadi/casadi/wiki/L_1ki

Definition at line 60 of file linsol.hpp.

60 {return "Linsol";}

◆ weak()

Extra doc: https://github.com/casadi/casadi/wiki/L_aw

Definition at line 130 of file generic_shared_impl.hpp.

136  {
137  return (*this)->weak();
138  }

The documentation for this class was generated from the following files: