test_complex.py
Go to the documentation of this file.
1 from __future__ import print_function
2 
3 import numpy as np
4 from complex import *
5 
6 switchToNumpyArray()
7 
8 rows = 10
9 cols = 20
10 
11 def test(dtype):
12  Z = np.zeros((rows,cols),dtype=dtype)
13  Z.real = np.random.rand(rows,cols)
14  Z.imag = np.random.rand(rows,cols)
15 
16  Z_real = real(Z)
17  assert (Z_real == Z.real).all()
18  Z_imag = imag(Z)
19  assert (Z_imag == Z.imag).all()
20 
21  Y = np.ones((rows,cols))
22  Y_complex = ascomplex(Y)
23  assert (Y_complex.real == Y).all()
24  assert (Y_complex.imag == np.zeros((rows,cols))).all()
25 
26 # Float
27 test(np.csingle)
28 # Double
29 test(np.cdouble)
30 # Long Double
31 test(np.clongdouble)
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > imag(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
Definition: complex.cpp:49
def test(dtype)
Definition: test_complex.py:11
Eigen::Matrix< std::complex< Scalar >, Rows, Cols, Options > ascomplex(const Eigen::Matrix< Scalar, Rows, Cols, Options > &mat)
Definition: complex.cpp:56
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > real(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
Definition: complex.cpp:42


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Apr 17 2021 02:37:59