diff --git a/src/mmath/smatrix.nim b/src/mmath/smatrix.nim index 1e90281..69fa921 100644 --- a/src/mmath/smatrix.nim +++ b/src/mmath/smatrix.nim @@ -8,7 +8,7 @@ import random type SMatrix*[ROWS, COLUMNS: static[int], T] = object data : array[0..(ROWS*COLUMNS - 1), T] - SquareSMatrix[SIZE: static[int], T] = SMatrix[SIZE, SIZE, T] + SquareSMatrix*[SIZE: static[int], T] = SMatrix[SIZE, SIZE, T] proc size*[ROWS, COLUMNS : static[int], T](m : SMatrix) : (int, int) = (m.rows, m.columns) @@ -63,7 +63,12 @@ proc `*`*[ROWS1, COLUMNS2, COMMON : static[int], T]( for k in 0...m1.columns: result[i, j] = result[i, j] + m1[i, k] * m2[k, j] -proc `*`*[ROWS, COLUMNS : static[int], T](m1 : SMatrix[ROWS, COLUMNS, T], v2 : SVector[ROWS, T]) : SVector[ROWS, T] = +proc `*`*[SIZE : static[int], T](v : SVector[SIZE, T], m : SquareSMatrix[SIZE, T]) : SVector[SIZE, T] = + for i in 0...m.rows: + for j in 0...m.columns: + result[j] += m[i, j] * v[i] + +proc `*`*[SIZE : static[int], T](m1 : SquareSMatrix[SIZE, T], v2 : SVector[SIZE, T]) : SVector[SIZE, T] = for i in 0...m1.rows: for j in 0...m1.columns: result[i] += m1[i, j] * v2[j]