Skip to content

Commit 866750e

Browse files
committed
Clean code
1 parent c7a7393 commit 866750e

20 files changed

+11
-206
lines changed

include/nanoeigenpy/decompositions/sparse/sparse-lu.hpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ void exposeSparseLU(nb::module_ m, const char *name) {
1919
using SparseLUTransposeViewTrue = Eigen::SparseLUTransposeView<true, Solver>;
2020
using SparseLUTransposeViewFalse =
2121
Eigen::SparseLUTransposeView<false, Solver>;
22-
// using SCMatrix = typename Solver::SCMatrix;
23-
// using MappedSparseMatrixType = Eigen::MappedSparseMatrix<typename
24-
// Solver::Scalar, Eigen::ColMajor, typename Solver::StorageIndex>; using
25-
// SparseLUMatrixLType = Eigen::SparseLUMatrixLReturnType<SCMatrix>; using
26-
// SparseLUMatrixUType = Eigen::SparseLUMatrixUReturnType<SCMatrix,
27-
// MappedSparseMatrixType>;
2822

2923
if (check_registration_alias<Solver>(m)) {
3024
return;
@@ -44,14 +38,6 @@ void exposeSparseLU(nb::module_ m, const char *name) {
4438
.def("rows", &SparseLUTransposeViewTrue::rows)
4539
.def("cols", &SparseLUTransposeViewTrue::cols);
4640

47-
// nb::class_<SparseLUMatrixLType>(m, "SparseLUMatrixL")
48-
// .def("rows", &SparseLUMatrixLType::rows)
49-
// .def("cols", &SparseLUMatrixLType::cols);
50-
51-
// nb::class_<SparseLUMatrixUType>(m, "SparseLUMatrixU")
52-
// .def("rows", &SparseLUMatrixUType::rows)
53-
// .def("cols", &SparseLUMatrixUType::cols);
54-
5541
nb::class_<Solver>(
5642
m, name,
5743
"Sparse supernodal LU factorization for general matrices.\n\n"
@@ -124,20 +110,6 @@ void exposeSparseLU(nb::module_ m, const char *name) {
124110
.def("isSymmetric", &Solver::isSymmetric,
125111
"Indicate that the pattern of the input matrix is symmetric.")
126112

127-
// .def("matrixU",
128-
// [](Solver& self) -> SparseLUMatrixUType {
129-
// auto view = self.matrixU();
130-
// return view;
131-
// },
132-
// "Returns an expression of the matrix U.")
133-
134-
// .def("matrixL",
135-
// [](Solver& self) -> SparseLUMatrixLType {
136-
// auto view = self.matrixL();
137-
// return view;
138-
// },
139-
// "Returns an expression of the matrix L.")
140-
141113
.def("rowsPermutation", &Solver::rowsPermutation,
142114
"Returns a reference to the row matrix permutation "
143115
"\f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$.",

include/nanoeigenpy/decompositions/sparse/sparse-qr.hpp

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,6 @@ namespace nanoeigenpy {
1010
namespace nb = nanobind;
1111
using namespace nb::literals;
1212

13-
// template<typename SparseQRType>
14-
// class SparseQRMatrixQReturnTypeWrapper {
15-
// private:
16-
// Eigen::SparseQRMatrixQReturnType<SparseQRType> m_q_expr;
17-
18-
// public:
19-
// explicit SparseQRMatrixQReturnTypeWrapper(const SparseQRType& qr)
20-
// : m_q_expr(qr) {}
21-
22-
// Eigen::Index rows() const { return m_q_expr.rows(); }
23-
// Eigen::Index cols() const { return m_q_expr.cols(); }
24-
25-
// Eigen::VectorXd multiply_vec(const Eigen::VectorXd& vec) {
26-
// return Eigen::VectorXd(m_q_expr * vec);
27-
// }
28-
29-
// Eigen::MatrixXd multiply_mat(const Eigen::MatrixXd& mat) {
30-
// return Eigen::MatrixXd(m_q_expr * mat);
31-
// }
32-
33-
// auto adjoint() const {
34-
// return
35-
// SparseQRMatrixQTransposeReturnTypeWrapper<SparseQRType>(m_q_expr);
36-
// }
37-
38-
// auto transpose() const {
39-
// return
40-
// SparseQRMatrixQTransposeReturnTypeWrapper<SparseQRType>(m_q_expr);
41-
// }
42-
// };
43-
44-
// template<typename SparseQRType>
45-
// class SparseQRMatrixQTransposeReturnTypeWrapper {
46-
// private:
47-
// Eigen::SparseQRMatrixQTransposeReturnType<SparseQRType> m_qt_expr;
48-
49-
// public:
50-
// explicit SparseQRMatrixQTransposeReturnTypeWrapper(const SparseQRType&
51-
// qt)
52-
// : m_qt_expr(qt) {}
53-
54-
// Eigen::VectorXd multiply_vec(const Eigen::VectorXd& vec) {
55-
// return Eigen::VectorXd(m_qt_expr * vec);
56-
// }
57-
58-
// Eigen::MatrixXd multiply_mat(const Eigen::MatrixXd& mat) {
59-
// return Eigen::MatrixXd(m_qt_expr * mat);
60-
// }
61-
// };
62-
6313
template <typename _MatrixType, typename _Ordering = Eigen::COLAMDOrdering<
6414
typename _MatrixType::StorageIndex>>
6515
void exposeSparseQR(nb::module_ m, const char *name) {
@@ -70,37 +20,11 @@ void exposeSparseQR(nb::module_ m, const char *name) {
7020
using RealScalar = typename MatrixType::RealScalar;
7121
using QRMatrixType = Eigen::SparseMatrix<Scalar, Eigen::ColMajor,
7222
typename MatrixType::StorageIndex>;
73-
// using QWrapper = SparseQRMatrixQReturnTypeWrapper<Solver>;
74-
// using QTWrapper = SparseQRMatrixQTransposeReturnTypeWrapper<Solver>;
7523

7624
if (check_registration_alias<Solver>(m)) {
7725
return;
7826
}
7927

80-
// nb::class_<QWrapper>(m, "SparseQRMatrixQ")
81-
// .def("rows", &QWrapper::rows)
82-
// .def("cols", &QWrapper::cols)
83-
// .def("__mul__", [](const QWrapper& self, const Eigen::Ref<const
84-
// Eigen::VectorXd>& vec) {
85-
// return self.multiply_vec(vec);
86-
// }, "vec"_a)
87-
// .def("__mul__", [](const QWrapper& self, const Eigen::Ref<const
88-
// Eigen::MatrixXd>& mat) {
89-
// return self.multiply_mat(mat);
90-
// }, "mat"_a)
91-
// .def("adjoint", &QWrapper::adjoint)
92-
// .def("transpose", &QWrapper::transpose);
93-
94-
// nb::class_<QTWrapper>(m, "SparseQRMatrixQTranspose")
95-
// .def("__mul__", [](const QTWrapper& self, const Eigen::Ref<const
96-
// Eigen::VectorXd>& vec) {
97-
// return self.multiply_vec(vec);
98-
// }, "vec"_a)
99-
// .def("__mul__", [](const QTWrapper& self, const Eigen::Ref<const
100-
// Eigen::MatrixXd>& mat) {
101-
// return self.multiply_mat(mat);
102-
// }, "mat"_a);
103-
10428
nb::class_<Solver>(
10529
m, name,
10630
"Sparse left-looking QR factorization with numerical column pivoting. "
@@ -147,10 +71,6 @@ void exposeSparseQR(nb::module_ m, const char *name) {
14771
"The input matrix should be in compressed mode "
14872
"(see SparseMatrix::makeCompressed()).")
14973

150-
// .def("matrixQ", [](const Solver& self) -> QWrapper {
151-
// return QWrapper(self);
152-
// }, "Returns an expression of the matrix Q")
153-
15474
.def(
15575
"matrixR",
15676
[](Solver &self) -> const QRMatrixType & { return self.matrixR(); },

include/nanoeigenpy/geometry/quaternion.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct QuaternionVisitor : nb::def_visitor<QuaternionVisitor<Quaternion>> {
6262
},
6363
"u"_a, "v"_a, "Initialize from two vectors u and v.")
6464

65-
// Add property with x, y, z, w
6665
.def_prop_rw("x", &QuaternionVisitor::getCoeff<0>,
6766
&QuaternionVisitor::setCoeff<0>, "The x coefficient.")
6867
.def_prop_rw("y", &QuaternionVisitor::getCoeff<1>,

include/nanoeigenpy/geometry/scaling.hpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,42 +68,6 @@ void exposeUniformScaling(nb::module_ m, const char* name) {
6868
-> Eigen::MatrixXd { return self * matrix; },
6969
"matrix"_a, "Multiplies uniform scaling with a matrix")
7070

71-
.def(
72-
"__mul__",
73-
[](const UniformScaling& self, const Eigen::Translation<Scalar, 2>& t)
74-
-> Eigen::Transform<Scalar, 2, Eigen::Affine> {
75-
return self * t;
76-
},
77-
"translation"_a, "Concatenates uniform scaling with 2D translation")
78-
79-
.def(
80-
"__mul__",
81-
[](const UniformScaling& self, const Eigen::Translation<Scalar, 3>& t)
82-
-> Eigen::Transform<Scalar, 3, Eigen::Affine> {
83-
return self * t;
84-
},
85-
"translation"_a, "Concatenates uniform scaling with 3D translation")
86-
87-
.def(
88-
"__mul__",
89-
[](const UniformScaling& self,
90-
const Eigen::Transform<Scalar, 2, Eigen::Affine>& t)
91-
-> Eigen::Transform<Scalar, 2, Eigen::Affine> {
92-
return self * t;
93-
},
94-
"transform"_a,
95-
"Concatenates uniform scaling with 2D affine transform")
96-
97-
.def(
98-
"__mul__",
99-
[](const UniformScaling& self,
100-
const Eigen::Transform<Scalar, 3, Eigen::Affine>& t)
101-
-> Eigen::Transform<Scalar, 3, Eigen::Affine> {
102-
return self * t;
103-
},
104-
"transform"_a,
105-
"Concatenates uniform scaling with 3D affine transform")
106-
10771
.def(
10872
"__mul__",
10973
[](const UniformScaling& self, const Eigen::AngleAxis<Scalar>& r)

include/nanoeigenpy/geometry/translation.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ void exposeTranslation(nb::module_ m, const char* name) {
104104

105105
.def("inverse", &Translation::inverse,
106106
"Returns the inverse translation (opposite)")
107-
.def("Identity", &Translation::Identity)
108107

109108
.def(
110109
"isApprox",

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright 2025 INRIA
2+
13
# Create a shared nanobind library for testing
24
set(NANOBIND_TESTING_TARGET nanobind-testing)
35
nanobind_build_library(${NANOBIND_TESTING_TARGET} SHARED)

tests/quaternion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// Copyright 2025 INRIA
2+
23
#include <Eigen/Geometry>
34
#include <nanobind/nanobind.h>
45

tests/test_accelerate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test(SolverType: type):
1919
X = rng.random((dim, 20))
2020
B = A.dot(X)
2121
X_est = llt.solve(B)
22-
# import pdb; pdb.set_trace()
22+
2323
assert nanoeigenpy.is_approx(X, X_est)
2424
assert nanoeigenpy.is_approx(A.dot(X_est), B)
2525

tests/test_complex_schur.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import nanoeigenpy
22
import numpy as np
33

4-
dim = 5
4+
dim = 100
55
rng = np.random.default_rng()
66
A = rng.random((dim, dim))
77

tests/test_eigen_solver.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@
55
rng = np.random.default_rng()
66

77
A = rng.random((dim, dim))
8-
print("A :")
9-
print(A)
108

11-
# Tests init
129
es = nanoeigenpy.EigenSolver()
1310
es = nanoeigenpy.EigenSolver(dim)
1411
es = nanoeigenpy.EigenSolver(A)
1512
assert es.info() == nanoeigenpy.ComputationInfo.Success
1613

17-
# Test eigenvectors
18-
# Test eigenvalues
1914
V = es.eigenvectors()
2015
D = es.eigenvalues()
2116

2217
assert nanoeigenpy.is_approx(A.dot(V).real, V.dot(np.diag(D)).real)
2318
assert nanoeigenpy.is_approx(A.dot(V).imag, V.dot(np.diag(D)).imag)
2419

25-
# Test nb::init<>()
26-
# Test id
2720
es1 = nanoeigenpy.EigenSolver()
2821
es2 = nanoeigenpy.EigenSolver()
2922

@@ -34,8 +27,6 @@
3427
assert id1 == es1.id()
3528
assert id2 == es2.id()
3629

37-
# Test nb::init<Eigen::DenseIndex>()
38-
# Test id
3930
dim_constructor = 3
4031

4132
es3 = nanoeigenpy.EigenSolver(dim_constructor)

0 commit comments

Comments
 (0)