-
Notifications
You must be signed in to change notification settings - Fork 72
Numeric & tensor manipulation functions
The following numeric and tensor manipulation functions are available.
Sum all elements of a tensor. Works for any order tensors
Tensor<double,K,M,N> A;
double value = sum(A);
Multiply all elements of a tensor. Works for any order tensors
Tensor<double,K,M,N> A;
double value = product(A);
Compute the minimum element of a tensor. Works for any order tensors
Tensor<double,K,M,N> A;
double value = min(A);
Compute the maximum element of a tensor. Works for any order tensors
Tensor<double,K,M,N> A;
double value = max(A);
Reshape an existing tensor in to a tensor of different shape. Note that this reshapes in-place so changing the original tensor will change the reshaped tensor and vice versa
Tensor<double,3,4> A;
auto b = reshape<2,2,3>(A);
Flatten an existing multi-dimensional tensor in to a 1D tensor. Note that this flattens in-place so changing the original tensor will change the flattened tensor and vice versa
Tensor<double,2,3,4> A;
auto b = flatten(A); // will return TensorMap<double,24>
Squeeze a tensor - remove dimensions of 1 from a tensor. Note that this squeezes in-place so changing the original tensor will change the squeezed tensor and vice versa
Tensor<double,2,1,3,4,1> A;
auto b = sqeeze(A); // will return TensorMap<double,2,3,4>