-
Notifications
You must be signed in to change notification settings - Fork 4
Tensor type safety discussion
ghorn edited this page Jan 2, 2012
·
8 revisions
The fundamental specification is that this library is easy to use. No GHC extensions should be necessary for the user to use anything from the DVDA API.
Adding or multiplying a scalar with {scalar/vector/matrix} broadcasts (*) to properly scale the quantity
exprs :: [Expr a]
exprs = [x + y, 2*y]
where
x = sym "x"
y = vec 3 "y"
Adding vector to matrix (or doing other incompatible non-scalar operations) results in failure
exprs :: Expr a
exprs = x + y -- fail
where
x = vec 3 "x"
y = mat (4,2) "y"
- Use normal math characters (+) (-) (*) (/) as elementwise operations
- Do tensor dimensionality checking at compile time
Option 1: Hijack (+), use -XMultiParamTypeClasses/-XFunctionalDependencies