linsol.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef CASADI_LINSOL_HPP
27 #define CASADI_LINSOL_HPP
28 
29 #include "function.hpp"
30 #include "printable.hpp"
31 
32 namespace casadi {
33 
34  // Forward declaration of internal class
35  class LinsolInternal;
36 
142  class CASADI_EXPORT Linsol
143  : public SharedObject,
144  public SWIG_IF_ELSE(PrintableCommon, Printable<Linsol>) {
145  public:
149  static std::string type_name() {return "Linsol";}
150 
153 
200  explicit Linsol(const std::string& name, const std::string& solver,
201  const Sparsity& sp, const Dict& opts=Dict());
202 
204  LinsolInternal* operator->();
205  const LinsolInternal* operator->() const;
206 
207 #ifndef SWIG
209  static bool test_cast(const SharedObjectInternal* ptr);
210 #endif //SWIG
211 
213 #ifndef SWIG
217  static Linsol create(LinsolInternal* node);
218 #endif // SWIG
220 
248  static bool has_plugin(const std::string& name);
249 
284  static void load_plugin(const std::string& name);
285 
312  static std::string doc(const std::string& name);
313 
315  std::string plugin_name() const;
316 
318  const Sparsity& sparsity() const;
319 
326  void sfact(const DM& A) const;
327 
371  void nfact(const DM& A) const;
372 
374 
425  DM solve(const DM& A, const DM& B, bool tr=false) const;
426  MX solve(const MX& A, const MX& B, bool tr=false) const;
428 
477  casadi_int neig(const DM& A) const;
478 
515  casadi_int rank(const DM& A) const;
516 
559  double det(const DM& A) const;
560 
562  MX det(const MX& A) const;
563 
616  Dict stats(int mem=1) const;
617 
618  #ifndef SWIG
621  int sfact(const double* A, int mem=0) const;
622  int nfact(const double* A, int mem=0) const;
623  int solve(const double* A, double* x, casadi_int nrhs=1, bool tr=false, int mem=0) const;
624  double det(const double* A, int mem = 0) const;
625  casadi_int neig(const double* A, int mem=0) const;
626  casadi_int rank(const double* A, int mem=0) const;
628 
630  casadi_int checkout() const;
631 
633  void release(int mem) const;
634 
638  void serialize(SerializingStream &s) const;
639 
643  static Linsol deserialize(DeserializingStream& s);
644 
645  #endif // SWIG
646  };
647 
675  CASADI_EXPORT bool has_linsol(const std::string& name);
676 
712  CASADI_EXPORT void load_linsol(const std::string& name);
713 
740  CASADI_EXPORT std::string doc_linsol(const std::string& name);
741 
742 } // namespace casadi
743 
744 #endif // CASADI_LINSOL_HPP
Helper class for Serialization.
Linear solver.
Definition: linsol.hpp:144
Linsol(const std::string &name, const std::string &solver, const Sparsity &sp, const Dict &opts=Dict())
Create a linear solver.
casadi_int rank(const DM &A) const
Matrix rank.
static bool has_plugin(const std::string &name)
Check if a plugin is available.
static void load_plugin(const std::string &name)
Explicitly load a plugin dynamically.
void nfact(const DM &A) const
Numeric factorization of the linear system.
Linsol()
Default constructor (a null object)
double det(const DM &A) const
Matrix determinant.
MX solve(const MX &A, const MX &B, bool tr=false) const
Solve the linear system A*X = B (or A'*X = B with tr true)
LinsolInternal * operator->()
Access functions of the node.
Dict stats(int mem=1) const
Get all statistics obtained at the end of the last evaluate call.
const LinsolInternal * operator->() const
static std::string doc(const std::string &name)
Get solver specific documentation.
std::string plugin_name() const
Query plugin name.
const Sparsity & sparsity() const
Get the sparsity pattern of A fixed at construction.
DM solve(const DM &A, const DM &B, bool tr=false) const
Solve the linear system A*X = B (or A'*X = B with tr true)
static std::string type_name()
Get type name.
Definition: linsol.hpp:149
void sfact(const DM &A) const
Symbolic factorization of the linear system, e.g. selecting pivots.
casadi_int neig(const DM &A) const
Number of negative eigenvalues.
MX det(const MX &A) const
Matrix determinant as an MX graph node.
MX - Matrix expression.
Definition: mx.hpp:145
Helper class for Serialization.
GenericShared implements a reference counting framework similar for efficient and.
General sparsity class.
Definition: sparsity.hpp:200
The casadi namespace.
Definition: archiver.hpp:32
CASADI_EXPORT std::string doc_linsol(const std::string &name)
Get the documentation string of a linear solver plugin.
CASADI_EXPORT bool has_linsol(const std::string &name)
Check if a linear solver plugin is available.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
CASADI_EXPORT void load_linsol(const std::string &name)
Explicitly load a linear solver plugin.