use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.
the class BooleanMatrixTest method assertDotProductFalse.
private final void assertDotProductFalse(BooleanMatrix mF, BooleanMatrix m) {
BooleanMatrix product = mF.dot(m);
assertEquals(0, product.density());
assertTrue(equivalent(mF.dimensions().dot(m.dimensions()), product.dimensions()));
}
use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.
the class Evaluator method evaluate.
/**
* Evaluates the specified expession with respect to the relation-tuple mappings
* given by this.instance and using this.options.
*
* @return {@link kodkod.instance.TupleSet set} of tuples to which the
* expression evaluates given the mappings in this.instance and the
* options in this.options.
* @throws kodkod.engine.fol2sat.HigherOrderDeclException the expression
* contains a higher order declaration
* @throws kodkod.engine.fol2sat.UnboundLeafException the expression contains an
* undeclared variable or a relation not mapped by this.instance
*/
public TupleSet evaluate(Expression expression) {
if (expression == null)
throw new NullPointerException("expression");
final BooleanMatrix sol = Translator.evaluate(expression, instance, options);
this.wasOverflow = sol.defCond().getAccumOverflow() == BooleanConstant.TRUE;
return instance.universe().factory().setOf(expression.arity(), sol.denseIndices());
}
use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.
the class BooleanMatrixTest method testTranspose.
public final void testTranspose() {
BooleanMatrix mF43t = mF43.transpose();
assertEquals(mF43.density(), mF43t.density());
assertTrue(equivalent(dim43.transpose(), mF43t.dimensions()));
fill(mF43, range(0, dim43.capacity() - 1));
BooleanValue[] result = new BooleanValue[dim43.capacity()];
final int a = dim43.dimension(0), b = dim43.dimension(1);
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
result[j * a + i] = vars[i * b + j];
}
}
mF43t = mF43.transpose();
assertEquals(mF43.density(), mF43t.density());
assertTrue(equivalent(dim43.transpose(), mF43t.dimensions()));
assertTrue(equivalent(mF43t, result));
}
use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.
the class BooleanMatrixTest method assertCrossProductFalse.
private final void assertCrossProductFalse(BooleanMatrix mF, BooleanMatrix m) {
BooleanMatrix product = mF.cross(m);
assertEquals(0, product.density());
assertTrue(equivalent(mF.dimensions().cross(m.dimensions()), product.dimensions()));
}
use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.
the class BooleanMatrixTest method testNot.
public final void testNot() {
fill(mT324, mCells, mR[1]);
fill(mT324, mCells, mR[3]);
for (int i = mR[1].min(); i <= mR[1].max(); i++) {
mCells[i] = f.not(mCells[i]);
}
for (int i = mR[3].min(); i <= mR[3].max(); i++) {
mCells[i] = f.not(mCells[i]);
}
mT324.set(mR[1].max() + 1, FALSE);
mCells[mR[1].max() + 1] = TRUE;
BooleanMatrix mNot = mT324.not();
assertTrue(equivalent(mT324.dimensions(), mNot.dimensions()));
assertTrue(equivalent(mNot, mCells));
// System.out.println(mT324);
// System.out.println(mNot);
}
Aggregations