Copyright  (c) Sam Stites 2017 

License  BSD3 
Maintainer  sam@stites.io 
Stability  experimental 
Portability  nonportable 
Safe Haskell  None 
Language  Haskell2010 
Torch provides MATLABlike functions for manipulating Tensor objects. Functions fall into several types of categories:
 Constructors like zeros, ones;
 Extractors like diag and triu;
 Elementwise mathematical operations like abs and pow;
 BLAS operations;
 Column or rowwise operations like sum and max;
 Matrixwide operations like trace and norm;
 Convolution and crosscorrelation operations like conv2;
 Basic linear algebra operations like eig;
 Logical operations on Tensors.
Unfortunately the above this comes from the Lua docs. Hasktorch doesn't mimic this exactly and (FIXME) we will have to restructure this module header to reflect these changes.
Synopsis
 fill_ :: Dynamic > HsReal > IO ()
 zero_ :: Dynamic > IO ()
 zeros_ :: Dynamic > IndexStorage > IO ()
 zerosLike_ :: Dynamic > Dynamic > IO ()
 ones_ :: Dynamic > IndexStorage > IO ()
 onesLike_ :: Dynamic > Dynamic > IO ()
 numel :: Dynamic > Integer
 _reshape :: Dynamic > Dynamic > IndexStorage > IO ()
 catArray :: NonEmpty Dynamic > Word > Either String Dynamic
 _catArray :: Dynamic > NonEmpty Dynamic > Word > IO ()
 _tril :: Dynamic > Dynamic > Integer > IO ()
 _triu :: Dynamic > Dynamic > Integer > IO ()
 _cat :: Dynamic > Dynamic > Dynamic > Word > IO ()
 cat :: Dynamic > Dynamic > Word > Either String Dynamic
 catDims :: NonEmpty Dynamic > Word > Either String [Word]
 _nonzero :: IndexDynamic > Dynamic > IO ()
 ttrace :: Dynamic > HsAccReal
 eye_ :: Dynamic > Integer > Integer > IO ()
 _arange :: Dynamic > HsAccReal > HsAccReal > HsAccReal > IO ()
 arange :: HsAccReal > HsAccReal > HsAccReal > Dynamic
 range_ :: Dynamic > HsAccReal > HsAccReal > HsAccReal > IO ()
 range :: Dims (d :: [Nat]) > HsAccReal > HsAccReal > HsAccReal > Dynamic
 constant :: Dims (d :: [Nat]) > HsReal > Dynamic
 _diag :: Dynamic > Dynamic > Int > IO ()
 diag_ :: Dynamic > Int > IO ()
 diag :: Dynamic > Int > Dynamic
 diag1d :: Dynamic > Dynamic
 _tenLike :: (Dynamic > Dynamic > IO ()) > Dims (d :: [Nat]) > IO Dynamic
 onesLike :: Dims (d :: [Nat]) > Dynamic
 zerosLike :: Dims (d :: [Nat]) > Dynamic
