9 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ 11 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \ 13 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \ 15 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix; 17 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \ 19 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \ 21 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix; 23 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ 24 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ 25 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ 26 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ 27 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \ 28 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \ 29 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \ 30 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4) 35 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES 36 #undef EIGEN_MAKE_TYPEDEFS 37 #undef EIGEN_MAKE_FIXED_TYPEDEFS 40 template<
typename ComplexMatrix>
41 typename Eigen::Matrix<typename ComplexMatrix::RealScalar,ComplexMatrix::RowsAtCompileTime,ComplexMatrix::ColsAtCompileTime,ComplexMatrix::Options>
42 real(
const Eigen::MatrixBase<ComplexMatrix> & complex_mat)
44 return complex_mat.real();
47 template<
typename ComplexMatrix>
48 typename Eigen::Matrix<typename ComplexMatrix::RealScalar,ComplexMatrix::RowsAtCompileTime,ComplexMatrix::ColsAtCompileTime,ComplexMatrix::Options>
49 imag(
const Eigen::MatrixBase<ComplexMatrix> & complex_mat)
51 return complex_mat.imag();
54 template<
typename Scalar,
int Rows,
int Cols,
int Options>
55 Eigen::Matrix<std::complex<Scalar>,Rows,Cols,Options>
58 typedef Eigen::Matrix<std::complex<Scalar>,Rows,Cols,Options> ReturnType;
59 return ReturnType(mat.template cast<std::complex<Scalar> >());
64 using namespace Eigen;
68 bp::def(
"ascomplex", ascomplex<float,Eigen::Dynamic,Eigen::Dynamic,0>);
69 bp::def(
"ascomplex", ascomplex<double,Eigen::Dynamic,Eigen::Dynamic,0>);
70 bp::def(
"ascomplex", ascomplex<long double,Eigen::Dynamic,Eigen::Dynamic,0>);
72 bp::def(
"real", (MatrixXf (*)(
const Eigen::MatrixBase<MatrixXcf> &))&real<MatrixXcf>);
73 bp::def(
"real", (MatrixXd (*)(
const Eigen::MatrixBase<MatrixXcd> &))&real<MatrixXcd>);
74 bp::def(
"real", (MatrixXld (*)(
const Eigen::MatrixBase<MatrixXcld> &))&real<MatrixXcld>);
76 bp::def(
"imag", (MatrixXf (*)(
const Eigen::MatrixBase<MatrixXcf> &))&imag<MatrixXcf>);
77 bp::def(
"imag", (MatrixXd (*)(
const Eigen::MatrixBase<MatrixXcd> &))&imag<MatrixXcd>);
78 bp::def(
"imag", (MatrixXld (*)(
const Eigen::MatrixBase<MatrixXcld> &))&imag<MatrixXcld>);
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > imag(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
Eigen::Matrix< std::complex< Scalar >, Rows, Cols, Options > ascomplex(const Eigen::Matrix< Scalar, Rows, Cols, Options > &mat)
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix)
void EIGENPY_DLLAPI enableEigenPy()
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > real(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
BOOST_PYTHON_MODULE(complex)