Partition
: describes an unordered partition of the integers \(\{1,...,n\}\),
Sequence
: describes a lazily evaluated sequence of elements, with 1-based vpi (big integer) indices
msg
: Prints a diagnostic message
Bases: replab.Str
Represents an unordered partition of the set {1..n}
into disjoint subsets
The subsets, or blocks, are represented by sorted integer row vectors. The subsets themselves are sorted by their minimal element.
Class members list
Properties
blockIndex
– Index of the block for each element
blocks
– List of blocks
n
– Domain size
Prettyprinting
additionalFields
– Returns the name/value pairs corresponding to additional fields to be printed
disp
– Standard MATLAB/Octave display method
headerStr
– Tiny single line description of the current object type
hiddenFields
– Returns the names of the fields that are not printed as a row vector
longStr
– Multi-line description of the current object
shortStr
– Single line text description of the current object
General
Partition
– Constructs a Partition from blockIndex and list of blocks
check
– Verifies the sanity of this partition
finest
– Constructs the partition of n
singleton blocks
fromApproximateVector
– Returns the partition that groups approximately equal coefficients of a vector
fromBlocks
– Constructs a partition from disjoint blocks
fromVector
– Returns the partition that groups equal coefficients of a vector
permutationsOrbits
– Returns the partition of the domain 1...N
into orbits
restrictedToBlocks
– Returns the partition containing only the given blocks
singletons
– Returns a set of all points that are singletons of this partition
trivial
– Constructs the trivial partition with a single block of given cardinality
Properties
block
– Returns the i
-th subset in this partition
blockSize
– Returns the size of the i
-th block
blockSizes
– Returns the sizes of blocks
nBlocks
– Returns the number of subsets/blocks in this partition
Comparison
eq
– Checks if this partition is equal to another partition
ge
– Returns whether the given partition is finer than this partition
gt
– Returns whether the given partition is strictly finer than this partition
join
– Returns the finest common coarsening of two partitions
le
– Returns whether the given partition is coarser than this partition
lt
– Returns whether the given partition is strictly coarser than this partition
meet
– Returns the common refinement of two partitions
ne
– Checks if this partition differs to another partition
Inherited elements
Documentation in replab.Str.additionalFields()
Documentation in replab.Str.disp()
Documentation in replab.Str.headerStr()
Documentation in replab.Str.hiddenFields()
Documentation in replab.Str.longStr()
Documentation in replab.Str.shortStr()
Index of the block for each element
integer(1, n)
List of blocks
cell(1,*) of integer(1,*)
Domain size
integer
Constructs a Partition from blockIndex and list of blocks
Do not use this function direclty, rather use another
constructor such as .fromBlocks
.
blockIndex –
blocks (cell(1,*) of integer(1,*)
) – Disjoint blocks
The partition
See also
Returns the i
-th subset in this partition
i (integer
) – Block index
Subset
integer(1,*)
Returns the size of the i
-th block
i (integer
) – Block index
Size of the i
-th block in this partition
integer
Returns the sizes of blocks
block sizes
integer(1,*)
Verifies the sanity of this partition
Checks if this partition is equal to another partition
rhs (Partition
) – Another partition
True is both partitions are equal
logical
Constructs the partition of n
singleton blocks
n (integer
) – Size of the partition and number of blocks
Partition
Returns the partition that groups approximately equal coefficients of a vector
Example
>>> replab.Partition.fromApproximateVector([0.1 0.2 0.9 1 0.3], 0.11)
Partition '125|34'
blockIndex: [1, 1, 2, 2, 1]
blocks: {[1, 2, 5], [3, 4]}
n: 5
vec (double(1,*), real
) – Vector to group the coefficients of
tol (double
) – Tolerance
Partition of blocks with approximately equal coefficients
Constructs a partition from disjoint blocks
The blocks will be sorted and reorganized.
Example
>>> replab.Partition.fromBlocks({[1 2 5] [3 4]})
Partition '125|34'
blockIndex: [1, 1, 2, 2, 1]
blocks: {[1, 2, 5], [3, 4]}
n: 5
blocks (cell(1,*) of integer(1,*)
) – Disjoint blocks
Constructed partition
Returns the partition that groups equal coefficients of a vector
Example
>>> replab.Partition.fromVector([0 0 1 1 0])
Partition '125|34'
blockIndex: [1, 1, 2, 2, 1]
blocks: {[1, 2, 5], [3, 4]}
n: 5
vec (double(1,*)
) – Vector to group the coefficients of
Partition of blocks with equal coefficients
Returns whether the given partition is finer than this partition
rhs (Partition
) – Partition to compare this one with
True if every block of the given partition is a subset of a block of this partition
logical
Returns whether the given partition is strictly finer than this partition
rhs (Partition
) – Partition to compare this one with
True if self >= rhs
and self ~= rhs
logical
Returns the finest common coarsening of two partitions
Returns whether the given partition is coarser than this partition
rhs (Partition
) – Partition to compare this one with
True if every block of this partition is a subset of a block of the given partition
logical
Returns whether the given partition is strictly coarser than this partition
This is a strict version of le
rhs (Partition
) – Partition to compare this one with
True if self <= rhs
and self ~= rhs
logical
Returns the common refinement of two partitions
Returns the number of subsets/blocks in this partition
Number of blocks
integer
Checks if this partition differs to another partition
rhs (Partition
) – Another partition
True is both partitions differ
logical
Returns the partition of the domain 1...N
into orbits
permutations (integer(nG, d)
) – Permutations given as rows in a matrix
Partition containing the orbits
Returns the partition containing only the given blocks
The selected blocks are ordered
Returns a set of all points that are singletons of this partition
The singletons are the blocks of size 1.
Set of points
integer(1,*)
Bases: replab.Domain
Describes a sequence of elements
See https://en.wikipedia.org/wiki/Sequence .
Our indices are (bounded) integers, represented by vpi
instances.
The sequence supports element indexing and searching for elements.
Class members list
Properties
nElements
– Number of elements contained in this enumerator
Prettyprinting
additionalFields
– Returns the name/value pairs corresponding to additional fields to be printed
disp
– Standard MATLAB/Octave display method
headerStr
– Tiny single line description of the current object type
hiddenFields
– Returns the names of the fields that are not printed as a row vector
longStr
– Multi-line description of the current object
shortStr
– Single line text description of the current object
Property cache
cache
– Sets the value of the designated property in the cache
cached
– Returns the cached property if it exists, computing it if necessary
cachedOrDefault
– Returns the cached property if it exists, or the provided default value if it is unknown yet
cachedOrEmpty
– Returns the cached property if it exists, or []
if it is unknown yet
inCache
– Returns whether the value of the given property has already been computed
Laws
check
– Checks the consistency of this object
checkAndContinue
– Checks the consistency of this object
laws
– Returns the laws that this object obeys
Unique ID
eq
– Equality test
id
– Returns the unique ID of this object (deprecated)
isequal
– Equality test
ne
– Non-equality test
Test helpers
assertEqv
– Compares two elements for equality
assertNotEqv
– Compares two elements for inequality
Sampling and equality test
Domain construction
lambda
– Constructs an indexed family from function handles
General
Inherited elements
No documentation
Documentation in replab.Str.additionalFields()
Documentation in replab.Domain.assertEqv()
Documentation in replab.Domain.assertNotEqv()
Documentation in replab.Obj.cache()
Documentation in replab.Obj.cached()
Documentation in replab.Obj.cachedOrDefault()
Documentation in replab.Obj.cachedOrEmpty()
Documentation in replab.Obj.check()
Documentation in replab.Obj.checkAndContinue()
Documentation in replab.Str.disp()
Documentation in replab.Obj.eq()
Documentation in replab.Domain.eqv()
Documentation in replab.Str.headerStr()
Documentation in replab.Str.hiddenFields()
Documentation in replab.Obj.id()
No documentation
Documentation in replab.Obj.inCache()
Documentation in replab.Obj.isequal()
Documentation in replab.Obj.laws()
Documentation in replab.Str.longStr()
Documentation in replab.Obj.ne()
Documentation in replab.Domain.sample()
Documentation in replab.Str.shortStr()
Number of elements contained in this enumerator
vpi
Retrieves a element by position
Normally, RepLAB encodes big integers using the vpi
type. As a user convenience
(esp. on the command line), this method must also accept string and double arguments.
ind (vpi or double or string
) – Index of element to be retrieved, 1 <= ind
<= self.nElements
The element at the “ind” position
Returns the index of a given element
If the element is not part of the family, this returns vpi(0)
.
obj – Element to retrieve
1-based index of the given element
vpi
Constructs an indexed family from function handles
nElements (vpi
) – Size of the indexed family, so that the index set is 1..``nElements``
atFun (function_handle
) – Handle that implements the at
method
To simplify implementation, it is guaranteed
that atFun
will receive an argument of type vpi
.
findFun (function_handle
) – Handle that implements the find
method
The constructed indexed family
Returns a row cell array containing all elements of this family
A cell array C
such that C{i} = self.at(i)
row cell array of elements
An error if the enumerator is too big and the elements cannot fit in a cell array.
–
Displays a diagnostic message on the console output
Additional arguments can be function handles, to be evaluated only when the message is actually displayed.
level (integer
) – Verbosity level beginning at which to show the message (see replab.globals.verbosity
)
message (charstring
) – Message to display, can include sprintf-style formatting directives