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

'lapackqr' plugin for Linsol More...

#include <lapack_qr.hpp>

Detailed Description

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].


List of available options
IdTypeDescriptionUsed in
ad_weightOT_DOUBLEWeighting factor for derivative calculation.When there is an option of either using forward or reverse mode directional derivatives, the condition ad_weight*nf<=(1-ad_weight)*na is used where nf and na are estimates of the number of forward/reverse mode directional derivatives needed. By default, ad_weight is calculated automatically, but this can be overridden by setting this option. In particular, 0 means forcing forward mode and 1 forcing reverse mode. Leave unset for (class specific) heuristics.casadi::FunctionInternal
ad_weight_spOT_DOUBLEWeighting factor for sparsity pattern calculation calculation.Overrides default behavior. Set to 0 and 1 to force forward and reverse mode respectively. Cf. option "ad_weight". When set to -1, sparsity is completely ignored and dense matrices are used.casadi::FunctionInternal
always_inlineOT_BOOLForce inlining.casadi::FunctionInternal
cacheOT_DICTPrepopulate the function cache. Default: emptycasadi::FunctionInternal
compilerOT_STRINGJust-in-time compiler plugin to be used.casadi::FunctionInternal
custom_jacobianOT_FUNCTIONOverride CasADi's AD. Use together with 'jac_penalty': 0. Note: Highly experimental. Syntax may break often.casadi::FunctionInternal
der_optionsOT_DICTDefault options to be used to populate forward_options, reverse_options, and jacobian_options before those options are merged in.casadi::FunctionInternal
derivative_ofOT_FUNCTIONThe function is a derivative of another function. The type of derivative (directional derivative, Jacobian) is inferred from the function name.casadi::FunctionInternal
dumpOT_BOOLDump function to file upon first evaluation. [false]casadi::FunctionInternal
dump_dirOT_STRINGDirectory to dump inputs/outputs to. Make sure the directory exists [.]casadi::FunctionInternal
dump_formatOT_STRINGChoose file format to dump matrices. See DM.from_file [mtx]casadi::FunctionInternal
dump_inOT_BOOLDump numerical values of inputs to file (readable with DM.from_file) [default: false]casadi::FunctionInternal
dump_outOT_BOOLDump numerical values of outputs to file (readable with DM.from_file) [default: false]casadi::FunctionInternal
enable_fdOT_BOOLEnable derivative calculation by finite differencing. [default: false]]casadi::FunctionInternal
enable_forwardOT_BOOLEnable derivative calculation using generated functions for Jacobian-times-vector products - typically using forward mode AD - if available. [default: true]casadi::FunctionInternal
enable_jacobianOT_BOOLEnable derivative calculation using generated functions for Jacobians of all differentiable outputs with respect to all differentiable inputs - if available. [default: true]casadi::FunctionInternal
enable_reverseOT_BOOLEnable derivative calculation using generated functions for transposed Jacobian-times-vector products - typically using reverse mode AD - if available. [default: true]casadi::FunctionInternal
error_on_failOT_BOOLThrow exceptions when function evaluation fails (default true).casadi::ProtoFunction
external_transformOT_VECTORVECTORList of external_transform instruction arguments. Default: emptycasadi::FunctionInternal
fd_methodOT_STRINGMethod for finite differencing [default 'central']casadi::FunctionInternal
fd_optionsOT_DICTOptions to be passed to the finite difference instancecasadi::FunctionInternal
forward_optionsOT_DICTOptions to be passed to a forward mode constructorcasadi::FunctionInternal
gather_statsOT_BOOLDeprecated option (ignored): Statistics are now always collected.casadi::FunctionInternal
input_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
inputs_checkOT_BOOLThrow exceptions when the numerical values of the inputs don't make sensecasadi::FunctionInternal
is_diff_inOT_BOOLVECTORIndicate for each input if it should be differentiable.casadi::FunctionInternal
is_diff_outOT_BOOLVECTORIndicate for each output if it should be differentiable.casadi::FunctionInternal
jac_penaltyOT_DOUBLEWhen requested for a number of forward/reverse directions, it may be cheaper to compute first the full jacobian and then multiply with seeds, rather than obtain the requested directions in a straightforward manner. Casadi uses a heuristic to decide which is cheaper. A high value of 'jac_penalty' makes it less likely for the heurstic to chose the full Jacobian strategy. The special value -1 indicates never to use the full Jacobian strategycasadi::FunctionInternal
jacobian_optionsOT_DICTOptions to be passed to a Jacobian constructorcasadi::FunctionInternal
jitOT_BOOLUse just-in-time compiler to speed up the evaluationcasadi::FunctionInternal
jit_cleanupOT_BOOLCleanup up the temporary source file that jit creates. Default: truecasadi::FunctionInternal
jit_nameOT_STRINGThe file name used to write out code. The actual file names used depend on 'jit_temp_suffix' and include extensions. Default: 'jit_tmp'casadi::FunctionInternal
jit_optionsOT_DICTOptions to be passed to the jit compiler.casadi::FunctionInternal
jit_serializeOT_STRINGSpecify behaviour when serializing a jitted function: SOURCE|link|embed.casadi::FunctionInternal
jit_temp_suffixOT_BOOLUse a temporary (seemingly random) filename suffix for generated code and libraries. This is desired for thread-safety. This behaviour may defeat caching compiler wrappers. Default: truecasadi::FunctionInternal
max_ioOT_INTAcceptable number of inputs and outputs. Warn if exceeded.casadi::FunctionInternal
max_nrhsOT_INTMaximum number of right-hand-sides that get processed in a single pass [default:10].casadi::LapackQr
max_num_dirOT_INTSpecify the maximum number of directions for derivative functions. Overrules the builtin optimized_num_dir.casadi::FunctionInternal
never_inlineOT_BOOLForbid inlining.casadi::FunctionInternal
output_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
post_expandOT_BOOLAfter construction, expand this Function. Default: Falsecasadi::FunctionInternal
post_expand_optionsOT_DICTOptions to be passed to post-construction expansion. Default: emptycasadi::FunctionInternal
print_inOT_BOOLPrint numerical values of inputs [default: false]casadi::FunctionInternal
print_outOT_BOOLPrint numerical values of outputs [default: false]casadi::FunctionInternal
print_timeOT_BOOLprint information about execution time. Implies record_time.casadi::ProtoFunction
record_timeOT_BOOLrecord information about execution time, for retrieval with stats().casadi::ProtoFunction
regularity_checkOT_BOOLThrow exceptions when NaN or Inf appears during evaluationcasadi::ProtoFunction
reverse_optionsOT_DICTOptions to be passed to a reverse mode constructorcasadi::FunctionInternal
user_dataOT_VOIDPTRA user-defined field that can be used to identify the function or pass additional informationcasadi::FunctionInternal
verboseOT_BOOLVerbose evaluation – for debuggingcasadi::ProtoFunction

