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

'qr' plugin for Linsol More...

#include <linsol_qr.hpp>

Detailed Description

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]


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

Definition at line 55 of file linsol_qr.hpp.

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

Public Types

typedef LinsolInternal *(* Creator) (const std::string &name, const Sparsity &sp)
 
using weak_ref_type = WeakRefInternal
 
typedef int(* RegFcn) (Plugin *plugin)
 

Public Member Functions

 LinsolQr (const std::string &name, const Sparsity &sp)
 
 ~LinsolQr () override
 
void init (const Dict &opts) override
 Initialize. More...
 
void finalize () override
 Finalize the object creation. More...
 
void * alloc_mem () const override
 Create memory block. More...
 
int init_mem (void *mem) const override
 Initalize memory block. More...
 
void free_mem (void *mem) const override
 Free memory block. More...
 
int nfact (void *mem, const double *A) const override
 Numeric factorization. More...
 
int sfact (void *mem, const double *A) const override
 
int solve (void *mem, const double *A, double *x, casadi_int nrhs, bool tr) const override
 
void generate (CodeGenerator &g, const std::string &A, const std::string &x, casadi_int nrhs, bool tr) const override
 Generate C code. More...
 
const char * plugin_name () const override
 
std::string class_name () const override
 Readable name of the internal class. More...
 
void serialize_body (SerializingStream &s) const override
 Serialize an object without type information. More...
 
void disp (std::ostream &stream, bool more) const override
 Display object. More...
 
virtual void disp_more (std::ostream &stream) const
 Print more. More...
 
virtual void linsol_eval_sx (const SXElem **arg, SXElem **res, casadi_int *iw, SXElem *w, void *mem, bool tr, casadi_int nrhs) const
 Evaluate SX, possibly transposed. More...
 
virtual casadi_int neig (void *mem, const double *A) const
 Number of negative eigenvalues. More...
 
virtual casadi_int rank (void *mem, const double *A) const
 Matrix rank. More...
 
casadi_int nrow () const
 Get sparsity pattern. More...
 
casadi_int ncol () const
 
const casadi_int * colind () const
 
const casadi_int * row () const
 
casadi_int nnz () const
 
void serialize_type (SerializingStream &s) const override
 Serialize type information. More...
 
void construct (const Dict &opts)
 Construct. More...
 
virtual Dict generate_options (const std::string &target) const
 Reconstruct options dict. More...
 
void print_options (std::ostream &stream) const
 Print list of options. More...
 
void print_option (const std::string &name, std::ostream &stream) const
 Print all information there is to know about a certain option. More...
 
bool has_option (const std::string &option_name) const
 Does a particular option exist. More...
 
virtual void change_option (const std::string &option_name, const GenericType &option_value)
 Change option after object creation for debugging. More...
 
int checkout () const
 Checkout a memory object. More...
 
void release (int mem) const
 Release a memory object. More...
 
void * memory (int ind) const
 Memory objects. More...
 
bool has_memory (int ind) const
 Check for existance of memory object. More...
 
virtual void check_mem_count (casadi_int n) const
 Check for validatity of memory object count. More...
 
virtual Dict get_stats (void *mem) const
 Get all statistics. More...
 
void clear_mem ()
 Clear all memory (called from destructor) More...
 
void print (const char *fmt,...) const
 C-style formatted printing during evaluation. More...
 
void sprint (char *buf, size_t buf_sz, const char *fmt,...) const
 C-style formatted printing to string. More...
 
void format_time (char *buffer, double time) const
 Format time in a fixed width 8 format. More...
 
void print_time (const std::map< std::string, FStats > &fstats) const
 Print timing statistics. More...
 
void serialize (SerializingStream &s) const
 Serialize an object. More...
 
virtual std::string serialize_base_function () const
 String used to identify the immediate FunctionInternal subclass. More...
 
casadi_int getCount () const
 Get the reference count. More...
 
std::string debug_repr (const SharedObjectInternal *) const
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 

Static Public Member Functions

static LinsolInternalcreator (const std::string &name, const Sparsity &sp)
 Create a new LinsolInternal. More...
 
static ProtoFunctiondeserialize (DeserializingStream &s)
 Deserialize with type disambiguation. More...
 
static bool has_plugin (const std::string &pname, bool verbose=false)
 Check if a plugin is available or can be loaded. More...
 
static const Optionsplugin_options (const std::string &pname)
 Get the plugin options. More...
 
static Deserialize plugin_deserialize (const std::string &pname)
 Get the plugin deserialize_map. More...
 
static Plugin pluginFromRegFcn (RegFcn regfcn)
 Instantiate a Plugin struct from a factory function. More...
 
static Plugin load_plugin (const std::string &pname, bool register_plugin=true, bool needs_lock=true)
 Load a plugin dynamically. More...
 
static handle_t load_library (const std::string &libname, std::string &resultpath, bool global)
 Load a library dynamically. More...
 
static void registerPlugin (const Plugin &plugin, bool needs_lock=true)
 Register an integrator in the factory. More...
 
static void registerPlugin (RegFcn regfcn, bool needs_lock=true)
 Register an integrator in the factory. More...
 
static Plugin & getPlugin (const std::string &pname)
 Load and get the creator function. More...
 
static LinsolInternalinstantiate (const std::string &fname, const std::string &pname, Problem problem)
 

Public Attributes

std::vector< casadi_int > prinv_
 Symbolic factorization. More...
 
std::vector< casadi_int > pc_
 
Sparsity sp_v_
 
Sparsity sp_r_
 
double eps_
 
casadi_int n_cache_
 Cache size. More...
 
casadi_int cache_stride_
 
Sparsity sp_
 
std::string name_
 Name. More...
 
bool verbose_
 Verbose printout. More...
 
bool print_time_
 
bool record_time_
 
bool regularity_check_
 Errors are thrown when NaN is produced. More...
 
bool error_on_fail_
 Throw an exception on failure? More...
 

Static Public Attributes

static const std::string meta_doc
 A documentation string. More...
 
static std::map< std::string, Plugin > solvers_
 Collection of solvers. More...
 
static const std::string infix_ = "linsol"
 Infix. More...
 

Protected Member Functions

 LinsolQr (DeserializingStream &s)
 Deserializing constructor. More...
 
void initSingleton ()
 
void destroySingleton ()
 
shared_from_this ()
 Get a shared object from the current internal object. More...
 
const B shared_from_this () const
 Get a shared object from the current internal object. More...
 
static const Options options_
 Options. More...
 
const Optionsget_options () const override
 Options. More...
 

Member Typedef Documentation

◆ Creator

typedef LinsolInternal*(* casadi::LinsolInternal::Creator) (const std::string &name, const Sparsity &sp)
inherited

Definition at line 121 of file linsol_internal.hpp.

◆ RegFcn

typedef int(* casadi::PluginInterface< LinsolInternal >::RegFcn) (Plugin *plugin)
inherited

Definition at line 73 of file plugin_interface.hpp.

◆ weak_ref_type

Definition at line 152 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ LinsolQr() [1/2]

casadi::LinsolQr::LinsolQr ( const std::string &  name,
const Sparsity sp 
)

Definition at line 48 of file linsol_qr.cpp.

49  : LinsolInternal(name, sp) {
50  }
LinsolInternal(const std::string &name, const Sparsity &sp)
Constructor.

◆ ~LinsolQr()

casadi::LinsolQr::~LinsolQr ( )
override

Definition at line 52 of file linsol_qr.cpp.

52  {
53  clear_mem();
54  }
void clear_mem()
Clear all memory (called from destructor)

References casadi::ProtoFunction::clear_mem().

◆ LinsolQr() [2/2]

casadi::LinsolQr::LinsolQr ( DeserializingStream s)
explicitprotected

Definition at line 220 of file linsol_qr.cpp.

220  : LinsolInternal(s) {
221  int version = s.version("LinsolQr", 1, 2);
222  s.unpack("LinsolQr::prinv", prinv_);
223  s.unpack("LinsolQr::pc", pc_);
224  s.unpack("LinsolQr::sp_v", sp_v_);
225  s.unpack("LinsolQr::sp_r", sp_r_);
226  s.unpack("LinsolQr::eps", eps_);
227  if (version>1) {
228  s.unpack("LinsolQr::n_cache", n_cache_);
229  } else {
230  n_cache_ = 1;
231  }
232  }
std::vector< casadi_int > pc_
Definition: linsol_qr.hpp:113
std::vector< casadi_int > prinv_
Symbolic factorization.
Definition: linsol_qr.hpp:113
casadi_int n_cache_
Cache size.
Definition: linsol_qr.hpp:118

