Fix indexMaybe and add more utility functions

This commit is contained in:
Kiana Sheibani 2022-06-15 22:37:34 -04:00
parent de66efe75b
commit b0d48eaf00
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
3 changed files with 46 additions and 12 deletions

View file

@ -105,7 +105,5 @@ hconcat = concat 1
export
kronecker : Num a => Vector m a -> Vector n a -> Matrix m n a
kronecker a b = rewrite dimEq a in rewrite dimEq b in
fromFunction [dim a, dim b]
(\[i,j] => Vector.index (rewrite dimEq a in i) a *
Vector.index (rewrite dimEq b in j) b)
kronecker a b with (viewShape a, viewShape b)
_ | (Shape [m], Shape [n]) = fromFunction [m,n] (\[i,j] => index i a * index j b)