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>);
73 (MatrixXf(*)(
const Eigen::MatrixBase<MatrixXcf> &))&real<MatrixXcf>);
75 (MatrixXd(*)(
const Eigen::MatrixBase<MatrixXcd> &))&real<MatrixXcd>);
78 (MatrixXld(*)(
const Eigen::MatrixBase<MatrixXcld> &))&real<MatrixXcld>);
81 (MatrixXf(*)(
const Eigen::MatrixBase<MatrixXcf> &))&imag<MatrixXcf>);
83 (MatrixXd(*)(
const Eigen::MatrixBase<MatrixXcd> &))&imag<MatrixXcd>);
86 (MatrixXld(*)(
const Eigen::MatrixBase<MatrixXcld> &))&imag<MatrixXcld>);