References eps_, n_cache_, pc_, prinv_, sp_r_, sp_v_, casadi::DeserializingStream::unpack(), and casadi::DeserializingStream::version().

Member Function Documentation

◆ alloc_mem()

void* casadi::LinsolQr::alloc_mem ( ) const
inlineoverridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 82 of file linsol_qr.hpp.

82 { return new LinsolQrMemory();}

◆ change_option()

void casadi::ProtoFunction::change_option ( const std::string &  option_name,
const GenericType option_value 
)
virtualinherited

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

Reimplemented in casadi::MXFunction, casadi::FunctionInternal, and casadi::FmuFunction.

Definition at line 924 of file function_internal.cpp.

925  {
926  if (option_name == "verbose") {
927  verbose_ = option_value;
928  } else if (option_name == "regularity_check") {
929  regularity_check_ = option_value;
930  } else {
931  // Failure
932  casadi_error("Option '" + option_name + "' cannot be changed");
933  }
934  }
bool regularity_check_
Errors are thrown when NaN is produced.
bool verbose_
Verbose printout.

References casadi::ProtoFunction::regularity_check_, and casadi::ProtoFunction::verbose_.

Referenced by casadi::FunctionInternal::change_option().

◆ check_mem_count()

virtual void casadi::ProtoFunction::check_mem_count ( casadi_int  n) const
inlinevirtualinherited

Purpose if to allow more helpful error messages

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

Reimplemented in casadi::FmuFunction.

Definition at line 179 of file function_internal.hpp.

179 { }

Referenced by casadi::ProtoFunction::checkout().

◆ checkout()

int casadi::ProtoFunction::checkout ( ) const
inherited

Definition at line 3585 of file function_internal.cpp.

3585  {
3586 #ifdef CASADI_WITH_THREAD
3587  std::lock_guard<std::mutex> lock(mtx_);
3588 #endif //CASADI_WITH_THREAD
3589  if (unused_.empty()) {
3590  check_mem_count(mem_.size()+1);
3591  // Allocate a new memory object
3592  void* m = alloc_mem();
3593  mem_.push_back(m);
3594  if (init_mem(m)) {
3595  casadi_error("Failed to create or initialize memory object");
3596  }
3597  return static_cast<int>(mem_.size()) - 1;
3598  } else {
3599  // Use an unused memory object
3600  int m = unused_.top();
3601  unused_.pop();
3602  return m;
3603  }
3604  }
virtual int init_mem(void *mem) const
Initalize memory block.
virtual void * alloc_mem() const
Create memory block.
virtual void check_mem_count(casadi_int n) const
Check for validatity of memory object count.

References casadi::ProtoFunction::alloc_mem(), casadi::ProtoFunction::check_mem_count(), and casadi::ProtoFunction::init_mem().

Referenced by casadi::ProtoFunction::finalize(), casadi::FunctionBuffer::FunctionBuffer(), and casadi::Sqpmethod::init_mem().

◆ class_name()

std::string casadi::LinsolQr::class_name ( ) const
inlineoverridevirtual

Implements casadi::SharedObjectInternal.

Definition at line 107 of file linsol_qr.hpp.

107 { return "LinsolQr";}

◆ clear_mem()

void casadi::ProtoFunction::clear_mem ( )
inherited

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

Definition at line 3473 of file function_internal.cpp.

3473  {
3474  for (auto&& i : mem_) {
3475  if (i!=nullptr) free_mem(i);
3476  }
3477  mem_.clear();
3478  }
virtual void free_mem(void *mem) const
Free memory block.

References casadi::ProtoFunction::free_mem().

Referenced by casadi::AlpaqaInterface::~AlpaqaInterface(), casadi::AmplInterface::~AmplInterface(), casadi::BlazingSplineFunction::~BlazingSplineFunction(), casadi::Blocksqp::~Blocksqp(), casadi::BonminInterface::~BonminInterface(), casadi::BSplineInterpolant::~BSplineInterpolant(), casadi::CallbackInternal::~CallbackInternal(), casadi::CbcInterface::~CbcInterface(), casadi::ClarabelInterface::~ClarabelInterface(), casadi::ClpInterface::~ClpInterface(), casadi::CplexInterface::~CplexInterface(), casadi::CsparseInterface::~CsparseInterface(), casadi::CvodesInterface::~CvodesInterface(), casadi::DaqpInterface::~DaqpInterface(), casadi::External::~External(), casadi::FastNewton::~FastNewton(), casadi::FatropConicInterface::~FatropConicInterface(), casadi::FatropInterface::~FatropInterface(), casadi::Feasiblesqpmethod::~Feasiblesqpmethod(), casadi::FiniteDiff::~FiniteDiff(), casadi::FixedStepIntegrator::~FixedStepIntegrator(), casadi::FmuFunction::~FmuFunction(), casadi::GurobiInterface::~GurobiInterface(), casadi::HighsInterface::~HighsInterface(), casadi::HpipmInterface::~HpipmInterface(), casadi::HpmpcInterface::~HpmpcInterface(), casadi::IdasInterface::~IdasInterface(), casadi::ImplicitToNlp::~ImplicitToNlp(), casadi::IpoptInterface::~IpoptInterface(), casadi::Ipqp::~Ipqp(), casadi::JitFunction::~JitFunction(), casadi::KinsolInterface::~KinsolInterface(), casadi::KnitroInterface::~KnitroInterface(), casadi::LapackLu::~LapackLu(), casadi::LapackQr::~LapackQr(), casadi::LinearInterpolant::~LinearInterpolant(), casadi::LinearInterpolantJac::~LinearInterpolantJac(), casadi::LinsolLdl::~LinsolLdl(), ~LinsolQr(), casadi::LinsolTridiag::~LinsolTridiag(), casadi::Lsqr::~Lsqr(), casadi::Ma27Interface::~Ma27Interface(), casadi::MadnlpInterface::~MadnlpInterface(), casadi::Map::~Map(), casadi::MapSum::~MapSum(), casadi::MumpsInterface::~MumpsInterface(), casadi::MXFunction::~MXFunction(), casadi::Newton::~Newton(), casadi::Nlpsol::~Nlpsol(), casadi::OmpMap::~OmpMap(), casadi::OoqpInterface::~OoqpInterface(), casadi::OsqpInterface::~OsqpInterface(), casadi::ProxqpInterface::~ProxqpInterface(), casadi::QpoasesInterface::~QpoasesInterface(), casadi::QpToNlp::~QpToNlp(), casadi::Qrqp::~Qrqp(), casadi::Qrsqp::~Qrsqp(), casadi::Scpgen::~Scpgen(), casadi::SLEQPInterface::~SLEQPInterface(), casadi::SlicotDple::~SlicotDple(), casadi::SlicotExpm::~SlicotExpm(), casadi::SnoptInterface::~SnoptInterface(), casadi::Sqpmethod::~Sqpmethod(), casadi::SuperscsInterface::~SuperscsInterface(), casadi::Switch::~Switch(), casadi::SXFunction::~SXFunction(), casadi::SymbolicQr::~SymbolicQr(), casadi::ThreadMap::~ThreadMap(), and casadi::WorhpInterface::~WorhpInterface().

◆ colind()

const casadi_int* casadi::LinsolInternal::colind ( ) const
inlineinherited

Definition at line 142 of file linsol_internal.hpp.

142 { return sp_.colind();}
const casadi_int * colind() const
Get a reference to the colindex of all column element (see class description)
Definition: sparsity.cpp:168

Referenced by casadi::CsparseInterface::init_mem(), casadi::MumpsInterface::init_mem(), casadi::Ma27Interface::nfact(), and casadi::MumpsInterface::nfact().

◆ construct()

void casadi::ProtoFunction::construct ( const Dict opts)
inherited

Prepares the function for evaluation

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

Definition at line 137 of file function_internal.cpp.

