Interface Tensor
- All Known Subinterfaces:
Matrix
- All Known Implementing Classes:
AbstractTensor, AtA, BandMatrix, DenseMatrix, JTensor, Scalar, SparseMatrix, SymmMatrix, Vector
public interface Tensor
A Tensor is a multidimensional array containing elements of a single data type.
-
Method Summary
Modifier and TypeMethodDescriptionintdim()Returns the number of dimensions of tensor.get(int... index) Returns a portion of tensor given the index.default longlength()Returns the number of tensor elements.reshape(int... shape) Returns a tensor with the same data and number of elements but with the specified shape.Returns the element data type.Updates a sub-tensor in place.int[]shape()Returns the shape of tensor.intsize(int dim) Returns the size of given dimension.
-
Method Details
-
scalarType
-
dim
int dim()Returns the number of dimensions of tensor.- Returns:
- the number of dimensions of tensor
-
size
int size(int dim) Returns the size of given dimension.- Parameters:
dim- dimension index.- Returns:
- the size of given dimension.
-
length
default long length()Returns the number of tensor elements. For tensors with packed storage (e.g., BandMatrix, SparseMatrix, SymmMatrix), it returns the number of non-zero elements.- Returns:
- the number of tensor elements.
-
shape
int[] shape()Returns the shape of tensor. That is a list of the extent of each dimension.- Returns:
- the shape of tensor.
-
reshape
Returns a tensor with the same data and number of elements but with the specified shape. This method returns a view if shape is compatible with the current shape.- Parameters:
shape- the new shape of tensor.- Returns:
- the tensor with the specified shape.
-
set
-
get
Returns a portion of tensor given the index.- Parameters:
index- the index along the dimensions.- Returns:
- the sub-tensor.
-