26 #include "linsol_ldl.hpp"
27 #include "casadi/core/global_options.hpp"
32 int CASADI_LINSOL_LDL_EXPORT
37 plugin->version = CASADI_VERSION;
60 "Incomplete factorization, without any fill-in"}},
63 "Approximate minimal degree (AMD) preordering"}}
76 for (
auto&& op : opts) {
77 if (op.first==
"incomplete") {
79 }
else if (op.first==
"amd") {
89 std::vector<casadi_int> tmp;
91 sp_Lt_ = triu(Aperm,
false);
122 for (
double d : m->d) {
123 if (d==0) casadi_warning(
"LDL factorization has zeros in D");
128 int LinsolLdl::solve(
void* mem,
const double* A,
double* x, casadi_int nrhs,
bool tr)
const {
139 for (casadi_int i=0; i<
nrow; ++i)
if (m->d[i]<0) ret++;
148 for (casadi_int i=0; i<
nrow; ++i)
if (m->d[i]!=0) ret++;
153 casadi_int nrhs,
bool tr)
const {
161 g.
comment(
"FIXME(@jaeandersson): Memory allocation can be avoided");
162 g <<
"casadi_real lt[" <<
sp_Lt_.
nnz() <<
"], "
163 "d[" <<
nrow() <<
"], "
164 "w[" <<
nrow() <<
"];\n";
167 g << g.
ldl(sp, A, sp_Lt,
"lt",
"d", p,
"w") <<
"\n";
170 g << g.
ldl_solve(x, nrhs, sp_Lt,
"lt",
"d", p,
"w") <<
"\n";
185 s.
pack(
"LinsolLdl::p",
p_);
Helper class for C code generation.
void comment(const std::string &s)
Write a comment line (ignored if not verbose)
std::string constant(const std::vector< casadi_int > &v)
Represent an array constant; adding it when new.
std::string ldl_solve(const std::string &x, casadi_int nrhs, const std::string &sp_lt, const std::string <, const std::string &d, const std::string &p, const std::string &w)
LDL solve.
std::string ldl(const std::string &sp_a, const std::string &a, const std::string &sp_lt, const std::string <, const std::string &d, const std::string &p, const std::string &w)
LDL factorization.
std::string sparsity(const Sparsity &sp, bool canonical=true)
Helper class for Serialization.
void unpack(Sparsity &e)
Reconstruct an object from the input stream.
void version(const std::string &name, int v)
void init(const Dict &opts) override
Initialize.
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.
casadi_int nrow() const
Get sparsity pattern.
int init_mem(void *mem) const override
Initalize memory block.
void init(const Dict &opts) override
Initialize.
casadi_int rank(void *mem, const double *A) const override
Matrix rank.
static const std::string meta_doc
A documentation string.
int solve(void *mem, const double *A, double *x, casadi_int nrhs, bool tr) const override
int nfact(void *mem, const double *A) const override
Numeric factorization.
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.
static LinsolInternal * creator(const std::string &name, const Sparsity &sp)
Create a new LinsolInternal.
void generate(CodeGenerator &g, const std::string &A, const std::string &x, casadi_int nrhs, bool tr) const override
Generate C code.
LinsolLdl(const std::string &name, const Sparsity &sp)
casadi_int neig(void *mem, const double *A) const override
Number of negative eigenvalues.
static const Options options_
Options.
std::vector< casadi_int > p_
int sfact(void *mem, const double *A) const override
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize with type disambiguation.
int init_mem(void *mem) const override
Initalize memory block.
static void registerPlugin(const Plugin &plugin, bool needs_lock=true)
Register an integrator in the factory.
static const Options options_
Options.
void clear_mem()
Clear all memory (called from destructor)
Helper class for Serialization.
void version(const std::string &name, int v)
void pack(const Sparsity &e)
Serializes an object to the output stream.
Sparsity sub(const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, std::vector< casadi_int > &mapping, bool ind1=false) const
Get a submatrix.
casadi_int size1() const
Get the number of rows.
std::vector< casadi_int > amd() const
Approximate minimal degree preordering.
casadi_int nnz() const
Get the number of (structural) non-zeros.
Sparsity ldl(std::vector< casadi_int > &p, bool amd=true) const
Symbolic LDL factorization.
std::vector< casadi_int > range(casadi_int start, casadi_int stop, casadi_int step, casadi_int len)
Range function.
int CASADI_LINSOL_LDL_EXPORT casadi_register_linsol_ldl(LinsolInternal::Plugin *plugin)
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
void CASADI_LINSOL_LDL_EXPORT casadi_load_linsol_ldl()
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.
Options metadata for a class.