137  {
138  // Sanitize dictionary is needed
139  if (!Options::is_sane(opts)) {
140  // Call recursively
141  return construct(Options::sanitize(opts));
142  }
143 
144  // Make sure all options exist
145  get_options().check(opts);
146 
147  // Initialize the class hierarchy
148  try {
149  init(opts);
150  } catch(std::exception& e) {
151  casadi_error("Error calling " + class_name() + "::init for '" + name_ + "':\n"
152  + std::string(e.what()));
153  }
154 
155  // Revisit class hierarchy in reverse order
156  try {
157  finalize();
158  } catch(std::exception& e) {
159  casadi_error("Error calling " + class_name() + "::finalize for '" + name_ + "':\n"
160  + std::string(e.what()));
161  }
162  }
void construct(const Dict &opts)
Construct.
virtual const Options & get_options() const
Options.
virtual void init(const Dict &opts)
Initialize.
virtual void finalize()
Finalize the object creation.
virtual std::string class_name() const =0
Readable name of the internal class.
static bool is_sane(const Dict &opts)
Is the dictionary sane.
Definition: options.cpp:169
static Dict sanitize(const Dict &opts, bool top_level=true)
Sanitize a options dictionary.
Definition: options.cpp:173
void check(const Dict &opts) const
Check if options exist.
Definition: options.cpp:240

References casadi::Options::check(), casadi::SharedObjectInternal::class_name(), casadi::ProtoFunction::finalize(), casadi::ProtoFunction::get_options(), casadi::ProtoFunction::init(), casadi::Options::is_sane(), casadi::ProtoFunction::name_, and casadi::Options::sanitize().

Referenced by casadi::Function::create(), casadi::FmuFunction::factory(), casadi::FmuFunction::get_forward(), casadi::FmuFunction::get_jacobian(), casadi::LinearInterpolant::get_jacobian(), and casadi::FmuFunction::get_reverse().

◆ creator()

static LinsolInternal* casadi::LinsolQr::creator ( const std::string &  name,
const Sparsity sp 
)
inlinestatic

Definition at line 62 of file linsol_qr.hpp.

62  {
63  return new LinsolQr(name, sp);
64  }
LinsolQr(const std::string &name, const Sparsity &sp)
Definition: linsol_qr.cpp:48

Referenced by casadi::casadi_register_linsol_qr().

◆ debug_repr()

std::string casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::debug_repr ( const Internal *  i) const
inherited

Definition at line 62 of file generic_shared_internal.hpp.

162  {
163  // Note: i != this because of something something multiple inheritance
164  return str( (casadi_int)(i)) + "/" + static_cast<const Internal*>(this)->class_name();
165  }
std::string str(const T &v)
String representation, any type.

◆ deserialize()

static ProtoFunction* casadi::LinsolQr::deserialize ( DeserializingStream s)
inlinestatic

Definition at line 125 of file linsol_qr.hpp.

125 { return new LinsolQr(s); }

Referenced by casadi::casadi_register_linsol_qr().

◆ destroySingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::destroySingleton ( )
inlineprotectedinherited

Called in the destructor of singletons

Definition at line 77 of file generic_shared_internal.hpp.

77  {
78  static_cast<Internal*>(this)->count--;
79  }

◆ disp()

void casadi::LinsolInternal::disp ( std::ostream &  stream,
bool  more 
) const
overridevirtualinherited

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

Implements casadi::SharedObjectInternal.

Definition at line 43 of file linsol_internal.cpp.

43  {
44  stream << "Linear solver " << class_name();
45  if (more) {
46  stream << std::endl;
47  disp_more(stream);
48  }
49  }
virtual void disp_more(std::ostream &stream) const
Print more.

References casadi::SharedObjectInternal::class_name(), and casadi::LinsolInternal::disp_more().

◆ disp_more()

virtual void casadi::LinsolInternal::disp_more ( std::ostream &  stream) const
inlinevirtualinherited

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

Definition at line 65 of file linsol_internal.hpp.

65 {}

Referenced by casadi::LinsolInternal::disp().

◆ finalize()

void casadi::LinsolQr::finalize ( )
overridevirtual

Reimplemented from casadi::ProtoFunction.

Definition at line 86 of file linsol_qr.cpp.

86  {
89  }
casadi_int ncol() const
casadi_int cache_stride_
Definition: linsol_qr.hpp:119
casadi_int nnz() const
Get the number of (structural) non-zeros.
Definition: sparsity.cpp:148

References cache_stride_, casadi::ProtoFunction::finalize(), casadi::LinsolInternal::ncol(), casadi::Sparsity::nnz(), casadi::LinsolInternal::sp_, sp_r_, and sp_v_.

◆ format_time()

void casadi::ProtoFunction::format_time ( char *  buffer,
double  time 
) const
inherited

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

Definition at line 3772 of file function_internal.cpp.

3772  {
3773  // Always of width 8
3774  casadi_assert_dev(time>=0);
3775  double log_time = log10(time);
3776  int magn = static_cast<int>(floor(log_time));
3777  int iprefix = static_cast<int>(floor(log_time/3));
3778  if (iprefix<-4) {
3779  sprint(buffer, 10, " 0");
3780  return;
3781  }
3782  if (iprefix>=5) {
3783  sprint(buffer, 10, " inf");
3784  return;
3785  }
3786  char prefixes[] = "TGMk munp";
3787  char prefix = prefixes[4-iprefix];
3788 
3789  int rem = magn-3*iprefix;
3790  double time_normalized = time/pow(10, 3*iprefix);
3791 
3792  if (rem==0) {
3793  sprint(buffer, 10, " %1.2f%cs", time_normalized, prefix);
3794  } else if (rem==1) {
3795  sprint(buffer, 10, " %2.2f%cs", time_normalized, prefix);
3796  } else {
3797  sprint(buffer, 10, "%3.2f%cs", time_normalized, prefix);
3798  }
3799  }
void sprint(char *buf, size_t buf_sz, const char *fmt,...) const
C-style formatted printing to string.

References casadi::ProtoFunction::sprint().

Referenced by casadi::ProtoFunction::print_time().

◆ free_mem()

void casadi::LinsolQr::free_mem ( void *  mem) const
inlineoverridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 88 of file linsol_qr.hpp.

88 { delete static_cast<LinsolQrMemory*>(mem);}

◆ generate()

void casadi::LinsolQr::generate ( CodeGenerator g,
const std::string &  A,
const std::string &  x,
casadi_int  nrhs,
bool  tr 
) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 165 of file linsol_qr.cpp.

166  {
167  // Codegen the integer vectors
168  std::string prinv = g.constant(prinv_);
169  std::string pc = g.constant(pc_);
170  std::string sp = g.sparsity(sp_);
171  std::string sp_v = g.sparsity(sp_v_);
172  std::string sp_r = g.sparsity(sp_r_);
173 
174  // Place in block to avoid conflicts caused by local variables
175  g << "{\n";
176  g.comment("FIXME(@jaeandersson): Memory allocation can be avoided");
177  g << "casadi_real v[" << sp_v_.nnz() << "], "
178  "r[" << sp_r_.nnz() << "], "
179  "beta[" << ncol() << "], "
180  "w[" << nrow() + ncol() << "];\n";
181 
182  if (n_cache_) {
183  g << "casadi_real *c;\n";
184  g << "casadi_real cache[" << cache_stride_*n_cache_ << "];\n";
185  g << "int cache_loc[" << n_cache_ << "] = {";
186  for (casadi_int i=0;i<n_cache_;++i) {
187  g << "-1,";
188  }
189  g << "};\n";
190  g << "if (" << g.cache_check(A, "cache", "cache_loc",
191  cache_stride_, n_cache_, sp_.nnz(), "&c") << ") {\n";
192  casadi_int offset = sp_.nnz();
193  g.comment("Retrieve from cache");
194  g << g.copy("c+" + str(offset), sp_v_.nnz(), "v") << "\n"; offset+=sp_v_.nnz();
195  g << g.copy("c+" + str(offset), sp_r_.nnz(), "r") << "\n"; offset+=sp_r_.nnz();
196  g << g.copy("c+" + str(offset), ncol(), "beta") << "\n"; offset+=ncol();
197  g << "} else {\n";
198  }
199 
200  // Factorize
201  g << g.qr(sp, A, "w", sp_v, "v", sp_r, "r", "beta", prinv, pc) << "\n";
202 
203  if (n_cache_) {
204  casadi_int offset = 0;
205  g.comment("Store in cache");
206  g << g.copy(A, sp_.nnz(), "c") << "\n";; offset+=sp_.nnz();
207  g << g.copy("v", sp_v_.nnz(), "c+"+str(offset)) << "\n"; offset+=sp_v_.nnz();
208  g << g.copy("r", sp_r_.nnz(), "c+"+str(offset)) << "\n"; offset+=sp_r_.nnz();
209  g << g.copy("beta", ncol(), "c+"+str(offset)) << "\n"; offset+=ncol();
210  g << "}\n";
211  }
212 
213  // Solve
214  g << g.qr_solve(x, nrhs, tr, sp_v, "v", sp_r, "r", "beta", prinv, pc, "w") << "\n";
215 
216  // End of block
217  g << "}\n";
218  }
casadi_int nrow() const
Get sparsity pattern.

