Skip to content

Commit 5d86fcd

Browse files
committed
Reformulate constructors with optional arguments
1 parent 923b35e commit 5d86fcd

File tree

8 files changed

+11
-32
lines changed

8 files changed

+11
-32
lines changed

include/nanoeigenpy/decompositions/bdcsvd.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ void exposeBDCSVD(nb::module_ m, const char *name) {
4040

4141
.def(nb::init<>(), "Default constructor.")
4242
.def(nb::init<Eigen::DenseIndex, Eigen::DenseIndex, unsigned int>(),
43-
"rows"_a, "cols"_a, "computationOptions"_a,
43+
"rows"_a, "cols"_a, "computationOptions"_a = 0,
4444
"Default constructor with memory preallocation.")
45-
.def(nb::init<Eigen::DenseIndex, Eigen::DenseIndex>(), "rows"_a, "cols"_a,
46-
"Default constructor with memory preallocation.")
47-
.def(nb::init<const MatrixType &>(), "matrix"_a,
48-
"Constructs a SVD factorization from a given matrix.")
45+
4946
.def(nb::init<const MatrixType &, unsigned int>(), "matrix"_a,
50-
"computationOptions"_a,
47+
"computationOptions"_a = 0,
5148
"Constructs a SVD factorization from a given matrix.")
5249

5350
.def(SVDBaseVisitor())

include/nanoeigenpy/decompositions/complex-eigen-solver.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ void exposeComplexEigenSolver(nb::module_ m, const char *name) {
2222
.def(nb::init<>(), "Default constructor.")
2323
.def(nb::init<Eigen::DenseIndex>(), "size"_a,
2424
"Default constructor with memory preallocation.")
25-
.def(nb::init<const MatrixType &>(), "matrix"_a,
26-
"Computes eigendecomposition of given matrix")
2725
.def(nb::init<const MatrixType &, bool>(), "matrix"_a,
28-
"computeEigenvectors"_a,
26+
"computeEigenvectors"_a = true,
2927
"Computes eigendecomposition of given matrix")
3028

3129
.def("eigenvalues", &Solver::eigenvalues,

include/nanoeigenpy/decompositions/complex-schur.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ void exposeComplexSchur(nb::module_ m, const char *name) {
2121

2222
.def(nb::init<Eigen::DenseIndex>(), "size"_a,
2323
"Default constructor with memory preallocation.")
24-
.def(nb::init<const MatrixType &>(), "matrix"_a,
25-
"Constructor; computes Schur decomposition of given matrix.")
2624
.def(nb::init<const MatrixType &, bool>(), "matrix"_a,
2725
"computeU"_a = true,
2826
"Constructor; computes Schur decomposition of given matrix.")

include/nanoeigenpy/decompositions/generalized-eigen-solver.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ void exposeGeneralizedEigenSolver(nb::module_ m, const char *name) {
2222
.def(nb::init<>(), "Default constructor.")
2323
.def(nb::init<Eigen::DenseIndex>(), "size"_a,
2424
"Default constructor with memory preallocation.")
25-
.def(nb::init<const MatrixType &, const MatrixType &>(), "A"_a, "B"_a,
26-
"Constructor; computes the generalized eigendecomposition of given "
27-
"matrix pair.")
2825
.def(nb::init<const MatrixType &, const MatrixType &, bool>(), "A"_a,
29-
"B"_a,
30-
"computeEigenvectors"_a
26+
"B"_a, "computeEigenvectors"_a = true,
3127
"Constructor; computes the generalized eigendecomposition of given "
3228
"matrix pair.")
3329

include/nanoeigenpy/decompositions/generalized-self-adjoint-eigen-solver.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ void exposeGeneralizedSelfAdjointEigenSolver(nb::module_ m, const char *name) {
2222
.def(nb::init<>(), "Default constructor.")
2323
.def(nb::init<Eigen::DenseIndex>(), nb::arg("size"),
2424
"Default constructor with memory preallocation.")
25-
.def(nb::init<const MatrixType &, const MatrixType &>(), "matA"_a,
26-
"matB"_a,
27-
"Computes the generalized eigendecomposition of given matrix pencil")
2825
.def(nb::init<const MatrixType &, const MatrixType &, int>(), "matA"_a,
29-
"matB"_a, "options"_a,
26+
"matB"_a, "options"_a = Eigen::ComputeEigenvectors | Eigen::Ax_lBx,
3027
"Computes the generalized eigendecomposition of given matrix pencil")
3128

3229
.def(

include/nanoeigenpy/decompositions/jacobi-svd.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ struct JacobiSVDVisitor : nb::def_visitor<JacobiSVDVisitor<JacobiSVD>> {
2626
using namespace nb::literals;
2727
cl.def(nb::init<>(), "Default constructor.")
2828
.def(nb::init<Eigen::DenseIndex, Eigen::DenseIndex, unsigned int>(),
29-
"rows"_a, "cols"_a, "computationOptions"_a,
29+
"rows"_a, "cols"_a, "computationOptions"_a = 0,
3030
"Default constructor with memory preallocation.")
31-
.def(nb::init<Eigen::DenseIndex, Eigen::DenseIndex>(), "rows"_a,
32-
"cols"_a, "Default constructor with memory preallocation.")
33-
.def(nb::init<const MatrixType &>(), "matrix"_a,
34-
"Constructs a SVD factorization from a given matrix.")
3531
.def(nb::init<const MatrixType &, unsigned int>(), "matrix"_a,
36-
"computationOptions"_a,
32+
"computationOptions"_a = 0,
3733
"Constructs a SVD factorization from a given matrix.")
3834

3935
.def(SVDBaseVisitor())

include/nanoeigenpy/decompositions/real-qz.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ void exposeRealQZ(nb::module_ m, const char *name) {
2121

2222
.def(nb::init<Eigen::DenseIndex>(), "size"_a,
2323
"Default constructor with memory preallocation.")
24-
.def(nb::init<const MatrixType &, const MatrixType &>(), "A"_a, "B"_a,
25-
"Constructor; computes real QZ decomposition of given matrices.")
2624
.def(nb::init<const MatrixType &, const MatrixType &, bool>(), "A"_a,
27-
"B"_a, "computeQZ"_a,
25+
"B"_a, "computeQZ"_a = true,
2826
"Constructor; computes real QZ decomposition of given matrices.")
2927

3028
.def("matrixQ", &Solver::matrixQ,

include/nanoeigenpy/decompositions/real-schur.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ void exposeRealSchur(nb::module_ m, const char *name) {
2121

2222
.def(nb::init<Eigen::DenseIndex>(), "size"_a,
2323
"Default constructor with memory preallocation.")
24-
.def(nb::init<const MatrixType &>(), "matrix"_a,
25-
"Constructor; computes real Schur decomposition of given matrices.")
26-
.def(nb::init<const MatrixType &, bool>(), "matrix"_a, "computeU"_a,
24+
.def(nb::init<const MatrixType &, bool>(), "matrix"_a,
25+
"computeU"_a = true,
2726
"Constructor; computes real Schur decomposition of given matrices.")
2827

2928
.def("matrixU", &Solver::matrixU,

0 commit comments

Comments
 (0)