eigenpy
3.13.0
Bindings between Numpy and Eigen using Boost.Python
Toggle main menu visibility
Loading...
Searching...
No Matches
BDCSVD.hpp
1
/*
2
* Copyright 2025 INRIA
3
*/
4
5
#ifndef __eigenpy_decompositions_bdcsvd_hpp__
6
#define __eigenpy_decompositions_bdcsvd_hpp__
7
8
#include <Eigen/SVD>
9
#include <Eigen/Core>
10
11
#include "eigenpy/eigenpy.hpp"
12
#include "eigenpy/utils/scalar-name.hpp"
13
#include "eigenpy/eigen/EigenBase.hpp"
14
#include "eigenpy/decompositions/SVDBase.hpp"
15
16
namespace
eigenpy
{
17
18
template
<
typename
_MatrixType>
19
struct
BDCSVDVisitor
20
:
public
boost::python::def_visitor<BDCSVDVisitor<_MatrixType>> {
21
typedef
_MatrixType MatrixType;
22
typedef
Eigen::BDCSVD<MatrixType> Solver;
23
typedef
typename
MatrixType::Scalar Scalar;
24
25
template
<
class
PyClass>
26
void
visit(PyClass& cl)
const
{
27
cl.def(bp::init<>(bp::arg(
"self"
),
"Default constructor"
))
28
.def(bp::init<Eigen::DenseIndex, Eigen::DenseIndex,
29
bp::optional<unsigned int>>(
30
bp::args(
"self"
,
"rows"
,
"cols"
,
"computationOptions "
),
31
"Default Constructor with memory preallocation. "
))
32
.def(bp::init<MatrixType, bp::optional<unsigned int>>(
33
bp::args(
"self"
,
"matrix"
,
"computationOptions "
),
34
"Constructor performing the decomposition of given matrix."
))
35
36
.def(
"cols"
, &Solver::cols, bp::arg(
"self"
),
37
"Returns the number of columns. "
)
38
.def(
39
"compute"
,
40
+[](Solver& self,
const
MatrixType& matrix) -> Solver& {
41
return
self.compute(matrix);
42
},
43
bp::args(
"self"
,
"matrix"
),
44
"Method performing the decomposition of given matrix. Computes "
45
"Thin/Full "
46
"unitaries U/V if specified using the Options template parameter "
47
"or the class constructor. "
,
48
bp::return_self<>())
49
.def(
50
"compute"
,
51
+[](Solver& self,
const
MatrixType& matrix,
52
unsigned
int
computationOptions) -> Solver& {
53
return
self.compute(matrix, computationOptions);
54
},
55
bp::args(
"self"
,
"matrix"
,
"computationOptions"
),
56
"Method performing the decomposition of given matrix, as "
57
"specified by the computationOptions parameter. "
,
58
bp::return_self<>())
59
.def(
"rows"
, &Solver::rows, bp::arg(
"self"
),
60
"Returns the number of rows. "
)
61
.def(
"setSwitchSize"
, &Solver::setSwitchSize, bp::args(
"self"
,
"s"
))
62
63
.def(
SVDBaseVisitor<Solver>
());
64
}
65
66
static
void
expose
() {
67
static
const
std::string classname =
68
"BDCSVD_"
+ scalar_name<Scalar>::shortname();
69
expose
(classname);
70
}
71
72
static
void
expose
(
const
std::string& name) {
73
bp::class_<Solver, boost::noncopyable>(
74
name.c_str(),
75
"Class Bidiagonal Divide and Conquer SVD.\n\n"
76
"This class first reduces the input matrix to bi-diagonal form using "
77
"class "
78
"UpperBidiagonalization, and then performs a divide-and-conquer "
79
"diagonalization. "
80
"Small blocks are diagonalized using class JacobiSVD. You can control "
81
"the "
82
"switching size with the setSwitchSize() method, default is 16. For "
83
"small matrice "
84
"(<16), it is thus preferable to directly use JacobiSVD. For larger "
85
"ones, BDCSVD "
86
"is highly recommended and can several order of magnitude faster.\n\n"
87
"Warming: this algorithm is unlikely to provide accurate result when "
88
"compiled with "
89
"unsafe math optimizations. For instance, this concerns Intel's "
90
"compiler (ICC), which "
91
"performs such optimization by default unless you compile with the "
92
"-fp-model precise "
93
"option. Likewise, the -ffast-math option of GCC or clang will "
94
"significantly degrade the "
95
"accuracy."
,
96
bp::no_init)
97
.def(
BDCSVDVisitor
())
98
.def(
IdVisitor<Solver>
());
99
}
100
};
101
102
}
// namespace eigenpy
103
104
#endif
// ifndef __eigenpy_decompositions_bdcsvd_hpp__
eigenpy
Definition
alignment.hpp:14
eigenpy::expose
void expose()
Call the expose function of a given type T.
Definition
expose.hpp:23
eigenpy::BDCSVDVisitor
Definition
BDCSVD.hpp:20
eigenpy::IdVisitor
Add the Python method id to retrieving a unique id for a given object exposed with Boost....
Definition
id.hpp:18
eigenpy::SVDBaseVisitor
Definition
SVDBase.hpp:19
include
eigenpy
decompositions
BDCSVD.hpp
Generated by
1.17.0