org.nd4j.linalg.util
Class Shape
- java.lang.Object
-
- org.nd4j.linalg.util.Shape
-
public class Shape extends java.lang.ObjectEncapsulates all shape related logic (vector of 0 dimension is a scalar is equivalent to a vector of length 1...)
-
-
Constructor Summary
Constructors Constructor and Description Shape()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static booleanisColumnVectorShape(int[] shape)static booleanisMatrix(int[] shape)Returns whether the passed in shape is a matrixstatic booleanisRowVectorShape(int[] shape)static booleanisVector(int[] shape)Returns whether the given shape is a vectorstatic intnonZeroDimension(int[] shape)static booleanscalarEquals(int[] shape1, int[] shape2)Returns true if the given shapes are both scalars (0 dimension or shape[0] == 1)static booleanshapeEquals(int[] shape1, int[] shape2)Returns whether 2 shapes are equals by checking for dimension semantics as well as array equalitystatic int[]sizeForAxes(int[] axes, int[] shape)static int[]squeeze(int[] shape)Gets rid of any singleton dimensions of the given arraystatic int[]squeeze(int[] shape, int[] stride)Gets rid of any singleton dimensions of the given arraystatic booleansqueezeEquals(int[] test1, int[] test2)Returns true for the case where singleton dimensions are being compared
-
-
-
Method Detail
-
squeeze
public static int[] squeeze(int[] shape, int[] stride)Gets rid of any singleton dimensions of the given array- Parameters:
shape- the shape to squeeze- Returns:
- the array with all of the singleton dimensions removed
-
sizeForAxes
public static int[] sizeForAxes(int[] axes, int[] shape)
-
isVector
public static boolean isVector(int[] shape)
Returns whether the given shape is a vector- Parameters:
shape- the shape to test- Returns:
- whether the given shape is a vector
-
isMatrix
public static boolean isMatrix(int[] shape)
Returns whether the passed in shape is a matrix- Parameters:
shape- whether the passed in shape is a matrix- Returns:
- true if the shape is a matrix false otherwise
-
squeeze
public static int[] squeeze(int[] shape)
Gets rid of any singleton dimensions of the given array- Parameters:
shape- the shape to squeeze- Returns:
- the array with all of the singleton dimensions removed
-
nonZeroDimension
public static int nonZeroDimension(int[] shape)
-
shapeEquals
public static boolean shapeEquals(int[] shape1, int[] shape2)Returns whether 2 shapes are equals by checking for dimension semantics as well as array equality- Parameters:
shape1- the first shape for comparisonshape2- the second shape for comparison- Returns:
- whether the shapes are equivalent
-
scalarEquals
public static boolean scalarEquals(int[] shape1, int[] shape2)Returns true if the given shapes are both scalars (0 dimension or shape[0] == 1)- Parameters:
shape1- the first shape for comparisonshape2- the second shape for comparison- Returns:
- whether the 2 shapes are equal based on scalar rules
-
isRowVectorShape
public static boolean isRowVectorShape(int[] shape)
-
isColumnVectorShape
public static boolean isColumnVectorShape(int[] shape)
-
squeezeEquals
public static boolean squeezeEquals(int[] test1, int[] test2)Returns true for the case where singleton dimensions are being compared- Parameters:
test1- the first to testtest2- the second to test- Returns:
- true if the arrays are equal with the singleton dimension omitted
-
-
DMelt 3.0 © DataMelt by jWork.ORG