test_complex.py
Go to the documentation of this file.
1 import numpy as np
2 from complex import ascomplex, imag, real
3 
4 rows = 10
5 cols = 20
6 rng = np.random.default_rng()
7 
8 
9 def test(dtype):
10  Z = np.zeros((rows, cols), dtype=dtype)
11  Z.real = rng.random((rows, cols))
12  Z.imag = rng.random((rows, cols))
13 
14  Z_real = real(Z)
15  assert (Z_real == Z.real).all()
16  Z_imag = imag(Z)
17  assert (Z_imag == Z.imag).all()
18 
19  Y = np.ones((rows, cols))
20  Y_complex = ascomplex(Y)
21  assert (Y_complex.real == Y).all()
22  assert (Y_complex.imag == np.zeros((rows, cols))).all()
23 
24 
25 # Float
26 test(np.csingle)
27 # Double
28 test(np.cdouble)
29 # Long Double
30 test(np.clongdouble)
test_complex.test
def test(dtype)
Definition: test_complex.py:9
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 Wed Jun 5 2024 02:14:54