-
Notifications
You must be signed in to change notification settings - Fork 47
Linear algebra: Expose the remaining classes listed in Eigen documentation (decompositions and solvers) #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jcarpent
merged 43 commits into
stack-of-tasks:devel
from
Lucas-Haubert:topic/linear_algebra
Aug 8, 2025
Merged
Changes from 42 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
67e7be2
decompositions: Expose classes
Lucas-Haubert aac8d03
readme: added lucas haubert
Lucas-Haubert 15aaa07
decompositions: SVDBase, BDCSVD, JacobiSVD
Lucas-Haubert bd1c0f5
eigenvalues: Expose classes
Lucas-Haubert c8cb13e
solvers: BiCGSTAB
Lucas-Haubert b67c685
unittest: Comments about permutationP and permutationQ in FullPivLU
Lucas-Haubert 9c809b2
unittest: PartialPivLU reconstructedMatrix to retrieve the original m…
Lucas-Haubert 493cd13
Added comments and setThreshold default option in SVDBase
Lucas-Haubert d17a012
solvers: Completed tests
Lucas-Haubert 76269d9
decompositions: comments and rewrites
Lucas-Haubert 8aa33b9
decompositions: Put ordering option AMD in SparseQR
Lucas-Haubert 0ba3768
decompositions: Fixed computation options in BDCSVD
Lucas-Haubert b2ccf7d
decompositions: Rewrite comments in constructors in BDCSVD and JacobiSVD
Lucas-Haubert e3a256e
Set COLAMD Ordering in SParseQR
Lucas-Haubert 8cbaf19
decompositions: Completed tests
Lucas-Haubert 01e2d77
Add IncompleteCholesky and IncompleteLUT
Lucas-Haubert 0ce8903
Added all preconditioners in solvers
Lucas-Haubert c187974
Clean code: Set the same nomenclature of files for exposed classes an…
Lucas-Haubert 5e12ee1
Set Eigen::Lower everywhere for UpLo template option
Lucas-Haubert 4c749d6
Switch MINRES, IncompleteLUT and IncompleteCholesky in eigenpy.solver…
Lucas-Haubert 98ee63f
Optional arguments with bp::optional
Lucas-Haubert 15fc163
README: Remove the 'SVD and QR to be added', but enounce them
Lucas-Haubert a0ee5d5
CI: Fix test_JacobiSVD
Lucas-Haubert 5cc2cbc
is_approx: Put is_approx and set the precision
Lucas-Haubert 7abc77b
Add const in some lambda functions on Solver& to stick to definition
Lucas-Haubert 43be3a6
Add matrixQ in SparseQR
Lucas-Haubert 2c5d645
Add actual date in copyrights
Lucas-Haubert d98d12c
Add methods matrixU and matrixL in SParseLU
Lucas-Haubert 30dfff9
Capital letters in header names in sparse decompositions
Lucas-Haubert a508351
CMakeLists: Added FullPivLU and PartialPivLU headers
Lucas-Haubert b8774a1
Removed outpassed guards regarding eigen version in decompositions an…
Lucas-Haubert ff0fc25
Include guards: Set name that corresopnds to directory
Lucas-Haubert 4908cca
Include guards: Updated date in copyright
Lucas-Haubert 59619e1
MINRES: Backward compatibility to call from eigenpy and eigenpy.solvers
Lucas-Haubert 060253b
Split solvers.cpp into separated .cpp as in decompositions
Lucas-Haubert f6b774b
fwd:hpp: Corrected definition of macro EIGENPY_PRAGMA_DEPRECATED_HEAD…
Lucas-Haubert 18275ed
Add back compatibility headers due to changes in name and directory o…
Lucas-Haubert fca41b2
unittest: Simplify test_GeneralizedEigenSolver to reduce computation …
Lucas-Haubert 912c901
Back compatibility accelerate.hpp
Lucas-Haubert 0761b74
unittest: Reduced computation time of tests
Lucas-Haubert 9eb1056
CHANGELOG: Update
Lucas-Haubert 4dbdc9b
SparseQR: Add toSparse method in matrixQ return type to extract the r…
Lucas-Haubert e08c704
nix: patch eigen
nim65s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * Copyright 2025 INRIA | ||
| */ | ||
|
|
||
| #ifndef __eigenpy_decompositions_bdcsvd_hpp__ | ||
| #define __eigenpy_decompositions_bdcsvd_hpp__ | ||
|
|
||
| #include <Eigen/SVD> | ||
| #include <Eigen/Core> | ||
|
|
||
| #include "eigenpy/eigenpy.hpp" | ||
| #include "eigenpy/utils/scalar-name.hpp" | ||
| #include "eigenpy/eigen/EigenBase.hpp" | ||
| #include "eigenpy/decompositions/SVDBase.hpp" | ||
|
|
||
| namespace eigenpy { | ||
|
|
||
| template <typename _MatrixType> | ||
| struct BDCSVDVisitor | ||
| : public boost::python::def_visitor<BDCSVDVisitor<_MatrixType>> { | ||
| typedef _MatrixType MatrixType; | ||
| typedef Eigen::BDCSVD<MatrixType> Solver; | ||
| typedef typename MatrixType::Scalar Scalar; | ||
|
|
||
| template <class PyClass> | ||
| void visit(PyClass &cl) const { | ||
| cl.def(bp::init<>(bp::arg("self"), "Default constructor")) | ||
| .def(bp::init<Eigen::DenseIndex, Eigen::DenseIndex, | ||
| bp::optional<unsigned int>>( | ||
| bp::args("self", "rows", "cols", "computationOptions "), | ||
| "Default Constructor with memory preallocation. ")) | ||
| .def(bp::init<MatrixType, bp::optional<unsigned int>>( | ||
| bp::args("self", "matrix", "computationOptions "), | ||
| "Constructor performing the decomposition of given matrix.")) | ||
|
|
||
| .def("cols", &Solver::cols, bp::arg("self"), | ||
| "Returns the number of columns. ") | ||
| .def("compute", | ||
| (Solver & (Solver::*)(const MatrixType &matrix)) & Solver::compute, | ||
| bp::args("self", "matrix"), | ||
| "Method performing the decomposition of given matrix. Computes " | ||
| "Thin/Full " | ||
| "unitaries U/V if specified using the Options template parameter " | ||
| "or the class constructor. ", | ||
| bp::return_self<>()) | ||
| .def("compute", | ||
| (Solver & (Solver::*)(const MatrixType &matrix, | ||
| unsigned int computationOptions)) & | ||
| Solver::compute, | ||
| bp::args("self", "matrix", "computationOptions"), | ||
| "Method performing the decomposition of given matrix, as " | ||
| "specified by the computationOptions parameter. ", | ||
| bp::return_self<>()) | ||
| .def("rows", &Solver::rows, bp::arg("self"), | ||
| "Returns the number of rows. ") | ||
| .def("setSwitchSize", &Solver::setSwitchSize, bp::args("self", "s")) | ||
|
|
||
| .def(SVDBaseVisitor<Solver>()); | ||
| } | ||
|
|
||
| static void expose() { | ||
| static const std::string classname = | ||
| "BDCSVD_" + scalar_name<Scalar>::shortname(); | ||
| expose(classname); | ||
| } | ||
|
|
||
| static void expose(const std::string &name) { | ||
| bp::class_<Solver, boost::noncopyable>( | ||
| name.c_str(), | ||
| "Class Bidiagonal Divide and Conquer SVD.\n\n" | ||
| "This class first reduces the input matrix to bi-diagonal form using " | ||
| "class " | ||
| "UpperBidiagonalization, and then performs a divide-and-conquer " | ||
| "diagonalization. " | ||
| "Small blocks are diagonalized using class JacobiSVD. You can control " | ||
| "the " | ||
| "switching size with the setSwitchSize() method, default is 16. For " | ||
| "small matrice " | ||
| "(<16), it is thus preferable to directly use JacobiSVD. For larger " | ||
| "ones, BDCSVD " | ||
| "is highly recommended and can several order of magnitude faster.\n\n" | ||
| "Warming: this algorithm is unlikely to provide accurate result when " | ||
| "compiled with " | ||
| "unsafe math optimizations. For instance, this concerns Intel's " | ||
| "compiler (ICC), which " | ||
| "performs such optimization by default unless you compile with the " | ||
| "-fp-model precise " | ||
| "option. Likewise, the -ffast-math option of GCC or clang will " | ||
| "significantly degrade the " | ||
| "accuracy.", | ||
| bp::no_init) | ||
| .def(BDCSVDVisitor()) | ||
| .def(IdVisitor<Solver>()); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace eigenpy | ||
|
|
||
| #endif // ifndef __eigenpy_decompositions_bdcsvd_hpp__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * Copyright 2025 INRIA | ||
| */ | ||
|
|
||
| #ifndef __eigenpy_decompositions_complex_eigen_solver_hpp__ | ||
| #define __eigenpy_decompositions_complex_eigen_solver_hpp__ | ||
|
|
||
| #include <Eigen/Core> | ||
| #include <Eigen/Eigenvalues> | ||
|
|
||
| #include "eigenpy/eigen-to-python.hpp" | ||
| #include "eigenpy/eigenpy.hpp" | ||
| #include "eigenpy/utils/scalar-name.hpp" | ||
|
|
||
| namespace eigenpy { | ||
|
|
||
| template <typename _MatrixType> | ||
| struct ComplexEigenSolverVisitor : public boost::python::def_visitor< | ||
| ComplexEigenSolverVisitor<_MatrixType>> { | ||
| typedef _MatrixType MatrixType; | ||
| typedef typename MatrixType::Scalar Scalar; | ||
| typedef Eigen::ComplexEigenSolver<MatrixType> Solver; | ||
|
|
||
| template <class PyClass> | ||
| void visit(PyClass& cl) const { | ||
| cl.def(bp::init<>("Default constructor")) | ||
| .def(bp::init<Eigen::DenseIndex>( | ||
| bp::arg("size"), "Default constructor with memory preallocation")) | ||
| .def(bp::init<MatrixType, bp::optional<bool>>( | ||
| bp::args("matrix", "compute_eigen_vectors"), | ||
| "Computes eigendecomposition of given matrix")) | ||
|
|
||
| .def("eigenvalues", &Solver::eigenvalues, bp::arg("self"), | ||
| "Returns the eigenvalues of given matrix.", | ||
| bp::return_internal_reference<>()) | ||
| .def("eigenvectors", &Solver::eigenvectors, bp::arg("self"), | ||
| "Returns the eigenvectors of given matrix.", | ||
| bp::return_internal_reference<>()) | ||
|
|
||
| .def("compute", &ComplexEigenSolverVisitor::compute_proxy<MatrixType>, | ||
| bp::args("self", "matrix"), | ||
| "Computes the eigendecomposition of given matrix.", | ||
| bp::return_self<>()) | ||
| .def("compute", | ||
| (Solver & | ||
| (Solver::*)(const Eigen::EigenBase<MatrixType>& matrix, bool)) & | ||
| Solver::compute, | ||
| bp::args("self", "matrix", "compute_eigen_vectors"), | ||
| "Computes the eigendecomposition of given matrix.", | ||
| bp::return_self<>()) | ||
|
|
||
| .def("info", &Solver::info, bp::arg("self"), | ||
| "NumericalIssue if the input contains INF or NaN values or " | ||
| "overflow occured. Returns Success otherwise.") | ||
|
|
||
| .def("getMaxIterations", &Solver::getMaxIterations, bp::arg("self"), | ||
| "Returns the maximum number of iterations.") | ||
| .def("setMaxIterations", &Solver::setMaxIterations, | ||
| bp::args("self", "max_iter"), | ||
| "Sets the maximum number of iterations allowed.", | ||
| bp::return_self<>()); | ||
| } | ||
|
|
||
| static void expose() { | ||
| static const std::string classname = | ||
| "ComplexEigenSolver" + scalar_name<Scalar>::shortname(); | ||
| expose(classname); | ||
| } | ||
|
|
||
| static void expose(const std::string& name) { | ||
| bp::class_<Solver>(name.c_str(), bp::no_init) | ||
| .def(ComplexEigenSolverVisitor()) | ||
| .def(IdVisitor<Solver>()); | ||
| } | ||
|
|
||
| private: | ||
| template <typename MatrixType> | ||
| static Solver& compute_proxy(Solver& self, | ||
| const Eigen::EigenBase<MatrixType>& matrix) { | ||
| return self.compute(matrix); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace eigenpy | ||
|
|
||
| #endif // ifndef __eigenpy_decompositions_complex_eigen_solver_hpp__ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.