Class Linexpr0
- All Implemented Interfaces:
Serializable
,Cloneable
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.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLinexpr0()
Creates a new empty sparse Linexpr0.Linexpr0
(boolean sparse, int size) Creates a new dense or sparse Linexpr0 of the given size.Linexpr0
(int size) Creates a new dense Linexpr0 of the given size.Creates a new dense Linexpr0 with the specified dimension and constant coefficients.Creates a copy of c.Creates a new sparse Linexpr0 with the specified dimension and constant coefficient. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds some dimensions and shifts coefficients accordingly .Returns a copy of the expression with some dimensions added.clone()
Returns a copy of this.int
Compares this and x with a lexicographic ordering.boolean
Whether x is a Linexpr0 and structurally equal to this.protected void
finalize()
Deallocates the underlying Apron object.getCoeff
(int dim) Returns a copy of the coefficient of dimension dim.Coeff[]
Returns a copy of all dimension coefficients.getCst()
Returns a copy of the constant coefficient.Linterm0[]
Returns a copy of all dimensions coefficients.int
getSize()
Returns the size of the Linexpr0.int
hashCode()
Returns a hash of the expression.boolean
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
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
Permutes some dimensions in the expression.Returns a copy of the expression with some dimensions permuted.void
resize
(int size) Changes the size of the Linexpr0.void
Sets the coefficient of dimension dim to c.void
Sets several dimension coefficients at the same time.void
Sets the constant coefficient to c.toString()
Returns a string representation of the expression.Returns a string representation of the expression.
-
Constructor Details
-
Linexpr0
public Linexpr0()Creates a new empty sparse Linexpr0. -
Linexpr0
public Linexpr0(int size) Creates a new dense Linexpr0 of the given size.All coefficient are initially set to 0.
-
Linexpr0
public Linexpr0(boolean sparse, int size) Creates a new dense or sparse Linexpr0 of the given size.All coefficient are initially set to 0.
-
Linexpr0
Creates a copy of c.All coefficients are copied.
-
Linexpr0
Creates a new sparse Linexpr0 with the specified dimension and constant coefficient.All coefficients are copied.
-
Linexpr0
Creates a new dense Linexpr0 with the specified dimension and constant coefficients.The Linexpr0 has the same size as the term array.
Dimension i gets coefficient term[i].
All coefficients are copied.
-
-
Method Details
-
finalize
protected void finalize()Deallocates the underlying Apron object. -
setCoeff
Sets the coefficient of dimension dim to 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.
-
setCst
Sets the constant coefficient to c.The coefficient is copied.
-
setCoeff
Sets several dimension coefficients at the same time.All coefficients are copied.
-
getCoeff
Returns a copy of the coefficient of dimension dim.dim must be positive.
-
getCst
Returns a copy of the constant coefficient. -
getLinterms
Returns a copy of all dimensions coefficients.The array is sorted in increasing order of dimension. For sparse Linexpr0, some dimensions may be missing.
-
getCoeffs
Returns a copy of all dimension coefficients. -
getSize
public int getSize()Returns the size of the Linexpr0.The size is fixed at creation time for dense Linexpr0, but changes dynamically for sparse Linexpr0.
-
maxDim
public int maxDim()Maximum dimension occurring in the expression + 1. -
toString
Returns a string representation of the expression.Dimension i is denoted as xi.
-
toString
-
toString
Returns a string representation of the expression.Dimension i is denoted by names[i].
-
hashCode
public int hashCode()Returns a hash of the expression. -
isSparse
public boolean isSparse()Whether the Linexpr0 is sparse or dense. -
isInteger
public boolean isInteger(int intdim) Whether the expression only depends on the integer-valued dimensions (dimensions 0 to intdim-1). -
isReal
public boolean isReal(int intdim) Whether the expression only depends on real-valued dimensions (dimensions intdim and greater). -
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. -
cmp
Compares this and x with a lexicographic ordering. -
resize
public void resize(int size) Changes the size of the Linexpr0.Added coefficients are set to 0.
-
minimize
public void minimize()Simplifies the representation.Transforms intervals into scalars when possible (when their bounds are equal). For sparse Linexpr0, also removes zero coefficients.
-
addDimensions
Adds some dimensions and shifts coefficients accordingly . -
permuteDimensions
Permutes some dimensions in the expression. -
addDimensionsCopy
Returns a copy of the expression with some dimensions added.this is not changed.
-
permuteDimensionsCopy
Returns a copy of the expression with some dimensions permuted.this is not changed.
-
clone
Returns a copy of this. -
equals
Whether x is a Linexpr0 and structurally equal to this.
-