|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.engine.bool.Dimensions
public abstract class Dimensions
Stores information about the size of a matrix. Specifically, for an n-dimensional matrix n, a Dimensions object is abstractly a vector consisting of n integers; the ith integer in the vector represents the size of the ith dimension of a matrix.
n > 0 |
n: int |
dimensions: [0..n) -> one int |
capacity: dimensions[0] x ... x dimensions[n-1] |
Method Summary | |
---|---|
int |
capacity()
Returns the capacity of this. |
int[] |
convert(int index)
Converts an integer index into a matrix with these dimensions into a vector index. |
int |
convert(int[] vectorIndex)
Converts the first this.n positions of the given vector index into an integer index. |
void |
convert(int index,
int[] vectorIndex)
Converts an integer index into a matrix with these dimensions into a vector index, and stores the result in the provided array. |
Dimensions |
cross(Dimensions dim)
Returns the dimensions of a matrix that would result from taking the cross product of a matrix of dimensions given by this and a matrix whose dimensions are specified by dim. |
abstract int |
dimension(int i)
Returns the size of the ith dimensions |
Dimensions |
dot(Dimensions dim)
Returns the dimensions of a matrix that would result from multiplying a matrix of dimensions given by this by a matrix whose dimensions are specified by dim. |
abstract boolean |
isSquare()
Returns true if this represents the dimensions of a square matrix; otherwise returns false. |
abstract int |
numDimensions()
Returns the number of dimensions in this Dimensions object. |
static Dimensions |
rectangular(int[] dimensions)
Constructs a new Dimensions object with the given dimensions. |
static Dimensions |
square(int size,
int n)
Returns a new Dimensions object with n dimensions, each of which has the specified size. |
java.lang.String |
toString()
|
abstract Dimensions |
transpose()
Returns the transpose of these dimensions. |
boolean |
validate(int index)
Returns true if index is a valid flat index for a matrix with these dimensions; otherwise returns false. |
boolean |
validate(int[] index)
Returns true if index is a valid vector index for a matrix with these dimensions; otherwise returns false. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static Dimensions square(int size, int n)
java.lang.IllegalArgumentException
- - n < 1 || size < 1public static Dimensions rectangular(int[] dimensions)
java.lang.NullPointerException
- - dimensions = null
java.lang.IllegalArgumentException
- - dimensions.length = 0 ||
some i: [0..dimensions.n) | dimensions[i] < 1public final int capacity()
public abstract int dimension(int i)
java.lang.ArrayIndexOutOfBoundsException
- - i < 0 || i >= this.capacitypublic abstract int numDimensions()
public abstract boolean isSquare()
public final Dimensions dot(Dimensions dim)
java.lang.IllegalArgumentException
- - this.n + dim.n < 3 || this.dimensions[n-1] != dim.dimensions[0]public final Dimensions cross(Dimensions dim)
public abstract Dimensions transpose()
java.lang.UnsupportedOperationException
- - this.n != 2public final boolean validate(int index)
public final boolean validate(int[] index)
java.lang.NullPointerException
- - index = nullpublic final int[] convert(int index)
java.lang.IndexOutOfBoundsException
- - !validate(index)public final void convert(int index, int[] vectorIndex)
vectorIndex
beyond the first this.n cells are left unchanged.
java.lang.NullPointerException
- - vectorIndex = null
java.lang.IllegalArgumentException
- - vectorIndex.length < this.numDimensions
java.lang.IndexOutOfBoundsException
- - !validate(index)the first this.numDimensions entries of |
vectorIndex.length <= this.n |
public final int convert(int[] vectorIndex)
java.lang.NullPointerException
- - index == null
java.lang.IllegalArgumentException
- - index.length < this.n
java.lang.IndexOutOfBoundsException
- - some i: [0..n) | index[i] < 0 ||
index[i] >= this.dimensions[i]public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |