This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,13 @@
link matrix
procedure main ()
m1 := [[1,2,3], [4,5,6]]
m2 := [[1,2],[3,4],[5,6]]
m3 := mult_matrix (m1, m2)
write ("Multiply:")
write_matrix ("", m1) # first argument is filename, or "" for stdout
write ("by:")
write_matrix ("", m2)
write ("Result: ")
write_matrix ("", m3)
end

View file

@ -0,0 +1,15 @@
procedure multiply_matrix (m1, m2)
result := [] # to hold the final matrix
every row1 := !m1 do { # loop through each row in the first matrix
row := []
every colIndex := 1 to *m1 do { # and each column index of the result
value := 0
every rowIndex := 1 to *m2 do {
value +:= row1[rowIndex] * m2[rowIndex][colIndex]
}
put (row, value)
}
put (result, row) # add each row as it is complete
}
return result
end