References casadi::CodeGenerator::cache_check(), cache_stride_, casadi::CodeGenerator::comment(), casadi::CodeGenerator::constant(), casadi::CodeGenerator::copy(), n_cache_, casadi::LinsolInternal::ncol(), casadi::Sparsity::nnz(), casadi::LinsolInternal::nrow(), pc_, prinv_, casadi::CodeGenerator::qr(), casadi::CodeGenerator::qr_solve(), casadi::LinsolInternal::sp_, sp_r_, sp_v_, casadi::CodeGenerator::sparsity(), and casadi::str().

◆ generate_options()

Dict casadi::ProtoFunction::generate_options ( const std::string &  target) const
virtualinherited

Reimplemented in casadi::SXFunction, casadi::MXFunction, and casadi::FunctionInternal.

Definition at line 372 of file function_internal.cpp.

372  {
373  Dict opts;
374  opts["verbose"] = verbose_;
375  opts["print_time"] = print_time_;
376  opts["record_time"] = record_time_;
377  opts["regularity_check"] = regularity_check_;
378  opts["error_on_fail"] = error_on_fail_;
379  return opts;
380  }
bool error_on_fail_
Throw an exception on failure?
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References casadi::ProtoFunction::error_on_fail_, casadi::ProtoFunction::print_time_, casadi::ProtoFunction::record_time_, casadi::ProtoFunction::regularity_check_, and casadi::ProtoFunction::verbose_.

Referenced by casadi::FunctionInternal::generate_options().

◆ get_options()

const Options& casadi::LinsolQr::get_options ( ) const
inlineoverridevirtual

Reimplemented from casadi::ProtoFunction.

Definition at line 78 of file linsol_qr.hpp.

78 { return options_;}
static const Options options_
Options.
Definition: linsol_qr.hpp:77

◆ get_stats()

Dict casadi::ProtoFunction::get_stats ( void *  mem) const
virtualinherited

◆ getCount()

Definition at line 60 of file generic_shared_internal.hpp.

186  {
187  return static_cast<const Internal*>(this)->count;
188  }

◆ getPlugin()

PluginInterface< LinsolInternal >::Plugin & casadi::PluginInterface< LinsolInternal >::getPlugin ( const std::string &  pname)
staticinherited

Definition at line 102 of file plugin_interface.hpp.

291  {
292 
293 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
294  std::lock_guard<std::mutex> lock(Derived::mutex_solvers_);
295 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
296 
297  // Check if the solver has been loaded
298  auto it=Derived::solvers_.find(pname);
299 
300  // Load the solver if needed
301  if (it==Derived::solvers_.end()) {
302  load_plugin(pname, true, false);
303  it=Derived::solvers_.find(pname);
304  }
305  casadi_assert_dev(it!=Derived::solvers_.end());
306  return it->second;
307  }
static Plugin load_plugin(const std::string &pname, bool register_plugin=true, bool needs_lock=true)
Load a plugin dynamically.

◆ has_memory()

bool casadi::ProtoFunction::has_memory ( int  ind) const
inherited

Definition at line 3581 of file function_internal.cpp.

3581  {
3582  return ind<mem_.size();
3583  }

◆ has_option()

bool casadi::ProtoFunction::has_option ( const std::string &  option_name) const
inherited

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

Definition at line 920 of file function_internal.cpp.

920  {
921  return get_options().find(option_name) != 0;
922  }
const Options::Entry * find(const std::string &name) const
Definition: options.cpp:32

References casadi::Options::find(), and casadi::ProtoFunction::get_options().

◆ has_plugin()

bool casadi::PluginInterface< LinsolInternal >::has_plugin ( const std::string &  pname,
bool  verbose = false 
)
staticinherited

Definition at line 76 of file plugin_interface.hpp.

131  {
132 
133 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
134  std::lock_guard<std::mutex> lock(Derived::mutex_solvers_);
135 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
136 
137  // Quick return if available
138  if (Derived::solvers_.find(pname) != Derived::solvers_.end()) {
139  return true;
140  }
141 
142  // Try loading the plugin
143  try {
144  (void)load_plugin(pname, false, false);
145  return true;
146  } catch (CasadiException& ex) {
147  if (verbose) {
148  casadi_warning(ex.what());
149  }
150  return false;
151  }
152  }
std::vector< casadi_int > find(const std::vector< T > &v)
find nonzeros

◆ init()

void casadi::LinsolQr::init ( const Dict opts)
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 67 of file linsol_qr.cpp.

67  {
68  // Call the init method of the base class
70 
71  // Read options
72  eps_ = 1e-12;
73  n_cache_ = 0;
74  for (auto&& op : opts) {
75  if (op.first=="eps") {
76  eps_ = op.second;
77  } else if (op.first=="cache") {
78  n_cache_ = op.second;
79  }
80  }
81 
82  // Symbolic factorization
84  }
void init(const Dict &opts) override
Initialize.
void qr_sparse(Sparsity &V, Sparsity &R, std::vector< casadi_int > &prinv, std::vector< casadi_int > &pc, bool amd=true) const
Symbolic QR factorization.
Definition: sparsity.cpp:654

References eps_, casadi::LinsolInternal::init(), n_cache_, pc_, prinv_, casadi::Sparsity::qr_sparse(), casadi::LinsolInternal::sp_, sp_r_, and sp_v_.

◆ init_mem()

int casadi::LinsolQr::init_mem ( void *  mem) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 91 of file linsol_qr.cpp.

91  {
92  if (LinsolInternal::init_mem(mem)) return 1;
93  auto m = static_cast<LinsolQrMemory*>(mem);
94 
95  // Memory for numerical solution
96  m->v.resize(sp_v_.nnz());
97  m->r.resize(sp_r_.nnz());
98  m->beta.resize(ncol());
99  m->w.resize(nrow() + ncol());
100 
101  m->cache.resize(cache_stride_*n_cache_);
102  m->cache_loc.resize(n_cache_, -1);
103 
104  return 0;
105  }
int init_mem(void *mem) const override
Initalize memory block.

References cache_stride_, casadi::LinsolInternal::init_mem(), n_cache_, casadi::LinsolInternal::ncol(), casadi::Sparsity::nnz(), casadi::LinsolInternal::nrow(), sp_r_, sp_v_, and casadi::LinsolQrMemory::v.

◆ initSingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::initSingleton ( )
inlineprotectedinherited

Called in the constructor of singletons to avoid that the counter reaches zero

Definition at line 71 of file generic_shared_internal.hpp.

71  {
72  casadi_assert_dev(static_cast<Internal*>(this)->count==0);
73  static_cast<Internal*>(this)->count++;
74  }

◆ instantiate()

LinsolInternal * casadi::PluginInterface< LinsolInternal >::instantiate ( const std::string &  fname,
const std::string &  pname,
Problem  problem 
)
staticinherited

Definition at line 106 of file plugin_interface.hpp.

313  {
314 
315  // Assert the plugin exists (needed for adaptors)
316  if (!has_plugin(pname, true)) {
317  casadi_error("Plugin '" + pname + "' is not found.");
318  }
319  return getPlugin(pname).creator(fname, problem);
320  }
static bool has_plugin(const std::string &pname, bool verbose=false)
Check if a plugin is available or can be loaded.
static Plugin & getPlugin(const std::string &pname)
Load and get the creator function.

◆ linsol_eval_sx()

