Add vector & matrix modules

This commit is contained in:
Kiana Sheibani 2022-05-21 16:38:21 -04:00
parent 1e7660b1f2
commit 861f1e29f2
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
9 changed files with 236 additions and 34 deletions

View file

@ -0,0 +1,23 @@
module Data.NumIdr.Scalar
import Data.Vect
import Data.NumIdr.PrimArray
import public Data.NumIdr.Array
%default total
||| Scalars are `Array []`, the unique 0-rank array type. They hold a single value.
||| Scalars are not particularly useful as container types, but they are
||| included here anyways.
public export
Scalar : Type -> Type
Scalar = Array []
export
scalar : a -> Scalar a
scalar x = fromVect _ [x]
export
unwrap : Scalar a -> a
unwrap = index 0 . getPrim