deepnetts.util

## Class Tensors

• ```public class Tensors
extends Object```
Static utility methods for tensors.
Author:
Zoran Sevarac
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static float[]` ```absMax(float[] arr, float[] max)```
Returns array with max values for each position in the given input vectors.
`static Tensor` ```absMax(Tensor t, Tensor max)```
Returns tensors with max value for each component of input tensors.
`static float[]` ```absMin(float[] arr, float[] min)```
`static Tensor` ```absMin(Tensor t, Tensor min)```
`static void` ```add(float[] array1, float[] array2)```
Adds given vector and store result in first.
`static void` ```copy(float[] src, float[] dest)```
`static void` ```copy(Tensor src, Tensor dest)```
`static float[]` `copyOf(float[] arr)`
`static void` ```div(float[] array, float val)```
`static void` ```div(float[] array, float[] divisor)```
`static void` ```fillFourthDim(Tensor deltaWeights, int fourthIdx, float val)```
`static void` ```max(Tensor t1, Tensor t2, Tensor result)```
`static void` ```min(Tensor t1, Tensor t2, Tensor result)```
`static void` ```multiply(float[] arr1, float[] arr2)```
`static Tensor` `ones(int cols)`
`static Tensor` `random(int size)`
`static Tensor` ```random(int rows, int cols)```
Generate and return random tensor with specified number of rows and cols.
`static Tensor` ```random(int rows, int cols, int depth)```
`static Tensor` ```random(int rows, int cols, int depth, int fourthDim)```
`static void` ```sub(float[] arr, float val)```
`static void` ```sub(float[] array1, float[] array2)```
`static Tensor` `zeros(int cols)`
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

• #### copyOf

`public static float[] copyOf(float[] arr)`
• #### copy

```public static final void copy(Tensor src,
Tensor dest)```
• #### copy

```public static final void copy(float[] src,
float[] dest)```
• #### sub

```public static void sub(float[] arr,
float val)```
• #### multiply

```public static void multiply(float[] arr1,
float[] arr2)```
• #### fillFourthDim

```public static void fillFourthDim(Tensor deltaWeights,
int fourthIdx,
float val)```
• #### absMax

```public static Tensor absMax(Tensor t,
Tensor max)```
Returns tensors with max value for each component of input tensors.
Parameters:
`t` -
`max` - proposed max tensor
Returns:
tensor with max value for each component
• #### absMax

```public static float[] absMax(float[] arr,
float[] max)```
Returns array with max values for each position in the given input vectors. Stores max values in second parameter.
Parameters:
`arr` -
`max` -
Returns:
• #### absMin

```public static Tensor absMin(Tensor t,
Tensor min)```
• #### absMin

```public static float[] absMin(float[] arr,
float[] min)```
• #### div

```public static void div(float[] array,
float val)```
• #### div

```public static void div(float[] array,
float[] divisor)```
• #### sub

```public static final void sub(float[] array1,
float[] array2)```

```public static final void add(float[] array1,
float[] array2)```
Adds given vector and store result in first.
Parameters:
`array1` -
`array2` -
• #### zeros

`public static Tensor zeros(int cols)`
• #### ones

`public static Tensor ones(int cols)`
• #### random

`public static Tensor random(int size)`
• #### random

```public static Tensor random(int rows,
int cols)```
Generate and return random tensor with specified number of rows and cols.
Parameters:
`rows` -
`cols` -
Returns:
• #### random

```public static Tensor random(int rows,
int cols,
int depth)```
• #### random

```public static Tensor random(int rows,
int cols,
int depth,
int fourthDim)```
• #### min

```public static void min(Tensor t1,
Tensor t2,
Tensor result)```
• #### max

```public static void max(Tensor t1,
Tensor t2,
Tensor result)```