diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f16c60239..0a0313cde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: autoupdate_schedule: quarterly repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.2 + rev: v0.13.3 hooks: - id: ruff args: @@ -18,15 +18,15 @@ repos: hooks: - id: cmake-format - repo: https://github.com/pappasam/toml-sort - rev: v0.24.2 + rev: v0.24.3 hooks: - id: toml-sort-fix exclude: pixi.toml|dockgen.toml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v20.1.7 + rev: v21.1.2 hooks: - id: clang-format - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: trailing-whitespace diff --git a/include/eigenpy/alignment.hpp b/include/eigenpy/alignment.hpp index 4e0594a80..33cf1e182 100644 --- a/include/eigenpy/alignment.hpp +++ b/include/eigenpy/alignment.hpp @@ -23,23 +23,23 @@ struct aligned_storage { template struct aligned_instance { - PyObject_VAR_HEAD PyObject *dict; - PyObject *weakrefs; - boost::python::instance_holder *objects; + PyObject_VAR_HEAD PyObject* dict; + PyObject* weakrefs; + boost::python::instance_holder* objects; typename aligned_storage::type storage; }; -inline void *aligned_malloc( +inline void* aligned_malloc( std::size_t size, std::size_t alignment = EIGENPY_DEFAULT_ALIGN_BYTES) { - void *original = std::malloc(size + alignment); + void* original = std::malloc(size + alignment); if (original == 0) return 0; if (is_aligned(original, alignment)) return original; - void *aligned = - reinterpret_cast((reinterpret_cast(original) & - ~(std::size_t(alignment - 1))) + - alignment); - *(reinterpret_cast(aligned) - 1) = original; + void* aligned = + reinterpret_cast((reinterpret_cast(original) & + ~(std::size_t(alignment - 1))) + + alignment); + *(reinterpret_cast(aligned) - 1) = original; return aligned; } @@ -52,50 +52,50 @@ namespace detail { template struct referent_storage< - Eigen::Matrix &> { + Eigen::Matrix&> { typedef Eigen::Matrix T; typedef - typename eigenpy::aligned_storage::value>::type type; + typename eigenpy::aligned_storage::value>::type type; }; template struct referent_storage< - const Eigen::Matrix &> { + const Eigen::Matrix&> { typedef Eigen::Matrix T; typedef - typename eigenpy::aligned_storage::value>::type type; + typename eigenpy::aligned_storage::value>::type type; }; #ifdef EIGENPY_WITH_TENSOR_SUPPORT template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::Tensor T; typedef - typename eigenpy::aligned_storage::value>::type type; + typename eigenpy::aligned_storage::value>::type type; }; template struct referent_storage< - const Eigen::Tensor &> { + const Eigen::Tensor&> { typedef Eigen::Tensor T; typedef - typename eigenpy::aligned_storage::value>::type type; + typename eigenpy::aligned_storage::value>::type type; }; #endif template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::Quaternion T; typedef - typename eigenpy::aligned_storage::value>::type type; + typename eigenpy::aligned_storage::value>::type type; }; template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::Quaternion T; typedef - typename eigenpy::aligned_storage::value>::type type; + typename eigenpy::aligned_storage::value>::type type; }; } // namespace detail @@ -119,10 +119,10 @@ namespace eigenpy { template struct call_destructor { - static void run(void *bytes) { + static void run(void* bytes) { typedef typename boost::remove_const< typename boost::remove_reference::type>::type T_; - static_cast((void *)bytes)->~T_(); + static_cast((void*)bytes)->~T_(); } }; @@ -143,22 +143,22 @@ struct rvalue_from_python_data // The usual constructor rvalue_from_python_data( - ::boost::python::converter::rvalue_from_python_stage1_data const - &_stage1) { + ::boost::python::converter::rvalue_from_python_stage1_data const& + _stage1) { this->stage1 = _stage1; } // This constructor just sets m_convertible -- used by // implicitly_convertible<> to perform the final step of the // conversion, where the construct() function is already known. - rvalue_from_python_data(void *convertible) { + rvalue_from_python_data(void* convertible) { this->stage1.convertible = convertible; } // Destroys any object constructed in the storage. ~rvalue_from_python_data() { if (this->stage1.convertible == this->storage.bytes) { - void *storage = reinterpret_cast(this->storage.bytes); + void* storage = reinterpret_cast(this->storage.bytes); call_destructor::run(storage); } } diff --git a/include/eigenpy/decompositions/BDCSVD.hpp b/include/eigenpy/decompositions/BDCSVD.hpp index 564372dfe..231b304cc 100644 --- a/include/eigenpy/decompositions/BDCSVD.hpp +++ b/include/eigenpy/decompositions/BDCSVD.hpp @@ -23,7 +23,7 @@ struct BDCSVDVisitor typedef typename MatrixType::Scalar Scalar; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init>( @@ -37,7 +37,7 @@ struct BDCSVDVisitor "Returns the number of columns. ") .def( "compute", - +[](Solver &self, const MatrixType &matrix) -> Solver & { + +[](Solver& self, const MatrixType& matrix) -> Solver& { return self.compute(matrix); }, bp::args("self", "matrix"), @@ -48,8 +48,8 @@ struct BDCSVDVisitor bp::return_self<>()) .def( "compute", - +[](Solver &self, const MatrixType &matrix, - unsigned int computationOptions) -> Solver & { + +[](Solver& self, const MatrixType& matrix, + unsigned int computationOptions) -> Solver& { return self.compute(matrix, computationOptions); }, bp::args("self", "matrix", "computationOptions"), @@ -69,7 +69,7 @@ struct BDCSVDVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "Class Bidiagonal Divide and Conquer SVD.\n\n" diff --git a/include/eigenpy/decompositions/ColPivHouseholderQR.hpp b/include/eigenpy/decompositions/ColPivHouseholderQR.hpp index b7068b288..f56697cd4 100644 --- a/include/eigenpy/decompositions/ColPivHouseholderQR.hpp +++ b/include/eigenpy/decompositions/ColPivHouseholderQR.hpp @@ -28,7 +28,7 @@ struct ColPivHouseholderQRSolverVisitor typedef Solver Self; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor.\n" "The default constructor is useful in cases in which the " @@ -107,7 +107,7 @@ struct ColPivHouseholderQRSolverVisitor "you can control by calling setThreshold(threshold).") .def("setThreshold", - (Self & (Self::*)(const RealScalar &)) & Self::setThreshold, + (Self & (Self::*)(const RealScalar&)) & Self::setThreshold, bp::args("self", "threshold"), "Allows to prescribe a threshold to be used by certain methods, " "such as rank(), who need to determine when pivots are to be " @@ -138,7 +138,7 @@ struct ColPivHouseholderQRSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the QR factorization of given matrix.", @@ -159,7 +159,7 @@ struct ColPivHouseholderQRSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "This class performs a rank-revealing QR decomposition of a matrix A " @@ -178,10 +178,10 @@ struct ColPivHouseholderQRSolverVisitor private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } - static MatrixXs inverse(const Self &self) { return self.inverse(); } + static MatrixXs inverse(const Self& self) { return self.inverse(); } }; } // namespace eigenpy diff --git a/include/eigenpy/decompositions/CompleteOrthogonalDecomposition.hpp b/include/eigenpy/decompositions/CompleteOrthogonalDecomposition.hpp index 5a2ab8f63..cce0b1c07 100644 --- a/include/eigenpy/decompositions/CompleteOrthogonalDecomposition.hpp +++ b/include/eigenpy/decompositions/CompleteOrthogonalDecomposition.hpp @@ -28,7 +28,7 @@ struct CompleteOrthogonalDecompositionSolverVisitor typedef Solver Self; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor.\n" "The default constructor is useful in cases in which the " @@ -117,7 +117,7 @@ struct CompleteOrthogonalDecompositionSolverVisitor "you can control by calling setThreshold(threshold).") .def("setThreshold", - (Self & (Self::*)(const RealScalar &)) & Self::setThreshold, + (Self & (Self::*)(const RealScalar&)) & Self::setThreshold, bp::args("self", "threshold"), "Allows to prescribe a threshold to be used by certain methods, " "such as rank(), who need to determine when pivots are to be " @@ -152,7 +152,7 @@ struct CompleteOrthogonalDecompositionSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the complete orthogonal factorization of given matrix.", @@ -174,7 +174,7 @@ struct CompleteOrthogonalDecompositionSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "This class performs a rank-revealing complete orthogonal " @@ -190,10 +190,10 @@ struct CompleteOrthogonalDecompositionSolverVisitor private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } - static MatrixXs pseudoInverse(const Self &self) { + static MatrixXs pseudoInverse(const Self& self) { return self.pseudoInverse(); } }; diff --git a/include/eigenpy/decompositions/FullPivHouseholderQR.hpp b/include/eigenpy/decompositions/FullPivHouseholderQR.hpp index 99adc9386..3e4180f74 100644 --- a/include/eigenpy/decompositions/FullPivHouseholderQR.hpp +++ b/include/eigenpy/decompositions/FullPivHouseholderQR.hpp @@ -28,7 +28,7 @@ struct FullPivHouseholderQRSolverVisitor typedef Solver Self; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor.\n" "The default constructor is useful in cases in which the " @@ -103,7 +103,7 @@ struct FullPivHouseholderQRSolverVisitor "you can control by calling setThreshold(threshold).") .def("setThreshold", - (Self & (Self::*)(const RealScalar &)) & Self::setThreshold, + (Self & (Self::*)(const RealScalar&)) & Self::setThreshold, bp::args("self", "threshold"), "Allows to prescribe a threshold to be used by certain methods, " "such as rank(), who need to determine when pivots are to be " @@ -131,7 +131,7 @@ struct FullPivHouseholderQRSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the QR factorization of given matrix.", @@ -152,7 +152,7 @@ struct FullPivHouseholderQRSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "This class performs a rank-revealing QR decomposition of a matrix A " @@ -172,10 +172,10 @@ struct FullPivHouseholderQRSolverVisitor private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } - static MatrixXs inverse(const Self &self) { return self.inverse(); } + static MatrixXs inverse(const Self& self) { return self.inverse(); } }; } // namespace eigenpy diff --git a/include/eigenpy/decompositions/FullPivLU.hpp b/include/eigenpy/decompositions/FullPivLU.hpp index 1a6c3788c..3143e69cf 100644 --- a/include/eigenpy/decompositions/FullPivLU.hpp +++ b/include/eigenpy/decompositions/FullPivLU.hpp @@ -28,7 +28,7 @@ struct FullPivLUSolverVisitor typedef Eigen::FullPivLU Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init( bp::args("self", "rows", "cols"), @@ -41,7 +41,7 @@ struct FullPivLUSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the LU decomposition of the given matrix.", @@ -55,7 +55,7 @@ struct FullPivLUSolverVisitor "is the LU decomposition.") .def( "image", - +[](Solver &self, const MatrixType &mat) -> MatrixType { + +[](Solver& self, const MatrixType& mat) -> MatrixType { return self.image(mat); }, bp::args("self", "originalMatrix"), @@ -64,7 +64,7 @@ struct FullPivLUSolverVisitor "image (column-space).") .def( "inverse", - +[](Solver &self) -> MatrixType { return self.inverse(); }, + +[](Solver& self) -> MatrixType { return self.inverse(); }, bp::arg("self"), "Returns the inverse of the matrix of which *this is the LU " "decomposition.") @@ -74,7 +74,7 @@ struct FullPivLUSolverVisitor .def("isSurjective", &Solver::isSurjective, bp::arg("self")) .def( - "kernel", +[](Solver &self) -> MatrixType { return self.kernel(); }, + "kernel", +[](Solver& self) -> MatrixType { return self.kernel(); }, bp::arg("self"), "Returns the kernel of the matrix, also called its null-space. " "The columns of the returned matrix will form a basis of the " @@ -107,7 +107,7 @@ struct FullPivLUSolverVisitor "purpose.") .def("setThreshold", - (Solver & (Solver::*)(const RealScalar &)) & Solver::setThreshold, + (Solver & (Solver::*)(const RealScalar&)) & Solver::setThreshold, bp::args("self", "threshold"), "Allows to prescribe a threshold to be used by certain methods, " "such as rank(), who need to determine when pivots are to be " @@ -126,7 +126,7 @@ struct FullPivLUSolverVisitor bp::return_self<>()) .def( "setThreshold", - +[](Solver &self) -> Solver & { + +[](Solver& self) -> Solver& { return self.setThreshold(Eigen::Default); }, bp::arg("self"), @@ -152,7 +152,7 @@ struct FullPivLUSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "LU decomposition of a matrix with complete pivoting, and related " @@ -182,7 +182,7 @@ struct FullPivLUSolverVisitor private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/HouseholderQR.hpp b/include/eigenpy/decompositions/HouseholderQR.hpp index 34d3f744b..1b548d928 100644 --- a/include/eigenpy/decompositions/HouseholderQR.hpp +++ b/include/eigenpy/decompositions/HouseholderQR.hpp @@ -28,7 +28,7 @@ struct HouseholderQRSolverVisitor typedef Solver Self; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor.\n" "The default constructor is useful in cases in which the " @@ -69,7 +69,7 @@ struct HouseholderQRSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the QR factorization of given matrix.", @@ -86,7 +86,7 @@ struct HouseholderQRSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "This class performs a QR decomposition of a matrix A into matrices Q " @@ -108,7 +108,7 @@ struct HouseholderQRSolverVisitor private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/JacobiSVD.hpp b/include/eigenpy/decompositions/JacobiSVD.hpp index 3580f15a0..4454e5eb6 100644 --- a/include/eigenpy/decompositions/JacobiSVD.hpp +++ b/include/eigenpy/decompositions/JacobiSVD.hpp @@ -24,7 +24,7 @@ struct JacobiSVDVisitor typedef typename MatrixType::Scalar Scalar; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init>( @@ -38,7 +38,7 @@ struct JacobiSVDVisitor "Returns the number of columns. ") .def( "compute", - +[](Solver &self, const MatrixType &matrix) -> Solver & { + +[](Solver& self, const MatrixType& matrix) -> Solver& { return self.compute(matrix); }, bp::args("self", "matrix"), @@ -49,8 +49,8 @@ struct JacobiSVDVisitor bp::return_self<>()) .def( "compute", - +[](Solver &self, const MatrixType &matrix, - unsigned int computationOptions) -> Solver & { + +[](Solver& self, const MatrixType& matrix, + unsigned int computationOptions) -> Solver& { return self.compute(matrix, computationOptions); }, bp::args("self", "matrix", "computation_options"), @@ -69,7 +69,7 @@ struct JacobiSVDVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "Two-sided Jacobi SVD decomposition of a rectangular matrix. \n\n" diff --git a/include/eigenpy/decompositions/LDLT.hpp b/include/eigenpy/decompositions/LDLT.hpp index 5360801a8..bf3600b07 100644 --- a/include/eigenpy/decompositions/LDLT.hpp +++ b/include/eigenpy/decompositions/LDLT.hpp @@ -28,7 +28,7 @@ struct LDLTSolverVisitor typedef Eigen::LDLT Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init( bp::args("self", "size"), @@ -58,8 +58,8 @@ struct LDLTSolverVisitor bp::return_internal_reference<>()) .def("rankUpdate", - (Solver & (Solver::*)(const Eigen::MatrixBase &, - const RealScalar &)) & + (Solver & (Solver::*)(const Eigen::MatrixBase&, + const RealScalar&)) & Solver::template rankUpdate, bp::args("self", "vector", "sigma"), bp::return_self<>()) @@ -72,7 +72,7 @@ struct LDLTSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the LDLT of given matrix.", bp::return_self<>()) @@ -107,7 +107,7 @@ struct LDLTSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "Robust Cholesky decomposition of a matrix with pivoting.\n\n" @@ -124,17 +124,17 @@ struct LDLTSolverVisitor } private: - static MatrixType matrixL(const Solver &self) { return self.matrixL(); } - static MatrixType matrixU(const Solver &self) { return self.matrixU(); } - static VectorXs vectorD(const Solver &self) { return self.vectorD(); } + static MatrixType matrixL(const Solver& self) { return self.matrixL(); } + static MatrixType matrixU(const Solver& self) { return self.matrixU(); } + static VectorXs vectorD(const Solver& self) { return self.vectorD(); } - static MatrixType transpositionsP(const Solver &self) { + static MatrixType transpositionsP(const Solver& self) { return self.transpositionsP() * MatrixType::Identity(self.matrixL().rows(), self.matrixL().rows()); } template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/LLT.hpp b/include/eigenpy/decompositions/LLT.hpp index 24763ee43..e4f0e7eb0 100644 --- a/include/eigenpy/decompositions/LLT.hpp +++ b/include/eigenpy/decompositions/LLT.hpp @@ -28,7 +28,7 @@ struct LLTSolverVisitor typedef Eigen::LLT Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init( bp::args("self", "size"), @@ -49,14 +49,14 @@ struct LLTSolverVisitor #if EIGEN_VERSION_AT_LEAST(3, 3, 90) .def("rankUpdate", - (Solver & (Solver::*)(const VectorXs &, const RealScalar &)) & + (Solver & (Solver::*)(const VectorXs&, const RealScalar&)) & Solver::template rankUpdate, bp::args("self", "vector", "sigma"), bp::return_self<>()) #else .def("rankUpdate", (Solver (Solver::*)( - const VectorXs &, - const RealScalar &))&Solver::template rankUpdate, + const VectorXs&, + const RealScalar&))&Solver::template rankUpdate, bp::args("self", "vector", "sigma")) #endif @@ -69,7 +69,7 @@ struct LLTSolverVisitor .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the LLT of given matrix.", bp::return_self<>()) @@ -101,7 +101,7 @@ struct LLTSolverVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "Standard Cholesky decomposition (LL^T) of a matrix and associated " @@ -121,11 +121,11 @@ struct LLTSolverVisitor } private: - static MatrixType matrixL(const Solver &self) { return self.matrixL(); } - static MatrixType matrixU(const Solver &self) { return self.matrixU(); } + static MatrixType matrixL(const Solver& self) { return self.matrixL(); } + static MatrixType matrixU(const Solver& self) { return self.matrixU(); } template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/PartialPivLU.hpp b/include/eigenpy/decompositions/PartialPivLU.hpp index 2c986a831..52ee95db0 100644 --- a/include/eigenpy/decompositions/PartialPivLU.hpp +++ b/include/eigenpy/decompositions/PartialPivLU.hpp @@ -28,7 +28,7 @@ struct PartialPivLUSolverVisitor : public boost::python::def_visitor< typedef Eigen::PartialPivLU Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init( bp::args("self", "size"), @@ -44,14 +44,14 @@ struct PartialPivLUSolverVisitor : public boost::python::def_visitor< "decomposition.") .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the LU factorization of given matrix.", bp::return_self<>()) .def( "inverse", - +[](const Solver &self) -> MatrixType { return self.inverse(); }, + +[](const Solver& self) -> MatrixType { return self.inverse(); }, bp::arg("self"), "Returns the inverse of the matrix of which *this is the LU " "decomposition.") @@ -86,7 +86,7 @@ struct PartialPivLUSolverVisitor : public boost::python::def_visitor< expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "LU decomposition of a matrix with partial pivoting, " @@ -128,7 +128,7 @@ struct PartialPivLUSolverVisitor : public boost::python::def_visitor< private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/PermutationMatrix.hpp b/include/eigenpy/decompositions/PermutationMatrix.hpp index 5ac7535e3..f589e20fe 100644 --- a/include/eigenpy/decompositions/PermutationMatrix.hpp +++ b/include/eigenpy/decompositions/PermutationMatrix.hpp @@ -26,7 +26,7 @@ struct PermutationMatrixVisitor VectorIndex; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init(bp::args("self", "size"), "Default constructor")) .def(bp::init( @@ -40,7 +40,7 @@ struct PermutationMatrixVisitor .def( "indices", - +[](const PermutationMatrix &self) { + +[](const PermutationMatrix& self) { return VectorIndex(self.indices()); }, bp::arg("self"), "The stored array representing the permutation.") @@ -73,13 +73,13 @@ struct PermutationMatrixVisitor .def( "transpose", - +[](const PermutationMatrix &self) -> PermutationMatrix { + +[](const PermutationMatrix& self) -> PermutationMatrix { return self.transpose(); }, bp::arg("self"), "Returns the tranpose permutation matrix.") .def( "inverse", - +[](const PermutationMatrix &self) -> PermutationMatrix { + +[](const PermutationMatrix& self) -> PermutationMatrix { return self.inverse(); }, bp::arg("self"), "Returns the inverse permutation matrix.") @@ -91,7 +91,7 @@ struct PermutationMatrixVisitor .def(EigenBaseVisitor()); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_(name.c_str(), "Permutation matrix.\n" "This class represents a permutation matrix, " diff --git a/include/eigenpy/decompositions/SVDBase.hpp b/include/eigenpy/decompositions/SVDBase.hpp index 5c9d0e391..fa6658bdf 100644 --- a/include/eigenpy/decompositions/SVDBase.hpp +++ b/include/eigenpy/decompositions/SVDBase.hpp @@ -30,7 +30,7 @@ struct SVDBaseVisitor MatrixXs; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def("computeU", &Solver::computeU, bp::arg("self"), @@ -53,7 +53,7 @@ struct SVDBaseVisitor "the rank of the matrix of which *this is the SVD. ") .def("setThreshold", - (Solver & (Solver::*)(const RealScalar &)) & Solver::setThreshold, + (Solver & (Solver::*)(const RealScalar&)) & Solver::setThreshold, bp::args("self", "threshold"), "Allows to prescribe a threshold to be used by certain methods, " "such as " @@ -69,7 +69,7 @@ struct SVDBaseVisitor bp::return_self<>()) .def( "setThreshold", - +[](Solver &self) -> Solver & { + +[](Solver& self) -> Solver& { return self.setThreshold(Eigen::Default); }, bp::arg("self"), @@ -94,11 +94,11 @@ struct SVDBaseVisitor } private: - static MatrixXs matrixU(const Solver &self) { return self.matrixU(); } - static MatrixXs matrixV(const Solver &self) { return self.matrixV(); } + static MatrixXs matrixU(const Solver& self) { return self.matrixU(); } + static MatrixXs matrixV(const Solver& self) { return self.matrixV(); } template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/Tridiagonalization.hpp b/include/eigenpy/decompositions/Tridiagonalization.hpp index d24deb988..8e93faed8 100644 --- a/include/eigenpy/decompositions/Tridiagonalization.hpp +++ b/include/eigenpy/decompositions/Tridiagonalization.hpp @@ -23,7 +23,7 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor< typedef Eigen::VectorXd VectorType; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def( bp::init(bp::arg("size"), "Default constructor. ")) .def(bp::init(bp::arg("matrix"), @@ -32,7 +32,7 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor< .def( "compute", - (Solver & (Solver::*)(const Eigen::EigenBase &matrix)) & + (Solver & (Solver::*)(const Eigen::EigenBase& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes tridiagonal decomposition of given matrix. ", @@ -46,24 +46,24 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor< .def( "matrixQ", - +[](const Solver &c) -> MatrixType { return c.matrixQ(); }, + +[](const Solver& c) -> MatrixType { return c.matrixQ(); }, "Returns the unitary matrix Q in the decomposition.") .def( "matrixT", - +[](const Solver &c) -> MatrixType { return c.matrixT(); }, + +[](const Solver& c) -> MatrixType { return c.matrixT(); }, "Returns an expression of the tridiagonal matrix T in the " "decomposition.") .def( "diagonal", - +[](const Solver &c) -> VectorType { return c.diagonal(); }, + +[](const Solver& c) -> VectorType { return c.diagonal(); }, bp::arg("self"), "Returns the diagonal of the tridiagonal matrix T in the " "decomposition. ") .def( "subDiagonal", - +[](const Solver &c) -> VectorType { return c.subDiagonal(); }, + +[](const Solver& c) -> VectorType { return c.subDiagonal(); }, bp::arg("self"), "Returns the subdiagonal of the tridiagonal matrix T in the " "decomposition."); @@ -75,7 +75,7 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor< expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_(name.c_str(), bp::no_init) .def(TridiagonalizationVisitor()) .def(IdVisitor()); diff --git a/include/eigenpy/decompositions/sparse/SimplicialCholesky.hpp b/include/eigenpy/decompositions/sparse/SimplicialCholesky.hpp index 7fddd79d2..3924f3d1b 100644 --- a/include/eigenpy/decompositions/sparse/SimplicialCholesky.hpp +++ b/include/eigenpy/decompositions/sparse/SimplicialCholesky.hpp @@ -30,7 +30,7 @@ struct SimplicialCholeskyVisitor DenseMatrixXs; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def("analyzePattern", &Solver::analyzePattern, bp::args("self", "matrix"), "Performs a symbolic decomposition on the sparcity of matrix.\n" @@ -46,7 +46,7 @@ struct SimplicialCholeskyVisitor "Returns the upper triangular matrix U.") .def("compute", - (Solver & (Solver::*)(const MatrixType &matrix)) & Solver::compute, + (Solver & (Solver::*)(const MatrixType& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the sparse Cholesky decomposition of a given matrix.", bp::return_self<>()) @@ -85,8 +85,8 @@ struct SimplicialCholeskyVisitor } private: - static MatrixType matrixL(const Solver &self) { return self.matrixL(); } - static MatrixType matrixU(const Solver &self) { return self.matrixU(); } + static MatrixType matrixL(const Solver& self) { return self.matrixL(); } + static MatrixType matrixU(const Solver& self) { return self.matrixU(); } }; } // namespace eigenpy diff --git a/include/eigenpy/decompositions/sparse/SimplicialLDLT.hpp b/include/eigenpy/decompositions/sparse/SimplicialLDLT.hpp index 3ba78b0fb..e17bc7c0b 100644 --- a/include/eigenpy/decompositions/sparse/SimplicialLDLT.hpp +++ b/include/eigenpy/decompositions/sparse/SimplicialLDLT.hpp @@ -30,7 +30,7 @@ struct SimplicialLDLTVisitor DenseMatrixXs; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init(bp::args("self", "matrix"), "Constructs and performs the LDLT " @@ -47,7 +47,7 @@ struct SimplicialLDLTVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "A direct sparse LDLT Cholesky factorizations.\n\n" @@ -64,7 +64,7 @@ struct SimplicialLDLTVisitor } private: - static DenseVectorXs vectorD(const Solver &self) { return self.vectorD(); } + static DenseVectorXs vectorD(const Solver& self) { return self.vectorD(); } }; } // namespace eigenpy diff --git a/include/eigenpy/decompositions/sparse/SimplicialLLT.hpp b/include/eigenpy/decompositions/sparse/SimplicialLLT.hpp index 50581e9cd..331b85c20 100644 --- a/include/eigenpy/decompositions/sparse/SimplicialLLT.hpp +++ b/include/eigenpy/decompositions/sparse/SimplicialLLT.hpp @@ -30,7 +30,7 @@ struct SimplicialLLTVisitor DenseMatrixXs; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init(bp::args("self", "matrix"), "Constructs and performs the LLT " @@ -45,7 +45,7 @@ struct SimplicialLLTVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "A direct sparse LLT Cholesky factorizations.\n\n" diff --git a/include/eigenpy/decompositions/sparse/SparseLU.hpp b/include/eigenpy/decompositions/sparse/SparseLU.hpp index 3b7ed3af4..b099c9b3c 100644 --- a/include/eigenpy/decompositions/sparse/SparseLU.hpp +++ b/include/eigenpy/decompositions/sparse/SparseLU.hpp @@ -25,13 +25,13 @@ struct SparseLUMatrixLReturnTypeVisitor MatrixXs; template - static void solveInPlace(const LType &self, + static void solveInPlace(const LType& self, Eigen::Ref mat_vec) { self.solveInPlace(mat_vec); } template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init(bp::args("self", "mapL"))) .def("rows", <ype::rows) @@ -41,7 +41,7 @@ struct SparseLUMatrixLReturnTypeVisitor .def("solveInPlace", &solveInPlace, bp::args("self", "x")); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_(name.c_str(), "Eigen SparseLUMatrixLReturnType", bp::no_init) .def(SparseLUMatrixLReturnTypeVisitor()) @@ -60,13 +60,13 @@ struct SparseLUMatrixUReturnTypeVisitor MatrixXs; template - static void solveInPlace(const UType &self, + static void solveInPlace(const UType& self, Eigen::Ref mat_vec) { self.solveInPlace(mat_vec); } template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init(bp::args("self", "mapL", "mapU"))) .def("rows", &UType::rows) @@ -76,7 +76,7 @@ struct SparseLUMatrixUReturnTypeVisitor .def("solveInPlace", &solveInPlace, bp::args("self", "x")); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_(name.c_str(), "Eigen SparseLUMatrixUReturnType", bp::no_init) .def(SparseLUMatrixUReturnTypeVisitor()) @@ -110,7 +110,7 @@ struct SparseLUVisitor : public boost::python::def_visitor< typedef Eigen::SparseLUMatrixUReturnType UType; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def(bp::init<>(bp::arg("self"), "Default constructor")) .def(bp::init(bp::args("self", "matrix"), "Constructs and performs the LU " @@ -139,11 +139,11 @@ struct SparseLUVisitor : public boost::python::def_visitor< .def( "matrixL", - +[](const Solver &self) -> LType { return self.matrixL(); }, + +[](const Solver& self) -> LType { return self.matrixL(); }, "Returns an expression of the matrix L.") .def( "matrixU", - +[](const Solver &self) -> UType { return self.matrixU(); }, + +[](const Solver& self) -> UType { return self.matrixU(); }, "Returns an expression of the matrix U.") .def("colsPermutation", &Solver::colsPermutation, bp::arg("self"), @@ -191,7 +191,7 @@ struct SparseLUVisitor : public boost::python::def_visitor< expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "Sparse supernodal LU factorization for general matrices. \n\n" diff --git a/include/eigenpy/decompositions/sparse/SparseSolverBase.hpp b/include/eigenpy/decompositions/sparse/SparseSolverBase.hpp index 7ce3a2237..71939a060 100644 --- a/include/eigenpy/decompositions/sparse/SparseSolverBase.hpp +++ b/include/eigenpy/decompositions/sparse/SparseSolverBase.hpp @@ -29,7 +29,7 @@ struct SparseSolverBaseVisitor DenseMatrixXs; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def("solve", &solve, bp::args("self", "b"), "Returns the solution x of A x = b using the current " "decomposition of A.") @@ -44,7 +44,7 @@ struct SparseSolverBaseVisitor private: template - static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec) { + static MatrixOrVector solve(const Solver& self, const MatrixOrVector& vec) { return self.solve(vec); } }; diff --git a/include/eigenpy/decompositions/sparse/accelerate/Accelerate.hpp b/include/eigenpy/decompositions/sparse/accelerate/Accelerate.hpp index 29cf9cdef..580109e13 100644 --- a/include/eigenpy/decompositions/sparse/accelerate/Accelerate.hpp +++ b/include/eigenpy/decompositions/sparse/accelerate/Accelerate.hpp @@ -25,7 +25,7 @@ struct AccelerateImplVisitor : public boost::python::def_visitor< typedef typename MatrixType::StorageIndex StorageIndex; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl .def("analyzePattern", &Solver::analyzePattern, @@ -38,7 +38,7 @@ struct AccelerateImplVisitor : public boost::python::def_visitor< .def(SparseSolverBaseVisitor()) .def("compute", - (Solver & (Solver::*)(const MatrixType &matrix)) & Solver::compute, + (Solver & (Solver::*)(const MatrixType& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the sparse Cholesky decomposition of a given matrix.", bp::return_self<>()) @@ -56,7 +56,7 @@ struct AccelerateImplVisitor : public boost::python::def_visitor< .def("setOrder", &Solver::setOrder, bp::arg("self"), "Set order"); } - static void expose(const std::string &name, const std::string &doc = "") { + static void expose(const std::string& name, const std::string& doc = "") { bp::class_(name.c_str(), doc.c_str(), bp::no_init) .def(AccelerateImplVisitor()) diff --git a/include/eigenpy/decompositions/sparse/cholmod/CholmodBase.hpp b/include/eigenpy/decompositions/sparse/cholmod/CholmodBase.hpp index 9cb5e54a4..17ca6a458 100644 --- a/include/eigenpy/decompositions/sparse/cholmod/CholmodBase.hpp +++ b/include/eigenpy/decompositions/sparse/cholmod/CholmodBase.hpp @@ -25,7 +25,7 @@ struct CholmodBaseVisitor typedef typename MatrixType::StorageIndex StorageIndex; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def("analyzePattern", &Solver::analyzePattern, bp::args("self", "matrix"), "Performs a symbolic decomposition on the sparcity of matrix.\n" @@ -36,7 +36,7 @@ struct CholmodBaseVisitor .def(SparseSolverBaseVisitor()) .def("compute", - (Solver & (Solver::*)(const MatrixType &matrix)) & Solver::compute, + (Solver & (Solver::*)(const MatrixType& matrix)) & Solver::compute, bp::args("self", "matrix"), "Computes the sparse Cholesky decomposition of a given matrix.", bp::return_self<>()) diff --git a/include/eigenpy/decompositions/sparse/cholmod/CholmodDecomposition.hpp b/include/eigenpy/decompositions/sparse/cholmod/CholmodDecomposition.hpp index 2525169ca..8e7abde54 100644 --- a/include/eigenpy/decompositions/sparse/cholmod/CholmodDecomposition.hpp +++ b/include/eigenpy/decompositions/sparse/cholmod/CholmodDecomposition.hpp @@ -17,7 +17,7 @@ struct CholmodDecompositionVisitor typedef CholdmodDerived Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl .def(CholmodBaseVisitor()) diff --git a/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLDLT.hpp b/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLDLT.hpp index 9710628c7..c8cd51e26 100644 --- a/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLDLT.hpp +++ b/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLDLT.hpp @@ -22,7 +22,7 @@ struct CholmodSimplicialLDLTVisitor typedef Eigen::CholmodSimplicialLDLT Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl .def(CholmodBaseVisitor()) @@ -40,7 +40,7 @@ struct CholmodSimplicialLDLTVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "A simplicial direct Cholesky (LDLT) factorization and solver based on " diff --git a/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLLT.hpp b/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLLT.hpp index c9404b00f..3fed248ea 100644 --- a/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLLT.hpp +++ b/include/eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLLT.hpp @@ -22,7 +22,7 @@ struct CholmodSimplicialLLTVisitor typedef Eigen::CholmodSimplicialLLT Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl .def(CholmodBaseVisitor()) @@ -40,7 +40,7 @@ struct CholmodSimplicialLLTVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "A simplicial direct Cholesky (LLT) factorization and solver based on " diff --git a/include/eigenpy/decompositions/sparse/cholmod/CholmodSupernodalLLT.hpp b/include/eigenpy/decompositions/sparse/cholmod/CholmodSupernodalLLT.hpp index ea818e2e4..ed4d45c0f 100644 --- a/include/eigenpy/decompositions/sparse/cholmod/CholmodSupernodalLLT.hpp +++ b/include/eigenpy/decompositions/sparse/cholmod/CholmodSupernodalLLT.hpp @@ -22,7 +22,7 @@ struct CholmodSupernodalLLTVisitor typedef Eigen::CholmodSupernodalLLT Solver; template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl .def(CholmodBaseVisitor()) @@ -40,7 +40,7 @@ struct CholmodSupernodalLLTVisitor expose(classname); } - static void expose(const std::string &name) { + static void expose(const std::string& name) { bp::class_( name.c_str(), "A supernodal direct Cholesky (LLT) factorization and solver based on " diff --git a/include/eigenpy/deprecation-policy.hpp b/include/eigenpy/deprecation-policy.hpp index e1e953f5a..9824e3019 100644 --- a/include/eigenpy/deprecation-policy.hpp +++ b/include/eigenpy/deprecation-policy.hpp @@ -13,7 +13,7 @@ enum class DeprecationType { DEPRECATION, FUTURE }; namespace detail { -inline PyObject *deprecationTypeToPyObj(DeprecationType dep) { +inline PyObject* deprecationTypeToPyObj(DeprecationType dep) { switch (dep) { case DeprecationType::DEPRECATION: return PyExc_DeprecationWarning; @@ -36,17 +36,17 @@ struct deprecation_warning_policy : BasePolicy { using result_converter = typename BasePolicy::result_converter; using argument_package = typename BasePolicy::argument_package; - deprecation_warning_policy(const std::string &warning_msg) + deprecation_warning_policy(const std::string& warning_msg) : BasePolicy(), m_what(warning_msg) {} std::string what() const { return m_what; } - const BasePolicy *derived() const { - return static_cast(this); + const BasePolicy* derived() const { + return static_cast(this); } template - bool precall(const ArgPackage &args) const { + bool precall(const ArgPackage& args) const { PyErr_WarnEx(detail::deprecationTypeToPyObj(deprecation_type), m_what.c_str(), 1); return derived()->precall(args); @@ -60,7 +60,7 @@ template struct deprecated_function : deprecation_warning_policy { - deprecated_function(const std::string &msg = + deprecated_function(const std::string& msg = "This function has been marked as deprecated, and " "will be removed in the future.") : deprecation_warning_policy(msg) {} @@ -70,7 +70,7 @@ template struct deprecated_member : deprecation_warning_policy { - deprecated_member(const std::string &msg = + deprecated_member(const std::string& msg = "This attribute or method has been marked as " "deprecated, and will be removed in the future.") : deprecation_warning_policy(msg) {} diff --git a/include/eigenpy/eigen-allocator.hpp b/include/eigenpy/eigen-allocator.hpp index 2b4c88252..881bd9e5d 100644 --- a/include/eigenpy/eigen-allocator.hpp +++ b/include/eigenpy/eigen-allocator.hpp @@ -17,14 +17,14 @@ namespace details { template struct init_matrix_or_array { - static MatType *run(int rows, int cols, void *storage) { + static MatType* run(int rows, int cols, void* storage) { if (storage) return new (storage) MatType(rows, cols); else return new MatType(rows, cols); } - static MatType *run(PyArrayObject *pyArray, void *storage = NULL) { + static MatType* run(PyArrayObject* pyArray, void* storage = NULL) { assert(PyArray_NDIM(pyArray) == 1 || PyArray_NDIM(pyArray) == 2); int rows = -1, cols = -1; @@ -43,21 +43,21 @@ struct init_matrix_or_array { template struct init_matrix_or_array { - static MatType *run(int rows, int cols, void *storage) { + static MatType* run(int rows, int cols, void* storage) { if (storage) return new (storage) MatType(rows, cols); else return new MatType(rows, cols); } - static MatType *run(int size, void *storage) { + static MatType* run(int size, void* storage) { if (storage) return new (storage) MatType(size); else return new MatType(size); } - static MatType *run(PyArrayObject *pyArray, void *storage = NULL) { + static MatType* run(PyArrayObject* pyArray, void* storage = NULL) { const int ndim = PyArray_NDIM(pyArray); if (ndim == 1) { const int size = (int)PyArray_DIMS(pyArray)[0]; @@ -73,7 +73,7 @@ struct init_matrix_or_array { #ifdef EIGENPY_WITH_TENSOR_SUPPORT template struct init_tensor { - static Tensor *run(PyArrayObject *pyArray, void *storage = NULL) { + static Tensor* run(PyArrayObject* pyArray, void* storage = NULL) { enum { Rank = Tensor::NumDimensions }; assert(PyArray_NDIM(pyArray) == Rank); typedef typename Tensor::Index Index; @@ -103,8 +103,8 @@ struct check_swap_impl> template struct check_swap_impl_matrix { - static bool run(PyArrayObject *pyArray, - const Eigen::MatrixBase &mat) { + static bool run(PyArrayObject* pyArray, + const Eigen::MatrixBase& mat) { if (PyArray_NDIM(pyArray) == 0) return false; if (mat.rows() == PyArray_DIMS(pyArray)[0]) return false; @@ -114,14 +114,14 @@ struct check_swap_impl_matrix { }; template -bool check_swap(PyArrayObject *pyArray, const EigenType &mat) { +bool check_swap(PyArrayObject* pyArray, const EigenType& mat) { return check_swap_impl::run(pyArray, mat); } #ifdef EIGENPY_WITH_TENSOR_SUPPORT template struct check_swap_impl_tensor { - static bool run(PyArrayObject * /*pyArray*/, const TensorType & /*tensor*/) { + static bool run(PyArrayObject* /*pyArray*/, const TensorType& /*tensor*/) { return false; } }; @@ -157,8 +157,8 @@ template ::value> struct cast { template - static void run(const Eigen::MatrixBase &input, - const Eigen::MatrixBase &dest) { + static void run(const Eigen::MatrixBase& input, + const Eigen::MatrixBase& dest) { dest.const_cast_derived() = input.template cast(); } }; @@ -167,7 +167,7 @@ struct cast { template struct cast { template - static void run(const TensorIn &input, TensorOut &dest) { + static void run(const TensorIn& input, TensorOut& dest) { dest = input.template cast(); } }; @@ -307,23 +307,23 @@ struct eigen_allocator_impl_matrix { typedef typename MatType::Scalar Scalar; static void allocate( - PyArrayObject *pyArray, - boost::python::converter::rvalue_from_python_storage *storage) { - void *raw_ptr = storage->storage.bytes; + PyArrayObject* pyArray, + boost::python::converter::rvalue_from_python_storage* storage) { + void* raw_ptr = storage->storage.bytes; assert(is_aligned(raw_ptr, EIGENPY_DEFAULT_ALIGN_BYTES) && "The pointer is not aligned."); - Type *mat_ptr = details::init_matrix_or_array::run(pyArray, raw_ptr); - Type &mat = *mat_ptr; + Type* mat_ptr = details::init_matrix_or_array::run(pyArray, raw_ptr); + Type& mat = *mat_ptr; copy(pyArray, mat); } /// \brief Copy Python array into the input matrix mat. template - static void copy(PyArrayObject *pyArray, - const Eigen::MatrixBase &mat_) { - MatrixDerived &mat = mat_.const_cast_derived(); + static void copy(PyArrayObject* pyArray, + const Eigen::MatrixBase& mat_) { + MatrixDerived& mat = mat_.const_cast_derived(); const int pyArray_type_code = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int Scalar_type_code = Register::getTypeCode(); @@ -339,10 +339,9 @@ struct eigen_allocator_impl_matrix { /// \brief Copy mat into the Python array using Eigen::Map template - static void copy(const Eigen::MatrixBase &mat_, - PyArrayObject *pyArray) { - const MatrixDerived &mat = - const_cast(mat_.derived()); + static void copy(const Eigen::MatrixBase& mat_, + PyArrayObject* pyArray) { + const MatrixDerived& mat = const_cast(mat_.derived()); const int pyArray_type_code = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int Scalar_type_code = Register::getTypeCode(); @@ -374,16 +373,16 @@ template struct eigen_allocator_impl_tensor { typedef typename TensorType::Scalar Scalar; static void allocate( - PyArrayObject *pyArray, - boost::python::converter::rvalue_from_python_storage - *storage) { - void *raw_ptr = storage->storage.bytes; + PyArrayObject* pyArray, + boost::python::converter::rvalue_from_python_storage* + storage) { + void* raw_ptr = storage->storage.bytes; assert(is_aligned(raw_ptr, EIGENPY_DEFAULT_ALIGN_BYTES) && "The pointer is not aligned."); - TensorType *tensor_ptr = + TensorType* tensor_ptr = details::init_tensor::run(pyArray, raw_ptr); - TensorType &tensor = *tensor_ptr; + TensorType& tensor = *tensor_ptr; copy(pyArray, tensor); } @@ -400,7 +399,7 @@ struct eigen_allocator_impl_tensor { /// \brief Copy Python array into the input matrix mat. template - static void copy(PyArrayObject *pyArray, TensorDerived &tensor) { + static void copy(PyArrayObject* pyArray, TensorDerived& tensor) { const int pyArray_type_code = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int Scalar_type_code = Register::getTypeCode(); @@ -426,7 +425,7 @@ struct eigen_allocator_impl_tensor { } /// \brief Copy mat into the Python array using Eigen::Map - static void copy(const TensorType &tensor, PyArrayObject *pyArray) { + static void copy(const TensorType& tensor, PyArrayObject* pyArray) { const int pyArray_type_code = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int Scalar_type_code = Register::getTypeCode(); @@ -452,7 +451,7 @@ struct eigen_allocator_impl_tensor { /// you want a compile-time vector /// in these cases, data layout fits desired view layout template -inline bool is_arr_layout_compatible_with_mat_type(PyArrayObject *pyArray) { +inline bool is_arr_layout_compatible_with_mat_type(PyArrayObject* pyArray) { bool is_array_C_cont = PyArray_IS_C_CONTIGUOUS(pyArray); bool is_array_F_cont = PyArray_IS_F_CONTIGUOUS(pyArray); return (MatType::IsRowMajor && is_array_C_cont) || @@ -467,13 +466,13 @@ struct eigen_allocator_impl_matrix> { typedef typename MatType::Scalar Scalar; typedef - typename ::boost::python::detail::referent_storage::StorageType + typename ::boost::python::detail::referent_storage::StorageType StorageType; static void allocate( - PyArrayObject *pyArray, - ::boost::python::converter::rvalue_from_python_storage - *storage) { + PyArrayObject* pyArray, + ::boost::python::converter::rvalue_from_python_storage* + storage) { typedef typename StrideType< MatType, Eigen::internal::traits::StrideType::InnerStrideAtCompileTime, @@ -491,20 +490,20 @@ struct eigen_allocator_impl_matrix> { Eigen::Unaligned) // we need to check whether the memory is correctly // aligned and composed of a continuous segment { - void *data_ptr = PyArray_DATA(pyArray); + void* data_ptr = PyArray_DATA(pyArray); if (!PyArray_ISONESEGMENT(pyArray) || !is_aligned(data_ptr, Options)) need_to_allocate |= true; } - void *raw_ptr = storage->storage.bytes; + void* raw_ptr = storage->storage.bytes; if (need_to_allocate) { - MatType *mat_ptr; + MatType* mat_ptr; mat_ptr = details::init_matrix_or_array::run(pyArray); RefType mat_ref(*mat_ptr); new (raw_ptr) StorageType(mat_ref, pyArray, mat_ptr); - RefType &mat = *reinterpret_cast(raw_ptr); + RefType& mat = *reinterpret_cast(raw_ptr); EigenAllocator::copy(pyArray, mat); } else { assert(pyArray_type_code == Scalar_type_code); @@ -516,7 +515,7 @@ struct eigen_allocator_impl_matrix> { } } - static void copy(RefType const &ref, PyArrayObject *pyArray) { + static void copy(RefType const& ref, PyArrayObject* pyArray) { EigenAllocator::copy(ref, pyArray); } }; @@ -528,13 +527,13 @@ struct eigen_allocator_impl_matrix< typedef typename MatType::Scalar Scalar; typedef - typename ::boost::python::detail::referent_storage::StorageType + typename ::boost::python::detail::referent_storage::StorageType StorageType; static void allocate( - PyArrayObject *pyArray, - ::boost::python::converter::rvalue_from_python_storage - *storage) { + PyArrayObject* pyArray, + ::boost::python::converter::rvalue_from_python_storage* + storage) { typedef typename StrideType< MatType, Eigen::internal::traits::StrideType::InnerStrideAtCompileTime, @@ -553,20 +552,20 @@ struct eigen_allocator_impl_matrix< Eigen::Unaligned) // we need to check whether the memory is correctly // aligned and composed of a continuous segment { - void *data_ptr = PyArray_DATA(pyArray); + void* data_ptr = PyArray_DATA(pyArray); if (!PyArray_ISONESEGMENT(pyArray) || !is_aligned(data_ptr, Options)) need_to_allocate |= true; } - void *raw_ptr = storage->storage.bytes; + void* raw_ptr = storage->storage.bytes; if (need_to_allocate) { - MatType *mat_ptr; + MatType* mat_ptr; mat_ptr = details::init_matrix_or_array::run(pyArray); RefType mat_ref(*mat_ptr); new (raw_ptr) StorageType(mat_ref, pyArray, mat_ptr); - MatType &mat = *mat_ptr; + MatType& mat = *mat_ptr; EigenAllocator::copy(pyArray, mat); } else { assert(pyArray_type_code == Scalar_type_code); @@ -578,7 +577,7 @@ struct eigen_allocator_impl_matrix< } } - static void copy(RefType const &ref, PyArrayObject *pyArray) { + static void copy(RefType const& ref, PyArrayObject* pyArray) { EigenAllocator::copy(ref, pyArray); } }; @@ -604,13 +603,13 @@ struct eigen_allocator_impl_tensor_ref { typedef typename TensorType::Scalar Scalar; typedef - typename ::boost::python::detail::referent_storage::StorageType + typename ::boost::python::detail::referent_storage::StorageType StorageType; static void allocate( - PyArrayObject *pyArray, - ::boost::python::converter::rvalue_from_python_storage - *storage) { + PyArrayObject* pyArray, + ::boost::python::converter::rvalue_from_python_storage* + storage) { // typedef typename StrideType< // MatType, // Eigen::internal::traits::StrideType::InnerStrideAtCompileTime, @@ -637,16 +636,16 @@ struct eigen_allocator_impl_tensor_ref { // need_to_allocate |= true; // } - void *raw_ptr = storage->storage.bytes; + void* raw_ptr = storage->storage.bytes; if (need_to_allocate) { typedef typename boost::remove_const::type TensorTypeNonConst; - TensorTypeNonConst *tensor_ptr; + TensorTypeNonConst* tensor_ptr; tensor_ptr = details::init_tensor::run(pyArray); RefType tensor_ref(*tensor_ptr); new (raw_ptr) StorageType(tensor_ref, pyArray, tensor_ptr); - TensorTypeNonConst &tensor = *tensor_ptr; + TensorTypeNonConst& tensor = *tensor_ptr; EigenAllocator::copy(pyArray, tensor); } else { assert(pyArray_type_code == Scalar_type_code); @@ -657,7 +656,7 @@ struct eigen_allocator_impl_tensor_ref { } } - static void copy(RefType const &ref, PyArrayObject *pyArray) { + static void copy(RefType const& ref, PyArrayObject* pyArray) { EigenAllocator::copy(ref, pyArray); } }; diff --git a/include/eigenpy/eigen-from-python.hpp b/include/eigenpy/eigen-from-python.hpp index 0d0ab4ace..e0a93df03 100644 --- a/include/eigenpy/eigen-from-python.hpp +++ b/include/eigenpy/eigen-from-python.hpp @@ -18,8 +18,8 @@ struct expected_pytype_for_arg {}; template struct expected_pytype_for_arg> { - static PyTypeObject const *get_pytype() { - PyTypeObject const *py_type = eigenpy::getPyArrayType(); + static PyTypeObject const* get_pytype() { + PyTypeObject const* py_type = eigenpy::getPyArrayType(); return py_type; } }; @@ -45,16 +45,16 @@ namespace eigenpy { namespace details { template ::value> struct copy_if_non_const { - static void run(const Eigen::MatrixBase &input, - PyArrayObject *pyArray) { + static void run(const Eigen::MatrixBase& input, + PyArrayObject* pyArray) { EigenAllocator::copy(input, pyArray); } }; template struct copy_if_non_const { - static void run(const Eigen::MatrixBase & /*input*/, - PyArrayObject * /*pyArray*/) {} + static void run(const Eigen::MatrixBase& /*input*/, + PyArrayObject* /*pyArray*/) {} }; #if EIGEN_VERSION_AT_LEAST(3, 2, 0) @@ -64,19 +64,19 @@ struct referent_storage_eigen_ref { typedef _RefType RefType; typedef typename get_eigen_plain_type::type PlainObjectType; typedef typename ::eigenpy::aligned_storage< - ::boost::python::detail::referent_size::value>::type + ::boost::python::detail::referent_size::value>::type AlignedStorage; referent_storage_eigen_ref() : pyArray(NULL), plain_ptr(NULL), - ref_ptr(reinterpret_cast(ref_storage.bytes)) {} + ref_ptr(reinterpret_cast(ref_storage.bytes)) {} - referent_storage_eigen_ref(const RefType &ref, PyArrayObject *pyArray, - PlainObjectType *plain_ptr = NULL) + referent_storage_eigen_ref(const RefType& ref, PyArrayObject* pyArray, + PlainObjectType* plain_ptr = NULL) : pyArray(pyArray), plain_ptr(plain_ptr), - ref_ptr(reinterpret_cast(ref_storage.bytes)) { + ref_ptr(reinterpret_cast(ref_storage.bytes)) { Py_INCREF(pyArray); new (ref_storage.bytes) RefType(ref); } @@ -93,9 +93,9 @@ struct referent_storage_eigen_ref { } AlignedStorage ref_storage; - PyArrayObject *pyArray; - PlainObjectType *plain_ptr; - RefType *ref_ptr; + PyArrayObject* pyArray; + PlainObjectType* plain_ptr; + RefType* ref_ptr; }; #endif @@ -107,19 +107,19 @@ namespace python { namespace detail { #if EIGEN_VERSION_AT_LEAST(3, 2, 0) template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::Ref RefType; typedef ::eigenpy::details::referent_storage_eigen_ref StorageType; typedef typename ::eigenpy::aligned_storage< - referent_size::value>::type type; + referent_size::value>::type type; }; template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::Ref RefType; typedef ::eigenpy::details::referent_storage_eigen_ref StorageType; typedef typename ::eigenpy::aligned_storage< - referent_size::value>::type type; + referent_size::value>::type type; }; #endif } // namespace detail @@ -133,42 +133,42 @@ namespace converter { #define EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(type) \ typedef ::eigenpy::rvalue_from_python_data Base; \ \ - rvalue_from_python_data(rvalue_from_python_stage1_data const &_stage1) \ + rvalue_from_python_data(rvalue_from_python_stage1_data const& _stage1) \ : Base(_stage1) {} \ \ - rvalue_from_python_data(void *convertible) : Base(convertible){}; + rvalue_from_python_data(void* convertible) : Base(convertible){}; template struct rvalue_from_python_data< - Eigen::Matrix const &> - : ::eigenpy::rvalue_from_python_data const &> { + Eigen::Matrix const&> + : ::eigenpy::rvalue_from_python_data< + Eigen::Matrix const&> { typedef Eigen::Matrix T; - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const &) + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const&) }; template -struct rvalue_from_python_data const &> - : ::eigenpy::rvalue_from_python_data { - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) +struct rvalue_from_python_data const&> + : ::eigenpy::rvalue_from_python_data { + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const&) }; template -struct rvalue_from_python_data const &> - : ::eigenpy::rvalue_from_python_data { - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) +struct rvalue_from_python_data const&> + : ::eigenpy::rvalue_from_python_data { + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const&) }; template -struct rvalue_from_python_data const &> - : ::eigenpy::rvalue_from_python_data { - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) +struct rvalue_from_python_data const&> + : ::eigenpy::rvalue_from_python_data { + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const&) }; template -struct rvalue_from_python_data &> - : rvalue_from_python_storage &> { +struct rvalue_from_python_data&> + : rvalue_from_python_storage&> { typedef Eigen::Ref RefType; #if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) && \ @@ -182,14 +182,14 @@ struct rvalue_from_python_data &> #endif // The usual constructor - rvalue_from_python_data(rvalue_from_python_stage1_data const &_stage1) { + rvalue_from_python_data(rvalue_from_python_stage1_data const& _stage1) { this->stage1 = _stage1; } // This constructor just sets m_convertible -- used by // implicitly_convertible<> to perform the final step of the // conversion, where the construct() function is already known. - rvalue_from_python_data(void *convertible) { + rvalue_from_python_data(void* convertible) { this->stage1.convertible = convertible; } @@ -197,15 +197,15 @@ struct rvalue_from_python_data &> ~rvalue_from_python_data() { typedef ::eigenpy::details::referent_storage_eigen_ref StorageType; if (this->stage1.convertible == this->storage.bytes) - static_cast((void *)this->storage.bytes)->~StorageType(); + static_cast((void*)this->storage.bytes)->~StorageType(); } }; template struct rvalue_from_python_data< - const Eigen::Ref &> + const Eigen::Ref&> : rvalue_from_python_storage< - const Eigen::Ref &> { + const Eigen::Ref&> { typedef Eigen::Ref RefType; #if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) && \ @@ -219,14 +219,14 @@ struct rvalue_from_python_data< #endif // The usual constructor - rvalue_from_python_data(rvalue_from_python_stage1_data const &_stage1) { + rvalue_from_python_data(rvalue_from_python_stage1_data const& _stage1) { this->stage1 = _stage1; } // This constructor just sets m_convertible -- used by // implicitly_convertible<> to perform the final step of the // conversion, where the construct() function is already known. - rvalue_from_python_data(void *convertible) { + rvalue_from_python_data(void* convertible) { this->stage1.convertible = convertible; } @@ -234,7 +234,7 @@ struct rvalue_from_python_data< ~rvalue_from_python_data() { typedef ::eigenpy::details::referent_storage_eigen_ref StorageType; if (this->stage1.convertible == this->storage.bytes) - static_cast((void *)this->storage.bytes)->~StorageType(); + static_cast((void*)this->storage.bytes)->~StorageType(); } }; @@ -246,15 +246,15 @@ namespace eigenpy { template void eigen_from_py_construct( - PyObject *pyObj, bp::converter::rvalue_from_python_stage1_data *memory) { - PyArrayObject *pyArray = reinterpret_cast(pyObj); + PyObject* pyObj, bp::converter::rvalue_from_python_stage1_data* memory) { + PyArrayObject* pyArray = reinterpret_cast(pyObj); assert((PyArray_DIMS(pyArray)[0] < INT_MAX) && (PyArray_DIMS(pyArray)[1] < INT_MAX)); - bp::converter::rvalue_from_python_storage *storage = + bp::converter::rvalue_from_python_storage* storage = reinterpret_cast< - bp::converter::rvalue_from_python_storage *>( - reinterpret_cast(memory)); + bp::converter::rvalue_from_python_storage*>( + reinterpret_cast(memory)); EigenAllocator::allocate(pyArray, storage); @@ -267,11 +267,11 @@ struct eigen_from_py_impl { typedef typename EigenType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj); + static void* convertible(PyObject* pyObj); /// \brief Allocate memory and copy pyObj in the new storage - static void construct(PyObject *pyObj, - bp::converter::rvalue_from_python_stage1_data *memory); + static void construct(PyObject* pyObj, + bp::converter::rvalue_from_python_stage1_data* memory); static void registration(); }; @@ -281,11 +281,11 @@ struct eigen_from_py_impl> { typedef typename MatType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj); + static void* convertible(PyObject* pyObj); /// \brief Allocate memory and copy pyObj in the new storage - static void construct(PyObject *pyObj, - bp::converter::rvalue_from_python_stage1_data *memory); + static void construct(PyObject* pyObj, + bp::converter::rvalue_from_python_stage1_data* memory); static void registration(); }; @@ -296,11 +296,11 @@ template {}; template -void *eigen_from_py_impl>::convertible( - PyObject *pyObj) { - if (!call_PyArray_Check(reinterpret_cast(pyObj))) return 0; +void* eigen_from_py_impl>::convertible( + PyObject* pyObj) { + if (!call_PyArray_Check(reinterpret_cast(pyObj))) return 0; - PyArrayObject *pyArray = reinterpret_cast(pyObj); + PyArrayObject* pyArray = reinterpret_cast(pyObj); if (!np_type_is_convertible_into_scalar( EIGENPY_GET_PY_ARRAY_TYPE(pyArray))) @@ -399,14 +399,14 @@ void *eigen_from_py_impl>::convertible( template void eigen_from_py_impl>::construct( - PyObject *pyObj, bp::converter::rvalue_from_python_stage1_data *memory) { + PyObject* pyObj, bp::converter::rvalue_from_python_stage1_data* memory) { eigen_from_py_construct(pyObj, memory); } template void eigen_from_py_impl>::registration() { bp::converter::registry::push_back( - reinterpret_cast(&eigen_from_py_impl::convertible), + reinterpret_cast(&eigen_from_py_impl::convertible), &eigen_from_py_impl::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -458,7 +458,7 @@ struct EigenFromPy> : EigenFromPy { static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &EigenFromPy::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -476,7 +476,7 @@ struct EigenFromPy, typename MatType::Scalar> static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &EigenFromPy::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -493,7 +493,7 @@ struct EigenFromPy> : EigenFromPy { static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &EigenFromPy::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -511,16 +511,16 @@ struct EigenFromPy> { typedef typename MatType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj) { + static void* convertible(PyObject* pyObj) { if (!call_PyArray_Check(pyObj)) return 0; - PyArrayObject *pyArray = reinterpret_cast(pyObj); + PyArrayObject* pyArray = reinterpret_cast(pyObj); if (!PyArray_ISWRITEABLE(pyArray)) return 0; return EigenFromPy::convertible(pyObj); } static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &eigen_from_py_construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -536,13 +536,13 @@ struct EigenFromPy> { typedef typename MatType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj) { + static void* convertible(PyObject* pyObj) { return EigenFromPy::convertible(pyObj); } static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &eigen_from_py_construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , diff --git a/include/eigenpy/eigen/EigenBase.hpp b/include/eigenpy/eigen/EigenBase.hpp index 2a589faf7..8f42128d5 100644 --- a/include/eigenpy/eigen/EigenBase.hpp +++ b/include/eigenpy/eigen/EigenBase.hpp @@ -13,7 +13,7 @@ template struct EigenBaseVisitor : public boost::python::def_visitor> { template - void visit(PyClass &cl) const { + void visit(PyClass& cl) const { cl.def("cols", &Derived::cols, bp::arg("self"), "Returns the number of columns.") .def("rows", &Derived::rows, bp::arg("self"), diff --git a/include/eigenpy/exception.hpp b/include/eigenpy/exception.hpp index c7694fb00..3247a5542 100644 --- a/include/eigenpy/exception.hpp +++ b/include/eigenpy/exception.hpp @@ -19,10 +19,10 @@ namespace eigenpy { class Exception : public std::exception { public: Exception() : message() {} - Exception(const std::string &msg) : message(msg) {} - const char *what() const throw() { return this->getMessage().c_str(); } + Exception(const std::string& msg) : message(msg) {} + const char* what() const throw() { return this->getMessage().c_str(); } ~Exception() throw() {} - virtual const std::string &getMessage() const { return message; } + virtual const std::string& getMessage() const { return message; } std::string copyMessage() const { return getMessage(); } /* Call this static function to "enable" the translation of this C++ exception @@ -30,8 +30,8 @@ class Exception : public std::exception { static void registerException(); private: - static void translateException(Exception const &e); - static PyObject *pyType; + static void translateException(Exception const& e); + static PyObject* pyType; protected: std::string message; diff --git a/include/eigenpy/fwd.hpp b/include/eigenpy/fwd.hpp index d95a81f2c..9111ebafc 100644 --- a/include/eigenpy/fwd.hpp +++ b/include/eigenpy/fwd.hpp @@ -108,7 +108,7 @@ namespace bp = boost::python; #define EIGENPY_NO_ALIGNMENT_VALUE Eigen::Unaligned #define EIGENPY_UNUSED_VARIABLE(var) (void)(var) -#define EIGENPY_UNUSED_TYPE(type) EIGENPY_UNUSED_VARIABLE((type *)(NULL)) +#define EIGENPY_UNUSED_TYPE(type) EIGENPY_UNUSED_VARIABLE((type*)(NULL)) #ifndef NDEBUG #define EIGENPY_USED_VARIABLE_ONLY_IN_DEBUG_MODE(var) #else @@ -185,7 +185,7 @@ namespace internal { template struct has_operator_equal_impl { template - static auto check(U *) -> decltype(std::declval() == std::declval()); + static auto check(U*) -> decltype(std::declval() == std::declval()); template static auto check(...) -> std::false_type; @@ -201,7 +201,7 @@ namespace literals { /// /// Using-declare this operator or do `using namespace eigenpy::literals`. Then /// `bp::arg("matrix")` can be replaced by the literal `"matrix"_a`. -inline boost::python::arg operator"" _a(const char *name, std::size_t) { +inline boost::python::arg operator"" _a(const char* name, std::size_t) { return boost::python::arg(name); } } // namespace literals diff --git a/include/eigenpy/numpy-allocator.hpp b/include/eigenpy/numpy-allocator.hpp index 6c5fc4c9c..1a50d3765 100644 --- a/include/eigenpy/numpy-allocator.hpp +++ b/include/eigenpy/numpy-allocator.hpp @@ -35,8 +35,8 @@ struct numpy_allocator_impl< //{}; template -struct numpy_allocator_impl> - : numpy_allocator_impl_matrix {}; +struct numpy_allocator_impl> + : numpy_allocator_impl_matrix {}; template ::type> @@ -45,13 +45,13 @@ struct NumpyAllocator : numpy_allocator_impl {}; template struct numpy_allocator_impl_matrix { template - static PyArrayObject *allocate( - const Eigen::MatrixBase &mat, npy_intp nd, - npy_intp *shape) { + static PyArrayObject* allocate( + const Eigen::MatrixBase& mat, npy_intp nd, + npy_intp* shape) { typedef typename SimilarMatrixType::Scalar Scalar; const int code = Register::getTypeCode(); - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_SimpleNew( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_SimpleNew( static_cast(nd), shape, code); // Copy data @@ -78,15 +78,15 @@ struct numpy_allocator_impl struct numpy_allocator_impl_tensor { template - static PyArrayObject *allocate(const TensorDerived &tensor, npy_intp nd, - npy_intp *shape) { + static PyArrayObject* allocate(const TensorDerived& tensor, npy_intp nd, + npy_intp* shape) { const int code = Register::getTypeCode(); - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_SimpleNew( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_SimpleNew( static_cast(nd), shape, code); // Copy data EigenAllocator::copy( - static_cast(tensor), pyArray); + static_cast(tensor), pyArray); return pyArray; } @@ -94,10 +94,10 @@ struct numpy_allocator_impl_tensor { #endif template -struct numpy_allocator_impl_matrix { +struct numpy_allocator_impl_matrix { template - static PyArrayObject *allocate(Eigen::PlainObjectBase &mat, - npy_intp nd, npy_intp *shape) { + static PyArrayObject* allocate(Eigen::PlainObjectBase& mat, + npy_intp nd, npy_intp* shape) { typedef typename SimilarMatrixType::Scalar Scalar; enum { NPY_ARRAY_MEMORY_CONTIGUOUS = @@ -106,7 +106,7 @@ struct numpy_allocator_impl_matrix { if (NumpyType::sharedMemory()) { const int Scalar_type_code = Register::getTypeCode(); - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_New( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_New( getPyArrayType(), static_cast(nd), shape, Scalar_type_code, mat.data(), NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED); @@ -123,7 +123,7 @@ template struct numpy_allocator_impl_matrix> { typedef Eigen::Ref RefType; - static PyArrayObject *allocate(RefType &mat, npy_intp nd, npy_intp *shape) { + static PyArrayObject* allocate(RefType& mat, npy_intp nd, npy_intp* shape) { typedef typename RefType::Scalar Scalar; enum { NPY_ARRAY_MEMORY_CONTIGUOUS = @@ -146,7 +146,7 @@ struct numpy_allocator_impl_matrix> { #endif npy_intp strides[2] = {elsize * inner_stride, elsize * outer_stride}; - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_New( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_New( getPyArrayType(), static_cast(nd), shape, Scalar_type_code, strides, mat.data(), NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED); @@ -160,11 +160,11 @@ struct numpy_allocator_impl_matrix> { #endif template -struct numpy_allocator_impl_matrix { +struct numpy_allocator_impl_matrix { template - static PyArrayObject *allocate( - const Eigen::PlainObjectBase &mat, npy_intp nd, - npy_intp *shape) { + static PyArrayObject* allocate( + const Eigen::PlainObjectBase& mat, npy_intp nd, + npy_intp* shape) { typedef typename SimilarMatrixType::Scalar Scalar; enum { NPY_ARRAY_MEMORY_CONTIGUOUS_RO = SimilarMatrixType::IsRowMajor @@ -174,9 +174,9 @@ struct numpy_allocator_impl_matrix { if (NumpyType::sharedMemory()) { const int Scalar_type_code = Register::getTypeCode(); - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_New( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_New( getPyArrayType(), static_cast(nd), shape, Scalar_type_code, - const_cast(mat.data()), + const_cast(mat.data()), NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED); return pyArray; @@ -193,7 +193,7 @@ struct numpy_allocator_impl_matrix< const Eigen::Ref> { typedef const Eigen::Ref RefType; - static PyArrayObject *allocate(RefType &mat, npy_intp nd, npy_intp *shape) { + static PyArrayObject* allocate(RefType& mat, npy_intp nd, npy_intp* shape) { typedef typename RefType::Scalar Scalar; enum { NPY_ARRAY_MEMORY_CONTIGUOUS_RO = @@ -217,9 +217,9 @@ struct numpy_allocator_impl_matrix< #endif npy_intp strides[2] = {elsize * inner_stride, elsize * outer_stride}; - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_New( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_New( getPyArrayType(), static_cast(nd), shape, Scalar_type_code, - strides, const_cast(mat.data()), + strides, const_cast(mat.data()), NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED); return pyArray; @@ -236,8 +236,8 @@ template struct numpy_allocator_impl_tensor> { typedef Eigen::TensorRef RefType; - static PyArrayObject *allocate(RefType &tensor, npy_intp nd, - npy_intp *shape) { + static PyArrayObject* allocate(RefType& tensor, npy_intp nd, + npy_intp* shape) { typedef typename RefType::Scalar Scalar; static const bool IsRowMajor = TensorType::Options & Eigen::RowMajorBit; enum { @@ -253,9 +253,9 @@ struct numpy_allocator_impl_tensor> { // call_PyArray_DescrFromType(Scalar_type_code)->elsize; npy_intp // strides[NumIndices]; - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_New( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_New( getPyArrayType(), static_cast(nd), shape, Scalar_type_code, NULL, - const_cast(tensor.data()), + const_cast(tensor.data()), NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED); return pyArray; @@ -269,8 +269,8 @@ template struct numpy_allocator_impl_tensor> { typedef const Eigen::TensorRef RefType; - static PyArrayObject *allocate(RefType &tensor, npy_intp nd, - npy_intp *shape) { + static PyArrayObject* allocate(RefType& tensor, npy_intp nd, + npy_intp* shape) { typedef typename RefType::Scalar Scalar; static const bool IsRowMajor = TensorType::Options & Eigen::RowMajorBit; enum { @@ -281,9 +281,9 @@ struct numpy_allocator_impl_tensor> { if (NumpyType::sharedMemory()) { const int Scalar_type_code = Register::getTypeCode(); - PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_New( + PyArrayObject* pyArray = (PyArrayObject*)call_PyArray_New( getPyArrayType(), static_cast(nd), shape, Scalar_type_code, NULL, - const_cast(tensor.data()), + const_cast(tensor.data()), NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED); return pyArray; diff --git a/include/eigenpy/optional.hpp b/include/eigenpy/optional.hpp index 5e123fd5e..8987c987b 100644 --- a/include/eigenpy/optional.hpp +++ b/include/eigenpy/optional.hpp @@ -63,7 +63,7 @@ struct nullopt_helper { template struct NoneToPython { - static PyObject *convert(const NoneType &) { Py_RETURN_NONE; } + static PyObject* convert(const NoneType&) { Py_RETURN_NONE; } static void registration() { if (!check_registration()) { @@ -75,7 +75,7 @@ struct NoneToPython { template class OptionalTpl = EIGENPY_DEFAULT_OPTIONAL> struct OptionalToPython { - static PyObject *convert(const OptionalTpl &obj) { + static PyObject* convert(const OptionalTpl& obj) { if (obj) return bp::incref(bp::object(*obj).ptr()); else { @@ -83,7 +83,7 @@ struct OptionalToPython { } } - static PyTypeObject const *get_pytype() { + static PyTypeObject const* get_pytype() { return bp::converter::registered_pytype::get_pytype(); } @@ -97,16 +97,16 @@ struct OptionalToPython { template class OptionalTpl = EIGENPY_DEFAULT_OPTIONAL> struct OptionalFromPython { - static void *convertible(PyObject *obj_ptr); + static void* convertible(PyObject* obj_ptr); - static void construct(PyObject *obj_ptr, - bp::converter::rvalue_from_python_stage1_data *memory); + static void construct(PyObject* obj_ptr, + bp::converter::rvalue_from_python_stage1_data* memory); static void registration(); }; template class OptionalTpl> -void *OptionalFromPython::convertible(PyObject *obj_ptr) { +void* OptionalFromPython::convertible(PyObject* obj_ptr) { if (obj_ptr == Py_None) { return obj_ptr; } @@ -119,12 +119,12 @@ void *OptionalFromPython::convertible(PyObject *obj_ptr) { template class OptionalTpl> void OptionalFromPython::construct( - PyObject *obj_ptr, bp::converter::rvalue_from_python_stage1_data *memory) { + PyObject* obj_ptr, bp::converter::rvalue_from_python_stage1_data* memory) { // create storage using rvalue_storage_t = bp::converter::rvalue_from_python_storage>; - void *storage = - reinterpret_cast(reinterpret_cast(memory)) + void* storage = + reinterpret_cast(reinterpret_cast(memory)) ->storage.bytes; if (obj_ptr == Py_None) { diff --git a/include/eigenpy/register.hpp b/include/eigenpy/register.hpp index 5b5055ad2..fb2171299 100644 --- a/include/eigenpy/register.hpp +++ b/include/eigenpy/register.hpp @@ -18,22 +18,22 @@ namespace eigenpy { /// \brief Structure collecting all the types registers in Numpy via EigenPy struct EIGENPY_DLLAPI Register { - static PyArray_Descr *getPyArrayDescr(PyTypeObject *py_type_ptr); + static PyArray_Descr* getPyArrayDescr(PyTypeObject* py_type_ptr); - static PyArray_Descr *getPyArrayDescrFromTypeNum(const int type_num); + static PyArray_Descr* getPyArrayDescrFromTypeNum(const int type_num); template - static PyArray_Descr *getPyArrayDescrFromScalarType() { + static PyArray_Descr* getPyArrayDescrFromScalarType() { if (!isNumpyNativeType()) { - const std::type_info &info = typeid(Scalar); + const std::type_info& info = typeid(Scalar); if (instance().type_to_py_type_bindings.find(&info) != instance().type_to_py_type_bindings.end()) { - PyTypeObject *py_type = instance().type_to_py_type_bindings[&info]; + PyTypeObject* py_type = instance().type_to_py_type_bindings[&info]; return instance().py_array_descr_bindings[py_type]; } else return nullptr; } else { - PyArray_Descr *new_descr = + PyArray_Descr* new_descr = call_PyArray_DescrFromType(NumpyEquivalentType::type_code); return new_descr; } @@ -44,14 +44,14 @@ struct EIGENPY_DLLAPI Register { return isRegistered(Register::getPyType()); } - static bool isRegistered(PyTypeObject *py_type_ptr); + static bool isRegistered(PyTypeObject* py_type_ptr); - static int getTypeCode(PyTypeObject *py_type_ptr); + static int getTypeCode(PyTypeObject* py_type_ptr); template - static PyTypeObject *getPyType() { + static PyTypeObject* getPyType() { if (!isNumpyNativeType()) { - const PyTypeObject *const_py_type_ptr = + const PyTypeObject* const_py_type_ptr = bp::converter::registered_pytype::get_pytype(); if (const_py_type_ptr == NULL) { std::stringstream ss; @@ -60,17 +60,17 @@ struct EIGENPY_DLLAPI Register { << std::endl; throw std::invalid_argument(ss.str()); } - PyTypeObject *py_type_ptr = const_cast(const_py_type_ptr); + PyTypeObject* py_type_ptr = const_cast(const_py_type_ptr); return py_type_ptr; } else { - PyArray_Descr *new_descr = + PyArray_Descr* new_descr = call_PyArray_DescrFromType(NumpyEquivalentType::type_code); return new_descr->typeobj; } } template - static PyArray_Descr *getPyArrayDescr() { + static PyArray_Descr* getPyArrayDescr() { if (!isNumpyNativeType()) { return getPyArrayDescr(getPyType()); } else { @@ -83,10 +83,10 @@ struct EIGENPY_DLLAPI Register { if (isNumpyNativeType()) return NumpyEquivalentType::type_code; else { - const std::type_info &info = typeid(Scalar); + const std::type_info& info = typeid(Scalar); if (instance().type_to_py_type_bindings.find(&info) != instance().type_to_py_type_bindings.end()) { - PyTypeObject *py_type = instance().type_to_py_type_bindings[&info]; + PyTypeObject* py_type = instance().type_to_py_type_bindings[&info]; int code = instance().py_array_code_bindings[py_type]; return code; @@ -96,39 +96,39 @@ struct EIGENPY_DLLAPI Register { } static int registerNewType( - PyTypeObject *py_type_ptr, const std::type_info *type_info_ptr, - const int type_size, const int alignment, PyArray_GetItemFunc *getitem, - PyArray_SetItemFunc *setitem, PyArray_NonzeroFunc *nonzero, - PyArray_CopySwapFunc *copyswap, PyArray_CopySwapNFunc *copyswapn, - PyArray_DotFunc *dotfunc, PyArray_FillFunc *fill, - PyArray_FillWithScalarFunc *fillwithscalar); + PyTypeObject* py_type_ptr, const std::type_info* type_info_ptr, + const int type_size, const int alignment, PyArray_GetItemFunc* getitem, + PyArray_SetItemFunc* setitem, PyArray_NonzeroFunc* nonzero, + PyArray_CopySwapFunc* copyswap, PyArray_CopySwapNFunc* copyswapn, + PyArray_DotFunc* dotfunc, PyArray_FillFunc* fill, + PyArray_FillWithScalarFunc* fillwithscalar); - static Register &instance(); + static Register& instance(); private: Register() {}; struct Compare_PyTypeObject { - bool operator()(const PyTypeObject *a, const PyTypeObject *b) const { + bool operator()(const PyTypeObject* a, const PyTypeObject* b) const { return std::string(a->tp_name) < std::string(b->tp_name); } }; struct Compare_TypeInfo { - bool operator()(const std::type_info *a, const std::type_info *b) const { + bool operator()(const std::type_info* a, const std::type_info* b) const { return std::string(a->name()) < std::string(b->name()); } }; - typedef std::map + typedef std::map MapInfo; MapInfo type_to_py_type_bindings; - typedef std::map + typedef std::map MapDescr; MapDescr py_array_descr_bindings; - typedef std::map MapCode; + typedef std::map MapCode; MapCode py_array_code_bindings; }; diff --git a/include/eigenpy/scipy-allocator.hpp b/include/eigenpy/scipy-allocator.hpp index 6cb77d8f4..2adfb5b15 100644 --- a/include/eigenpy/scipy-allocator.hpp +++ b/include/eigenpy/scipy-allocator.hpp @@ -36,9 +36,9 @@ struct scipy_allocator_impl -struct scipy_allocator_impl> - : scipy_allocator_impl_sparse_matrix {}; + : scipy_allocator_impl_sparse_matrix {}; template ::type> @@ -47,8 +47,8 @@ struct ScipyAllocator : scipy_allocator_impl {}; template struct scipy_allocator_impl_sparse_matrix { template - static PyObject *allocate( - const Eigen::SparseCompressedBase &mat_, + static PyObject* allocate( + const Eigen::SparseCompressedBase& mat_, bool copy = false) { EIGENPY_UNUSED_VARIABLE(copy); typedef typename SimilarMatrixType::Scalar Scalar; @@ -62,7 +62,7 @@ struct scipy_allocator_impl_sparse_matrix { typedef Eigen::Matrix ScipyStorageIndexVector; typedef const Eigen::Map MapStorageIndexVector; - SimilarMatrixType &mat = mat_.const_cast_derived(); + SimilarMatrixType& mat = mat_.const_cast_derived(); bp::object scipy_sparse_matrix_type = ScipyType::get_pytype_object(); diff --git a/include/eigenpy/sparse/eigen-from-python.hpp b/include/eigenpy/sparse/eigen-from-python.hpp index 1b57e0142..0f07c18bd 100644 --- a/include/eigenpy/sparse/eigen-from-python.hpp +++ b/include/eigenpy/sparse/eigen-from-python.hpp @@ -15,8 +15,8 @@ namespace eigenpy { template struct expected_pytype_for_arg> { - static PyTypeObject const *get_pytype() { - PyTypeObject const *py_type = ScipyType::get_pytype(); + static PyTypeObject const* get_pytype() { + PyTypeObject const* py_type = ScipyType::get_pytype(); return py_type; } }; @@ -35,17 +35,17 @@ struct expected_pytype_for_arg< template struct rvalue_from_python_data< - Eigen::SparseMatrix const &> + Eigen::SparseMatrix const&> : ::eigenpy::rvalue_from_python_data< - Eigen::SparseMatrix const &> { + Eigen::SparseMatrix const&> { typedef Eigen::SparseMatrix T; - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const &) + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const&) }; template -struct rvalue_from_python_data const &> - : ::eigenpy::rvalue_from_python_data { - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) +struct rvalue_from_python_data const&> + : ::eigenpy::rvalue_from_python_data { + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const&) }; } // namespace converter @@ -82,21 +82,21 @@ struct eigen_from_py_impl -void *eigen_from_py_impl< +void* eigen_from_py_impl< SparseMatrixType, - Eigen::SparseMatrixBase>::convertible(PyObject *pyObj) { - const PyTypeObject *type = Py_TYPE(pyObj); - const PyTypeObject *sparse_matrix_py_type = + Eigen::SparseMatrixBase>::convertible(PyObject* pyObj) { + const PyTypeObject* type = Py_TYPE(pyObj); + const PyTypeObject* sparse_matrix_py_type = ScipyType::get_pytype(); typedef typename SparseMatrixType::Scalar Scalar; @@ -113,17 +113,17 @@ void *eigen_from_py_impl< template void eigen_sparse_matrix_from_py_construct( - PyObject *pyObj, bp::converter::rvalue_from_python_stage1_data *memory) { + PyObject* pyObj, bp::converter::rvalue_from_python_stage1_data* memory) { typedef typename MatOrRefType::Scalar Scalar; typedef typename MatOrRefType::StorageIndex StorageIndex; typedef Eigen::Map MapMatOrRefType; - bp::converter::rvalue_from_python_storage *storage = + bp::converter::rvalue_from_python_storage* storage = reinterpret_cast< - bp::converter::rvalue_from_python_storage *>( - reinterpret_cast(memory)); - void *raw_ptr = storage->storage.bytes; + bp::converter::rvalue_from_python_storage*>( + reinterpret_cast(memory)); + void* raw_ptr = storage->storage.bytes; bp::object obj(bp::handle<>(bp::borrowed(pyObj))); @@ -148,8 +148,8 @@ void eigen_sparse_matrix_from_py_construct( nnz = bp::extract(obj.attr("nnz")); // Handle the specific case of the null matrix - Scalar *data_ptr = nullptr; - StorageIndex *indices_ptr = nullptr; + Scalar* data_ptr = nullptr; + StorageIndex* indices_ptr = nullptr; if (nnz > 0) { data_ptr = data.data(); indices_ptr = indices.data(); @@ -169,8 +169,8 @@ void eigen_sparse_matrix_from_py_construct( template void eigen_from_py_impl>:: - construct(PyObject *pyObj, - bp::converter::rvalue_from_python_stage1_data *memory) { + construct(PyObject* pyObj, + bp::converter::rvalue_from_python_stage1_data* memory) { eigen_sparse_matrix_from_py_construct(pyObj, memory); } @@ -179,7 +179,7 @@ void eigen_from_py_impl< SparseMatrixType, Eigen::SparseMatrixBase>::registration() { bp::converter::registry::push_back( - reinterpret_cast(&eigen_from_py_impl::convertible), + reinterpret_cast(&eigen_from_py_impl::convertible), &eigen_from_py_impl::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -216,7 +216,7 @@ struct EigenFromPy> static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &EigenFromPy::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , diff --git a/include/eigenpy/std-array.hpp b/include/eigenpy/std-array.hpp index 7226a4ddf..44fcc757c 100644 --- a/include/eigenpy/std-array.hpp +++ b/include/eigenpy/std-array.hpp @@ -40,24 +40,24 @@ class array_indexing_suite static constexpr std::size_t Size = std::tuple_size{}; template - static void extension_def(Class &) {} + static void extension_def(Class&) {} // throws exception - static void delete_item(Container &, index_type) { + static void delete_item(Container&, index_type) { PyErr_SetString(PyExc_NotImplementedError, "Cannot delete item from std::array type."); bp::throw_error_already_set(); } // throws exception - static void delete_slice(Container &, index_type, index_type) { + static void delete_slice(Container&, index_type, index_type) { PyErr_SetString(PyExc_NotImplementedError, "Cannot delete slice from std::array type."); bp::throw_error_already_set(); } - static void set_slice(Container &container, index_type from, index_type to, - data_type const &v) { + static void set_slice(Container& container, index_type from, index_type to, + data_type const& v) { if (from >= to) { PyErr_SetString(PyExc_NotImplementedError, "Setting this slice would insert into an std::array, " @@ -69,7 +69,7 @@ class array_indexing_suite } template - static void set_slice(Container &container, index_type from, index_type to, + static void set_slice(Container& container, index_type from, index_type to, Iter first, Iter last) { if (from >= to) { PyErr_SetString(PyExc_NotImplementedError, @@ -88,7 +88,7 @@ class array_indexing_suite } } - static bp::object get_slice(Container &container, index_type from, + static bp::object get_slice(Container& container, index_type from, index_type to) { if (from > to) return bp::object(slice_vector_type()); slice_vector_type out; @@ -112,29 +112,29 @@ template ::run(self, deep_copy); } - static void expose(const std::string &class_name, - const std::string &doc_string = "") { + static void expose(const std::string& class_name, + const std::string& doc_string = "") { expose(class_name, doc_string, EmptyPythonVisitor()); } template - static void expose(const std::string &class_name, - const bp::def_visitor &visitor) { + static void expose(const std::string& class_name, + const bp::def_visitor& visitor) { expose(class_name, "", visitor); } template - static void expose(const std::string &class_name, - const std::string &doc_string, - const bp::def_visitor &visitor) { + static void expose(const std::string& class_name, + const std::string& doc_string, + const bp::def_visitor& visitor) { if (!register_symbolic_link_to_registered_type()) { bp::class_ cl(class_name.c_str(), doc_string.c_str()); - cl.def(bp::init(bp::args("self", "other"), - "Copy constructor")); + cl.def(bp::init(bp::args("self", "other"), + "Copy constructor")); cl.def(IdVisitor()); array_indexing_suite indexing_suite; @@ -149,7 +149,7 @@ struct StdArrayPythonVisitor { /// Exposes std::array template -void exposeStdArrayEigenSpecificType(const char *name) { +void exposeStdArrayEigenSpecificType(const char* name) { std::ostringstream oss; oss << "StdArr"; oss << Size << "_" << name; diff --git a/include/eigenpy/std-vector.hpp b/include/eigenpy/std-vector.hpp index d6f86c379..91616cefd 100644 --- a/include/eigenpy/std-vector.hpp +++ b/include/eigenpy/std-vector.hpp @@ -33,7 +33,7 @@ namespace details { /// \brief Check if a PyObject can be converted to an std::vector. template -bool from_python_list(PyObject *obj_ptr, T *) { +bool from_python_list(PyObject* obj_ptr, T*) { // Check if it is a list if (!PyList_Check(obj_ptr)) return false; @@ -53,7 +53,7 @@ bool from_python_list(PyObject *obj_ptr, T *) { template struct build_list { - static bp::list run(vector_type &vec, const bool deep_copy) { + static bp::list run(vector_type& vec, const bool deep_copy) { if (deep_copy) return build_list::run(vec, true); bp::list bp_list; @@ -66,7 +66,7 @@ struct build_list { template struct build_list { - static bp::list run(vector_type &vec, const bool) { + static bp::list run(vector_type& vec, const bool) { typedef bp::iterator iterator; return bp::list(iterator()(vec)); } @@ -83,7 +83,7 @@ struct overload_base_get_item_for_std_vector typedef size_t index_type; template - void visit(Class &cl) const { + void visit(Class& cl) const { cl.def("__getitem__", &base_get_item_int) .def("__getitem__", &base_get_item_slice) .def("__getitem__", &base_get_item_list_or_tuple) @@ -91,8 +91,8 @@ struct overload_base_get_item_for_std_vector } private: - static bp::object base_get_item_int(bp::back_reference container, - PyObject *i_) { + static bp::object base_get_item_int(bp::back_reference container, + PyObject* i_) { index_type idx = convert_index(container.get(), i_); typename Container::iterator i = container.get().begin(); std::advance(i, idx); @@ -101,21 +101,21 @@ struct overload_base_get_item_for_std_vector bp::throw_error_already_set(); } - typename bp::to_python_indirect convert; return bp::object(bp::handle<>(convert(*i))); } static bp::object base_get_item_slice( - bp::back_reference container, bp::slice slice) { + bp::back_reference container, bp::slice slice) { bp::list out; try { auto rng = slice.get_indices(container.get().begin(), container.get().end()); // rng.start, rng.stop are iterators; rng.step is int; [start, stop] is // closed - typename bp::to_python_indirect convert; // forward or backward @@ -124,7 +124,7 @@ struct overload_base_get_item_for_std_vector out.append(bp::object(bp::handle<>(convert(*it)))); if (it == rng.stop) break; // closed interval, include stop } - } catch (const std::invalid_argument &) { + } catch (const std::invalid_argument&) { // Boost.Python specifies empty ranges throw invalid_argument. // Return [] (matches Python's behavior for empty slices). return bp::list(); @@ -134,7 +134,7 @@ struct overload_base_get_item_for_std_vector template static bp::object base_get_item_list_or_tuple( - bp::back_reference c, list_or_tuple idxs) { + bp::back_reference c, list_or_tuple idxs) { const Py_ssize_t m = bp::len(idxs); bp::list out; for (Py_ssize_t k = 0; k < m; ++k) { @@ -160,14 +160,14 @@ struct overload_base_get_item_for_std_vector return static_cast(idx); } - static bp::object elem_ref(Container &c, index_type i) { - typename bp::to_python_indirect conv; return bp::object(bp::handle<>(conv(c[i]))); } - static index_type convert_index(Container &container, PyObject *i_) { + static index_type convert_index(Container& container, PyObject* i_) { bp::extract i(i_); if (i.check()) { long index = i(); @@ -203,53 +203,53 @@ struct extract_to_eigen_ref operator result_type() const { return (*this)(); } - extract_to_eigen_ref(PyObject *o) : base(o) {} - extract_to_eigen_ref(api::object const &o) : base(o.ptr()) {} + extract_to_eigen_ref(PyObject* o) : base(o) {} + extract_to_eigen_ref(api::object const& o) : base(o.ptr()) {} }; /// \brief Specialization of the bp::extract struct for references to /// Eigen matrix objects. template -struct extract &> +struct extract&> : extract_to_eigen_ref< Eigen::Matrix> { typedef Eigen::Matrix MatrixType; typedef extract_to_eigen_ref base; - extract(PyObject *o) : base(o) {} - extract(api::object const &o) : base(o.ptr()) {} + extract(PyObject* o) : base(o) {} + extract(api::object const& o) : base(o.ptr()) {} }; template -struct extract &> +struct extract&> : extract_to_eigen_ref> { typedef Eigen::MatrixBase MatrixType; typedef extract_to_eigen_ref base; - extract(PyObject *o) : base(o) {} - extract(api::object const &o) : base(o.ptr()) {} + extract(PyObject* o) : base(o) {} + extract(api::object const& o) : base(o.ptr()) {} }; template -struct extract &> +struct extract&> : extract_to_eigen_ref> { typedef Eigen::RefBase MatrixType; typedef extract_to_eigen_ref base; - extract(PyObject *o) : base(o) {} - extract(api::object const &o) : base(o.ptr()) {} + extract(PyObject* o) : base(o) {} + extract(api::object const& o) : base(o.ptr()) {} }; namespace converter { template -struct reference_arg_from_python &> +struct reference_arg_from_python&> : arg_lvalue_from_python_base { typedef std::vector vector_type; - typedef vector_type &ref_vector_type; + typedef vector_type& ref_vector_type; typedef ref_vector_type result_type; - typedef extract extract_type; + typedef extract extract_type; - reference_arg_from_python(PyObject *py_obj) + reference_arg_from_python(PyObject* py_obj) : arg_lvalue_from_python_base(converter::get_lvalue_from_python( py_obj, registered::converters)), m_data(NULL), @@ -261,15 +261,15 @@ struct reference_arg_from_python &> // Check if py_obj is a py_list, which can then be converted to an // std::vector bool is_convertible = - ::eigenpy::details::from_python_list(py_obj, (Type *)(0)); + ::eigenpy::details::from_python_list(py_obj, (Type*)(0)); if (!is_convertible) return; typedef ::eigenpy::StdContainerFromPythonList Constructor; Constructor::construct(py_obj, &m_data.stage1); - void *&m_result = const_cast(result()); + void*& m_result = const_cast(result()); m_result = m_data.stage1.convertible; - vec_ptr = reinterpret_cast(m_data.storage.bytes); + vec_ptr = reinterpret_cast(m_data.storage.bytes); } result_type operator()() const { @@ -280,7 +280,7 @@ struct reference_arg_from_python &> ~reference_arg_from_python() { if (m_data.stage1.convertible == m_data.storage.bytes) { // Copy back the reference - const vector_type &vec = *vec_ptr; + const vector_type& vec = *vec_ptr; list bp_list(handle<>(borrowed(m_source))); for (size_t i = 0; i < vec.size(); ++i) { typename extract_type::result_type elt = extract_type(bp_list[i]); @@ -291,8 +291,8 @@ struct reference_arg_from_python &> private: rvalue_from_python_data m_data; - PyObject *m_source; - vector_type *vec_ptr; + PyObject* m_source; + vector_type* vec_ptr; }; } // namespace converter @@ -326,7 +326,7 @@ struct StdContainerFromPythonList { typedef typename details::container_traits::Allocator Allocator; /// \brief Check if obj_ptr can be converted - static void *convertible(PyObject *obj_ptr) { + static void* convertible(PyObject* obj_ptr) { namespace bp = boost::python; // Check if it is a list @@ -348,16 +348,16 @@ struct StdContainerFromPythonList { /// \brief Allocate the std::vector and fill it with the element contained in /// the list - static void construct(PyObject *obj_ptr, - bp::converter::rvalue_from_python_stage1_data *memory) { + static void construct(PyObject* obj_ptr, + bp::converter::rvalue_from_python_stage1_data* memory) { // Extract the list bp::object bp_obj(bp::handle<>(bp::borrowed(obj_ptr))); bp::list bp_list(bp_obj); - void *storage = + void* storage = reinterpret_cast< - bp::converter::rvalue_from_python_storage *>( - reinterpret_cast(memory)) + bp::converter::rvalue_from_python_storage*>( + reinterpret_cast(memory)) ->storage.bytes; typedef bp::stl_input_iterator iterator; @@ -374,7 +374,7 @@ struct StdContainerFromPythonList { bp::type_id()); } - static bp::list tolist(vector_type &self, const bool deep_copy = false) { + static bp::list tolist(vector_type& self, const bool deep_copy = false) { return details::build_list::run(self, deep_copy); } }; @@ -389,7 +389,7 @@ struct contains_algo; template struct contains_algo { template - static bool run(const Container &container, key_type const &key) { + static bool run(const Container& container, key_type const& key) { return std::find(container.begin(), container.end(), key) != container.end(); } @@ -398,7 +398,7 @@ struct contains_algo { template struct contains_algo { template - static bool run(const Container &container, key_type const &key) { + static bool run(const Container& container, key_type const& key) { for (size_t k = 0; k < container.size(); ++k) { if (&container[k] == &key) return true; } @@ -413,7 +413,7 @@ struct contains_vector_derived_policies contains_vector_derived_policies> { typedef typename Container::value_type key_type; - static bool contains(Container &container, key_type const &key) { + static bool contains(Container& container, key_type const& key) { return contains_algo::run(container, key); } }; @@ -430,11 +430,11 @@ struct ExposeStdMethodToStdVector typedef StdContainerFromPythonList FromPythonListConverter; - ExposeStdMethodToStdVector(const CoVisitor &co_visitor) + ExposeStdMethodToStdVector(const CoVisitor& co_visitor) : m_co_visitor(co_visitor) {} template - void visit(Class &cl) const { + void visit(Class& cl) const { cl.def(m_co_visitor) .def("tolist", &FromPythonListConverter::tolist, (bp::arg("self"), bp::arg("deep_copy") = false), @@ -446,13 +446,13 @@ struct ExposeStdMethodToStdVector .def(CopyableVisitor()); } - const CoVisitor &m_co_visitor; + const CoVisitor& m_co_visitor; }; /// Helper to ease ExposeStdMethodToStdVector construction template static ExposeStdMethodToStdVector -createExposeStdMethodToStdVector(const CoVisitor &co_visitor) { +createExposeStdMethodToStdVector(const CoVisitor& co_visitor) { return ExposeStdMethodToStdVector(co_visitor); } @@ -461,12 +461,12 @@ createExposeStdMethodToStdVector(const CoVisitor &co_visitor) { namespace internal { template struct def_pickle_std_vector { - static void run(bp::class_ &) {} + static void run(bp::class_&) {} }; template struct def_pickle_std_vector { - static void run(bp::class_ &cl) { + static void run(bp::class_& cl) { cl.def_pickle(PickleVector()); } }; @@ -487,21 +487,21 @@ struct StdVectorPythonVisitor { typedef StdContainerFromPythonList FromPythonListConverter; - static void expose(const std::string &class_name, - const std::string &doc_string = "") { + static void expose(const std::string& class_name, + const std::string& doc_string = "") { expose(class_name, doc_string, EmptyPythonVisitor()); } template - static void expose(const std::string &class_name, - const bp::def_visitor &visitor) { + static void expose(const std::string& class_name, + const bp::def_visitor& visitor) { expose(class_name, "", visitor); } template - static void expose(const std::string &class_name, - const std::string &doc_string, - const bp::def_visitor &visitor) { + static void expose(const std::string& class_name, + const std::string& doc_string, + const bp::def_visitor& visitor) { // Apply visitor on already registered type or if type is not already // registered, we define and apply the visitor on it auto add_std_visitor = @@ -518,11 +518,11 @@ struct StdVectorPythonVisitor { internal::contains_vector_derived_policies> vector_indexing; - cl.def(bp::init( + cl.def(bp::init( bp::args("self", "size", "value"), "Constructor from a given size and a given value.")) - .def(bp::init(bp::args("self", "other"), - "Copy constructor")) + .def(bp::init(bp::args("self", "other"), + "Copy constructor")) .def(vector_indexing) .def(add_std_visitor); @@ -542,7 +542,7 @@ struct StdVectorPythonVisitor { void EIGENPY_DLLAPI exposeStdVector(); template > -void exposeStdVectorEigenSpecificType(const char *name) { +void exposeStdVectorEigenSpecificType(const char* name) { typedef std::vector VecMatType; std::string full_name = "StdVec_"; full_name += name; diff --git a/include/eigenpy/tensor/eigen-from-python.hpp b/include/eigenpy/tensor/eigen-from-python.hpp index 1008fa34c..e364384ec 100644 --- a/include/eigenpy/tensor/eigen-from-python.hpp +++ b/include/eigenpy/tensor/eigen-from-python.hpp @@ -14,8 +14,8 @@ namespace eigenpy { template struct expected_pytype_for_arg> { - static PyTypeObject const *get_pytype() { - PyTypeObject const *py_type = eigenpy::getPyArrayType(); + static PyTypeObject const* get_pytype() { + PyTypeObject const* py_type = eigenpy::getPyArrayType(); return py_type; } }; @@ -33,17 +33,17 @@ struct expected_pytype_for_arg> template struct rvalue_from_python_data< - Eigen::Tensor const &> + Eigen::Tensor const&> : ::eigenpy::rvalue_from_python_data< - Eigen::Tensor const &> { + Eigen::Tensor const&> { typedef Eigen::Tensor T; - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const &) + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(T const&) }; template -struct rvalue_from_python_data const &> - : ::eigenpy::rvalue_from_python_data { - EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) +struct rvalue_from_python_data const&> + : ::eigenpy::rvalue_from_python_data { + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const&) }; } // namespace converter @@ -54,19 +54,19 @@ namespace boost { namespace python { namespace detail { template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::TensorRef RefType; typedef ::eigenpy::details::referent_storage_eigen_ref StorageType; typedef typename ::eigenpy::aligned_storage< - referent_size::value>::type type; + referent_size::value>::type type; }; template -struct referent_storage &> { +struct referent_storage&> { typedef Eigen::TensorRef RefType; typedef ::eigenpy::details::referent_storage_eigen_ref StorageType; typedef typename ::eigenpy::aligned_storage< - referent_size::value>::type type; + referent_size::value>::type type; }; } // namespace detail } // namespace python @@ -79,25 +79,24 @@ struct eigen_from_py_impl> { typedef typename TensorType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj); + static void* convertible(PyObject* pyObj); /// \brief Allocate memory and copy pyObj in the new storage - static void construct(PyObject *pyObj, - bp::converter::rvalue_from_python_stage1_data *memory); + static void construct(PyObject* pyObj, + bp::converter::rvalue_from_python_stage1_data* memory); static void registration(); }; template -void * -eigen_from_py_impl>::convertible( - PyObject *pyObj) { - if (!call_PyArray_Check(reinterpret_cast(pyObj))) return 0; +void* eigen_from_py_impl< + TensorType, Eigen::TensorBase>::convertible(PyObject* pyObj) { + if (!call_PyArray_Check(reinterpret_cast(pyObj))) return 0; typedef typename Eigen::internal::traits::Index Index; static const Index NumIndices = TensorType::NumIndices; - PyArrayObject *pyArray = reinterpret_cast(pyObj); + PyArrayObject* pyArray = reinterpret_cast(pyObj); if (!np_type_is_convertible_into_scalar( EIGENPY_GET_PY_ARRAY_TYPE(pyArray))) @@ -120,7 +119,7 @@ eigen_from_py_impl>::convertible( template void eigen_from_py_impl>::construct( - PyObject *pyObj, bp::converter::rvalue_from_python_stage1_data *memory) { + PyObject* pyObj, bp::converter::rvalue_from_python_stage1_data* memory) { eigen_from_py_construct(pyObj, memory); } @@ -128,7 +127,7 @@ template void eigen_from_py_impl>::registration() { bp::converter::registry::push_back( - reinterpret_cast(&eigen_from_py_impl::convertible), + reinterpret_cast(&eigen_from_py_impl::convertible), &eigen_from_py_impl::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -163,7 +162,7 @@ struct EigenFromPy> : EigenFromPy { static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &EigenFromPy::construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -179,16 +178,16 @@ struct EigenFromPy> { typedef typename TensorType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj) { + static void* convertible(PyObject* pyObj) { if (!call_PyArray_Check(pyObj)) return 0; - PyArrayObject *pyArray = reinterpret_cast(pyObj); + PyArrayObject* pyArray = reinterpret_cast(pyObj); if (!PyArray_ISWRITEABLE(pyArray)) return 0; return EigenFromPy::convertible(pyObj); } static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &eigen_from_py_construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , @@ -204,13 +203,13 @@ struct EigenFromPy> { typedef typename TensorType::Scalar Scalar; /// \brief Determine if pyObj can be converted into a MatType object - static void *convertible(PyObject *pyObj) { + static void* convertible(PyObject* pyObj) { return EigenFromPy::convertible(pyObj); } static void registration() { bp::converter::registry::push_back( - reinterpret_cast(&EigenFromPy::convertible), + reinterpret_cast(&EigenFromPy::convertible), &eigen_from_py_construct, bp::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , diff --git a/include/eigenpy/ufunc.hpp b/include/eigenpy/ufunc.hpp index eeb0902bb..f37da424f 100644 --- a/include/eigenpy/ufunc.hpp +++ b/include/eigenpy/ufunc.hpp @@ -21,12 +21,12 @@ namespace internal { #endif template -void matrix_multiply(char **args, npy_intp const *dimensions, - npy_intp const *steps) { +void matrix_multiply(char** args, npy_intp const* dimensions, + npy_intp const* steps) { /* pointers to data for input and output arrays */ - char *ip1 = args[0]; - char *ip2 = args[1]; - char *op = args[2]; + char* ip1 = args[0]; + char* ip2 = args[1]; + char* op = args[2]; /* lengths of core dimensions */ npy_intp dm = dimensions[0]; @@ -65,10 +65,10 @@ void matrix_multiply(char **args, npy_intp const *dimensions, } template -void gufunc_matrix_multiply(char **args, - npy_intp EIGENPY_NPY_CONST_UFUNC_ARG *dimensions, - npy_intp EIGENPY_NPY_CONST_UFUNC_ARG *steps, - void *NPY_UNUSED(func)) { +void gufunc_matrix_multiply(char** args, + npy_intp EIGENPY_NPY_CONST_UFUNC_ARG* dimensions, + npy_intp EIGENPY_NPY_CONST_UFUNC_ARG* steps, + void* NPY_UNUSED(func)) { /* outer dimensions counter */ npy_intp N_; @@ -92,15 +92,15 @@ void gufunc_matrix_multiply(char **args, #define EIGENPY_REGISTER_BINARY_OPERATOR(name, op) \ template \ void binary_op_##name( \ - char **args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *dimensions, \ - EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *steps, void * /*data*/) { \ + char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* dimensions, \ + EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* steps, void* /*data*/) { \ npy_intp is0 = steps[0], is1 = steps[1], os = steps[2], n = *dimensions; \ char *i0 = args[0], *i1 = args[1], *o = args[2]; \ int k; \ for (k = 0; k < n; k++) { \ - T1 &x = *static_cast(static_cast(i0)); \ - T2 &y = *static_cast(static_cast(i1)); \ - R &res = *static_cast(static_cast(o)); \ + T1& x = *static_cast(static_cast(i0)); \ + T2& y = *static_cast(static_cast(i1)); \ + R& res = *static_cast(static_cast(o)); \ res = x op y; \ i0 += is0; \ i1 += is1; \ @@ -110,8 +110,8 @@ void gufunc_matrix_multiply(char **args, \ template \ void binary_op_##name( \ - char **args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *dimensions, \ - EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *steps, void *data) { \ + char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* dimensions, \ + EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* steps, void* data) { \ binary_op_##name(args, dimensions, steps, data); \ } @@ -126,39 +126,39 @@ EIGENPY_REGISTER_BINARY_OPERATOR(greater, >) EIGENPY_REGISTER_BINARY_OPERATOR(less_equal, <=) EIGENPY_REGISTER_BINARY_OPERATOR(greater_equal, >=) -#define EIGENPY_REGISTER_UNARY_OPERATOR(name, op) \ - template \ - void unary_op_##name( \ - char **args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *dimensions, \ - EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *steps, void * /*data*/) { \ - npy_intp is = steps[0], os = steps[1], n = *dimensions; \ - char *i = args[0], *o = args[1]; \ - int k; \ - for (k = 0; k < n; k++) { \ - T &x = *static_cast(static_cast(i)); \ - R &res = *static_cast(static_cast(o)); \ - res = op x; \ - i += is; \ - o += os; \ - } \ - } \ - \ - template \ - void unary_op_##name( \ - char **args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *dimensions, \ - EIGENPY_NPY_CONST_UFUNC_ARG npy_intp *steps, void *data) { \ - unary_op_##name(args, dimensions, steps, data); \ +#define EIGENPY_REGISTER_UNARY_OPERATOR(name, op) \ + template \ + void unary_op_##name( \ + char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* dimensions, \ + EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* steps, void* /*data*/) { \ + npy_intp is = steps[0], os = steps[1], n = *dimensions; \ + char *i = args[0], *o = args[1]; \ + int k; \ + for (k = 0; k < n; k++) { \ + T& x = *static_cast(static_cast(i)); \ + R& res = *static_cast(static_cast(o)); \ + res = op x; \ + i += is; \ + o += os; \ + } \ + } \ + \ + template \ + void unary_op_##name( \ + char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* dimensions, \ + EIGENPY_NPY_CONST_UFUNC_ARG npy_intp* steps, void* data) { \ + unary_op_##name(args, dimensions, steps, data); \ } EIGENPY_REGISTER_UNARY_OPERATOR(negative, -) -EIGENPY_REGISTER_UNARY_OPERATOR(square, x *) +EIGENPY_REGISTER_UNARY_OPERATOR(square, x*) } // namespace internal #define EIGENPY_REGISTER_BINARY_UFUNC(name, code, T1, T2, R) \ { \ - PyUFuncObject *ufunc = \ - (PyUFuncObject *)PyObject_GetAttrString(numpy, #name); \ + PyUFuncObject* ufunc = \ + (PyUFuncObject*)PyObject_GetAttrString(numpy, #name); \ int _types[3] = {Register::getTypeCode(), Register::getTypeCode(), \ Register::getTypeCode()}; \ if (!ufunc) { \ @@ -171,7 +171,7 @@ EIGENPY_REGISTER_UNARY_OPERATOR(square, x *) (unsigned long)(sizeof(_types) / sizeof(int))); \ Py_DECREF(ufunc); \ } \ - if (PyUFunc_RegisterLoopForType((PyUFuncObject *)ufunc, code, \ + if (PyUFunc_RegisterLoopForType((PyUFuncObject*)ufunc, code, \ internal::binary_op_##name, \ _types, 0) < 0) { \ /*Py_DECREF(ufunc);*/ \ @@ -182,8 +182,8 @@ EIGENPY_REGISTER_UNARY_OPERATOR(square, x *) #define EIGENPY_REGISTER_UNARY_UFUNC(name, code, T, R) \ { \ - PyUFuncObject *ufunc = \ - (PyUFuncObject *)PyObject_GetAttrString(numpy, #name); \ + PyUFuncObject* ufunc = \ + (PyUFuncObject*)PyObject_GetAttrString(numpy, #name); \ int _types[2] = {Register::getTypeCode(), Register::getTypeCode()}; \ if (!ufunc) { \ /*goto fail; \*/ \ @@ -195,7 +195,7 @@ EIGENPY_REGISTER_UNARY_OPERATOR(square, x *) (unsigned long)(sizeof(_types) / sizeof(int))); \ Py_DECREF(ufunc); \ } \ - if (PyUFunc_RegisterLoopForType((PyUFuncObject *)ufunc, code, \ + if (PyUFunc_RegisterLoopForType((PyUFuncObject*)ufunc, code, \ internal::unary_op_##name, _types, \ 0) < 0) { \ /*Py_DECREF(ufunc);*/ \ @@ -208,9 +208,9 @@ template void registerCommonUfunc() { const int type_code = Register::getTypeCode(); - PyObject *numpy_str; + PyObject* numpy_str; numpy_str = PyStr_FromString("numpy"); - PyObject *numpy; + PyObject* numpy; numpy = PyImport_Import(numpy_str); Py_DECREF(numpy_str); @@ -223,15 +223,15 @@ void registerCommonUfunc() { std::stringstream ss; ss << "return result of multiplying two matrices of "; ss << bp::type_info(typeid(Scalar)).name(); - PyUFuncObject *ufunc = - (PyUFuncObject *)PyObject_GetAttrString(numpy, "matmul"); + PyUFuncObject* ufunc = + (PyUFuncObject*)PyObject_GetAttrString(numpy, "matmul"); if (!ufunc) { std::stringstream ss; ss << "Impossible to define matrix_multiply for given type " << bp::type_info(typeid(Scalar)).name() << std::endl; eigenpy::Exception(ss.str()); } - if (PyUFunc_RegisterLoopForType((PyUFuncObject *)ufunc, type_code, + if (PyUFunc_RegisterLoopForType((PyUFuncObject*)ufunc, type_code, &internal::gufunc_matrix_multiply, types, 0) < 0) { std::stringstream ss; diff --git a/include/eigenpy/utils/empty-visitor.hpp b/include/eigenpy/utils/empty-visitor.hpp index 1c832500a..ef5507042 100644 --- a/include/eigenpy/utils/empty-visitor.hpp +++ b/include/eigenpy/utils/empty-visitor.hpp @@ -8,7 +8,7 @@ namespace eigenpy { struct EmptyPythonVisitor : public ::boost::python::def_visitor { template - void visit(classT &) const {} + void visit(classT&) const {} }; } // namespace eigenpy diff --git a/python/main.cpp b/python/main.cpp index 19a643d99..763868b15 100644 --- a/python/main.cpp +++ b/python/main.cpp @@ -31,9 +31,9 @@ void exposeIsApprox() { Eigen::NumTraits::dummy_precision(); bp::def("is_approx", - (bool (*)(const Eigen::MatrixBase &, - const Eigen::MatrixBase &, - const RealScalar &))&is_approx, + (bool (*)(const Eigen::MatrixBase&, + const Eigen::MatrixBase&, + const RealScalar&))&is_approx, (bp::arg("A"), bp::arg("B"), bp::arg("prec") = dummy_precision), "Returns True if A is approximately equal to B, within the " "precision determined by prec."); diff --git a/src/type_info.cpp b/src/type_info.cpp index 482370cea..9c0d5661a 100644 --- a/src/type_info.cpp +++ b/src/type_info.cpp @@ -40,7 +40,7 @@ void exposeStdTypeIndex() { "and change between invocations of the same program.") .def( "pretty_name", - +[](const Self &value) -> std::string { + +[](const Self& value) -> std::string { return boost::core::demangle(value.name()); }, bp::arg("self"), "Human readible name."); diff --git a/unittest/bind_virtual_factory.cpp b/unittest/bind_virtual_factory.cpp index d142e3657..a2b561d36 100644 --- a/unittest/bind_virtual_factory.cpp +++ b/unittest/bind_virtual_factory.cpp @@ -14,9 +14,9 @@ struct MyVirtualClass { virtual ~MyVirtualClass() {} // polymorphic fn taking arg by shared_ptr - virtual void doSomethingPtr(shared_ptr const &data) const = 0; + virtual void doSomethingPtr(shared_ptr const& data) const = 0; // polymorphic fn taking arg by reference - virtual void doSomethingRef(MyVirtualData &data) const = 0; + virtual void doSomethingRef(MyVirtualData& data) const = 0; virtual shared_ptr createData() const { return std::make_shared(*this); @@ -24,20 +24,20 @@ struct MyVirtualClass { }; struct MyVirtualData { - MyVirtualData(MyVirtualClass const &) {} + MyVirtualData(MyVirtualClass const&) {} virtual ~MyVirtualData() {} // virtual dtor to mark class as polymorphic }; -shared_ptr callDoSomethingPtr(const MyVirtualClass &obj) { +shared_ptr callDoSomethingPtr(const MyVirtualClass& obj) { auto d = obj.createData(); - printf("Created MyVirtualData with address %p\n", (void *)d.get()); + printf("Created MyVirtualData with address %p\n", (void*)d.get()); obj.doSomethingPtr(d); return d; } -shared_ptr callDoSomethingRef(const MyVirtualClass &obj) { +shared_ptr callDoSomethingRef(const MyVirtualClass& obj) { auto d = obj.createData(); - printf("Created MyVirtualData with address %p\n", (void *)d.get()); + printf("Created MyVirtualData with address %p\n", (void*)d.get()); obj.doSomethingRef(*d); return d; } @@ -48,7 +48,7 @@ void throw_virtual_not_implemented_error() { /// Wrapper classes struct VirtualClassWrapper : MyVirtualClass, bp::wrapper { - void doSomethingPtr(shared_ptr const &data) const override { + void doSomethingPtr(shared_ptr const& data) const override { if (bp::override fo = this->get_override("doSomethingPtr")) { /// shared_ptr HAS to be passed by value. /// Boost.Python's argument converter has the wrong behaviour for @@ -63,7 +63,7 @@ struct VirtualClassWrapper : MyVirtualClass, bp::wrapper { /// and wrapped in a @c boost::reference_wrapper when passed to the override. /// Otherwise, Boost.Python's argument converter will convert to Python by /// value and create a copy. - void doSomethingRef(MyVirtualData &data) const override { + void doSomethingRef(MyVirtualData& data) const override { if (bp::override fo = this->get_override("doSomethingRef")) { fo(boost::ref(data)); return; @@ -98,25 +98,25 @@ struct DataWrapper : MyVirtualData, bp::wrapper { }; /// Take and return a const reference -const MyVirtualData &iden_ref(const MyVirtualData &d) { +const MyVirtualData& iden_ref(const MyVirtualData& d) { // try cast to holder return d; } /// Take a shared_ptr (by const reference or value, doesn't matter), return by /// const reference -const MyVirtualData &iden_shared(const shared_ptr &d) { +const MyVirtualData& iden_shared(const shared_ptr& d) { // get boost.python's custom deleter // boost.python hides the handle to the original object in there // dter being nonzero indicates shared_ptr was wrapped by Boost.Python - auto *dter = std::get_deleter(d); + auto* dter = std::get_deleter(d); if (dter != 0) printf("> input shared_ptr has a deleter\n"); return *d; } /// Take and return a shared_ptr -shared_ptr copy_shared(const shared_ptr &d) { - auto *dter = std::get_deleter(d); +shared_ptr copy_shared(const shared_ptr& d) { + auto* dter = std::get_deleter(d); if (dter != 0) printf("> input shared_ptr has a deleter\n"); return d; } @@ -141,7 +141,7 @@ BOOST_PYTHON_MODULE(bind_virtual_factory) { /// otherwise if passed as "HeldType", we need to define /// the constructor and call initializer manually. bp::class_("MyVirtualData", bp::no_init) - .def(bp::init(bp::args("self", "model"))); + .def(bp::init(bp::args("self", "model"))); bp::def("callDoSomethingPtr", callDoSomethingPtr, bp::args("obj")); bp::def("callDoSomethingRef", callDoSomethingRef, bp::args("obj")); diff --git a/unittest/complex.cpp b/unittest/complex.cpp index f4420cae5..cefc622ca 100644 --- a/unittest/complex.cpp +++ b/unittest/complex.cpp @@ -40,7 +40,7 @@ template typename Eigen::Matrix -real(const Eigen::MatrixBase &complex_mat) { +real(const Eigen::MatrixBase& complex_mat) { return complex_mat.real(); } @@ -48,13 +48,13 @@ template typename Eigen::Matrix -imag(const Eigen::MatrixBase &complex_mat) { +imag(const Eigen::MatrixBase& complex_mat) { return complex_mat.imag(); } template Eigen::Matrix, Rows, Cols, Options> ascomplex( - const Eigen::Matrix &mat) { + const Eigen::Matrix& mat) { typedef Eigen::Matrix, Rows, Cols, Options> ReturnType; return ReturnType(mat.template cast>()); } @@ -70,18 +70,18 @@ BOOST_PYTHON_MODULE(complex) { ascomplex); bp::def("real", - (MatrixXf (*)(const Eigen::MatrixBase &))&real); + (MatrixXf (*)(const Eigen::MatrixBase&))&real); bp::def("real", - (MatrixXd (*)(const Eigen::MatrixBase &))&real); + (MatrixXd (*)(const Eigen::MatrixBase&))&real); bp::def( "real", - (MatrixXld (*)(const Eigen::MatrixBase &))&real); + (MatrixXld (*)(const Eigen::MatrixBase&))&real); bp::def("imag", - (MatrixXf (*)(const Eigen::MatrixBase &))&imag); + (MatrixXf (*)(const Eigen::MatrixBase&))&imag); bp::def("imag", - (MatrixXd (*)(const Eigen::MatrixBase &))&imag); + (MatrixXd (*)(const Eigen::MatrixBase&))&imag); bp::def( "imag", - (MatrixXld (*)(const Eigen::MatrixBase &))&imag); + (MatrixXld (*)(const Eigen::MatrixBase&))&imag); } diff --git a/unittest/std_vector.cpp b/unittest/std_vector.cpp index 75a660b7f..f8deffbf5 100644 --- a/unittest/std_vector.cpp +++ b/unittest/std_vector.cpp @@ -9,7 +9,7 @@ template void printVectorOfMatrix( - const std::vector> &Ms) { + const std::vector>& Ms) { const std::size_t n = Ms.size(); for (std::size_t i = 0; i < n; i++) { std::cout << "el[" << i << "] =\n" << Ms[i] << '\n'; @@ -18,20 +18,20 @@ void printVectorOfMatrix( template std::vector> copy( - const std::vector> &Ms) { + const std::vector>& Ms) { std::vector> out = Ms; return out; } template -void setZero(std::vector> &Ms) { +void setZero(std::vector>& Ms) { for (std::size_t i = 0; i < Ms.size(); i++) { Ms[i].setZero(); } } struct CustomTestStruct { - bool operator==(const CustomTestStruct &) const { return true; } + bool operator==(const CustomTestStruct&) const { return true; } }; BOOST_PYTHON_MODULE(std_vector) {