Class Mpi_IntegerArrayImpl

java.lang.Object
de.tilman_neumann.jml.partitions.Mpi_IntegerArrayImpl
All Implemented Interfaces:
Mpi, java.lang.Comparable<Mpi>, java.lang.Iterable<java.lang.Integer>
Direct Known Subclasses:
PrimePowers_DefaultImpl

public class Mpi_IntegerArrayImpl
extends java.lang.Object
implements Mpi
int[] implementation of a multipartite number like [1,3,4,2,0,1].
  • Constructor Summary

    Constructors
    Constructor Description
    Mpi_IntegerArrayImpl​(int dim)
    Constructor for zero-initialized mpi with dim entries.
    Mpi_IntegerArrayImpl​(int[] values)
    Constructor from element array, with element copy.
    Mpi_IntegerArrayImpl​(Mpi original)
    Copy constructor.
    Mpi_IntegerArrayImpl​(java.lang.String str)
    Constructor from a comma-separated string of values.
    Mpi_IntegerArrayImpl​(java.util.Collection<java.lang.Integer> values)
    Constructor from value collection.
  • Method Summary

    Modifier and Type Method Description
    int compareTo​(Mpi other)
    Compare this with another multipartite integer.
    Mpi complement​(Mpi other)
    Like subtract() but when we know that other fits piece-wise into this.
    Mpi[] div2()
    Computes a kind of division by 2 of this.
    boolean equals​(java.lang.Object obj)  
    int firstNonZeroPartIndex()  
    int getCardinality()  
    int getDim()  
    int getElem​(int index)
    Returns the entry of the given index, with 0<=index
    int hashCode()  
    java.util.Iterator<java.lang.Integer> iterator()  
    Mpi maxNextPart​(Mpi firstPart, Mpi lastPart)
    Special operation computing the biggest allowed subvalue of this that is not greater than lastPart and not greater than this-firstPart.
    void setElem​(int index, int value)
    Sets the entry of the given index, with 0<=index
    Mpi[] subtract​(Mpi other)
    Returns the pair [lower, upper] of consecutive subvalues of this (according to the ordering relation) such that lower + other <= this and upper + other >= this.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • Mpi_IntegerArrayImpl

      public Mpi_IntegerArrayImpl​(int dim)
      Constructor for zero-initialized mpi with dim entries.
      Parameters:
      dim -
    • Mpi_IntegerArrayImpl

      public Mpi_IntegerArrayImpl​(int[] values)
      Constructor from element array, with element copy.
      Parameters:
      values -
    • Mpi_IntegerArrayImpl

      public Mpi_IntegerArrayImpl​(java.util.Collection<java.lang.Integer> values)
      Constructor from value collection.
      Parameters:
      values -
    • Mpi_IntegerArrayImpl

      public Mpi_IntegerArrayImpl​(Mpi original)
      Copy constructor.
      Parameters:
      original -
    • Mpi_IntegerArrayImpl

      public Mpi_IntegerArrayImpl​(java.lang.String str)
      Constructor from a comma-separated string of values.
      Parameters:
      str -
  • Method Details

    • getDim

      public int getDim()
      Specified by:
      getDim in interface Mpi
      Returns:
      dimension of the multipartite number, it's "partiteness"
    • getCardinality

      public int getCardinality()
      Specified by:
      getCardinality in interface Mpi
      Returns:
      total number of entries = the sum of the elements of this multipartite number
    • getElem

      public int getElem​(int index)
      Description copied from interface: Mpi
      Returns the entry of the given index, with 0<=index
      Specified by:
      getElem in interface Mpi
      Returns:
      entry at index 'index'
    • setElem

      public void setElem​(int index, int value)
      Description copied from interface: Mpi
      Sets the entry of the given index, with 0<=index
      Specified by:
      setElem in interface Mpi
    • firstNonZeroPartIndex

      public int firstNonZeroPartIndex()
      Specified by:
      firstNonZeroPartIndex in interface Mpi
      Returns:
      the index of the first non-zero entry
    • subtract

      public Mpi[] subtract​(Mpi other)
      Description copied from interface: Mpi
      Returns the pair [lower, upper] of consecutive subvalues of this (according to the ordering relation) such that lower + other <= this and upper + other >= this.
      Specified by:
      subtract in interface Mpi
      Returns:
      the lower and upper bound of this - other
    • complement

      public Mpi complement​(Mpi other)
      Description copied from interface: Mpi
      Like subtract() but when we know that other fits piece-wise into this. That means faster ;)
      Specified by:
      complement in interface Mpi
      Parameters:
      other - a multipartite integer that has no element greater than the corresponding element of this
      Returns:
      this - other
    • div2

      public Mpi[] div2()
      Description copied from interface: Mpi
      Computes a kind of division by 2 of this. The result is a pair of [lower, upper] values with lower + upper = this (element-wise addition) and lower<=upper.
      Specified by:
      div2 in interface Mpi
      Returns:
      [lower, upper]
    • maxNextPart

      public Mpi maxNextPart​(Mpi firstPart, Mpi lastPart)
      Description copied from interface: Mpi
      Special operation computing the biggest allowed subvalue of this that is not greater than lastPart and not greater than this-firstPart.
      Specified by:
      maxNextPart in interface Mpi
      Returns:
      min(lastPart, lower(this - firstPart))
    • compareTo

      public int compareTo​(Mpi other)
      Description copied from interface: Mpi
      Compare this with another multipartite integer. The first element that differs decides, i.e. [2,0,0] is bigger than [1,2,3].
      Specified by:
      compareTo in interface java.lang.Comparable<Mpi>
      Specified by:
      compareTo in interface Mpi
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • iterator

      public java.util.Iterator<java.lang.Integer> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<java.lang.Integer>