Skip to content
Snippets Groups Projects
eigenpy.cpp 2.22 KiB
Newer Older
 * Copyright 2014-2019, CNRS
 * Copyright 2018-2021, INRIA
#include "eigenpy/eigenpy.hpp"
  void seed(unsigned int seed_value)
  {
    srand(seed_value);
  }

  void exposeMatrixBool();
  void exposeMatrixInt();
  void exposeMatrixLong();
  void exposeMatrixFloat();
  void exposeMatrixDouble();
  void exposeMatrixLongDouble();

  void exposeMatrixComplexFloat();
  void exposeMatrixComplexDouble();
  void exposeMatrixComplexLongDouble();

  /* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */
    using namespace Eigen;
    import_numpy();
    Exception::registerException();
    bp::def("setNumpyType",&NumpyType::setNumpyType,
Justin Carpentier's avatar
Justin Carpentier committed
            bp::arg("numpy_type"),
Justin Carpentier's avatar
Justin Carpentier committed
            "Change the Numpy type returned by the converters from an Eigen object.");
            
    bp::def("getNumpyType",&NumpyType::getNumpyType,
            "Get the Numpy 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.");
    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();
    exposeMatrixInt();
    exposeMatrixLong();
    exposeMatrixFloat();
    exposeMatrixDouble();
    exposeMatrixLongDouble();
    exposeMatrixComplexFloat();
    exposeMatrixComplexDouble();
    exposeMatrixComplexLongDouble();