Exemplo n.º 1
0
def test01_bcast():
    a = Q()
    a.x = 0
    a.y = 0
    a.z = 0
    a.w = 5
    b = Q(Float(5))
    assert a == b
Exemplo n.º 2
0
def test03_mul():
    a = Q(1, 3, 5, 7)
    b = Q(11, 13, 19, 21)
    c = a * b
    d = Q(90, 190, 218, 2)
    assert c == d
    assert a * 2 == Q(2, 6, 10, 14)
    assert 2 * a == Q(2, 6, 10, 14)
Exemplo n.º 3
0
def test07_pow():
    assert ek.allclose(
        Q(1, 2, 3, 4)**Q(0.11, 0.13, 0.19, 0.21),
        Q(0.253509, 0.372162, 0.481497, 0.982482))
Exemplo n.º 4
0
def test06_exp():
    assert ek.allclose(ek.exp(Q(1, 2, 3, 4)),
                       Q(-8.24003, -16.4801, -24.7201, -45.0598))
Exemplo n.º 5
0
def test06_log():
    assert ek.allclose(ek.log(Q(1, 2, 3, 4)),
                       Q(0.200991, 0.401982, 0.602974, 1.7006))
Exemplo n.º 6
0
def test05_sqrt():
    assert ek.allclose(ek.sqrt(Q(1, 2, 3, 4)),
                       Q(0.229691, 0.459382, 0.689074, 2.17684))
Exemplo n.º 7
0
def test04_abs():
    assert ek.allclose(abs(Q(1, 3, 5, 7)), math.sqrt(84))
Exemplo n.º 8
0
def test03_div():
    a = Q(1, 3, 5, 7)
    b = Q(11, 13, 19, 21)
    c = a / b
    d = Q(-4 / 91, -16 / 273, -2 / 273, 73 / 273)
    assert ek.allclose(c, d)
Exemplo n.º 9
0
def test02_sub():
    a = Q(1, 3, 5, 7)
    b = Q(11, 12, 13, 14)
    c = Q(1 - 11, 3 - 12, 5 - 13, 7 - 14)
    assert a - b == c