Skip to content

Commit

Permalink
[test] [std] Add matrix SSA violation regression test (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate authored Jul 5, 2020
1 parent b709fb6 commit 213a774
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/python/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
from taichi import approx
import pytest
import math


@ti.all_archs
Expand Down Expand Up @@ -65,6 +66,25 @@ def init():
assert aNormalized[None][2] == approx(3.0 * invSqrt14)


@ti.all_archs
def test_matrix_ssa():
a = ti.Vector(2, ti.f32, ())
b = ti.Matrix(2, 2, ti.f32, ())

@ti.kernel
def func():
a[None] = a[None].normalized()
b[None] = b[None].transpose()

inv_sqrt2 = 1 / math.sqrt(2)

a[None] = [1, 1]
b[None] = [[1, 2], [3, 4]]
func()
assert a[None].value == ti.Vector([inv_sqrt2, inv_sqrt2])
assert b[None].value == ti.Matrix([[1, 3], [2, 4]])


@ti.all_archs
def test_cross():
a = ti.Vector(3, dt=ti.f32)
Expand Down Expand Up @@ -243,8 +263,6 @@ def test_mat_inverse():

@ti.all_archs
def test_matrix_factories():
import math

a = ti.Vector.var(3, dt=ti.i32, shape=3)
b = ti.Matrix.var(2, 2, dt=ti.f32, shape=2)
c = ti.Matrix.var(2, 3, dt=ti.f32, shape=2)
Expand Down

0 comments on commit 213a774

Please sign in to comment.