8 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ 10 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \ 12 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \ 14 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix; 16 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \ 18 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \ 20 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix; 22 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ 23 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ 24 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ 25 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ 26 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \ 27 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \ 28 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \ 29 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4) 34 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES 35 #undef EIGEN_MAKE_TYPEDEFS 36 #undef EIGEN_MAKE_FIXED_TYPEDEFS 39 template <
typename ComplexMatrix>
40 typename Eigen::Matrix<
typename ComplexMatrix::RealScalar,
41 ComplexMatrix::RowsAtCompileTime,
42 ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options>
43 real(
const Eigen::MatrixBase<ComplexMatrix> &complex_mat) {
44 return complex_mat.real();
47 template <
typename ComplexMatrix>
48 typename Eigen::Matrix<
typename ComplexMatrix::RealScalar,
49 ComplexMatrix::RowsAtCompileTime,
50 ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options>
51 imag(
const Eigen::MatrixBase<ComplexMatrix> &complex_mat) {
52 return complex_mat.imag();
55 template <
typename Scalar,
int Rows,
int Cols,
int Options>
56 Eigen::Matrix<std::complex<Scalar>, Rows, Cols, Options>
ascomplex(
57 const Eigen::Matrix<Scalar, Rows, Cols, Options> &
mat) {
58 typedef Eigen::Matrix<std::complex<Scalar>, Rows, Cols, Options> ReturnType;
59 return ReturnType(mat.template
cast<std::complex<Scalar> >());
63 using namespace Eigen;
67 bp::def(
"ascomplex", ascomplex<float, Eigen::Dynamic, Eigen::Dynamic, 0>);
68 bp::def(
"ascomplex", ascomplex<double, Eigen::Dynamic, Eigen::Dynamic, 0>);
70 ascomplex<long double, Eigen::Dynamic, Eigen::Dynamic, 0>);
72 bp::def(
"real", (MatrixXf(*)(
const Eigen::MatrixBase<MatrixXcf> &)) &
74 bp::def(
"real", (MatrixXd(*)(
const Eigen::MatrixBase<MatrixXcd> &)) &
76 bp::def(
"real", (MatrixXld(*)(
const Eigen::MatrixBase<MatrixXcld> &)) &
79 bp::def(
"imag", (MatrixXf(*)(
const Eigen::MatrixBase<MatrixXcf> &)) &
81 bp::def(
"imag", (MatrixXd(*)(
const Eigen::MatrixBase<MatrixXcd> &)) &
83 bp::def(
"imag", (MatrixXld(*)(
const Eigen::MatrixBase<MatrixXcld> &)) &
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > imag(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix)
Eigen::Matrix< std::complex< Scalar >, Rows, Cols, Options > ascomplex(const Eigen::Matrix< Scalar, Rows, Cols, Options > &mat)
void EIGENPY_DLLAPI enableEigenPy()
BOOST_PYTHON_MODULE(complex)
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > real(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
static void cast(void *from_, void *to_, npy_intp n, void *, void *)