let map(l)(f)(x) = z where
rec forall i in 0 .. (l - 1), xi in x, zi out z
do zi = f xi done
let sum(l)(x, y) = z where
rec
forall i in 0 .. (l - 1), xi in x, yi in y, zi out z
do
zi = xi +. yi
done
let msum(l1)(l2)(m1, m2) = m3 where
rec
forall i in 0 .. (l1 - 1), m1i in m1, m2i in m2, m3i out m3 do
forall j in 0 .. (l2 - 1), m1ij in m1i, m2ij in m2i, m3ij out m3i do
m3ij = m1ij +. m2ij
done
done
let msum2(l1)(l2)(m1, m2) = m3 where
rec
forall i in 0 .. (l1 - 1), m1i in m1, m2i in m2, m3i out m3 do
m3i = sum(l2)(m1i, m2i)
done
let const(l)(x0) = o where
rec forall i in 0 .. (l - 1), oi out o do oi = x0 done
let vvproduct(l)(x, y) = acc where
rec
forall i in 0 .. (l - 1), xi in x, yi in y
do
acc = (xi *. yi) +. last acc
initialize
last acc = 0.0
done
let mvproduct(l)(c)(m, v) = o where
rec
forall i in 0 .. (l - 1), mi in m, oi out o
do
oi = vvproduct(c)(mi, v)
done
let mvproduct2(l)(c)(m, v) = o where
rec
forall i in 0 .. (l - 1), mi in m, oi out o do
forall j in 0 ..(c - 1), mij in mi, vj in v do
oi = (mij *. vj) +. last oi
initialize
last oi = 0.0
done
done
let mmproduct(l)(c)(m1, m2) = m3 where
rec
forall i in 0 .. (l - 1), m2i in m2, m3i out m3 do
m3i = mvproduct(l)(c)(m1, m2i)
done