# Overwrite this matrix with the identity matrix
fun set_identity
do
- for i in 4.times do
- for j in 4.times do
+ for i in [0..4[ do
+ for j in [0..4[ do
matrix_set(i, j, if i == j then 1.0 else 0.0)
end
end
# Copy content of this matrix to a `NativeGLfloatArray`
fun fill_native(native: NativeGLfloatArray)
do
- for i in width.times do
- for j in height.times do
+ for i in [0..width[ do
+ for j in [0..height[ do
native.matrix_set(i, j, self[i, j])
end
end
for j in height.times do assert items[j].length == width
- for j in height.times do
- for i in width.times do
+ for j in [0..height[ do
+ for i in [0..width[ do
self[j, i] = items[j][i]
end
end
assert size >= 0
var matrix = new Matrix(size, size)
- for i in size.times do
- for j in size.times do
+ for i in [0..size[ do
+ for j in [0..size[ do
matrix[j, i] = if i == j then 1.0 else 0.0
end
end
assert self.width == other.height
var out = new Matrix(other.width, self.height)
- for j in self.height.times do
- for i in other.width.times do
+ for j in [0..self.height[ do
+ for i in [0..other.width[ do
var sum = items[0].zero
- for k in self.width.times do sum += self[j, k] * other[k, i]
+ for k in [0..self.width[ do sum += self[j, k] * other[k, i]
out[j, i] = sum
end
end