public class Modulo2System
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
Modulo2System.Modulo2Equation |
An equation on F2.
|
Modifier | Constructor | Description |
---|---|---|
|
Modulo2System(int numVars) |
|
protected |
Modulo2System(int numVars,
java.util.ArrayList<Modulo2System.Modulo2Equation> equations) |
Modifier and Type | Method | Description |
---|---|---|
void |
add(Modulo2System.Modulo2Equation equation) |
Adds an equation to the system.
|
boolean |
check(long[] solution) |
|
Modulo2System |
copy() |
|
static boolean |
gaussianElimination(int[][] var2Eq,
long[] c,
int[] variable,
long[] solution) |
|
boolean |
gaussianElimination(long[] solution) |
Solves the system using Gaussian elimination.
|
static boolean |
lazyGaussianElimination(int[][] var2Eq,
long[] c,
int[] variable,
long[] solution) |
Solves a system using lazy Gaussian elimination.
|
boolean |
lazyGaussianElimination(long[] solution) |
Solves the system using lazy Gaussian elimination.
|
static boolean |
lazyGaussianElimination(Modulo2System system,
int[][] var2Eq,
long[] c,
int[] variable,
long[] solution) |
Solves a system using lazy Gaussian elimination.
|
java.lang.String |
toString() |
public Modulo2System(int numVars)
protected Modulo2System(int numVars, java.util.ArrayList<Modulo2System.Modulo2Equation> equations)
public Modulo2System copy()
public void add(Modulo2System.Modulo2Equation equation)
equation
- an equation with the same number of variables of the system.public java.lang.String toString()
toString
in class java.lang.Object
public boolean check(long[] solution)
public boolean gaussianElimination(long[] solution)
solution
- an array where the solution will be written.public boolean lazyGaussianElimination(long[] solution)
Warning: this method is very inefficient, as it
scans linearly the equations, builds from scratch the var2Eq
parameter of lazyGaussianElimination(Modulo2System, int[][], long[], int[], long[])
,
and finally calls it. It should be used mainly to write unit tests.
solution
- an array where the solution will be written.public static boolean lazyGaussianElimination(int[][] var2Eq, long[] c, int[] variable, long[] solution)
var2Eq
- an array of arrays describing, for each variable, in which equation it appears;
equation indices must appear in nondecreasing order; an equation
may appear several times for a given variable, in which case the final coefficient
of the variable in the equation is given by the number of appearances modulo 2 (this weird format is useful
when calling this method from a Linear3SystemSolver
). Note that this array
will be altered if some equation appears multiple time associated with a variable.c
- the array of known terms, one for each equation.variable
- the variables with respect to which the system should be solved
(variables not appearing in this array will be simply assigned zero).solution
- an array where the solution will be written.public static boolean lazyGaussianElimination(Modulo2System system, int[][] var2Eq, long[] c, int[] variable, long[] solution)
system
- a modulo-2 system, or null
, in which case the system will be rebuilt
from the other variables.var2Eq
- an array of arrays describing, for each variable, in which equation it appears;
equation indices must appear in nondecreasing order; an equation
may appear several times for a given variable, in which case the final coefficient
of the variable in the equation is given by the number of appearances modulo 2 (this weird format is useful
when calling this method from a Linear3SystemSolver
). The resulting system
must be identical to system
. Note that this array
will be altered if some equation appears multiple time associated with a variable.c
- the array of known terms, one for each equation.variable
- the variables with respect to which the system should be solved
(variables not appearing in this array will be simply assigned zero).solution
- an array where the solution will be written.public static boolean gaussianElimination(int[][] var2Eq, long[] c, int[] variable, long[] solution)