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
- = Scalar {
- scalarVal :: a
- | SimpleFinite { }
- | FiniteTensor {
- tensorFiniteIndex :: Index
- tensorsFinite :: Vector (Tensor a)
- | InfiniteTensor {
- tensorInfiniteIndex :: Index
- tensorsInfinite :: [Tensor a]
- | Err {
- errMessage :: String
- = Scalar {
- (!) :: Tensor a -> Int -> Tensor a
- mergeScalars :: Tensor a -> Tensor a
- isScalar :: Tensor a -> Bool
- isSimple :: Tensor a -> Bool
- isFiniteTensor :: Tensor a -> Bool
- isInfiniteTensor :: Tensor a -> Bool
- dot :: Num a => Tensor a -> Tensor a -> Tensor a
- _elemByElem :: Num a => Tensor a -> Tensor a -> (a -> a -> a) -> (Tensor a -> Tensor a -> Tensor a) -> Tensor a
- contractionErr :: TIndex -> TIndex -> Tensor a
- tensorIndex :: Tensor a -> TIndex
- _standardize :: Num 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 |
| |
InfiniteTensor | Infinite list of other tensors |
| |
Err | Operations on tensors may throw an error |
|
Instances
Recursive indexing on list tensor
t ! i = t[i]
mergeScalars :: Tensor a -> Tensor a Source #
Merge FiniteTensor of Scalars to SimpleFinite tensor for performance improvement
isFiniteTensor :: Tensor a -> Bool Source #
Return True if tensor is a complex tensor
isInfiniteTensor :: Tensor a -> Bool Source #
Return True if tensor is a infinite tensor
:: Num 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 and merge scalars to simple tensor at the and
tensorIndex :: Tensor a -> TIndex Source #
Return generic tensor index