Package apron

Class Linexpr0

java.lang.Object
apron.Linexpr0
All Implemented Interfaces:
Serializable, Cloneable

public class Linexpr0 extends Object implements Cloneable, Serializable
Class of level 0 linear expressions.

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

    Constructors
    Constructor
    Description
    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.
    Linexpr0(Coeff[] term, Coeff cst)
    Creates a new dense Linexpr0 with the specified dimension and constant coefficients.
    Creates a copy of c.
    Linexpr0(Linterm0[] term, Coeff cst)
    Creates a new sparse Linexpr0 with the specified dimension and constant coefficient.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds some dimensions and shifts coefficients accordingly .
    Returns a copy of the expression with some dimensions added.
    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
    Deallocates the underlying Apron object.
    getCoeff(int dim)
    Returns a copy of the coefficient of dimension dim.
    Returns a copy of all dimension coefficients.
    Returns a copy of the constant coefficient.
    Returns a copy of all dimensions coefficients.
    int
    Returns the size of the Linexpr0.
    int
    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
    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
    Whether the Linexpr0 is sparse or dense.
    int
    Maximum dimension occurring in the expression + 1.
    void
    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
    setCoeff(int dim, Coeff c)
    Sets the coefficient of dimension dim to c.
    void
    Sets several dimension coefficients at the same time.
    void
    Sets the constant coefficient to c.
    Returns a string representation of the expression.
    toString(Var[] names)
    Returns a string representation of the expression.
    toString(String[] names)
     

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • 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

      public Linexpr0(Linexpr0 c)
      Creates a copy of c.

      All coefficients are copied.

    • Linexpr0

      public Linexpr0(Linterm0[] term, Coeff cst)
      Creates a new sparse Linexpr0 with the specified dimension and constant coefficient.

      All coefficients are copied.

    • Linexpr0

      public Linexpr0(Coeff[] term, Coeff cst)
      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.
      Overrides:
      finalize in class Object
    • setCoeff

      public void setCoeff(int dim, Coeff c)
      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

      public void setCst(Coeff c)
      Sets the constant coefficient to c.

      The coefficient is copied.

    • setCoeff

      public void setCoeff(Linterm0[] c)
      Sets several dimension coefficients at the same time.

      All coefficients are copied.

    • getCoeff

      public Coeff getCoeff(int dim)
      Returns a copy of the coefficient of dimension dim.

      dim must be positive.

    • getCst

      public Coeff getCst()
      Returns a copy of the constant coefficient.
    • getLinterms

      public Linterm0[] 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

      public Coeff[] 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

      public String toString()
      Returns a string representation of the expression.

      Dimension i is denoted as xi.

      Overrides:
      toString in class Object
    • toString

      public String toString(String[] names)
    • toString

      public String toString(Var[] names)
      Returns a string representation of the expression.

      Dimension i is denoted by names[i].

    • hashCode

      public int hashCode()
      Returns a hash of the expression.
      Overrides:
      hashCode in class Object
    • 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

      public boolean isEqual(Linexpr0 x)
      Whether this and x have identical coefficients.
    • cmp

      public int cmp(Linexpr0 x)
      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

      public void addDimensions(Dimchange c)
      Adds some dimensions and shifts coefficients accordingly .
    • permuteDimensions

      public void permuteDimensions(Dimperm p)
      Permutes some dimensions in the expression.
    • addDimensionsCopy

      public Linexpr0 addDimensionsCopy(Dimchange c)
      Returns a copy of the expression with some dimensions added.

      this is not changed.

    • permuteDimensionsCopy

      public Linexpr0 permuteDimensionsCopy(Dimperm p)
      Returns a copy of the expression with some dimensions permuted.

      this is not changed.

    • clone

      public Linexpr0 clone()
      Returns a copy of this.
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object x)
      Whether x is a Linexpr0 and structurally equal to this.
      Overrides:
      equals in class Object