Package it.unimi.dsi.sux4j.mph.solve
Class Modulo2System.Modulo2Equation
- java.lang.Object
-
- it.unimi.dsi.sux4j.mph.solve.Modulo2System.Modulo2Equation
-
- Enclosing class:
- Modulo2System
public static class Modulo2System.Modulo2Equation extends java.lang.Object
An equation on F2.
-
-
Field Summary
Fields Modifier and Type Field Description protected long[]
bits
Thebv.bits()
, cached.protected it.unimi.dsi.bits.LongArrayBitVector
bitVector
The vector representing the coefficients (one bit for each variable).protected long
c
The constant term.protected int
firstVar
The first variable.
-
Constructor Summary
Constructors Modifier Constructor Description Modulo2Equation(long c, int numVars)
Creates a new equation.protected
Modulo2Equation(Modulo2System.Modulo2Equation equation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Modulo2System.Modulo2Equation
add(int variable)
Adds a new variable.void
add(Modulo2System.Modulo2Equation equation)
Add another equation to this equation.Modulo2System.Modulo2Equation
copy()
boolean
equals(java.lang.Object o)
int
hashCode()
boolean
isIdentity()
boolean
isUnsolvable()
static long
scalarProduct(long[] bits, long[] values)
Returns the modulo-2 scalar product of the two provided bit vectors.java.lang.String
toString()
void
updateFirstVar()
Updates the information contained infirstVar
.int[]
variables()
Returns an array containing the variables in increasing order.
-
-
-
Field Detail
-
bitVector
protected final it.unimi.dsi.bits.LongArrayBitVector bitVector
The vector representing the coefficients (one bit for each variable).
-
bits
protected final long[] bits
Thebv.bits()
, cached.
-
c
protected long c
The constant term.
-
firstVar
protected int firstVar
The first variable. It isInteger.MAX_VALUE
if the first variable is not known. This field must be updated byupdateFirstVar()
to be meaningful.
-
-
Constructor Detail
-
Modulo2Equation
public Modulo2Equation(long c, int numVars)
Creates a new equation.- Parameters:
c
- the constant term.numVars
- the number of variables.
-
Modulo2Equation
protected Modulo2Equation(Modulo2System.Modulo2Equation equation)
-
-
Method Detail
-
add
public Modulo2System.Modulo2Equation add(int variable)
Adds a new variable.- Parameters:
variable
- a variable.- Returns:
- this equation.
- Throws:
java.lang.IllegalStateException
- if you try to add twice the same variable.
-
variables
public int[] variables()
Returns an array containing the variables in increasing order.Mainly for debugging purposes.
- Returns:
- an array containing the variables in increasing order.
-
add
public void add(Modulo2System.Modulo2Equation equation)
Add another equation to this equation.- Parameters:
equation
- an equation.
-
updateFirstVar
public void updateFirstVar()
Updates the information contained infirstVar
.
-
isUnsolvable
public boolean isUnsolvable()
-
isIdentity
public boolean isIdentity()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
scalarProduct
public static long scalarProduct(long[] bits, long[] values)
Returns the modulo-2 scalar product of the two provided bit vectors.- Parameters:
bits
- a bit vector represented as an array of longs.values
- an array of long representing the 64-bit values associated with each variable.- Returns:
- the modulo-2 scalar product of
x
and {code y}.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
copy
public Modulo2System.Modulo2Equation copy()
-
-