import pyOcean_cpu as ocean

# NaN + 1j
x = ocean.chalf(1j)
x.real = ocean.nan

# 3 + NaN*j
y = ocean.chalf(1)
y.imag = ocean.nan

print([x, y])

print(ocean.minimumAbs(ocean.half([ocean.nan, 2])))
print(ocean.minimumAbs(ocean.half([1, ocean.nan, 2])))
print(ocean.minimumAbs(ocean.half([-2, ocean.nan, 1])))

print("========= Complex with NaN =========")
print(ocean.minimumAbs(ocean.chalf([x, 3 + 4j])))
print(ocean.minimumAbs(ocean.chalf([y, 0 + 2j])))
print(ocean.minimumAbs(ocean.chalf([x, y])))

print("========= Complex =========")
print(ocean.minimumAbs(ocean.chalf([3 + 4j, 1 + 0j])))
print(ocean.minimumAbs(ocean.chalf([1 + 0j, 3 + 4j])))
Esempio n. 2
0
import pyOcean_cpu as ocean

a = ocean.bool(0)
print(a.asPython())

a = ocean.int16(1)
print(a.asPython())

a = ocean.float(2)
print(a.asPython())

a = ocean.chalf(3 + 4j)
print(a.asPython())
Esempio n. 3
0
import pyOcean_cpu as ocean

# Type casting applied to ad-hoc values
print(ocean.int8(1))
print(ocean.int16([1, 2]))
print(ocean.chalf([[1, 2], [3, 4]]))
print(ocean.bool([]))
import pyOcean_cpu as ocean

# NaN + 1j
x = ocean.chalf(1j)
x.real = ocean.nan

# 3 + NaN*j
y = ocean.chalf(1)
y.imag = ocean.nan

print([x,y])

print(ocean.minimum(ocean.half([ocean.nan, 2])))
print(ocean.minimum(ocean.half([1,ocean.nan,2])))
print(ocean.minimum(ocean.half([2,ocean.nan,1])))

print("========= Complex with NaN =========")
print(ocean.minimum(ocean.chalf([x, 2+1j])))
print(ocean.minimum(ocean.chalf([y, 0+2j])))
print(ocean.minimum(ocean.chalf([y, 1+3j])))
print(ocean.minimum(ocean.chalf([y, 2+4j])))
print(ocean.minimum(ocean.chalf([x, y])))
print(ocean.minimum(ocean.chalf([y, x])))


print("========= Complex =========")
print(ocean.minimum(ocean.chalf([2+1j, 1+0j])))
print(ocean.minimum(ocean.chalf([2+1j, 1+1j])))
print(ocean.minimum(ocean.chalf([2+1j, 1+2j])))
print(ocean.minimum(ocean.chalf([1+1j, 1+2j])))
print(ocean.minimum(ocean.chalf([1+2j, 1+2j])))
Esempio n. 5
0
import pyOcean_cpu as ocean

a = ocean.chalf(1 + 2j)
print(bool(a))
a = ocean.chalf(0 + 1j)
print(bool(a))
a = ocean.chalf(0 + 0j)
print(bool(a))

a = ocean.chalf(1 + 2j)
print(int(a))
print(long(a))
print(float(a))
print(complex(a))
    try:
        eval(command)
    except:
        exceptionMsg()


a = ocean.double(2)
print(a)
print(-a)

a = ocean.half(2)
print(a)
print(-a)

a = ocean.cdouble(1 + 2j)
print(-a)

a = ocean.chalf(1 + 2j)
print(-a)

a = ocean.bool(1)
print(a)
print(-a)

a = ocean.uint8(1)
print(-a)

ocean.setScalarCastMode(0)
a = ocean.uint8(1)
failTest("-a")