eigenpy.cpp 3.68 KB
Newer Older
jcarpent's avatar
jcarpent committed
1
/*
2
3
 * Copyright 2014-2019, CNRS
 * Copyright 2018-2019, INRIA
jcarpent's avatar
jcarpent committed
4
5
 */

6
#include "eigenpy/eigenpy.hpp"
7
#include "eigenpy/version.hpp"
8
9
10
11

namespace eigenpy
{

12
  /* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */
13
14
  void enableEigenPy()
  {
15
    using namespace Eigen;
16
17
18
19
20
21
22
    
    bp::scope().attr("__version__") = eigenpy::printVersion();
    bp::scope().attr("__raw_version__") = bp::str(EIGENPY_VERSION);
    bp::def("checkVersionAtLeast",&eigenpy::checkVersionAtLeast,
            bp::args("major_version","minor_version","patch_version"),
            "Checks if the current version of EigenPy is at least the version provided by the input arguments.");
    
23
    Exception::registerException();
24
    
25
    bp::def("setNumpyType",&NumpyType::setNumpyType,
26
            bp::arg("Numpy type (np.ndarray or np.matrix)"),
Justin Carpentier's avatar
Justin Carpentier committed
27
            "Change the Numpy type returned by the converters from an Eigen object.");
28
29
30
            
    bp::def("getNumpyType",&NumpyType::getNumpyType,
            "Get the Numpy type returned by the converters from an Eigen object.");
31
    
32
    bp::def("switchToNumpyArray",&NumpyType::switchToNumpyArray,
33
34
            "Set the conversion from Eigen::Matrix to numpy.ndarray.");
    
35
    bp::def("switchToNumpyMatrix",&NumpyType::switchToNumpyMatrix,
36
            "Set the conversion from Eigen::Matrix to numpy.matrix.");
37

38
    ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2d);
39
40
41
42
43
    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);
44
    ENABLE_SPECIFIC_MATRIX_TYPE(Matrix3d);
45
46
47
48
49
    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);
50
    ENABLE_SPECIFIC_MATRIX_TYPE(Matrix4d);
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    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);

82
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector2d);
83
84
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector2f);
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector2i);
85
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector3d);
86
87
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector3f);
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector3i);
88
    ENABLE_SPECIFIC_MATRIX_TYPE(Vector4d);
89
90
91
92
93
    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);
94
95
96
  }

} // namespace eigenpy