Matrix multiplication: Difference between revisions

Formatting. Added reference to library "strfmt".
(Formatting. Added reference to library "strfmt".)
Line 3,391:
 
=={{header|Nim}}==
{{libheader|strfmt}}
<lang nim>import strfmt
 
type Matrix[M, N: static[int]] = array[M, array[N, float]]
 
let a = [[1.0, 1.0, 1.0, 1.0],
Line 3,400 ⟶ 3,401:
[4.0, 16.0, 64.0, 256.0]]
 
let b = [[ 4.0 , -3.0 , 4/3.0, -1/4.0 ],
[-13/3.0, 19/4.0, -7/3.0, 11/24.0],
[ 3/2.0, -2.0 , 7/6.0, -1/4.0 ],
[ -1/6.0, 1/4.0, -1/6.0, 1/24.0]]
 
Line 3,412 ⟶ 3,413:
result.add "])"
 
proc `*`[M, P, N](a: Matrix[M, P]; b: Matrix[P, N]): Matrix[M, N] =
for i in result.low .. result.high:
for j in result[0].low .. result[0].high:
Anonymous user