void casadi::LinsolInternal::linsol_eval_sx ( const SXElem **  arg,
SXElem **  res,
casadi_int *  iw,
SXElem w,
void *  mem,
bool  tr,
casadi_int  nrhs 
) const
virtualinherited

Reimplemented in casadi::SymbolicQr.

Definition at line 63 of file linsol_internal.cpp.

64  {
65  casadi_error("eval_sx not defined for " + class_name());
66  }

References casadi::SharedObjectInternal::class_name().

◆ load_library()

handle_t casadi::PluginInterface< LinsolInternal >::load_library ( const std::string &  libname,
std::string &  resultpath,
bool  global 
)
staticinherited

Definition at line 92 of file plugin_interface.hpp.

184  {
185 
186 #ifndef WITH_DL
187  casadi_error("WITH_DL option needed for dynamic loading");
188 #else // WITH_DL
189 
190  // Get the name of the shared library
191  std::string lib = SHARED_LIBRARY_PREFIX + libname + SHARED_LIBRARY_SUFFIX;
192 
193  // Build up search paths;
194  std::vector<std::string> search_paths = get_search_paths();
195  return open_shared_library(lib, search_paths, resultpath,
196  "PluginInterface::load_plugin", global);
197 
198 #endif // WITH_DL
199  }
std::vector< std::string > get_search_paths()
Definition: casadi_os.cpp:49

◆ load_plugin()

PluginInterface< LinsolInternal >::Plugin casadi::PluginInterface< LinsolInternal >::load_plugin ( const std::string &  pname,
bool  register_plugin = true,
bool  needs_lock = true 
)
staticinherited

Definition at line 88 of file plugin_interface.hpp.

204  {
205 
206 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
207  casadi::conditional_lock_guard<std::mutex> lock(Derived::mutex_solvers_, needs_lock);
208 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
209 
210  // Issue warning and quick return if already loaded
211  if (Derived::solvers_.find(pname) != Derived::solvers_.end()) {
212  casadi_warning("PluginInterface: Solver " + pname + " is already in use. Ignored.");
213  return Plugin();
214  }
215 
216  // Logger singletons are lazily instantiated on first uout()/uerr() calls
217  // This instantation may lead to a data race with potential instatiations in plugin
218  // To be safe, trigger instantatin before any plugin loading
219  uout();
220  uerr();
221 
222 #ifndef WITH_DL
223  casadi_error("WITH_DL option needed for dynamic loading");
224 #else // WITH_DL
225  // Retrieve the registration function
226  RegFcn reg;
227 
228  // Load the dll
229  std::string regName = "casadi_register_" + Derived::infix_ + "_" + pname;
230 
231  std::string searchpath;
232  handle_t handle = load_library("casadi_" + Derived::infix_ + "_" + pname, searchpath,
233  false);
234 
235 #ifdef _WIN32
236 
237 #if __GNUC__
238 #pragma GCC diagnostic push
239 #pragma GCC diagnostic ignored "-Wcast-function-type"
240 #endif
241  reg = reinterpret_cast<RegFcn>(GetProcAddress(handle, TEXT(regName.c_str())));
242 #if __GNUC__
243 #pragma GCC diagnostic pop
244 #endif
245 
246 #else // _WIN32
247  // Reset error
248  dlerror();
249 
250  // Load creator
251  reg = reinterpret_cast<RegFcn>(dlsym(handle, regName.c_str()));
252 #endif // _WIN32
253  casadi_assert(reg!=nullptr,
254  "PluginInterface::load_plugin: no \"" + regName + "\" found in " + searchpath + ".");
255 
256  // Create a temporary struct
257  Plugin plugin = pluginFromRegFcn(reg);
258  // Register the plugin
259  if (register_plugin) {
260  registerPlugin(plugin, false);
261  }
262 
263  return plugin;
264 
265 #endif // WITH_DL
266  }
static handle_t load_library(const std::string &libname, std::string &resultpath, bool global)
Load a library dynamically.
static Plugin pluginFromRegFcn(RegFcn regfcn)
Instantiate a Plugin struct from a factory function.
static void registerPlugin(const Plugin &plugin, bool needs_lock=true)
Register an integrator in the factory.
std::ostream & uerr()
std::ostream & uout()

◆ memory()

void * casadi::ProtoFunction::memory ( int  ind) const
inherited

Definition at line 3574 of file function_internal.cpp.

3574  {
3575 #ifdef CASADI_WITH_THREAD
3576  std::lock_guard<std::mutex> lock(mtx_);
3577 #endif //CASADI_WITH_THREAD
3578  return mem_.at(ind);
3579  }

