BFGSPreconditioners.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017, Justin Carpentier, LAAS-CNRS
3  *
4  * This file is part of eigenpy.
5  * eigenpy is free software: you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation, either version 3 of
8  * the License, or (at your option) any later version.
9  * eigenpy is distributed in the hope that it will be
10  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details. You should
13  * have received a copy of the GNU Lesser General Public License along
14  * with eigenpy. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __eigenpy_bfgs_preconditioners_hpp__
18 #define __eigenpy_bfgs_preconditioners_hpp__
19 
20 #include <Eigen/IterativeLinearSolvers>
21 
22 #include "eigenpy/fwd.hpp"
24 
25 namespace eigenpy {
26 
27 template <typename Preconditioner>
29  : public bp::def_visitor<BFGSPreconditionerBaseVisitor<Preconditioner> > {
30  typedef Eigen::VectorXd VectorType;
31  template <class PyClass>
32  void visit(PyClass& cl) const {
34  .def("rows", &Preconditioner::rows,
35  "Returns the number of rows in the preconditioner.")
36  .def("cols", &Preconditioner::cols,
37  "Returns the number of cols in the preconditioner.")
38  .def("dim", &Preconditioner::dim,
39  "Returns the dimension of the BFGS preconditioner")
40  .def("update",
41  (const Preconditioner& (Preconditioner::*)(const VectorType&,
42  const VectorType&)
43  const) &
44  Preconditioner::update,
45  bp::args("s", "y"), "Update the BFGS estimate of the matrix A.",
46  bp::return_value_policy<bp::reference_existing_object>())
47  .def("reset", &Preconditioner::reset, "Reset the BFGS estimate.");
48  }
49 
50  static void expose(const std::string& name) {
51  bp::class_<Preconditioner>(name, bp::no_init)
53  }
54 };
55 
56 template <typename Preconditioner>
58  : public bp::def_visitor<
59  LimitedBFGSPreconditionerBaseVisitor<Preconditioner> > {
60  template <class PyClass>
61  void visit(PyClass& cl) const {
64  .def("resize", &Preconditioner::resize, bp::arg("dim"),
65  "Resizes the preconditionner with size dim.",
66  bp::return_value_policy<bp::reference_existing_object>());
67  }
68 
69  static void expose(const std::string& name) {
70  bp::class_<Preconditioner>(name.c_str(), bp::no_init)
72  }
73 };
74 
75 } // namespace eigenpy
76 
77 #endif // ifndef __eigenpy_bfgs_preconditioners_hpp__
static void expose(const std::string &name)
static void expose(const std::string &name)


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Jun 2 2023 02:10:26