Stability | experimental |
---|---|
Maintainer | Patrick Perry <patperry@stanford.edu> |
Overloaded interface for mutable tensors. This modules includes tensors
which can be read in a monad, ReadTensor
, as well as tensors which
can be modified in a monad, WriteTensor
.
- class (Shaped x i, Monad m) => ReadTensor x i e m | x -> i where
- getSize :: x n e -> m Int
- unsafeReadElem :: x n e -> i -> m e
- getIndices :: x n e -> m [i]
- getIndices' :: x n e -> m [i]
- getElems :: x n e -> m [e]
- getElems' :: x n e -> m [e]
- getAssocs :: x n e -> m [(i, e)]
- getAssocs' :: x n e -> m [(i, e)]
- readElem :: ReadTensor x i e m => x n e -> i -> m e
- class ReadTensor x i e m => WriteTensor x i e m | x -> m where
- getMaxSize :: x n e -> m Int
- setZero :: Num e => x n e -> m ()
- setConstant :: e -> x n e -> m ()
- canModifyElem :: x n e -> i -> m Bool
- unsafeWriteElem :: x n e -> i -> e -> m ()
- unsafeModifyElem :: x n e -> i -> (e -> e) -> m ()
- modifyWith :: (e -> e) -> x n e -> m ()
- unsafeSwapElems :: x n e -> i -> i -> m ()
- doConj :: Elem e => x n e -> m ()
- scaleBy :: Num e => e -> x n e -> m ()
- shiftBy :: Num e => e -> x n e -> m ()
- writeElem :: WriteTensor x i e m => x n e -> i -> e -> m ()
- modifyElem :: WriteTensor x i e m => x n e -> i -> (e -> e) -> m ()
- swapElems :: WriteTensor x i e m => x n e -> i -> i -> m ()
Read-only tensor type class
class (Shaped x i, Monad m) => ReadTensor x i e m | x -> i whereSource
Class for mutable read-only tensors.
getSize :: x n e -> m IntSource
Get the number of elements stored in the tensor.
unsafeReadElem :: x n e -> i -> m eSource
Get the value at the specified index, without doing any range-checking.
getIndices :: x n e -> m [i]Source
Returns a lazy list of the indices in the tensor. Because of the laziness, this function should be used with care. See also getIndices'.
getIndices' :: x n e -> m [i]Source
Returns a list of the indices in the tensor. See also
getIndices
.
getElems :: x n e -> m [e]Source
Returns a lazy list of the elements in the tensor. Because of the laziness, this function should be used with care. See also getElems'.
getElems' :: x n e -> m [e]Source
Returns a list of the elements in the tensor. See also
getElems
.
getAssocs :: x n e -> m [(i, e)]Source
Returns a lazy list of the elements-index pairs in the tensor. Because of the laziness, this function should be used with care. See also getAssocs'.
getAssocs' :: x n e -> m [(i, e)]Source
Returns a list of the index-elements pairs in the tensor. See also
getAssocs
.
Elem e => ReadTensor IOVector Int e IO | |
(BLAS1 e, Monad m) => ReadTensor Vector Int e m | |
Elem e => ReadTensor IOMatrix (Int, Int) e IO | |
(BLAS3 e, Monad m) => ReadTensor Matrix (Int, Int) e m | |
BLAS3 e => ReadTensor IOBanded (Int, Int) e IO | |
(BLAS3 e, Monad m) => ReadTensor Banded (Int, Int) e m | |
Elem e => ReadTensor (STVector s) Int e (ST s) | |
Elem e => ReadTensor (STMatrix s) (Int, Int) e (ST s) | |
BLAS3 e => ReadTensor (STBanded s) (Int, Int) e (ST s) |
readElem :: ReadTensor x i e m => x n e -> i -> m eSource
Gets the value at the specified index after checking that the argument is in bounds.
Modifiable tensor type class
class ReadTensor x i e m => WriteTensor x i e m | x -> m whereSource
Class for modifiable mutable tensors.
getMaxSize :: x n e -> m IntSource
Get the maximum number of elements that can be stored in the tensor.
setZero :: Num e => x n e -> m ()Source
Sets all stored elements to zero.
setConstant :: e -> x n e -> m ()Source
Sets all stored elements to the given value.
canModifyElem :: x n e -> i -> m BoolSource
True if the value at a given index can be changed
unsafeWriteElem :: x n e -> i -> e -> m ()Source
Set the value of the element at the given index, without doing any range checking.
unsafeModifyElem :: x n e -> i -> (e -> e) -> m ()Source
Modify the value of the element at the given index, without doing any range checking.
modifyWith :: (e -> e) -> x n e -> m ()Source
Replace each element by a function applied to it
unsafeSwapElems :: x n e -> i -> i -> m ()Source
Same as swapElem
but arguments are not range-checked.
doConj :: Elem e => x n e -> m ()Source
Replace every element with its complex conjugate.
scaleBy :: Num e => e -> x n e -> m ()Source
Scale every element in the vector by the given value.
shiftBy :: Num e => e -> x n e -> m ()Source
Add a value to every element in a vector.
writeElem :: WriteTensor x i e m => x n e -> i -> e -> m ()Source
Set the value of the element at the given index.
modifyElem :: WriteTensor x i e m => x n e -> i -> (e -> e) -> m ()Source
Update the value of the element at the given index.
swapElems :: WriteTensor x i e m => x n e -> i -> i -> m ()Source
Swap the values stored at two positions in the tensor.