sievetools.ResidueClass

Inheritance diagram of abjad.tools.sievetools.ResidueClass.ResidueClass.ResidueClass

class abjad.tools.sievetools.ResidueClass.ResidueClass.ResidueClass(*args)[source]

Residue class (or congruence class). Residue classes form the basis of Xenakis sieves. They can be used to construct any complex periodic integer (or boolean) sequence as a combination of simple periodic sequences.

Example from the opening of Xenakis’s Psappha for solo percussion:

abjad> from abjad.tools.sievetools import ResidueClass as RC

abjad> s1 = (RC(8, 0) | RC(8, 1) | RC(8, 7)) & (RC(5, 1) | RC(5, 3))
abjad> s2 = (RC(8, 0) | RC(8, 1) | RC(8, 2)) & RC(5, 0)
abjad> s3 = RC(8, 3)
abjad> s4 = RC(8, 4)
abjad> s5 = (RC(8, 5) | RC(8, 6)) & (RC(5, 2) | RC(5, 3) | RC(5, 4))
abjad> s6 = (RC(8, 1) & RC(5, 2))
abjad> s7 = (RC(8, 6) & RC(5, 1))

abjad> y = s1 | s2 | s3 | s4 | s5 | s6 | s7
abjad> y
{{{ResidueClass(8, 0) | ResidueClass(8, 1) | ResidueClass(8, 7)} & {ResidueClass(5, 1) | ResidueClass(5, 3)}} | {{ResidueClass(8, 0) | ResidueClass(8, 1) | ResidueClass(8, 2)} & ResidueClass(5, 0)} | ResidueClass(8, 3) | ResidueClass(8, 4) | {{ResidueClass(8, 5) | ResidueClass(8, 6)} & {ResidueClass(5, 2) | ResidueClass(5, 3) | ResidueClass(5, 4)}} | {ResidueClass(5, 2) & ResidueClass(8, 1)} | {ResidueClass(5, 1) & ResidueClass(8, 6)}}

abjad> y.get_congruent_bases(40)
    [0, 1, 3, 4, 6, 8, 10, 11, 12, 13, 14, 16, 17, 19, 20, 22, 23, 25, 27,
    28, 29, 31, 33, 35, 36, 37, 38, 40]
abjad> y.get_boolean_train(40)
    [1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0,
    1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0]

Return residue class.

Read-only Properties

ResidueClass.modulo[source]

Period of residue class.

ResidueClass.residue[source]

Residue of residue class.

Methods

ResidueClass.get_boolean_train(*min_max)[source]

Returns a boolean train with 0s mapped to the integers that are not congruent bases of the residue class and 1s mapped to those that are. The method takes one or two integer arguments. If only one is given, it is taken as the max range and the min is assumed to be 0.

Example:

abjad> from abjad.tools.sievetools import ResidueClass as RC

abjad> r = RC(3, 0)
abjad> r.get_boolean_train(6)
[1, 0, 0, 1, 0, 0]
abjad> r.get_congruent_bases(-6, 6)
[-6, -3, 0, 3, 6]

Return list.

ResidueClass.get_congruent_bases(*min_max)[source]

Returns all the congruent bases of this residue class within the given range. The method takes one or two integer arguments. If only one it given, it is taken as the max range and the min is assumed to be 0.

Example:

abjad> from abjad.tools.sievetools import ResidueClass as RC

abjad> r = RC(3, 0)
abjad> r.get_congruent_bases(6)
[0, 3, 6]
abjad> r.get_congruent_bases(-6, 6)
[-6, -3, 0, 3, 6]

Return list.

Special Methods

ResidueClass.__and__(arg)

Note

Inherited from sievetools._BaseResidueClass

ResidueClass.__delattr__()

x.__delattr__(‘name’) <==> del x.name

Note

Inherited from __builtin__.object

ResidueClass.__eq__(exp)[source]
ResidueClass.__ge__(expr)[source]
ResidueClass.__gt__(expr)[source]
ResidueClass.__hash__() <==> hash(x)

Note

Inherited from __builtin__.object

ResidueClass.__le__(expr)[source]
ResidueClass.__lt__(expr)[source]
ResidueClass.__ne__(expr)[source]
ResidueClass.__or__(arg)

Note

Inherited from sievetools._BaseResidueClass

ResidueClass.__repr__()[source]
ResidueClass.__setattr__()

x.__setattr__(‘name’, value) <==> x.name = value

Note

Inherited from __builtin__.object

ResidueClass.__str__() <==> str(x)

Note

Inherited from __builtin__.object

ResidueClass.__xor__(arg)

Note

Inherited from sievetools._BaseResidueClass

Table Of Contents

This Page