Referenced by casadi::FunctionInternal::call_gen(), casadi::FunctionInternal::get_jac_sparsity_gen(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::Sqpmethod::solve_ela_QP(), and casadi::Sqpmethod::solve_QP().

◆ ncol()

casadi_int casadi::LinsolInternal::ncol ( ) const
inlineinherited

◆ neig()

casadi_int casadi::LinsolInternal::neig ( void *  mem,
const double *  A 
) const
virtualinherited

Reimplemented in casadi::LinsolLdl, and casadi::Ma27Interface.

Definition at line 102 of file linsol_internal.cpp.

102  {
103  casadi_error("'neig' not defined for " + class_name());
104  }

References casadi::SharedObjectInternal::class_name().

◆ nfact()

int casadi::LinsolQr::nfact ( void *  mem,
const double *  A 
) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 111 of file linsol_qr.cpp.

111  {
112  auto m = static_cast<LinsolQrMemory*>(mem);
113 
114  // Check for a cache hit
115  double* cache = nullptr;
116  bool cache_hit = cache_check(A, get_ptr(m->cache), get_ptr(m->cache_loc),
117  cache_stride_, n_cache_, sp_.nnz(), &cache);
118 
119  if (cache && cache_hit) {
120  cache += sp_.nnz();
121  // Retrieve from cache and return early
122  casadi_copy(cache, sp_v_.nnz(), get_ptr(m->v)); cache+=sp_v_.nnz();
123  casadi_copy(cache, sp_r_.nnz(), get_ptr(m->r)); cache+=sp_r_.nnz();
124  casadi_copy(cache, ncol(), get_ptr(m->beta)); cache+=ncol();
125  return 0;
126  }
127 
128  // Cache miss -> compute result
129  casadi_qr(sp_, A, get_ptr(m->w),
130  sp_v_, get_ptr(m->v), sp_r_, get_ptr(m->r),
131  get_ptr(m->beta), get_ptr(prinv_), get_ptr(pc_));
132  // Check singularity
133  double rmin;
134  casadi_int irmin, nullity;
135  nullity = casadi_qr_singular(&rmin, &irmin, get_ptr(m->r), sp_r_, get_ptr(pc_), eps_);
136  if (nullity) {
137  if (verbose_) {
138  print("Singularity detected: Rank %lld<%lld\n", ncol()-nullity, ncol());
139  print("First singular R entry: %g<%g, corresponding to row %lld\n", rmin, eps_, irmin);
140  casadi_qr_colcomb(get_ptr(m->w), get_ptr(m->r), sp_r_, get_ptr(pc_), eps_, 0);
141  print("Linear combination of columns:\n[");
142  for (casadi_int k=0; k<ncol(); ++k) print(k==0 ? "%g" : ", %g", m->w[k]);
143  print("]\n");
144  }
145  return 1;
146  }
147 
148  if (cache) { // Store result in cache
149  casadi_copy(A, sp_.nnz(), cache); cache+=sp_.nnz();
150  casadi_copy(get_ptr(m->v), sp_v_.nnz(), cache); cache+=sp_v_.nnz();
151  casadi_copy(get_ptr(m->r), sp_r_.nnz(), cache); cache+=sp_r_.nnz();
152  casadi_copy(get_ptr(m->beta), ncol(), cache); cache+=ncol();
153  }
154  return 0;
155  }
void print(const char *fmt,...) const
C-style formatted printing during evaluation.
void casadi_copy(const T1 *x, casadi_int n, T1 *y)
COPY: y <-x.
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.

References cache_stride_, casadi::casadi_copy(), eps_, casadi::get_ptr(), n_cache_, casadi::LinsolInternal::ncol(), casadi::Sparsity::nnz(), pc_, casadi::ProtoFunction::print(), prinv_, casadi::LinsolInternal::sp_, sp_r_, sp_v_, and casadi::ProtoFunction::verbose_.

◆ nnz()

casadi_int casadi::LinsolInternal::nnz ( ) const
inlineinherited

◆ nrow()

casadi_int casadi::LinsolInternal::nrow ( ) const
inlineinherited

◆ plugin_deserialize()

Deserialize casadi::PluginInterface< LinsolInternal >::plugin_deserialize ( const std::string &  pname)
staticinherited

Definition at line 82 of file plugin_interface.hpp.

162  {
163  Deserialize m = getPlugin(pname).deserialize;
164  casadi_assert(m, "Plugin \"" + pname + "\" does not support deserialize");
165  return m;
166  }
ProtoFunction *(* Deserialize)(DeserializingStream &)

◆ plugin_name()

const char* casadi::LinsolQr::plugin_name ( ) const
inlineoverridevirtual

Implements casadi::LinsolInternal.

Definition at line 104 of file linsol_qr.hpp.

104 { return "qr";}

◆ plugin_options()

const Options & casadi::PluginInterface< LinsolInternal >::plugin_options ( const std::string &  pname)
staticinherited

Definition at line 79 of file plugin_interface.hpp.

155  {
156  const Options *op = getPlugin(pname).options;
157  casadi_assert(op!=nullptr, "Plugin \"" + pname + "\" does not support options");
158  return *op;
159  }

◆ pluginFromRegFcn()

PluginInterface< LinsolInternal >::Plugin casadi::PluginInterface< LinsolInternal >::pluginFromRegFcn ( RegFcn  regfcn)
staticinherited

Definition at line 85 of file plugin_interface.hpp.

170  {
171  // Create a temporary struct
172  Plugin plugin;
173 
174  // Set the fields
175  int flag = regfcn(&plugin);
176  casadi_assert(flag==0, "Registration of plugin failed.");
177 
178  return plugin;
179  }

◆ print()

void casadi::ProtoFunction::print ( const char *  fmt,
  ... 
) const
inherited

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

Definition at line 3813 of file function_internal.cpp.

3813  {
3814  // Variable number of arguments
3815  va_list args;
3816  va_start(args, fmt);
3817  // Static & dynamic buffers
3818  char buf[256];
3819  size_t buf_sz = sizeof(buf);
3820  char* buf_dyn = nullptr;
3821  // Try to print with a small buffer
3822  casadi_int n = vsnprintf(buf, buf_sz, fmt, args);
3823  // Need a larger buffer?
3824  if (n>static_cast<casadi_int>(buf_sz)) {
3825  buf_sz = static_cast<size_t>(n+1);
3826  buf_dyn = new char[buf_sz];
3827  n = vsnprintf(buf_dyn, buf_sz, fmt, args);
3828  }
3829  // Print buffer content
3830  if (n>=0) uout() << (buf_dyn ? buf_dyn : buf) << std::flush;
3831  // Cleanup
3832  delete[] buf_dyn;
3833  va_end(args);
3834  // Throw error if failure
3835  casadi_assert(n>=0, "Print failure while processing '" + std::string(fmt) + "'");
3836  }

References casadi::uout().

Referenced by casadi::Feasiblesqpmethod::anderson_acc_step_update(), casadi::Nlpsol::callback(), casadi::Blocksqp::convertHessian(), casadi::FmuFunction::eval_task(), casadi::Feasiblesqpmethod::feasibility_iterations(), casadi::Blocksqp::feasibilityRestorationPhase(), casadi::Blocksqp::fullstep(), casadi::Blocksqp::init(), casadi::Feasiblesqpmethod::init(), casadi::Ipqp::init(), casadi::Qrqp::init(), casadi::Qrsqp::init(), casadi::Sqpmethod::init(), nfact(), casadi::Feasiblesqpmethod::print_iteration(), casadi::Qrsqp::print_iteration(), casadi::Sqpmethod::print_iteration(), casadi::SundialsInterface::print_stats(), casadi::ProtoFunction::print_time(), casadi::Blocksqp::printInfo(), casadi::Blocksqp::printProgress(), casadi::Blocksqp::run(), casadi::Blocksqp::solve(), casadi::Feasiblesqpmethod::solve(), casadi::Qrsqp::solve(), casadi::Sqpmethod::solve(), casadi::Sqpmethod::solve_ela_QP(), casadi::Feasiblesqpmethod::solve_LP(), casadi::Feasiblesqpmethod::solve_QP(), casadi::Qrsqp::solve_QP(), casadi::Sqpmethod::solve_QP(), and casadi::Blocksqp::solveQP().

◆ print_option()

void casadi::ProtoFunction::print_option ( const std::string &  name,
std::ostream &  stream 
) const
inherited

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

Definition at line 916 of file function_internal.cpp.

916  {
917  get_options().print_one(name, stream);
918  }
void print_one(const std::string &name, std::ostream &stream) const
Print all information there is to know about a certain option.
Definition: options.cpp:274

References casadi::ProtoFunction::get_options(), and casadi::Options::print_one().

◆ print_options()

void casadi::ProtoFunction::print_options ( std::ostream &  stream) const
inherited

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

Definition at line 912 of file function_internal.cpp.

912  {
913  get_options().print_all(stream);
914  }
void print_all(std::ostream &stream) const
Print list of options.
Definition: options.cpp:268

References casadi::ProtoFunction::get_options(), and casadi::Options::print_all().

◆ print_time()

void casadi::ProtoFunction::print_time ( const std::map< std::string, FStats > &  fstats) const
inherited

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

Definition at line 3733 of file function_internal.cpp.

3733  {
3734  if (!print_time_) return;
3735  // Length of the name being printed
3736  size_t name_len=0;
3737  for (auto &&s : fstats) {
3738  name_len = std::max(s.first.size(), name_len);
3739  }
3740  name_len = std::max(name_.size(), name_len);
3741 
3742  // Print name with a given length. Format: "%NNs "
3743  char namefmt[10];
3744  sprint(namefmt, sizeof(namefmt), "%%%ds ", static_cast<casadi_int>(name_len));
3745 
3746  // Print header
3747  print(namefmt, name_.c_str());
3748 
3749  print(" : %8s %10s %8s %10s %9s\n", "t_proc", "(avg)", "t_wall", "(avg)", "n_eval");
3750 
3751 
3752  char buffer_proc[10];
3753  char buffer_wall[10];
3754  char buffer_proc_avg[10];
3755  char buffer_wall_avg[10];
3756 
3757  // Print keys
3758  for (const auto &s : fstats) {
3759  if (s.second.n_call!=0) {
3760  print(namefmt, s.first.c_str());
3761  format_time(buffer_proc, s.second.t_proc);
3762  format_time(buffer_wall, s.second.t_wall);
3763  format_time(buffer_proc_avg, s.second.t_proc/s.second.n_call);
3764  format_time(buffer_wall_avg, s.second.t_wall/s.second.n_call);
3765  print(" | %s (%s) %s (%s) %9d\n",
3766  buffer_proc, buffer_proc_avg,
3767  buffer_wall, buffer_wall_avg, s.second.n_call);
3768  }
3769  }
3770  }
void format_time(char *buffer, double time) const
Format time in a fixed width 8 format.

References casadi::ProtoFunction::format_time(), casadi::ProtoFunction::name_, casadi::ProtoFunction::print(), casadi::ProtoFunction::print_time_, and casadi::ProtoFunction::sprint().

Referenced by casadi::FunctionInternal::eval_gen().

◆ rank()

casadi_int casadi::LinsolInternal::rank ( void *  mem,
const double *  A 
) const
virtualinherited

Reimplemented in casadi::LinsolLdl, and casadi::Ma27Interface.

Definition at line 106 of file linsol_internal.cpp.

106  {
107  casadi_error("'rank' not defined for " + class_name());
108  }

References casadi::SharedObjectInternal::class_name().

◆ registerPlugin() [1/2]

void casadi::PluginInterface< LinsolInternal >::registerPlugin ( const Plugin &  plugin,
bool  needs_lock = true 
)
staticinherited

Definition at line 96 of file plugin_interface.hpp.

274  {
275 
276 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
277  casadi::conditional_lock_guard<std::mutex> lock(Derived::mutex_solvers_, needs_lock);
278 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
279 
280  // Check if the solver name is in use
281  typename std::map<std::string, Plugin>::iterator it=Derived::solvers_.find(plugin.name);
282  casadi_assert(it==Derived::solvers_.end(),
283  "Solver " + str(plugin.name) + " is already in use");
284 
285  // Add to list of solvers
286  Derived::solvers_[plugin.name] = plugin;
287  }

◆ registerPlugin() [2/2]

void casadi::PluginInterface< LinsolInternal >::registerPlugin ( RegFcn  regfcn,
bool  needs_lock = true 
)
staticinherited

Definition at line 99 of file plugin_interface.hpp.

269  {
270  registerPlugin(pluginFromRegFcn(regfcn), needs_lock);
271  }

◆ release()

void casadi::ProtoFunction::release ( int  mem) const
inherited

Definition at line 3606 of file function_internal.cpp.

3606  {
3607 #ifdef CASADI_WITH_THREAD
3608  std::lock_guard<std::mutex> lock(mtx_);
3609 #endif //CASADI_WITH_THREAD
3610  unused_.push(mem);
3611  }

◆ row()

const casadi_int* casadi::LinsolInternal::row ( ) const
inlineinherited

Definition at line 143 of file linsol_internal.hpp.

143 { return sp_.row();}
const casadi_int * row() const
Get a reference to row-vector,.
Definition: sparsity.cpp:164

Referenced by casadi::CsparseInterface::init_mem(), casadi::MumpsInterface::init_mem(), casadi::Ma27Interface::nfact(), and casadi::MumpsInterface::nfact().

◆ serialize()

void casadi::ProtoFunction::serialize ( SerializingStream s) const
inherited

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

Definition at line 4090 of file function_internal.cpp.

4090  {
4091  serialize_type(s);
4092  serialize_body(s);
4093  }
virtual void serialize_type(SerializingStream &s) const
Serialize type information.
virtual void serialize_body(SerializingStream &s) const
Serialize an object without type information.

References casadi::ProtoFunction::serialize_body(), and casadi::ProtoFunction::serialize_type().

◆ serialize_base_function()

virtual std::string casadi::ProtoFunction::serialize_base_function ( ) const
inlinevirtualinherited

◆ serialize_body()

void casadi::LinsolQr::serialize_body ( SerializingStream s) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 234 of file linsol_qr.cpp.

234  {
236  s.version("LinsolQr", 2);
237  s.pack("LinsolQr::prinv", prinv_);
238  s.pack("LinsolQr::pc", pc_);
239  s.pack("LinsolQr::sp_v", sp_v_);
240  s.pack("LinsolQr::sp_r", sp_r_);
241  s.pack("LinsolQr::eps", eps_);
242  s.pack("LinsolQr::n_cache", n_cache_);
243  }
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.

References eps_, n_cache_, casadi::SerializingStream::pack(), pc_, prinv_, casadi::LinsolInternal::serialize_body(), sp_r_, sp_v_, and casadi::SerializingStream::version().

◆ serialize_type()

void casadi::LinsolInternal::serialize_type ( SerializingStream s) const
overridevirtualinherited

◆ sfact()

int casadi::LinsolQr::sfact ( void *  mem,
const double *  A 
) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 107 of file linsol_qr.cpp.

107  {
108  return 0;
109  }

◆ shared_from_this() [1/2]

B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( )
inlineprotectedinherited

Definition at line 83 of file generic_shared_internal.hpp.

83  {
84  casadi_assert_dev(B::test_cast(static_cast<Internal*>(this)));
85  B ret;
86  ret.own(static_cast<Internal*>(this));
87  return ret;
88  }

◆ shared_from_this() [2/2]

const B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( ) const
inlineprotectedinherited

Definition at line 92 of file generic_shared_internal.hpp.

92  {
93  casadi_assert_dev(B::test_cast(static_cast<const Internal*>(this)));
94  B ret;
95  ret.own(const_cast<Internal*>(static_cast<const Internal*>(this)));
96  return ret;
97  }

◆ solve()

int casadi::LinsolQr::solve ( void *  mem,
const double *  A,
double *  x,
casadi_int  nrhs,
bool  tr 
) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 157 of file linsol_qr.cpp.

157  {
158  auto m = static_cast<LinsolQrMemory*>(mem);
159  casadi_qr_solve(x, nrhs, tr,
160  sp_v_, get_ptr(m->v), sp_r_, get_ptr(m->r),
161  get_ptr(m->beta), get_ptr(prinv_), get_ptr(pc_), get_ptr(m->w));
162  return 0;
163  }

References casadi::get_ptr(), pc_, prinv_, sp_r_, and sp_v_.

◆ sprint()

void casadi::ProtoFunction::sprint ( char *  buf,
size_t  buf_sz,
const char *  fmt,
  ... 
) const
inherited

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

Definition at line 3801 of file function_internal.cpp.

3801  {
3802  // Variable number of arguments
3803  va_list args;
3804  va_start(args, fmt);
3805  // Print to buffer
3806  casadi_int n = vsnprintf(buf, buf_sz, fmt, args);
3807  // Cleanup
3808  va_end(args);
3809  // Throw error if failure
3810  casadi_assert(n>=0 && n<buf_sz, "Print failure while processing '" + std::string(fmt) + "'");
3811  }

Referenced by casadi::ProtoFunction::format_time(), and casadi::ProtoFunction::print_time().

◆ weak()

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

Definition at line 67 of file generic_shared_internal.hpp.

191  {
192  if (weak_ref_==nullptr) {
193  weak_ref_ = new GenericWeakRef<Shared, Internal>(static_cast<Internal*>(this));
194  }
195  return weak_ref_;
196  }

Member Data Documentation

◆ cache_stride_

casadi_int casadi::LinsolQr::cache_stride_

Definition at line 119 of file linsol_qr.hpp.

Referenced by finalize(), generate(), init_mem(), and nfact().

◆ eps_

double casadi::LinsolQr::eps_

Definition at line 115 of file linsol_qr.hpp.

Referenced by init(), LinsolQr(), nfact(), and serialize_body().

◆ error_on_fail_

bool casadi::ProtoFunction::error_on_fail_
inherited

◆ infix_

const std::string casadi::LinsolInternal::infix_ = "linsol"
staticinherited

Definition at line 134 of file linsol_internal.hpp.

◆ meta_doc

const std::string casadi::LinsolQr::meta_doc
static
Initial value:
=
"\n"
"\n"
"\n"
"Linear solver using sparse direct QR factorization\n"
"\n"
"Extra doc: https://github.com/casadi/casadi/wiki/L_22z \n"
"\n"
"\n"
">List of available options\n"
"\n"
"+-------+-----------+------------------------------------------------------+\n"
"| Id | Type | Description |\n"
"+=======+===========+======================================================+\n"
"| cache | OT_DOUBLE | Amount of factorisations to remember (thread-local) |\n"
"| | | [0] |\n"
"+-------+-----------+------------------------------------------------------+\n"
"| eps | OT_DOUBLE | Minimum R entry before singularity is declared |\n"
"| | | [1e-12] |\n"
"+-------+-----------+------------------------------------------------------+\n"
"\n"
"\n"
"\n"
"\n"

Definition at line 110 of file linsol_qr.hpp.

Referenced by casadi::casadi_register_linsol_qr().

◆ n_cache_

casadi_int casadi::LinsolQr::n_cache_

Definition at line 118 of file linsol_qr.hpp.

Referenced by generate(), init(), init_mem(), LinsolQr(), nfact(), and serialize_body().

◆ name_

std::string casadi::ProtoFunction::name_
inherited

Definition at line 246 of file function_internal.hpp.

Referenced by casadi::MXFunction::ad_forward(), casadi::SXFunction::ad_forward(), casadi::MXFunction::ad_reverse(), casadi::SXFunction::ad_reverse(), casadi::Integrator::augmented_dae(), casadi::OracleFunction::calc_function(), casadi::FunctionInternal::call_forward(), casadi::FunctionInternal::call_reverse(), casadi::FunctionInternal::codegen_body(), casadi::External::codegen_body(), casadi::External::codegen_checkout(), casadi::External::codegen_declarations(), casadi::MXFunction::codegen_declarations(), casadi::SXFunction::codegen_declarations(), casadi::External::codegen_decref(), casadi::External::codegen_incref(), casadi::FunctionInternal::codegen_meta(), casadi::FunctionInternal::codegen_name(), casadi::External::codegen_release(), casadi::FunctionInternal::codegen_sparsities(), casadi::ProtoFunction::construct(), casadi::OracleFunction::create_function(), casadi::FunctionInternal::definition(), casadi::FunctionInternal::eval(), casadi::MXFunction::eval(), casadi::SXFunction::eval(), casadi::FunctionInternal::eval_mx(), casadi::MXFunction::eval_mx(), casadi::SXFunction::eval_mx(), casadi::SXFunction::eval_sx(), casadi::FmuFunction::factory(), casadi::FunctionInternal::finalize(), casadi::FunctionInternal::forward(), casadi::FunctionInternal::FunctionInternal(), casadi::Integrator::get_forward(), casadi::Integrator::get_forward_dae(), casadi::Map::get_function(), casadi::MapSum::get_function(), casadi::OracleFunction::get_function(), casadi::GenericExternal::get_jac_sparsity(), casadi::BlazingSplineFunction::get_jacobian(), casadi::FunctionInternal::get_n_in(), casadi::External::get_n_in(), casadi::FunctionInternal::get_n_out(), casadi::External::get_n_out(), casadi::FunctionInternal::get_name_in(), casadi::External::get_name_in(), casadi::FunctionInternal::get_name_out(), casadi::External::get_name_out(), casadi::FunctionInternal::get_partition(), casadi::Integrator::get_reverse(), casadi::FunctionInternal::get_sparsity_in(), casadi::GenericExternal::get_sparsity_in(), casadi::FunctionInternal::get_sparsity_out(), casadi::GenericExternal::get_sparsity_out(), casadi::FunctionInternal::get_stats(), casadi::External::has_forward(), casadi::GenericExternal::has_jac_sparsity(), casadi::External::has_jacobian(), casadi::External::has_reverse(), casadi::External::init(), casadi::FunctionInternal::init(), casadi::MXFunction::init(), casadi::SXFunction::init(), casadi::CvodesInterface::init(), casadi::IdasInterface::init(), casadi::External::init_external(), casadi::GenericExternal::init_external(), casadi::FunctionInternal::jac_is_symm(), casadi::FunctionInternal::jacobian(), casadi::FunctionInternal::map(), casadi::OracleFunction::monitored(), casadi::MXFunction::print_arg(), casadi::FunctionInternal::print_in(), casadi::FunctionInternal::print_out(), casadi::MXFunction::print_res(), casadi::ProtoFunction::print_time(), casadi::ProtoFunction::ProtoFunction(), casadi::CvodesInterface::reset(), casadi::IdasInterface::reset(), casadi::IdasInterface::resetB(), casadi::FunctionInternal::reverse(), casadi::ProtoFunction::serialize_body(), casadi::GurobiInterface::solve(), casadi::SnoptInterface::solve(), casadi::Integrator::sp_forward(), casadi::Integrator::sp_reverse(), casadi::FunctionInternal::wrap(), and casadi::FunctionInternal::wrap_as_needed().

◆ options_

const Options casadi::LinsolQr::options_
static
Initial value:
{{"eps",
"Minimum R entry before singularity is declared [1e-12]"}},
{"cache",
"Amount of factorisations to remember (thread-local) [0]"}}
}
}
static const Options options_
Options.

