I have this Matrix type defined as follows:
type
Matrix*[W, H] = array[W, array[H, float]]
Run
And for my raytracer I have to make a function that removes the last column and
row. But I can't get this right because my submatrix function always returns a
matrix of the same dimensions, and not it's dimensions minus 1.
This was the beginning version of my function:
func submatrix*(m: Matrix): Matrix =
for row in 0 ..< high(m):
for col in 0 ..< high(m[0]):
result[row][col] = m[row][col]
Run
I also tried some other stuff like initializing the result matrix with the
correct dimensions but I got an error saying it can't evaluate that at compile
time.
So anybody got some tips on how to make a Nim-worthy submatrix function?