Documentation
zeros_ :: Dynamic > IndexStorage > IO () Source #
mutate a tensor, inplace, resizing the tensor to the given IndexStorage size and replacing its value with zeros.
:: Dynamic  tensor to mutate inplace and replace contents with zeros 
> Dynamic  tensor to extract shape information from. 
> IO () 
mutate a tensor, inplace, resizing the tensor to the same shape as the second tensor argument and replacing the first tensor's values with zeros.
ones_ :: Dynamic > IndexStorage > IO () Source #
mutate a tensor, inplace, resizing the tensor to the given IndexStorage size and replacing its value with ones.
:: Dynamic  tensor to mutate inplace and replace contents with ones 
> Dynamic  tensor to extract shape information from. 
> IO () 
mutate a tensor, inplace, resizing the tensor to the same shape as the second tensor argument and replacing the first tensor's values with ones.
_reshape :: Dynamic > Dynamic > IndexStorage > IO () Source #
_reshape y x (Ix.newStorage [m, n, k, l, o])
Mutates the y
dynamic tensor to be reshaped as a m × n × k × l × o
tensor whose elements are
taken rowwise from x
, which must have m * n * k * l * o
elements. The elements are copied into
the new Tensor.
:: Dynamic  result to mutate 
> NonEmpty Dynamic  tensors to concatenate 
> Word  dimension to concatenate along. 
> IO () 
Concatenate all tensors in a given list of dynamic tensors along the given dimension.
NOTE: In C, if the dimension is not specified or if it is 1, it is the maximum last dimension over all input tensors, except if all tensors are empty, then it is 1.
CStyle: In the classic Torch Cstyle, the first argument is treated as the return type and is mutated inplace.
_tril :: Dynamic > Dynamic > Integer > IO () Source #
"Get the lower triangle of a tensor."
Mutates the first tensor to have the triangular part of the second tensor under the Kth diagonal. where k=0 is the main diagonal, k>0 is above the main diagonal, and k<0 is below the main diagonal. All other elements are set to 0.
CStyle: In the classic Torch Cstyle, the first argument is treated as the return type and is mutated inplace.
_triu :: Dynamic > Dynamic > Integer > IO () Source #
"Get the upper triangle of a tensor."
Mutates the first tensor to have the triangular part of the second tensor above the Kth diagonal. where k=0 is the main diagonal, k>0 is above the main diagonal, and k<0 is below the main diagonal. All other elements are set to 0.
CStyle: In the classic Torch Cstyle, the first argument is treated as the return type and is mutated inplace.
Concatinate two dynamic tensors along the specified dimension, treating the first argument as the return tensor, to be mutated inplace.
NOTE: In C, if the dimension is not specified or if it is 1, it is the maximum last dimension over all input tensors, except if all tensors are empty, then it is 1.
CStyle: In the classic Torch Cstyle, the first argument is treated as the return type and is mutated inplace.
_nonzero :: IndexDynamic > Dynamic > IO () Source #
Finds and returns a LongTensor corresponding to the subscript indices of all nonzero elements in tensor.
CStyle: In the classic Torch Cstyle, the first argument is treated as the return type and is mutated inplace.
ttrace :: Dynamic > HsAccReal Source #
Returns the trace (sum of the diagonal elements) of a matrix x. This is equal to the sum of the eigenvalues of x.
:: Dynamic  tensor to mutate inplace 
> Integer 

> Integer 

> IO () 
mutates a tensor to be an n × m
identity matrix with ones on the diagonal and zeros elsewhere.
_arange :: Dynamic > HsAccReal > HsAccReal > HsAccReal > IO () Source #
identical to a direct C call to the arange
, or range
with special consideration for floating precision types.
arange :: HsAccReal > HsAccReal > HsAccReal > Dynamic Source #
identical to a direct C call to the arange
, or range
with special consideration for floating precision types.
mutate a Tensor inplace, filling it with values from min
to max
with step
. Will make the tensor take a
shape of size floor((y  x) / step) + 1
.
range :: Dims (d :: [Nat]) > HsAccReal > HsAccReal > HsAccReal > Dynamic Source #
pure version of range_
constant :: Dims (d :: [Nat]) > HsReal > Dynamic Source #
create a Dynamic
tensor with a given dimension and value
We can get away unsafePerformIO
this as constant is pure and threadsafe
_diag :: Dynamic > Dynamic > Int > IO () Source #
direct call to the CFFI of diag
, mutating the first tensor argument with
the data from the remaining aruments.
diag_ :: Dynamic > Int > IO () Source #
mutates the tensor inplace and replaces it with the given kth diagonal, where k=0 is the main diagonal, k>0 is above the main diagonal, and k<0 is below the main diagonal.
diag :: Dynamic > Int > Dynamic Source #
returns the kth diagonal of the input tensor, where k=0 is the main diagonal, k>0 is above the main diagonal, and k<0 is below the main diagonal.
diag1d :: Dynamic > Dynamic Source #
returns a diagonal matrix with diagonal elements constructed from the input tensor