Definition at line 77 of file linsol_qr.hpp.

Referenced by casadi::casadi_register_linsol_qr().

◆ pc_

std::vector<casadi_int> casadi::LinsolQr::pc_

Definition at line 113 of file linsol_qr.hpp.

Referenced by generate(), init(), LinsolQr(), nfact(), serialize_body(), and solve().

◆ print_time_

bool casadi::ProtoFunction::print_time_
inherited

◆ prinv_

std::vector<casadi_int> casadi::LinsolQr::prinv_

Definition at line 113 of file linsol_qr.hpp.

Referenced by generate(), init(), LinsolQr(), nfact(), serialize_body(), and solve().

◆ record_time_

bool casadi::ProtoFunction::record_time_
inherited

◆ regularity_check_

bool casadi::ProtoFunction::regularity_check_
inherited

◆ solvers_

std::map< std::string, LinsolInternal::Plugin > casadi::LinsolInternal::solvers_
staticinherited

Definition at line 127 of file linsol_internal.hpp.

◆ sp_

Sparsity casadi::LinsolInternal::sp_
inherited

◆ sp_r_

Sparsity casadi::LinsolQr::sp_r_

Definition at line 114 of file linsol_qr.hpp.

Referenced by finalize(), generate(), init(), init_mem(), LinsolQr(), nfact(), serialize_body(), and solve().

