Class Linexpr1
- All Implemented Interfaces:
Serializable
,Cloneable
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Environment
Environment.protected Linexpr0
Level 0 expression. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new dense expression.Linexpr1
(Environment e, int size) Creates a empty sparse expression of the given size on environment e.Linexpr1
(Environment e, Coeff[] term, Coeff cst) Creates a new dense expression initialized with the corresponding variable and constant coefficients.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.Creates a copy of c. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a copy of this.int
Compares this and x.boolean
Whether x is a Linexpr1 tree and structurally equal to this.void
Expands the expression to fit the given environment.Returns a new expression expanded to fit the given environment.Returns a copy of the coefficient of variable var.Coeff[]
Returns a copy of all variable coefficients.getCst()
Returns a copy of the constant coefficient.Returns the environment of the expression.Returns a copy of the Linexpr0 underlying this expression.Returns a (read-only) reference to the Linexpr0 underlying this expression.Linterm1[]
Gets a copy of all variable coefficients.int
hashCode()
Returns a hash of the expression.boolean
Whether this and x have identical coefficients and environment.boolean
Whether the expression only depends on integer-valued variables.boolean
isLinear()
Whether the expression has only scalar coefficients.boolean
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
Sets several variable coefficients at the same time.void
Sets the coefficient of variable var to c.void
void
Sets the constant coefficient to c.toString()
Returns a string representation of the expression.
-
Field Details
-
expr
Level 0 expression. -
env
Environment.
-
-
Constructor Details
-
Linexpr1
Creates a empty sparse expression of the given size on environment e.size is only an initial guess; the expression will grow dynamically when needed.
All coefficient are initially set to 0.
-
Linexpr1
Creates a new dense expression. -
Linexpr1
Creates a copy of c.All coefficients are copied.
-
Linexpr1
Creates a new sparse expression initialized with the corresponding terms and constant coefficient.All coefficients are copied.
-
Linexpr1
Creates a new dense expression initialized with the corresponding variable and constant coefficients.All coefficients are copied.
The number of coefficients must match the environment size;
-
Linexpr1
Creates a new level 1 linear expression from a level 0 linear expression.All coefficients are copied.
The environment must be large enough for all variables in x.
-
-
Method Details
-
make
This function is used internally to construct a level 1 expression by referencing a level 0 expression.The level 0 expression should no longer be used afterwards.
-
setCst
Sets the constant coefficient to c.The coefficient is copied.
-
setCoeff
-
setCoeff
Sets the coefficient of variable var to c. -
setCoeff
Sets several variable coefficients at the same time.All coefficients are copied.
-
getEnvironment
Returns the environment of the expression. -
getLinexpr0
Returns a copy of the Linexpr0 underlying this expression. -
getLinexpr0Ref
Returns a (read-only) reference to the Linexpr0 underlying this expression.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.
-
getCst
Returns a copy of the constant coefficient. -
getCoeff
-
getCoeff
Returns a copy of the coefficient of variable var. -
getLinterms
Gets a copy of all variable coefficients.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).
-
getCoeffs
Returns a copy of all variable coefficients.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).
-
toString
Returns a string representation of the expression. -
hashCode
public int hashCode()Returns a hash of the expression. -
isSparse
public boolean isSparse()Whether the expression is sparse or dense. -
isInteger
public boolean isInteger()Whether the expression only depends on integer-valued variables. -
isReal
public boolean isReal()Whether the expression only depends on real-valued variables. -
isLinear
public boolean isLinear()Whether the expression has only scalar coefficients. -
isQuasilinear
public boolean isQuasilinear()Whether the expression has only scalar coefficients, except maybe for the constant coefficient. -
isEqual
Whether this and x have identical coefficients and environment. -
cmp
Compares this and x.The order is a lexicographic order of
Environment.cmp(apron.Environment)
andLinexpr0.cmp(apron.Linexpr0)
. -
minimize
public void minimize()Simplifies the representation.- See Also:
-
extendEnvironment
Expands the expression to fit the given environment.e must be a super-environment of that of this.
-
extendEnvironmentCopy
Returns a new expression expanded to fit the given environment.e must be a super-environment of that of this.
this is not modified.
-
clone
Returns a copy of this. -
equals
Whether x is a Linexpr1 tree and structurally equal to this.
-