This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/futhark/example.fut
Troels Henriksen 323a7056a7
Futhark: add missing tokens (#2118)
Adds recognition of 'def'/'type^'/'type~' keywords and adds some
missing characters to the regexes for identifiers and punctuation.
2022-04-24 14:57:53 +02:00

17 lines
507 B
Text

local let dotprod [n] 't
(mul: t -> t -> t) (add: t -> t -> t) (zero: t)
(a: [n]t) (b: [n]t): t =
map2 mul a b |> reduce add zero
module matmul (F: numeric) = {
type t = F.t
open F
let matmul [n1][n2][m] (xss: [n1][m]t) (yss: [m][n2]t): *[n1][n2]t =
map (\xs -> map (\ys -> dotprod (*) (+) (i32 0) xs ys) <| transpose yss) xss
}
module matmul32 = matmul f32
let main [n][m] (xss: [n][m]f32) (yss: [m][n]f32): ?[a][b].[a][b]f32 =
matmul32.matmul xss yss