Package de.tilman_neumann.jml.partitions
Class Mpi_IntegerArrayImpl
- java.lang.Object
-
- de.tilman_neumann.jml.partitions.Mpi_IntegerArrayImpl
-
- All Implemented Interfaces:
Mpi,Comparable<Mpi>,Iterable<Integer>
- Direct Known Subclasses:
PrimePowers_DefaultImpl
public class Mpi_IntegerArrayImpl extends Object implements Mpi
int[] implementation of a multipartite number like [1,3,4,2,0,1].- Author:
- Tilman Neumann
-
-
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(String str)Constructor from a comma-separated string of values.Mpi_IntegerArrayImpl(Collection<Integer> values)Constructor from value collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Mpi other)Compare this with another multipartite integer.Mpicomplement(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.booleanequals(Object obj)intfirstNonZeroPartIndex()intgetCardinality()intgetDim()intgetElem(int index)Returns the entry of the given index, with 0<=indexinthashCode()Iterator<Integer>iterator()MpimaxNextPart(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.voidsetElem(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.StringtoString()-
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 Detail
-
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(Collection<Integer> values)
Constructor from value collection.- Parameters:
values-
-
Mpi_IntegerArrayImpl
public Mpi_IntegerArrayImpl(Mpi original)
Copy constructor.- Parameters:
original-
-
Mpi_IntegerArrayImpl
public Mpi_IntegerArrayImpl(String str)
Constructor from a comma-separated string of values.- Parameters:
str-
-
-
Method Detail
-
getDim
public int getDim()
-
getCardinality
public int getCardinality()
- Specified by:
getCardinalityin 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:MpiReturns the entry of the given index, with 0<=index-
setElem
public void setElem(int index, int value)Description copied from interface:MpiSets the entry of the given index, with 0<=index-
firstNonZeroPartIndex
public int firstNonZeroPartIndex()
- Specified by:
firstNonZeroPartIndexin interfaceMpi- Returns:
- the index of the first non-zero entry
-
subtract
public Mpi[] subtract(Mpi other)
Description copied from interface:MpiReturns the pair [lower, upper] of consecutive subvalues of this (according to the ordering relation) such that lower + other <= this and upper + other >= this.
-
complement
public Mpi complement(Mpi other)
Description copied from interface:MpiLike subtract() but when we know that other fits piece-wise into this. That means faster ;)- Specified by:
complementin interfaceMpi- 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:MpiComputes 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
public Mpi maxNextPart(Mpi firstPart, Mpi lastPart)
Description copied from interface:MpiSpecial operation computing the biggest allowed subvalue of this that is not greater than lastPart and not greater than this-firstPart.- Specified by:
maxNextPartin interfaceMpi- Returns:
- min(lastPart, lower(this - firstPart))
-
compareTo
public int compareTo(Mpi other)
Description copied from interface:MpiCompare this with another multipartite integer. The first element that differs decides, i.e. [2,0,0] is bigger than [1,2,3].- Specified by:
compareToin interfaceComparable<Mpi>- Specified by:
compareToin interfaceMpi
-
-
-
-