◆ sp_v_

Sparsity casadi::LinsolQr::sp_v_

Definition at line 114 of file linsol_qr.hpp.

Referenced by finalize(), generate(), init(), init_mem(), LinsolQr(), nfact(), serialize_body(), and solve().

◆ verbose_

bool casadi::ProtoFunction::verbose_
inherited

Definition at line 249 of file function_internal.hpp.

Referenced by casadi::MXFunction::ad_forward(), casadi::SXFunction::ad_forward(), casadi::MXFunction::ad_reverse(), casadi::SXFunction::ad_reverse(), casadi::Integrator::advance(), casadi::ProtoFunction::change_option(), casadi::BSplineInterpolant::construct_graph(), casadi::OracleFunction::create_function(), casadi::FmuFunction::eval(), casadi::Integrator::eval(), casadi::MXFunction::eval(), casadi::SXFunction::eval(), casadi::MXFunction::eval_mx(), casadi::SXFunction::eval_mx(), casadi::SXFunction::eval_sx(), casadi::FmuFunction::factory(), casadi::FunctionInternal::finalize(), casadi::KinsolInterface::func(), casadi::ProtoFunction::generate_options(), casadi::FmuFunction::get_forward(), casadi::Integrator::get_forward(), casadi::Integrator::get_forward_dae(), casadi::FunctionInternal::get_jac_sparsity_gen(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::FmuFunction::get_jacobian(), casadi::FunctionInternal::get_partition(), casadi::FmuFunction::get_reverse(), casadi::Integrator::get_reverse(), casadi::ProtoFunction::init(), casadi::FiniteDiff::init(), casadi::FmuFunction::init(), casadi::FunctionInternal::init(), casadi::MXFunction::init(), casadi::SXFunction::init(), casadi::Blocksqp::init(), casadi::FatropConicInterface::init(), casadi::FatropInterface::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::IpoptInterface::init(), casadi::MadnlpInterface::init(), casadi::CvodesInterface::init(), casadi::IdasInterface::init(), casadi::Feasiblesqpmethod::init(), casadi::Scpgen::init(), casadi::Sqpmethod::init(), casadi::IpoptInterface::init_mem(), casadi::IdasInterface::init_mem(), casadi::SXFunction::instructions_sx(), casadi::BonminInterface::intermediate_callback(), casadi::OracleFunction::jit_dependencies(), casadi::CsparseInterface::nfact(), casadi::LapackLu::nfact(), casadi::LapackQr::nfact(), nfact(), casadi::Integrator::predict_events(), casadi::ProtoFunction::ProtoFunction(), casadi::CvodesInterface::reset(), casadi::IdasInterface::reset(), casadi::IdasInterface::resetB(), casadi::ProtoFunction::serialize_body(), casadi::CbcInterface::solve(), casadi::ClpInterface::solve(), casadi::CplexInterface::solve(), casadi::GurobiInterface::solve(), casadi::HpipmInterface::solve(), casadi::QpoasesInterface::solve(), casadi::Ipqp::solve(), casadi::Qrqp::solve(), casadi::AlpaqaInterface::solve(), casadi::AmplInterface::solve(), casadi::SnoptInterface::solve(), casadi::KinsolInterface::solve(), casadi::WorhpInterface::solve(), casadi::Newton::solve(), casadi::Qrsqp::solve(), casadi::Scpgen::solve(), casadi::Sqpmethod::solve(), casadi::Sqpmethod::solve_ela_QP(), casadi::Feasiblesqpmethod::solve_LP(), casadi::Feasiblesqpmethod::solve_QP(), casadi::Qrsqp::solve_QP(), casadi::Sqpmethod::solve_QP(), casadi::Integrator::sp_forward(), casadi::Integrator::sp_reverse(), and casadi::Integrator::trigger_event().


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