Skip to content

Commit

Permalink
[Bug] [lang] Fix outer_product output matrix shape (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Jul 11, 2020
1 parent 5d8b8cb commit 846fc15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/taichi/lang/matrix.py
Expand Up @@ -882,7 +882,7 @@ def outer_product(self, other):
impl.static_assert(other.m == 1,
"rhs for outer_product is not a vector"))
ret = Matrix([[self[i] * other[j] for j in range(other.n)]
for i in range(other.n)])
for i in range(self.n)])
return ret


Expand Down
8 changes: 4 additions & 4 deletions tests/python/test_linalg.py
Expand Up @@ -28,8 +28,8 @@ def init():
@ti.all_archs
def test_basic_utils():
a = ti.Vector(3, dt=ti.f32)
b = ti.Vector(3, dt=ti.f32)
abT = ti.Matrix(3, 3, dt=ti.f32)
b = ti.Vector(2, dt=ti.f32)
abT = ti.Matrix(3, 2, dt=ti.f32)
aNormalized = ti.Vector(3, dt=ti.f32)

normA = ti.var(ti.f32)
Expand All @@ -41,7 +41,7 @@ def test_basic_utils():
@ti.kernel
def init():
a[None] = ti.Vector([1.0, 2.0, 3.0])
b[None] = ti.Vector([4.0, 5.0, 6.0])
b[None] = ti.Vector([4.0, 5.0])
abT[None] = a[None].outer_product(b[None])

normA[None] = a[None].norm()
Expand All @@ -53,7 +53,7 @@ def init():
init()

for i in range(3):
for j in range(3):
for j in range(2):
assert abT[None][i, j] == a[None][i] * b[None][j]

sqrt14 = np.sqrt(14.0)
Expand Down

0 comments on commit 846fc15

Please sign in to comment.