Copyright | (c) Artur M. Brodzki 2018 |
---|---|
License | BSD3 |
Maintainer | artur@brodzki.org |
Stability | experimental |
Portability | Windows/POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- This module contains generic implementation of tensor defined as nested arrays
Synopsis
- data Tensor a where
- Scalar :: {..} -> Tensor a
- SimpleFinite :: {..} -> Tensor a
- FiniteTensor :: {..} -> Tensor a
- (!) :: Unbox a => Tensor a -> Int -> Tensor a
- isScalar :: Unbox a => Tensor a -> Bool
- isSimple :: Unbox a => Tensor a -> Bool
- isFiniteTensor :: Unbox a => Tensor a -> Bool
- dot :: (Num a, Unbox a, NFData a) => Tensor a -> Tensor a -> Tensor a
- _elemByElem :: (Num a, Unbox a, NFData a) => Tensor a -> Tensor a -> (a -> a -> a) -> (Tensor a -> Tensor a -> Tensor a) -> Tensor a
- contractionErr :: TIndex -> TIndex -> Tensor a
- tensorIndex :: Unbox a => Tensor a -> TIndex
- _standardize :: (Num a, Unbox a, NFData a) => Tensor a -> Tensor a
Documentation
Tensor defined recursively as scalar or list of other tensors
c
is type of a container, i
is type of index size and a
is type of tensor elements
Scalar | Scalar |
SimpleFinite | Simple, one-dimensional finite tensor |
| |
FiniteTensor | Finite array of other tensors |
|
Instances
Recursive indexing on list tensor
t ! i = t[i]
:: (Num a, Unbox a, NFData a) | |
=> Tensor a | First argument of operator |
-> Tensor a | Second argument of operator |
-> (a -> a -> a) | Operator on tensor elements if indices are different |
-> (Tensor a -> Tensor a -> Tensor a) | Tensor operator called if indices are the same |
-> Tensor a | Result tensor |
Apply a tensor operator elem by elem