Package de.tilman_neumann.jml.partitions
Class Mpi_IntegerArrayImpl
java.lang.Object
de.tilman_neumann.jml.partitions.Mpi_IntegerArrayImpl
- 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<=indexint
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<=indexMpi[]
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
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() -
getCardinality
public int getCardinality()- Specified by:
getCardinality
in interfaceMpi
- 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<=indexsetElem
public void setElem(int index, int value)Description copied from interface:Mpi
Sets the entry of the given index, with 0<=indexfirstNonZeroPartIndex
public int firstNonZeroPartIndex()- Specified by:
firstNonZeroPartIndex
in interfaceMpi
- Returns:
- the index of the first non-zero entry
subtract
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.complement
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 interfaceMpi
- Parameters:
other
- a multipartite integer that has no element greater than the corresponding element of this- Returns:
- this - other
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.maxNextPart
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 interfaceMpi
- Returns:
- min(lastPart, lower(this - firstPart))
compareTo
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].hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
iterator
public java.util.Iterator<java.lang.Integer> iterator()- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Integer>
-