-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
In Matrix.lua, the function mat.innersum() references result.rows and result.cols. However, in this context, result is a number, not a matrix:
-- Inner Sum
function mat.innersum(m1)
local result = 0
for i=1,result.rows do
for j=1,result.cols do
result = m1.matrix[i][j] + result
end
end
return result
end
Is this intending to sum the values in the matrix m1 instead of result (which in this function isn't a matrix)?
If that's the case, perhaps this was intended?
function mat.innersum(m1)
local result = 0
-- iterate through all the rows in m1
for _, m1_row in ipairs( m1.matrix ) do
-- iterate through all the columns in the row
for _, col in ipairs( m1_row ) do
-- add the column value to the sum
result = result + col
end
end
return result
end
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels