Stability | experimental |
---|---|
Maintainer | Patrick Perry <[email protected]> |
Data.Tensor.Class.ITensor
Description
Overloaded interface for immutable tensors.
- class Shaped x i => ITensor x i e where
- size :: x n e -> Int
- (//) :: x n e -> [(i, e)] -> x n e
- unsafeAt :: x n e -> i -> e
- unsafeReplace :: x n e -> [(i, e)] -> x n e
- indices :: x n e -> [i]
- elems :: x n e -> [e]
- assocs :: x n e -> [(i, e)]
- tmap :: (e -> e) -> x n e -> x n e
- (*>) :: Num e => e -> x n e -> x n e
- shift :: Num e => e -> x n e -> x n e
- (!) :: ITensor x i e => x n e -> i -> e
Documentation
class Shaped x i => ITensor x i e whereSource
A class for immutable tensors.
Methods
Get the numer of elements stored in the tensor.
(//) :: x n e -> [(i, e)] -> x n eSource
Get a new tensor by replacing the elements at the given indices.
unsafeAt :: x n e -> i -> eSource
Get the value at the given index, without doing any bounds-checking.
unsafeReplace :: x n e -> [(i, e)] -> x n eSource
Same as '()' but doesn't do any bounds-checking.
Get the indices of the elements stored in the tensor.
Get the elements stored in the tensor.
assocs :: x n e -> [(i, e)]Source
Get the list of (
index,
element)
pairs stored in the tensor.
tmap :: (e -> e) -> x n e -> x n eSource
Apply a function elementwise to a tensor.
(*>) :: Num e => e -> x n e -> x n eSource
Scale every element by the given value.
shift :: Num e => e -> x n e -> x n eSource
Add a constant to every element.