Skip to content

Commit c92e8fe

Browse files
committed
solveWithGuess() is a const method, use templated proxy for solve()
1 parent 2612c34 commit c92e8fe

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

include/nanoeigenpy/solvers/iterative-solver-base.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,12 @@ struct IterativeSolverVisitor
2626
using IS = IterativeSolver;
2727
using namespace nb::literals;
2828
cl //
29-
.def(
30-
"solve",
31-
[](const IS& self, Eigen::Ref<const VectorType> vec) -> VectorType {
32-
return self.solve(vec);
33-
},
34-
"Returns the solution x of Ax = b using the current decomposition "
35-
"of A.")
36-
.def(
37-
"solve",
38-
[](const IS& self, Eigen::Ref<const DenseMatrix> mat)
39-
-> DenseMatrix { return self.solve(mat); },
40-
"Returns the solution x of Ax = b using the current decomposition "
41-
"of A.")
29+
.def("solve", &solve<VectorType>,
30+
"Returns the solution x of Ax = b using the current decomposition "
31+
"of A.")
32+
.def("solve", &solve<DenseMatrix>,
33+
"Returns the solution x of Ax = b using the current decomposition "
34+
"of A.")
4235
.def("error", &IS::error,
4336
"Returns the tolerance error reached during the last solve.\n"
4437
"It is a close approximation of the true relative residual error "
@@ -119,7 +112,12 @@ struct IterativeSolverVisitor
119112
}
120113

121114
template <typename T>
122-
static T solveWithGuess(IterativeSolver& self, Eigen::Ref<const T> b,
115+
static T solve(const IterativeSolver& self, Eigen::Ref<const T> b) {
116+
return self.solve(b);
117+
}
118+
119+
template <typename T>
120+
static T solveWithGuess(const IterativeSolver& self, Eigen::Ref<const T> b,
123121
Eigen::Ref<const T> x0) {
124122
return self.solveWithGuess(b, x0);
125123
}

0 commit comments

Comments
 (0)