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.
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.
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.
Note
Inherited from sievetools._BaseResidueClass
x.__delattr__(‘name’) <==> del x.name
Note
Inherited from __builtin__.object
Note
Inherited from __builtin__.object
Note
Inherited from sievetools._BaseResidueClass
x.__setattr__(‘name’, value) <==> x.name = value
Note
Inherited from __builtin__.object
Note
Inherited from __builtin__.object
Note
Inherited from sievetools._BaseResidueClass