26 #include "lapack_lu.hpp"
27 #include "../../core/casadi_misc.hpp"
32 int CASADI_LINSOL_LAPACKLU_EXPORT
35 plugin->name =
"lapacklu";
37 plugin->version = CASADI_VERSION;
64 "Equilibrate the matrix"}},
65 {
"allow_equilibration_failure",
67 "Non-fatal error when equilibration fails"}}
76 for (
auto&& op : opts) {
77 if (op.first==
"equilibration") {
79 }
else if (op.first==
"allow_equilibration_failure") {
91 m->ipiv.resize(
ncol());
114 double colcnd, rowcnd;
118 get_ptr(m->c), &colcnd, &rowcnd, &amax, &info);
119 if (info < 0)
return 1;
121 std::stringstream ss;
122 ss <<
"LapackLu::prepare: ";
123 if (info<=
ncol) ss << (info-1) <<
"-th row (zero-based) is exactly zero";
124 else ss << (info-1-
ncol) <<
"-th col (zero-based) is exactly zero";
125 uout() <<
"Warning: " << ss.str() << std::endl;
127 else casadi_error(ss.str());
133 &colcnd, &rowcnd, &amax, &m->equed);
142 if (
verbose_) casadi_warning(
"dgetrf_ failed: Info: " +
str(info));
148 int LapackLu::solve(
void* mem,
const double* A,
double* x, casadi_int nrhs,
bool tr)
const {
159 if (m->equed==
'C' || m->equed==
'B')
160 for (casadi_int rhs=0; rhs<nrhs; ++rhs)
161 for (casadi_int i=0; i<
nrow; ++i)
162 x[i+rhs*
nrow] *= m->c[i];
164 if (m->equed==
'R' || m->equed==
'B')
165 for (casadi_int rhs=0; rhs<nrhs; ++rhs)
166 for (casadi_int i=0; i<
ncol; ++i)
167 x[i+rhs*
nrow] *= m->r[i];
172 char trans = tr ?
'T' :
'N';
178 if (m->equed==
'R' || m->equed==
'B')
179 for (casadi_int rhs=0; rhs<nrhs; ++rhs)
180 for (casadi_int i=0; i<
ncol; ++i)
181 x[i+rhs*
nrow] *= m->r[i];
183 if (m->equed==
'C' || m->equed==
'B')
184 for (casadi_int rhs=0; rhs<nrhs; ++rhs)
185 for (casadi_int i=0; i<
nrow; ++i)
186 x[i+rhs*
nrow] *= m->c[i];
Helper class for Serialization.
void unpack(Sparsity &e)
Reconstruct an object from the input stream.
void version(const std::string &name, int v)
static const Options options_
Options.
int init_mem(void *mem) const override
Initalize memory block.
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize with type disambiguation.
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.
~LapackLu() override
Destructor.
bool equilibriate_
Equilibrate?
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 init(const Dict &opts) override
Initialize the solver.
static const Options options_
Options.
static LinsolInternal * creator(const std::string &name, const Sparsity &sp)
Create a new Linsol.
LapackLu(const std::string &name, const Sparsity &sp)
bool allow_equilibration_failure_
Allow the equilibration to fail.
static const std::string meta_doc
A documentation string.
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.
static void registerPlugin(const Plugin &plugin, bool needs_lock=true)
Register an integrator in the factory.
bool verbose_
Verbose printout.
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.
int CASADI_LINSOL_LAPACKLU_EXPORT casadi_register_linsol_lapacklu(LinsolInternal::Plugin *plugin)
std::string str(const T &v)
String representation, any type.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
void casadi_densify(const T1 *x, const casadi_int *sp_x, T2 *y, casadi_int tr)
Convert sparse to dense.
void CASADI_LINSOL_LAPACKLU_EXPORT casadi_load_linsol_lapacklu()
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.
std::vector< double > mat
Options metadata for a class.