26 #ifndef CASADI_LSQR_HPP
27 #define CASADI_LSQR_HPP
29 #include "casadi/core/linsol_internal.hpp"
30 #include <casadi/solvers/casadi_linsol_lsqr_export.h>
47 struct LsqrMemory :
public LinsolMemory {
49 std::vector<const double*> arg;
50 std::vector<double> w;
52 std::vector<double> A;
62 class Lsqr :
public LinsolInternal {
65 Lsqr(
const std::string& name,
const Sparsity& sp);
71 const char* plugin_name()
const override {
return "lsqr";}
74 std::string class_name()
const override {
return "Lsqr";}
77 static LinsolInternal* creator(
const std::string& name,
const Sparsity& sp) {
78 return new Lsqr(name, sp);
82 void* alloc_mem()
const override {
return new LsqrMemory();}
85 int init_mem(
void* mem)
const override;
88 void free_mem(
void *mem)
const override {
delete static_cast<LsqrMemory*
>(mem);}
91 int nfact(
void* mem,
const double* A)
const override;
94 int solve(
void* mem,
const double* A,
double* x, casadi_int nrhs,
bool tr)
const override;
97 void generate(CodeGenerator& g,
const std::string& A,
const std::string& x,
98 casadi_int nrhs,
bool tr)
const override;
101 static const std::string meta_doc;
104 static ProtoFunction* deserialize(DeserializingStream& s) {
return new Lsqr(s); }
108 explicit Lsqr(DeserializingStream& s) : LinsolInternal(s) {}