Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jcarpent/eigenpy
  • gsaurel/eigenpy
  • stack-of-tasks/eigenpy
3 results
Show changes
Showing
with 433 additions and 123 deletions
/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2019, INRIA
* Copyright 2018-2023, INRIA
*/
#include "eigenpy/memory.hpp"
#include "eigenpy/geometry.hpp"
#include "eigenpy/angle-axis.hpp"
#include "eigenpy/geometry.hpp"
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(Eigen::AngleAxisd)
namespace eigenpy
{
void exposeAngleAxis()
{
expose<Eigen::AngleAxisd>();
}
} // namespace eigenpy
namespace eigenpy {
void exposeAngleAxis() { expose<Eigen::AngleAxisd>(); }
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/fwd.hpp"
#include "eigenpy/decompositions/decompositions.hpp"
#include "eigenpy/decompositions/sparse/accelerate/accelerate.hpp"
namespace eigenpy {
void exposeAccelerate() {
using namespace Eigen;
typedef Eigen::SparseMatrix<double, Eigen::ColMajor> ColMajorSparseMatrix;
// typedef Eigen::SparseMatrix<double,Eigen::RowMajor> RowMajorSparseMatrix;
bp::enum_<SparseOrder_t>("SparseOrder")
.value("SparseOrderUser", SparseOrderUser)
.value("SparseOrderAMD", SparseOrderAMD)
.value("SparseOrderMetis", SparseOrderMetis)
.value("SparseOrderCOLAMD", SparseOrderCOLAMD);
#define EXPOSE_ACCELERATE_DECOMPOSITION(name, doc) \
AccelerateImplVisitor<name<ColMajorSparseMatrix> >::expose( \
EIGENPY_STRINGIZE(name), doc)
EXPOSE_ACCELERATE_DECOMPOSITION(
AccelerateLLT,
"A direct Cholesky (LLT) factorization and solver based on Accelerate.");
EXPOSE_ACCELERATE_DECOMPOSITION(AccelerateLDLT,
"The default Cholesky (LDLT) factorization "
"and solver based on Accelerate.");
EXPOSE_ACCELERATE_DECOMPOSITION(
AccelerateLDLTUnpivoted,
"A direct Cholesky-like LDL^T factorization and solver based on "
"Accelerate with only 1x1 pivots and no pivoting.");
EXPOSE_ACCELERATE_DECOMPOSITION(
AccelerateLDLTSBK,
"A direct Cholesky (LDLT) factorization and solver based on Accelerate "
"with Supernode Bunch-Kaufman and static pivoting.");
EXPOSE_ACCELERATE_DECOMPOSITION(
AccelerateLDLTTPP,
"A direct Cholesky (LDLT) factorization and solver based on Accelerate "
"with full threshold partial pivoting.");
EXPOSE_ACCELERATE_DECOMPOSITION(
AccelerateQR, "A QR factorization and solver based on Accelerate.");
EXPOSE_ACCELERATE_DECOMPOSITION(
AccelerateCholeskyAtA,
"A QR factorization and solver based on Accelerate without storing Q "
"(equivalent to A^TA = R^T R).");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/fwd.hpp"
#include "eigenpy/decompositions/decompositions.hpp"
#include "eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLLT.hpp"
#include "eigenpy/decompositions/sparse/cholmod/CholmodSimplicialLDLT.hpp"
#include "eigenpy/decompositions/sparse/cholmod/CholmodSupernodalLLT.hpp"
namespace eigenpy {
void exposeCholmod() {
using namespace Eigen;
typedef Eigen::SparseMatrix<double, Eigen::ColMajor> ColMajorSparseMatrix;
// typedef Eigen::SparseMatrix<double,Eigen::RowMajor> RowMajorSparseMatrix;
bp::enum_<CholmodMode>("CholmodMode")
.value("CholmodAuto", CholmodAuto)
.value("CholmodSimplicialLLt", CholmodSimplicialLLt)
.value("CholmodSupernodalLLt", CholmodSupernodalLLt)
.value("CholmodLDLt", CholmodLDLt);
CholmodSimplicialLLTVisitor<ColMajorSparseMatrix>::expose(
"CholmodSimplicialLLT");
CholmodSimplicialLDLTVisitor<ColMajorSparseMatrix>::expose(
"CholmodSimplicialLDLT");
CholmodSupernodalLLTVisitor<ColMajorSparseMatrix>::expose(
"CholmodSupernodalLLT");
}
} // namespace eigenpy
/*
* Copyright 2020-2024 INRIA
*/
#include "eigenpy/decompositions/decompositions.hpp"
#include "eigenpy/fwd.hpp"
namespace eigenpy {
void exposeEigenSolver();
void exposeSelfAdjointEigenSolver();
void exposeLLTSolver();
void exposeLDLTSolver();
void exposeQRSolvers();
void exposeMINRESSolver();
void exposeSimplicialLLTSolver();
void exposeSimplicialLDLTSolver();
void exposePermutationMatrix();
void exposeDecompositions() {
using namespace Eigen;
exposeEigenSolver();
exposeSelfAdjointEigenSolver();
exposeLLTSolver();
exposeLDLTSolver();
exposeQRSolvers();
exposeMINRESSolver();
{
bp::enum_<DecompositionOptions>("DecompositionOptions")
.value("ComputeFullU", ComputeFullU)
.value("ComputeThinU", ComputeThinU)
.value("ComputeFullV", ComputeFullV)
.value("ComputeThinV", ComputeThinV)
.value("EigenvaluesOnly", EigenvaluesOnly)
.value("ComputeEigenvectors", ComputeEigenvectors)
.value("Ax_lBx", Ax_lBx)
.value("ABx_lx", ABx_lx)
.value("BAx_lx", BAx_lx);
}
// Expose sparse decompositions
exposeSimplicialLLTSolver();
exposeSimplicialLDLTSolver();
exposePermutationMatrix();
#ifdef EIGENPY_WITH_CHOLMOD_SUPPORT
exposeCholmod();
#endif
#ifdef EIGENPY_WITH_ACCELERATE_SUPPORT
exposeAccelerate();
#endif
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/EigenSolver.hpp"
namespace eigenpy {
void exposeEigenSolver() {
using namespace Eigen;
EigenSolverVisitor<MatrixXd>::expose("EigenSolver");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/LDLT.hpp"
namespace eigenpy {
void exposeLDLTSolver() {
using namespace Eigen;
LDLTSolverVisitor<MatrixXd>::expose("LDLT");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/LLT.hpp"
namespace eigenpy {
void exposeLLTSolver() {
using namespace Eigen;
LLTSolverVisitor<MatrixXd>::expose("LLT");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/minres.hpp"
namespace eigenpy {
void exposeMINRESSolver() {
using namespace Eigen;
MINRESSolverVisitor<MatrixXd>::expose("MINRES");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/PermutationMatrix.hpp"
namespace eigenpy {
void exposePermutationMatrix() {
using namespace Eigen;
PermutationMatrixVisitor<Eigen::Dynamic>::expose("PermutationMatrix");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/QR.hpp"
namespace eigenpy {
void exposeQRSolvers() {
using namespace Eigen;
HouseholderQRSolverVisitor<MatrixXd>::expose("HouseholderQR");
FullPivHouseholderQRSolverVisitor<MatrixXd>::expose("FullPivHouseholderQR");
ColPivHouseholderQRSolverVisitor<MatrixXd>::expose("ColPivHouseholderQR");
CompleteOrthogonalDecompositionSolverVisitor<MatrixXd>::expose(
"CompleteOrthogonalDecomposition");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/EigenSolver.hpp"
namespace eigenpy {
void exposeEigenSolver() {
using namespace Eigen;
EigenSolverVisitor<MatrixXd>::expose("EigenSolver");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/SelfAdjointEigenSolver.hpp"
namespace eigenpy {
void exposeSelfAdjointEigenSolver() {
using namespace Eigen;
SelfAdjointEigenSolverVisitor<MatrixXd>::expose("SelfAdjointEigenSolver");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/sparse/LDLT.hpp"
namespace eigenpy {
void exposeSimplicialLDLTSolver() {
using namespace Eigen;
typedef SparseMatrix<double, ColMajor> ColMajorSparseMatrix;
SimplicialLDLTVisitor<ColMajorSparseMatrix>::expose("SimplicialLDLT");
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/decompositions/sparse/LLT.hpp"
namespace eigenpy {
void exposeSimplicialLLTSolver() {
using namespace Eigen;
typedef SparseMatrix<double, ColMajor> ColMajorSparseMatrix;
SimplicialLLTVisitor<ColMajorSparseMatrix>::expose("SimplicialLLT");
}
} // namespace eigenpy
/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2019, INRIA
* Copyright 2018-2023, INRIA
*/
#include "eigenpy/eigenpy.hpp"
namespace eigenpy
{
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */
void enableEigenPy()
{
using namespace Eigen;
Exception::registerException();
bp::def("setNumpyType",&NumpyType::setNumpyType,
bp::arg("Numpy type (np.ndarray or np.matrix)"),
"Change the type returned by the converters from an Eigen object.");
bp::def("switchToNumpyArray",&NumpyType::switchToNumpyArray,
"Set the conversion from Eigen::Matrix to numpy.ndarray.");
bp::def("switchToNumpyMatrix",&NumpyType::switchToNumpyMatrix,
"Set the conversion from Eigen::Matrix to numpy.matrix.");
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2d);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2f);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2i);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2Xd);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2Xf);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2Xi);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3d);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3f);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3i);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3Xd);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3Xf);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3Xi);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4d);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4f);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4i);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4Xd);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4Xf);
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4Xi);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX2d);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX2f);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX2i);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX3d);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX3f);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX3i);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX4d);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX4f);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixX4i);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixXd);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixXf);
ENABLE_SPECIFIC_MATRIX_TYPE(MatrixXi);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector2d);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector2f);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector2i);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector3d);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector3f);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector3i);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector4d);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector4f);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVector4i);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVectorXd);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVectorXf);
ENABLE_SPECIFIC_MATRIX_TYPE(RowVectorXi);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector2d);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector2f);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector2i);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector3d);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector3f);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector3i);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector4d);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector4f);
ENABLE_SPECIFIC_MATRIX_TYPE(Vector4i);
ENABLE_SPECIFIC_MATRIX_TYPE(VectorXd);
ENABLE_SPECIFIC_MATRIX_TYPE(VectorXf);
ENABLE_SPECIFIC_MATRIX_TYPE(VectorXi);
}
} // namespace eigenpy
#include <stdlib.h>
namespace eigenpy {
void seed(unsigned int seed_value) { srand(seed_value); }
void exposeMatrixBool();
void exposeMatrixInt8();
void exposeMatrixChar();
void exposeMatrixUInt8();
void exposeMatrixInt16();
void exposeMatrixUInt16();
void exposeMatrixInt32();
void exposeMatrixUInt32();
void exposeMatrixWindowsLong();
void exposeMatrixWindowsULong();
void exposeMatrixMacLong();
void exposeMatrixMacULong();
void exposeMatrixInt64();
void exposeMatrixUInt64();
void exposeMatrixLinuxLongLong();
void exposeMatrixLinuxULongLong();
void exposeMatrixFloat();
void exposeMatrixDouble();
void exposeMatrixLongDouble();
void exposeMatrixComplexFloat();
void exposeMatrixComplexDouble();
void exposeMatrixComplexLongDouble();
void exposeNoneType();
void exposeTypeInfo();
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances.
*/
void enableEigenPy() {
using namespace Eigen;
import_numpy();
Exception::registerException();
bp::def("sharedMemory", (void (*)(const bool))NumpyType::sharedMemory,
bp::arg("value"),
"Share the memory when converting from Eigen to Numpy.");
bp::def("sharedMemory", (bool (*)())NumpyType::sharedMemory,
"Status of the shared memory when converting from Eigen to Numpy.\n"
"If True, the memory is shared when converting an Eigen::Matrix to a "
"numpy.array.\n"
"Otherwise, a deep copy of the Eigen::Matrix is performed.");
bp::def("seed", &seed, bp::arg("seed_value"),
"Initialize the pseudo-random number generator with the argument "
"seed_value.");
exposeMatrixBool();
exposeMatrixInt8();
exposeMatrixChar();
exposeMatrixUInt8();
exposeMatrixInt16();
exposeMatrixUInt16();
exposeMatrixInt32();
exposeMatrixUInt32();
exposeMatrixWindowsLong();
exposeMatrixWindowsULong();
exposeMatrixMacLong();
exposeMatrixMacULong();
exposeMatrixInt64();
exposeMatrixUInt64();
exposeMatrixLinuxLongLong();
exposeMatrixLinuxULongLong();
exposeMatrixFloat();
exposeMatrixDouble();
exposeMatrixLongDouble();
exposeMatrixComplexFloat();
exposeMatrixComplexDouble();
exposeMatrixComplexLongDouble();
exposeNoneType();
exposeTypeInfo();
}
bool withTensorSupport() {
#ifdef EIGENPY_WITH_TENSOR_SUPPORT
return true;
#else
return false;
#endif
}
} // namespace eigenpy
......@@ -4,33 +4,30 @@
*/
#include "eigenpy/exception.hpp"
#include "eigenpy/registration.hpp"
#include <boost/python/exception_translator.hpp>
#include "eigenpy/registration.hpp"
namespace eigenpy {
PyObject* Exception::pyType;
namespace eigenpy
{
PyObject * Exception::pyType;
void Exception::translateException(Exception const& e) {
assert(NULL != pyType);
// Return an exception object of type pyType and value object(e).
PyErr_SetString(PyExc_RuntimeError, e.what());
}
void Exception::translateException( Exception const & e )
{
assert(NULL!=pyType);
// Return an exception object of type pyType and value object(e).
PyErr_SetString(PyExc_RuntimeError, e.what());
}
void Exception::registerException() {
if (check_registration<eigenpy::Exception>()) return;
void Exception::registerException()
{
if(check_registration<eigenpy::Exception>()) return;
pyType = boost::python::class_<eigenpy::Exception>
("Exception",boost::python::init<std::string>())
.add_property("message", &eigenpy::Exception::copyMessage)
.ptr();
pyType = boost::python::class_<eigenpy::Exception>(
"Exception", boost::python::init<std::string>())
.add_property("message", &eigenpy::Exception::copyMessage)
.ptr();
boost::python::register_exception_translator<eigenpy::Exception>
(&eigenpy::Exception::translateException);
}
boost::python::register_exception_translator<eigenpy::Exception>(
&eigenpy::Exception::translateException);
}
} // namespace eigenpy
} // namespace eigenpy
/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2019, INRIA
* Copyright 2018-2023, INRIA
*/
#include "eigenpy/memory.hpp"
#include "eigenpy/geometry.hpp"
#include "eigenpy/geometry-conversion.hpp"
#include "eigenpy/geometry.hpp"
namespace eigenpy
{
void exposeGeometryConversion()
{
EulerAnglesConvertor<double>::expose();
}
} // namespace eigenpy
namespace eigenpy {
void exposeGeometryConversion() { EulerAnglesConvertor<double>::expose(); }
} // namespace eigenpy
/*
* Copyright 2021 INRIA
*/
#include "eigenpy/eigenpy.hpp"
namespace eigenpy {
void exposeMatrixBool() {
exposeType<bool>();
exposeType<bool, Eigen::RowMajor>();
}
} // namespace eigenpy
/*
* Copyright 2024 INRIA
*/
#include "eigenpy/eigenpy.hpp"
#include <cstdint>
namespace eigenpy {
void exposeMatrixChar() {
exposeType<char>();
exposeType<char, Eigen::RowMajor>();
}
} // namespace eigenpy
/*
* Copyright 2020 INRIA
*/
#include "eigenpy/eigenpy.hpp"
namespace eigenpy {
void exposeMatrixComplexDouble() {
exposeType<std::complex<double> >();
exposeType<std::complex<double>, Eigen::RowMajor>();
}
} // namespace eigenpy