Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/code/.atom-build.yml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not like to add user-specific .gitignore files to the repository.

build/micropython
build/ulab
.idea
17 changes: 17 additions & 0 deletions tests/1d/numpy/complex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from ulab import numpy as np

print ( -0.3826834+0.9238795j + 0.5j )
Copy link
Owner

@v923z v923z Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test micropython's complex support, because the operands are scalars.

print ( -0.3826834+0.9238795j + 0.5 )
print ( -0.3826834+0.9238795j - 0.5 )
print ( -0.3826834+0.9238795j - 0.5j )
print ( -0.3826834+0.9238795j * 0.5 )
print ( -0.3826834+0.9238795j / 0.5 )

a = np.array([3.14j], dtype=np.complex)
print(np.exp(a))

for n in [0,1j,2,0.3j,4,5j]:
print(n**2)
Copy link
Owner

@v923z v923z Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, since n is a scalar, this is a test for micropython, and not ulab. The power operator is not implemented for complex arrays. See #456 (comment) .


x = (-1+1j)
print( np.sqrt(x) )
14 changes: 14 additions & 0 deletions tests/1d/numpy/complex.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(-0.3826834+1.4238795j)
(0.1173166+0.9238795j)
(-0.8826834+0.9238795j)
(-0.3826834+0.4238795j)
(-0.3826834+0.46193975j)
(-0.3826834+1.847759j)
array([-0.9999987317275394+0.001592652916486828j], dtype=complex)
0
(-1+1.224646799147353e-16j)
4
(-0.08999999999999998+1.102182119232618e-17j)
16
(-25+3.061616997868382e-15j)
(0.45508986056222733+1.09868411346781j)