public class Linexpr0
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
A Linexpr0 is a linear expression with Coeff
coefficients
and variables denoted by dimension (i.e., integer starting from 0).
A Linexpr0 object encapsulates an ap_linexpr0_t
Apron object
allocated in the C heap.
A Linexpr0 can be either sparse or dense. A dense Linexpr0 is similar to an array of coefficients. Its size is set a creation time, but can be manually changed. It has a coefficient for each dimension, from 0 to size-1. A sparse Linexpr0 needs not be continuous: omitted dimensions implicitly have a 0 coefficient. Also, sparse Linexpr0 grow automatically on-demand.
Constructor and Description |
---|
Linexpr0()
Creates a new empty sparse Linexpr0.
|
Linexpr0(boolean sparse,
int size)
Creates a new dense or sparse Linexpr0 of the given size.
|
Linexpr0(Coeff[] term,
Coeff cst)
Creates a new dense Linexpr0 with the specified dimension
and constant coefficients.
|
Linexpr0(int size)
Creates a new dense Linexpr0 of the given size.
|
Linexpr0(Linexpr0 c)
Creates a copy of c.
|
Linexpr0(Linterm0[] term,
Coeff cst)
Creates a new sparse Linexpr0 with the specified dimension
and constant coefficient.
|
Modifier and Type | Method and Description |
---|---|
void |
addDimensions(Dimchange c)
Adds some dimensions and shifts coefficients accordingly .
|
Linexpr0 |
addDimensionsCopy(Dimchange c)
Returns a copy of the expression with some dimensions added.
|
Linexpr0 |
clone()
Returns a copy of this.
|
int |
cmp(Linexpr0 x)
Compares this and x with a lexicographic ordering.
|
boolean |
equals(java.lang.Object x)
Whether x is a Linexpr0 and structurally equal to this.
|
protected void |
finalize()
Deallocates the underlying Apron object.
|
Coeff |
getCoeff(int dim)
Returns a copy of the coefficient of dimension dim.
|
Coeff[] |
getCoeffs()
Returns a copy of all dimension coefficients.
|
Coeff |
getCst()
Returns a copy of the constant coefficient.
|
Linterm0[] |
getLinterms()
Returns a copy of all dimensions coefficients.
|
int |
getSize()
Returns the size of the Linexpr0.
|
int |
hashCode()
Returns a hash of the expression.
|
boolean |
isEqual(Linexpr0 x)
Whether this and x have identical coefficients.
|
boolean |
isInteger(int intdim)
Whether the expression only depends on the integer-valued dimensions
(dimensions 0 to intdim-1).
|
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(int intdim)
Whether the expression only depends on real-valued dimensions
(dimensions intdim and greater).
|
boolean |
isSparse()
Whether the Linexpr0 is sparse or dense.
|
int |
maxDim()
Maximum dimension occurring in the expression + 1.
|
void |
minimize()
Simplifies the representation.
|
void |
permuteDimensions(Dimperm p)
Permutes some dimensions in the expression.
|
Linexpr0 |
permuteDimensionsCopy(Dimperm p)
Returns a copy of the expression with some dimensions permuted.
|
void |
resize(int size)
Changes the size of the Linexpr0.
|
void |
setCoeff(int dim,
Coeff c)
Sets the coefficient of dimension dim to c.
|
void |
setCoeff(Linterm0[] c)
Sets several dimension coefficients at the same time.
|
void |
setCst(Coeff c)
Sets the constant coefficient to c.
|
java.lang.String |
toString()
Returns a string representation of the expression.
|
java.lang.String |
toString(java.lang.String[] names) |
java.lang.String |
toString(Var[] names)
Returns a string representation of the expression.
|
public Linexpr0()
public Linexpr0(int size)
All coefficient are initially set to 0.
public Linexpr0(boolean sparse, int size)
All coefficient are initially set to 0.
public Linexpr0(Linexpr0 c)
All coefficients are copied.
public Linexpr0(Linterm0[] term, Coeff cst)
All coefficients are copied.
protected void finalize()
finalize
in class java.lang.Object
public void setCoeff(int dim, Coeff c)
Trying to set a dimension greater than the size is an error for a dense Linexpr0. For sparse Linexpr0, if there is no coefficient for dim, one is created.
dim must be positive.
The coefficient is copied.
public void setCst(Coeff c)
The coefficient is copied.
public void setCoeff(Linterm0[] c)
All coefficients are copied.
public Coeff getCoeff(int dim)
dim must be positive.
public Coeff getCst()
public Linterm0[] getLinterms()
The array is sorted in increasing order of dimension. For sparse Linexpr0, some dimensions may be missing.
public Coeff[] getCoeffs()
public int getSize()
The size is fixed at creation time for dense Linexpr0, but changes dynamically for sparse Linexpr0.
public int maxDim()
public java.lang.String toString()
Dimension i is denoted as xi.
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String[] names)
public java.lang.String toString(Var[] names)
Dimension i is denoted by names[i].
public int hashCode()
hashCode
in class java.lang.Object
public boolean isSparse()
public boolean isInteger(int intdim)
public boolean isReal(int intdim)
public boolean isLinear()
public boolean isQuasilinear()
public boolean isEqual(Linexpr0 x)
public int cmp(Linexpr0 x)
public void resize(int size)
Added coefficients are set to 0.
public void minimize()
Transforms intervals into scalars when possible (when their bounds are equal). For sparse Linexpr0, also removes zero coefficients.
public void addDimensions(Dimchange c)
public void permuteDimensions(Dimperm p)
public Linexpr0 addDimensionsCopy(Dimchange c)
this is not changed.
public Linexpr0 permuteDimensionsCopy(Dimperm p)
this is not changed.
public Linexpr0 clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object