Class Dimensions
java.lang.Object
com.singularsys.extensions.matrix.Dimensions
- All Implemented Interfaces:
Serializable
A class to represent a set of dimensions giving the size of a vector or matrix.
Might be 1 for 0-dimensional numbers.
[3] for a 3D vector
[3,3] for a matrix
- Author:
- rich Created on 25-Oct-2003 In Versions 2.2 the constant SCALER has been changed to SCALAR
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Dimensionsstatic final DimensionsDeprecated.static final Dimensionsstatic final Dimensionsstatic final Dimensionsstatic final Dimensionsstatic final Dimensions -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanequalsDim(Dimensions dims2) Two dimensions are equal if the element of dims are the same.intget the first dimension, 1 for numbers, or the length of a vector.intgetIthDim(int i) Get the value of the i-th dimension.intget the last dimension, 1 for numbers, or the length of a vector.inthashCode()booleanis0D()Is it 0D, ie a simple number.booleanis1D()Is it 1D, ie a vector [1,2,3].booleanis2D()Is it 2D, ie a matrix [[1,2,3],[4,5,6]].intnumEles()The total number of elements.intorder()Order of dimensions 0 for numbers, 1 for vectors, 2 for matricestoString()A string representation.static DimensionsvalueOf(int d) Deprecated.static DimensionsvalueOf(int[] dims) returns a dimensions with given dimensions.static DimensionsvalueOf(int rows, int cols) returns dimensions for a matrix.static DimensionsvalueOf(int d, Dimensions inDim) return a dimension [d,inDim[0],...,inDim[n]]static DimensionsvalueOf(Dimensions inDim, int d) return a dimension [inDim[0],...,inDim[n],d]static Dimensionsstatic Dimensionsstatic DimensionsvalueOfVec(int d) Factory method, treating an argument of 1 as a vector with a single element.static DimensionsvalueOfVecOrScalar(int d) Factory method, treating an argument of 1 as a scalar.
-
Field Details
-
UNKNOWN
-
SCALAR
-
EMPTY_VECTOR
-
ONE_ELEMENT_VECTOR
-
TWO
-
THREE
-
ONE
Deprecated.useSCALARorONE_ELEMENT_VECTOR.An ambiguous value which could be confused with a vector with a single element.
-
-
Method Details
-
valueOf
Deprecated.Factory method returns a Dimension for vector of given length. For 0, 1,2,3 returns constantsEMPTY_VECTOR,SCALAR,TWOorTHREEotherwise create a new object. This method treats an argument of 1 as a Scalar, rather than a vector with one element -
valueOfVecOrScalar
Factory method, treating an argument of 1 as a scalar.- Parameters:
d- either 1 for a scalar or a positive or zero number for vectors with that many elements- Returns:
- dimensions type
- Since:
- Extension 2.2
-
valueOfVec
Factory method, treating an argument of 1 as a vector with a single element.- Parameters:
d- dimension of the vector, a positive or zero integer- Returns:
- dimensions type
-
valueOf
returns dimensions for a matrix. -
valueOf
return a dimension [d,inDim[0],...,inDim[n]] -
valueOf
return a dimension [inDim[0],...,inDim[n],d] -
valueOf
returns a dimensions with given dimensions.- Parameters:
dims- list of dimensions, with no elements for a scalar, a single element for vector, two elements for matrices Logic changed when [1] passed in.
-
valueOf
-
valueOf
-
getFirstDim
public int getFirstDim()get the first dimension, 1 for numbers, or the length of a vector. for a matrix [[1,2,3],[4,5,6]] first dim is number of rows eg 2 -
getLastDim
public int getLastDim()get the last dimension, 1 for numbers, or the length of a vector. for a matrix [[1,2,3],[4,5,6]] last dim is number of cols eg 3 -
getIthDim
public int getIthDim(int i) Get the value of the i-th dimension.- Parameters:
i- index based at zero- Returns:
- value of ith dim or -1 if out of range
-
is0D
public boolean is0D()Is it 0D, ie a simple number. -
is1D
public boolean is1D()Is it 1D, ie a vector [1,2,3]. -
is2D
public boolean is2D()Is it 2D, ie a matrix [[1,2,3],[4,5,6]]. -
numEles
public int numEles()The total number of elements. Produce of all the dimensions. -
order
public int order()Order of dimensions 0 for numbers, 1 for vectors, 2 for matrices -
toString
A string representation. Either 1,[n],[m, n],[l, m, n] etc. -
equalsDim
Two dimensions are equal if the element of dims are the same. -
hashCode
public int hashCode() -
equals
-
SCALARorONE_ELEMENT_VECTOR.