|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.engine.bool.BooleanMatrix
public final class BooleanMatrix
An n-dimensional matrix of boolean values
.
Boolean matrices are indexed using flat integer indeces. For example,
let m be a the 2 x 3 matrix of boolean variables identifed by labels [0 4 1; 5 10 2].
Then, m[0] = 0, m[3] = 5, m[5] = 2, etc.
All values stored in the same matrix must be created by the same circuit factory
.
All methods that accept another BooleanMatrix as an input will throw an
IllegalArgumentException if the values in the input matrix do not belong
to the same factory as the values in the receiver matrix.
Some instances can store only constant values, or can only store
values at particular indices (see BooleanFactory.matrix(Dimensions, IntSet, IntSet)
).
If this is the case, an attempt to call set(int, BooleanValue)
with invalid parameters will cause an IllegalArgumentException or an IndexOutOfBoundsException.
dimensions: Dimensions |
factory: BooleanFactory |
elements: [0..dimensions.capacity) -> one factory.components |
Method Summary | |
---|---|
BooleanMatrix |
and(BooleanMatrix other)
Returns a new matrix such that an entry in the returned matrix represents a conjunction of the corresponding entries in this and other matrix. |
Int |
cardinality()
Returns an Int that represents the cardinality (number of non-FALSE entries) of this matrix using this.factory.intEncoding. |
BooleanMatrix |
choice(BooleanValue condition,
BooleanMatrix other)
Returns a boolean matrix m such that m = this if the given condition evaluates to TRUE and m = other otherwise. |
BooleanMatrix |
clone()
Returns a copy of this boolean matrix. |
BooleanMatrix |
closure()
Returns the transitive closure of this matrix. |
BooleanMatrix |
cross(BooleanMatrix other)
Returns the cross product of this and other matrix, using conjunction instead of multiplication. |
IntSet |
denseIndices()
Returns the set of all indices in this matrix that contain non-FALSE values. |
int |
density()
Returns the number of non-FALSE entries in this matrix. |
BooleanMatrix |
difference(BooleanMatrix other)
Returns a matrix representing the asymmetric difference between the entries in this and the given matrix. |
Dimensions |
dimensions()
Returns the dimensions of this matrix. |
BooleanMatrix |
dot(BooleanMatrix other)
Returns the dot product of this and other matrix, using conjunction instead of multiplication and disjunction instead of addition. |
BooleanValue |
eq(BooleanMatrix other)
Returns a formula stating that the entries in this matrix are equivalent to the entries in the given matrix; i.e. |
BooleanFactory |
factory()
Returns the factory used to construct all the non-constant entries in this matrix. |
BooleanValue |
get(int index)
Returns the element at the specified index. |
java.util.Iterator<IndexedEntry<BooleanValue>> |
iterator()
Returns an IndexedEntry-based view of the non-FALSE entries in this matrix. |
BooleanValue |
lone()
Returns a BooleanValue that constrains at most one value in this.elements to be true. |
BooleanValue |
none()
Returns a BooleanValue that constraints all values in this.elements to be false. |
BooleanMatrix |
not()
Returns a new matrix each of whose entries is a negation of the corresponding entry in this matrix. |
BooleanValue |
one()
Returns a BooleanValue that constraints exactly one value in this.elements to be true. |
BooleanMatrix |
or(BooleanMatrix other)
Returns a new matrix such that an entry in the returned matrix represents a combination of the corresponding entries in this and other matrix. |
BooleanMatrix |
override(BooleanMatrix other)
Overrides the values in this matrix with those in other . |
BooleanMatrix |
project(Int[] columns)
Returns a matrix m such that the relational value of m is equal to the relational value of this projected on the specified columns. |
void |
set(int index,
BooleanValue value)
Sets the specified index to the given value. |
BooleanValue |
some()
Returns a BooleanValue that constrains at least one value in this.elements to be true. |
BooleanValue |
subset(BooleanMatrix other)
Returns a formula stating that the entries in this matrix are a subset of the entries in the given matrix; i.e. |
java.lang.String |
toString()
|
BooleanMatrix |
transpose()
Returns the transpose of this matrix. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public final Dimensions dimensions()
public final BooleanFactory factory()
public final int density()
public final java.util.Iterator<IndexedEntry<BooleanValue>> iterator()
Iterator.remove()
on the returned iterator has the same effect
as setting the entry obtained through the last call to Iterator.next()
to FALSE.
iterator
in interface java.lang.Iterable<IndexedEntry<BooleanValue>>
public final IntSet denseIndices()
public final BooleanValue get(int index)
java.lang.IndexOutOfBoundsException
- - index < 0 || index >= this.dimensions.capacitypublic final BooleanMatrix not()
public final BooleanMatrix and(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - !other.dimensions.equals(this.dimensions) || this.factory != other.factorypublic final BooleanMatrix or(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - !other.dimensions.equals(this.dimensions) || this.factory != other.factorypublic final BooleanMatrix cross(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - this.factory != other.factorypublic final BooleanMatrix dot(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - this.factory != other.factory
java.lang.IllegalArgumentException
- - dimensions incompatible for multiplicationpublic final BooleanValue subset(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - !other.dimensions.equals(this.dimensions) || this.factory != other.factorypublic final BooleanValue eq(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - !other.dimensions.equals(this.dimensions) || this.factory != other.factorypublic final BooleanMatrix difference(BooleanMatrix other)
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - !other.dimensions.equals(this.dimensions) || this.factory != other.factorypublic final BooleanMatrix closure()
java.lang.UnsupportedOperationException
- - #this.diensions != 2 || !this.dimensions.square()public final BooleanMatrix transpose()
java.lang.UnsupportedOperationException
- - #this.dimensions != 2public final BooleanMatrix choice(BooleanValue condition, BooleanMatrix other)
java.lang.NullPointerException
- - other = null || condition = null
java.lang.IllegalArgumentException
- - !other.dimensions.equals(this.dimensions) || this.factory != other.factorypublic final BooleanMatrix project(Int[] columns)
IllegalArgumentExceptions
- - columns.length < 1 || !this.dimensions.isSquare()
java.lang.NullPointerException
- - columns = nullcolumn[int] in this.dimensions.dimensions[int] |
this.dimensions.isSquare() |
public final BooleanMatrix override(BooleanMatrix other)
other
.
Specifically, for each index i of the returned matrix m,
m.elements[i] is true iff other.elements[i] is true or
this.elements[i] is true and all elements of other
that are in the same row as i are false.
other
that are in the same row as i.
java.lang.NullPointerException
- - other = null
java.lang.IllegalArgumentException
- - other.dimensions != this.dimensionspublic final Int cardinality()
public final BooleanValue some()
public final BooleanValue lone()
public final BooleanValue one()
public final BooleanValue none()
public final void set(int index, BooleanValue value)
java.lang.NullPointerException
- - value = null
java.lang.IllegalArgumentException
- - the given is a formula, and this matrix accepts only constants
java.lang.IndexOutOfBoundsException
- - the given index does not belong to the set of indices at which
this matrix can store non-FALSE values.this.elements'[index] = value |
value in this.factory.components |
public BooleanMatrix clone()
clone
in class java.lang.Object
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 |