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 real, imag, ascomplex
5 
6 rows = 10
7 cols = 20
8 
9 
10 def test(dtype):
11  Z = np.zeros((rows, cols), dtype=dtype)
12  Z.real = np.random.rand(rows, cols)
13  Z.imag = np.random.rand(rows, cols)
14 
15  Z_real = real(Z)
16  assert (Z_real == Z.real).all()
17  Z_imag = imag(Z)
18  assert (Z_imag == Z.imag).all()
19 
20  Y = np.ones((rows, cols))
21  Y_complex = ascomplex(Y)
22  assert (Y_complex.real == Y).all()
23  assert (Y_complex.imag == np.zeros((rows, cols))).all()
24 
25 
26 # Float
27 test(np.csingle)
28 # Double
29 test(np.cdouble)
30 # Long Double
31 test(np.clongdouble)
test_complex.test
def test(dtype)
Definition: test_complex.py:10
real
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > real(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
Definition: complex.cpp:43
imag
Eigen::Matrix< typename ComplexMatrix::RealScalar, ComplexMatrix::RowsAtCompileTime, ComplexMatrix::ColsAtCompileTime, ComplexMatrix::Options > imag(const Eigen::MatrixBase< ComplexMatrix > &complex_mat)
Definition: complex.cpp:51
ascomplex
Eigen::Matrix< std::complex< Scalar >, Rows, Cols, Options > ascomplex(const Eigen::Matrix< Scalar, Rows, Cols, Options > &mat)
Definition: complex.cpp:56


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Tue Jan 23 2024 03:15:01