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 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(Object obj)
int
firstNonZeroPartIndex()
int
getCardinality()
int
getDim()
int
getElem(int index)
Returns the entry of the given index, with 0<=indexint
hashCode()
Iterator<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.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 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:
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
-
setElem
public void setElem(int index, int value)
Description copied from interface:Mpi
-
firstNonZeroPartIndex
public int firstNonZeroPartIndex()
- Specified by:
firstNonZeroPartIndex
in interfaceMpi
- 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.
-
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 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: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
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 interfaceMpi
- 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 interfaceComparable<Mpi>
- Specified by:
compareTo
in interfaceMpi
-
-