CDTK.Tools.Iterators module

class CDTK.Tools.Iterators.MultiCombination(n, m)[source]

Bases: object

Iterate over all possible combinations of n indices taken in groups of m

next()[source]
class CDTK.Tools.Iterators.MultiCounter(length=1, maxiter=1)[source]

Bases: object

Emulate the behaviour of multiple nested do loops

Maintains a list of integers that evolve as the indexes of a nested “for” loop. It may be useful to construct nested “for” loops from which the number of nested elements is not known at programming time, but at execution time.

getLimits()[source]

return the list of limits

getPointers()[source]

return the list of pointers

increase()[source]

increase the list of pointers return 0 if the end is reached return 1 if succeed

next()[source]

Increase the pointers vector and return it

reset()[source]

reset the iterator to the initial state

setLimits(l)[source]

set the list of index limits from a given list

setLimitsN(n=0, nd=1)[source]

set the list of initial limits to a given number N n – number at which the pointers are set nd – length of the vector

setMaxIter(l)[source]

set the list of maximum iterations per index

setMaxIterN(n=1, nd=1)[source]

set the list of initial limits to a given number N n – number at which the pointers are set nd – length of the vector

setPointers(p)[source]

set the list of initial pointers from a given list

setPointersN(n=0, nd=1)[source]

set the list of initial pointers to a given number N n – number at which the pointers are set nd – length of the vector

CDTK.Tools.Iterators.decreaseTuple(t)[source]

Decrease in 1 the value at every position of a tuple

CDTK.Tools.Iterators.excitations(x, m, n=None, r=None)[source]

Generate excitation indices for x degrees of freedom up to m quanta

x – integer, number of degrees of freedom m – integer, maximum quanta of excitation —- n – tuple with maximum states per DOF (max states = max quanta + 1) r – reference tuple passed recursively returns an interator object.

CDTK.Tools.Iterators.excitationsN(x, m, n=None)[source]

Generate excitations exactly of m quanta for x degrees of freedom

x – integer, number of degrees of freedom m – integer, exact quanta of excitation —- n – tuple with maximum states per DOF (max states = max quanta + 1)

CDTK.Tools.Iterators.mapTuple(t1, t2)[source]

Return a new tuple with the elements of t1 mapped at the positions specified in t2