public class Linexpr1
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
A Linexpr1 is a linear expression with Coeff
coefficients
and variables denoted by names in an environment.
A Linexpr1 is implemented as a pair containing a (sparse or dense)
Linexpr0
and an Environment
,
manipulated in conjunction.
Direct access to the fields is prohibited, to avoid desynchronizing them.
Modifier and Type | Field and Description |
---|---|
protected Environment |
env
Environment.
|
protected Linexpr0 |
expr
Level 0 expression.
|
Constructor and Description |
---|
Linexpr1(Environment e)
Creates a new dense expression.
|
Linexpr1(Environment e,
Coeff[] term,
Coeff cst)
Creates a new dense expression initialized with the corresponding
variable and constant coefficients.
|
Linexpr1(Environment e,
int size)
Creates a empty sparse expression of the given size on environment
e.
|
Linexpr1(Environment e,
Linexpr0 x)
Creates a new level 1 linear expression from a level 0
linear expression.
|
Linexpr1(Environment e,
Linterm1[] term,
Coeff cst)
Creates a new sparse expression initialized with the corresponding
terms and constant coefficient.
|
Linexpr1(Linexpr1 c)
Creates a copy of c.
|
Modifier and Type | Method and Description |
---|---|
Linexpr1 |
clone()
Returns a copy of this.
|
int |
cmp(Linexpr1 x)
Compares this and x.
|
boolean |
equals(java.lang.Object x)
Whether x is a Linexpr1 tree and structurally equal to this.
|
void |
extendEnvironment(Environment e)
Expands the expression to fit the given environment.
|
Linexpr1 |
extendEnvironmentCopy(Environment e)
Returns a new expression expanded to fit the given environment.
|
Coeff |
getCoeff(java.lang.String var) |
Coeff |
getCoeff(Var var)
Returns a copy of the coefficient of variable var.
|
Coeff[] |
getCoeffs()
Returns a copy of all variable coefficients.
|
Coeff |
getCst()
Returns a copy of the constant coefficient.
|
Environment |
getEnvironment()
Returns the environment of the expression.
|
Linexpr0 |
getLinexpr0()
Returns a copy of the Linexpr0 underlying this expression.
|
Linexpr0 |
getLinexpr0Ref()
Returns a (read-only) reference to the Linexpr0 underlying
this expression.
|
Linterm1[] |
getLinterms()
Gets a copy of all variable coefficients.
|
int |
hashCode()
Returns a hash of the expression.
|
boolean |
isEqual(Linexpr1 x)
Whether this and x have identical coefficients and environment.
|
boolean |
isInteger()
Whether the expression only depends on integer-valued variables.
|
boolean |
isLinear()
Whether the expression has only scalar coefficients.
|
boolean |
isQuasilinear()
Whether the expression has only scalar coefficients, except maybe
for the constant coefficient.
|
boolean |
isReal()
Whether the expression only depends on real-valued variables.
|
boolean |
isSparse()
Whether the expression is sparse or dense.
|
static Linexpr1 |
make(Environment v,
Linexpr0 x)
This function is used internally to construct a level 1 expression
by referencing a level 0 expression.
|
void |
minimize()
Simplifies the representation.
|
void |
setCoeff(Linterm1[] c)
Sets several variable coefficients at the same time.
|
void |
setCoeff(java.lang.String var,
Coeff c) |
void |
setCoeff(Var var,
Coeff c)
Sets the coefficient of variable var to c.
|
void |
setCst(Coeff c)
Sets the constant coefficient to c.
|
java.lang.String |
toString()
Returns a string representation of the expression.
|
protected Linexpr0 expr
protected Environment env
public Linexpr1(Environment e, int size)
size is only an initial guess; the expression will grow dynamically when needed.
All coefficient are initially set to 0.
public Linexpr1(Environment e)
public Linexpr1(Linexpr1 c)
All coefficients are copied.
public Linexpr1(Environment e, Linterm1[] term, Coeff cst)
All coefficients are copied.
public Linexpr1(Environment e, Coeff[] term, Coeff cst)
All coefficients are copied.
The number of coefficients must match the environment size;
public Linexpr1(Environment e, Linexpr0 x)
All coefficients are copied.
The environment must be large enough for all variables in x.
public static Linexpr1 make(Environment v, Linexpr0 x)
The level 0 expression should no longer be used afterwards.
public void setCst(Coeff c)
The coefficient is copied.
public void setCoeff(java.lang.String var, Coeff c)
public void setCoeff(Linterm1[] c)
All coefficients are copied.
public Environment getEnvironment()
public Linexpr0 getLinexpr0()
public Linexpr0 getLinexpr0Ref()
Warning: it is dangerous to add coefficients, resize the expression, add, remove, or permute dimensions as it may desynchrnonize the Linexpr0 dimensions and the Environment.
public Coeff getCst()
public Coeff getCoeff(java.lang.String var)
public Linterm1[] getLinterms()
All integer-valued variables appear before real-valued variables. Integer-valued and real-valued variables appear in increasing lexicographic order (i.e., the dimension order).
For sparse expressions, some variable may be missing (and should be considered implicitly as 0).
public Coeff[] getCoeffs()
All integer-valued variables appear before real-valued variables. Integer-valued and real-valued variables appear in increasing lexicographic order (i.e., the dimension order).
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean isSparse()
public boolean isInteger()
public boolean isReal()
public boolean isLinear()
public boolean isQuasilinear()
public boolean isEqual(Linexpr1 x)
public int cmp(Linexpr1 x)
The order is a lexicographic order of
Environment.cmp(apron.Environment)
and Linexpr0.cmp(apron.Linexpr0)
.
public void minimize()
Linexpr0.minimize()
public void extendEnvironment(Environment e)
e must be a super-environment of that of this.
public Linexpr1 extendEnvironmentCopy(Environment e)
e must be a super-environment of that of this.
this is not modified.
public Linexpr1 clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object