protected static class Modulo3System.Modulo3Equation extends Object
| Modifier and Type | Field and Description |
|---|---|
protected long[] |
bits
The
bv.bits(), cached. |
protected LongArrayBitVector |
bitVector
The vector representing the coefficients (two bits for each variable).
|
protected int |
c
The constant term.
|
protected int |
firstCoeff
The first coefficient.
|
protected int |
firstVar
The first variable.
|
protected LongBigList |
list
A 2-bit list view of
bitVector, cached. |
| Modifier | Constructor and Description |
|---|---|
|
Modulo3Equation(int c,
int numVars)
Creates a new equation.
|
protected |
Modulo3Equation(Modulo3System.Modulo3Equation equation) |
| Modifier and Type | Method and Description |
|---|---|
Modulo3System.Modulo3Equation |
add(int variable)
Adds a new variable with coefficient equal to one.
|
Modulo3System.Modulo3Equation |
add(int variable,
int coefficient)
Adds a new variable with given coefficient.
|
protected static long |
addMod3(long x,
long y)
Adds two 64-bit words made of 2-bit fields containing 00, 01 or 10, interpreted as values mod 3.
|
int[] |
coefficients()
Returns an array containing the coefficients in variable increasing order.
|
Modulo3System.Modulo3Equation |
copy() |
Modulo3System.Modulo3Equation |
eliminate(int var,
Modulo3System.Modulo3Equation equation)
Eliminates the given variable from this equation, using the provided equation, by subtracting it multiplied by a suitable constant.
|
boolean |
equals(Object o) |
boolean |
isIdentity() |
boolean |
isUnsolvable() |
void |
normalized(long[] result)
Writes in the provided array a normalized (all coefficients turned into ones) version of the bit vector representing the equation.
|
static int |
scalarProduct(long[] x,
long[] y)
Returns the modulo-3 scalar product of the two provided bit vectors.
|
void |
sub(Modulo3System.Modulo3Equation equation,
int mul)
Subtract from this equation another equation multiplied by a provided constant.
|
protected static long |
subMod3(long x,
long y)
Subtracts two 64-bit words made of 2-bit fields containing 00, 01 or 10, interpreted as values mod 3.
|
String |
toString() |
void |
updateFirstVar()
Updates the information contained in
firstVar and firstCoeff. |
int[] |
variables()
Returns an array containing the variables in increasing order.
|
protected final LongArrayBitVector bitVector
protected final long[] bits
bv.bits(), cached.protected final LongBigList list
bitVector, cached.protected int c
protected int firstVar
Integer.MAX_VALUE if the
first variable is not known. This field must be updated by updateFirstVar() to be meaningful.protected int firstCoeff
updateFirstVar() to be meaningful.public Modulo3Equation(int c,
int numVars)
c - the constant term.numVars - the number of variables.protected Modulo3Equation(Modulo3System.Modulo3Equation equation)
public Modulo3System.Modulo3Equation add(int variable, int coefficient)
variable - a variable.coefficient - its coefficient.IllegalStateException - if you try to add twice the same variable.public Modulo3System.Modulo3Equation add(int variable)
variable - a variable.public int[] variables()
Mainly for debugging purposes.
coefficients()public int[] coefficients()
Mainly for debugging purposes.
variables(), containing the coefficients in variable increasing order.variables()public Modulo3System.Modulo3Equation eliminate(int var, Modulo3System.Modulo3Equation equation)
var - a variable.equation - an equation in which var appears.public void sub(Modulo3System.Modulo3Equation equation, int mul)
equation - the subtrahend.mul - a multiplier that will be applied to the subtrahend.protected static final long addMod3(long x,
long y)
x - a 64-bit word made of modulo-3 2-bit fields.y - a 64-bit word made of modulo-3 2-bit fields.x and y.protected static final long subMod3(long x,
long y)
x - a 64-bit word made of modulo-3 2-bit fields.y - a 64-bit word made of modulo-3 2-bit fields.x and y.public void updateFirstVar()
firstVar and firstCoeff.public boolean isUnsolvable()
public boolean isIdentity()
public void normalized(long[] result)
result - an array where the result will be stored; must be long at least as bits.public static int scalarProduct(long[] x,
long[] y)
x - a bit vector represented as an array of longs.y - a bit vector represented as an array of longs.x and {code y}.public Modulo3System.Modulo3Equation copy()