Definition at line 76 of file lapack_qr.hpp.

Inheritance diagram for casadi::LapackQr:
Inheritance graph
[legend]
Collaboration diagram for casadi::LapackQr:
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

 LapackQr (const std::string &name, const Sparsity &sp)
 
 ~LapackQr () override
 
void init (const Dict &opts) override
 Initialize. 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 solve_batch (void *mem, const double *A, double *x, casadi_int nrhs, bool tr) const
 
int solve (void *mem, const double *A, double *x, casadi_int nrhs, bool tr) const override
 
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 int sfact (void *mem, const double *A) const
 
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...
 
virtual void generate (CodeGenerator &g, const std::string &A, const std::string &x, casadi_int nrhs, bool tr) const
 Generate C code. 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...
 
virtual void finalize ()
 Finalize the object creation. 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 Linsol. 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

casadi_int max_nrhs_
 
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

 LapackQr (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

◆ LapackQr() [1/2]

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

Definition at line 48 of file lapack_qr.cpp.

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

◆ ~LapackQr()

casadi::LapackQr::~LapackQr ( )
override

Definition at line 52 of file lapack_qr.cpp.

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

References casadi::ProtoFunction::clear_mem().

◆ LapackQr() [2/2]

casadi::LapackQr::LapackQr ( DeserializingStream s)
explicitprotected

Definition at line 172 of file lapack_qr.cpp.

172  : LinsolInternal(s) {
173  s.unpack("LapackQr::max_nrhs", max_nrhs_);
174  }
casadi_int max_nrhs_
Definition: lapack_qr.hpp:126

References max_nrhs_, and casadi::DeserializingStream::unpack().

Member Function Documentation

◆ alloc_mem()

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

Reimplemented from casadi::LinsolInternal.

Definition at line 99 of file lapack_qr.hpp.

99 { return new LapackQrMemory();}

◆ 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::LapackQr::class_name ( ) const
inlineoverridevirtual

Implements casadi::SharedObjectInternal.

Definition at line 123 of file lapack_qr.hpp.

123 { return "LapackQr";}

◆ 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(), ~LapackQr(), casadi::LinearInterpolant::~LinearInterpolant(), casadi::LinearInterpolantJac::~LinearInterpolantJac(), casadi::LinsolLdl::~LinsolLdl(), casadi::LinsolQr::~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::LapackQr::creator ( const std::string &  name,
const Sparsity sp 
)
inlinestatic

Definition at line 82 of file lapack_qr.hpp.

82  {
83  return new LapackQr(name, sp);
84  }
LapackQr(const std::string &name, const Sparsity &sp)
Definition: lapack_qr.cpp:48

Referenced by casadi::casadi_register_linsol_lapackqr().

◆ 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::LapackQr::deserialize ( DeserializingStream s)
inlinestatic

Definition at line 132 of file lapack_qr.hpp.

132 { return new LapackQr(s); }

Referenced by casadi::casadi_register_linsol_lapackqr().

◆ 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::ProtoFunction::finalize ( )
virtualinherited

This function, which visits the class hierarchy in reverse order is run after init() has been completed.

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

Reimplemented in casadi::LinsolQr, casadi::OracleFunction, casadi::FunctionInternal, and casadi::CallbackInternal.

Definition at line 725 of file function_internal.cpp.

725  {
726  // Create memory object
727  int mem = checkout();
728  casadi_assert_dev(mem==0);
729  }
int checkout() const
Checkout a memory object.

References casadi::ProtoFunction::checkout().

Referenced by casadi::ProtoFunction::construct(), casadi::Linsol::deserialize(), casadi::FunctionInternal::finalize(), and casadi::LinsolQr::finalize().

◆ 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::LapackQr::free_mem ( void *  mem) const
inlineoverridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 105 of file lapack_qr.hpp.

105 { delete static_cast<LapackQrMemory*>(mem);}

◆ generate()

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

Reimplemented in casadi::Lsqr, casadi::LinsolTridiag, casadi::LinsolQr, and casadi::LinsolLdl.

Definition at line 110 of file linsol_internal.cpp.

111  {
112  g << "#error " << class_name() << " does not support code generation\n";
113  }

References casadi::SharedObjectInternal::class_name().

◆ 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::LapackQr::get_options ( ) const
inlineoverridevirtual

Reimplemented from casadi::ProtoFunction.

Definition at line 95 of file lapack_qr.hpp.

95 { return options_;}
static const Options options_
Options.
Definition: lapack_qr.hpp:94

◆ 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::LapackQr::init ( const Dict opts)
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 64 of file lapack_qr.cpp.

64  {
65  // Call the base class initializer
67 
68  max_nrhs_ = 10;
69 
70  // Read options
71  for (auto&& op : opts) {
72  if (op.first=="max_nrhs") {
73  max_nrhs_ = op.second;
74  }
75  }
76  }
void init(const Dict &opts) override
Initialize.

References casadi::LinsolInternal::init(), and max_nrhs_.

◆ init_mem()

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

Reimplemented from casadi::LinsolInternal.

Definition at line 78 of file lapack_qr.cpp.

78  {
79  if (LinsolInternal::init_mem(mem)) return 1;
80  auto m = static_cast<LapackQrMemory*>(mem);
81  m->mat.resize(ncol() * ncol());
82  m->tau.resize(ncol());
83  m->work.resize(std::max(max_nrhs_, ncol())*10);
84  return 0;
85  }
casadi_int ncol() const
int init_mem(void *mem) const override
Initalize memory block.

References casadi::LinsolInternal::init_mem(), casadi::LapackQrMemory::mat, max_nrhs_, and casadi::LinsolInternal::ncol().

◆ 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::LapackQr::nfact ( void *  mem,
const double *  A 
) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 87 of file lapack_qr.cpp.

87  {
88  auto m = static_cast<LapackQrMemory*>(mem);
89 
90  // Dimensions
91  //casadi_int nrow = this->nrow();
92  int ncol = this->ncol();
93 
94  // Get the elements of the matrix, dense format
95  casadi_densify(A, sp_, get_ptr(m->mat), false);
96 
97  // Factorize the matrix
98  int info = -100;
99  int lwork = m->work.size();
100  dgeqrf_(&ncol, &ncol, get_ptr(m->mat), &ncol, get_ptr(m->tau),
101  get_ptr(m->work), &lwork, &info);
102  if (info) {
103  if (verbose_) casadi_warning("dgeqrf_ failed: Info: " + str(info));
104  return 1;
105  }
106  return 0;
107  }
void casadi_densify(const T1 *x, const casadi_int *sp_x, T2 *y, casadi_int tr)
Convert sparse to dense.
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.

References casadi::casadi_densify(), casadi::get_ptr(), casadi::LinsolInternal::ncol(), casadi::LinsolInternal::sp_, casadi::str(), 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::LapackQr::plugin_name ( ) const
inlineoverridevirtual

Implements casadi::LinsolInternal.

Definition at line 120 of file lapack_qr.hpp.

120 { return "lapackqr";}

◆ 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(), casadi::LinsolQr::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 print(const char *fmt,...) const
C-style formatted printing during evaluation.
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::LapackQr::serialize_body ( SerializingStream s) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 176 of file lapack_qr.cpp.

176  {
178  s.pack("LapackQr::max_nrhs", max_nrhs_);
179  }
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.

References max_nrhs_, casadi::SerializingStream::pack(), and casadi::LinsolInternal::serialize_body().

◆ serialize_type()

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

◆ sfact()

virtual int casadi::LinsolInternal::sfact ( void *  mem,
const double *  A 
) const
inlinevirtualinherited

◆ 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::LapackQr::solve ( void *  mem,
const double *  A,
double *  x,
casadi_int  nrhs,
bool  tr 
) const
overridevirtual

Reimplemented from casadi::LinsolInternal.

Definition at line 109 of file lapack_qr.cpp.

109  {
110  auto m = static_cast<LapackQrMemory*>(mem);
111 
112  // Solve up to max_nrhs rhs at a time
113  casadi_int offset = 0;
114  while (nrhs>0) {
115  if (solve_batch(m, A, x+offset, std::min(max_nrhs_, nrhs), tr)) return 1;
116  nrhs-= max_nrhs_;
117  offset+= max_nrhs_*nrow();
118  }
119  return 0;
120  }
int solve_batch(void *mem, const double *A, double *x, casadi_int nrhs, bool tr) const
Definition: lapack_qr.cpp:122
casadi_int nrow() const
Get sparsity pattern.

References max_nrhs_, casadi::LinsolInternal::nrow(), and solve_batch().

◆ solve_batch()

int casadi::LapackQr::solve_batch ( void *  mem,
const double *  A,
double *  x,
casadi_int  nrhs,
bool  tr 
) const

Definition at line 122 of file lapack_qr.cpp.

122  {
123  auto m = static_cast<LapackQrMemory*>(mem);
124 
125  // Dimensions
126  //casadi_int nrow = this->nrow();
127  int ncol = this->ncol();
128 
129  // Properties of R
130  char uploR = 'U';
131  char diagR = 'N';
132  char sideR = 'L';
133  double alphaR = 1.;
134  char transR = tr ? 'T' : 'N';
135 
136  // Properties of Q
137  char transQ = tr ? 'N' : 'T';
138  char sideQ = 'L';
139  int k = m->tau.size(); // minimum of ncol and nrow
140  int lwork = m->work.size();
141 
142  int n_rhs = nrhs;
143 
144  if (tr) {
145 
146  // Solve for transpose(R)
147  dtrsm_(&sideR, &uploR, &transR, &diagR, &ncol, &n_rhs, &alphaR,
148  get_ptr(m->mat), &ncol, x, &ncol);
149 
150  // Multiply by Q
151  int info = 100;
152  dormqr_(&sideQ, &transQ, &ncol, &n_rhs, &k, get_ptr(m->mat), &ncol, get_ptr(m->tau), x,
153  &ncol, get_ptr(m->work), &lwork, &info);
154  casadi_assert(info == 0,
155  "LapackQr::solve: dormqr_ A failed to solve the linear system. Info: " + str(info) + ".");
156  } else {
157 
158  // Multiply by transpose(Q)
159  int info = 100;
160  dormqr_(&sideQ, &transQ, &ncol, &n_rhs, &k, get_ptr(m->mat), &ncol, get_ptr(m->tau), x,
161  &ncol, get_ptr(m->work), &lwork, &info);
162  casadi_assert(info == 0,
163  "LapackQr::solve: dormqr_ B failed to solve the linear system. Info: " + str(info) + ".");
164 
165  // Solve for R
166  dtrsm_(&sideR, &uploR, &transR, &diagR, &ncol, &n_rhs, &alphaR,
167  get_ptr(m->mat), &ncol, x, &ncol);
168  }
169  return 0;
170  }

References casadi::get_ptr(), casadi::LinsolInternal::ncol(), and casadi::str().

Referenced by solve().

◆ 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

◆ 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.

◆ max_nrhs_

casadi_int casadi::LapackQr::max_nrhs_

Definition at line 126 of file lapack_qr.hpp.

Referenced by init(), init_mem(), LapackQr(), serialize_body(), and solve().

◆ meta_doc

const std::string casadi::LapackQr::meta_doc
static
Initial value:
=
"\n"
"\n"
"\n"
"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\n"
"\n"
"Extra doc: https://github.com/casadi/casadi/wiki/L_22g \n"
"\n"
"\n"
">List of available options\n"
"\n"
"+----------+--------+------------------------------------------------------+\n"
"| Id | Type | Description |\n"
"+==========+========+======================================================+\n"
"| max_nrhs | OT_INT | Maximum number of right-hand-sides that get |\n"
"| | | processed in a single pass [default:10]. |\n"
"+----------+--------+------------------------------------------------------+\n"
"\n"
"\n"
"\n"
"\n"

Definition at line 117 of file lapack_qr.hpp.

Referenced by casadi::casadi_register_linsol_lapackqr().

◆ 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::LapackQr::options_
static
Initial value:
{{"max_nrhs",
"Maximum number of right-hand-sides that get processed in a single pass [default:10]."}}
}
}
static const Options options_
Options.

Definition at line 94 of file lapack_qr.hpp.

Referenced by casadi::casadi_register_linsol_lapackqr().

◆ print_time_

bool casadi::ProtoFunction::print_time_
inherited

◆ 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

◆ 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(), nfact(), casadi::LinsolQr::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: