hmt-0.16: Haskell Music Theory

Safe HaskellSafe
LanguageHaskell98

Music.Theory.Z.Read_1978

Contents

Description

Ronald C. Read. "Every one a winner or how to avoid isomorphism search when cataloguing combinatorial configurations." /Annals of Discrete Mathematics/ 2:107–20, 1978.

Synopsis

Documentation

type Code = Int Source #

Coding.

type Array = [Bool] Source #

Bit array.

array_pp :: Array -> String Source #

Pretty printer for Array.

parse_array :: String -> Array Source #

Parse PP of Array.

parse_array "01001" == [False,True,False,False,True]

array_to_code :: Array -> Code Source #

Generate Code from Array, the coding is most to least significant.

array_to_code (map toEnum [1,1,0,0,1,0,0,0,1,1,1,0,0]) == 6428

code_to_array :: Int -> Code -> Array Source #

Inverse of array_to_code.

code_to_array 13 6428 == map toEnum [1,1,0,0,1,0,0,0,1,1,1,0,0]

array_to_set :: Integral i => [Bool] -> [i] Source #

Array to set.

array_to_set (map toEnum [1,1,0,0,1,0,0,0,1,1,1,0,0]) == [0,1,4,8,9,10]
encode [0,1,4,8,9,10] == 1811

set_to_array :: Integral i => i -> [i] -> Array Source #

Inverse of array_to_set, z is the degree of the array.

set_to_code :: Integral i => i -> [i] -> Code Source #

array_to_code of set_to_array.

set_to_code 12 [0,2,3,5] == 2880
map (set_to_code 12) (T.z_ti_related (flip mod 12) [0,2,3,5])

array_complement :: Array -> Array Source #

Logical complement.

array_is_prime :: Array -> Bool Source #

The prime form is the maximum encoding.

array_is_prime (set_to_array 12 [0,2,3,5]) == False

array_augment :: Array -> [Array] Source #

The augmentation rule adds 1 in each empty slot at end of array.

map array_pp (array_augment (parse_array "01000")) == ["01100","01010","01001"]

enumerate_half :: (Array -> Bool) -> Int -> [(Int, [Array])] Source #

Enumerate first half of the set-classes under given prime function. The second half can be derived as the complement of the first.

import Music.Theory.Z12.Forte_1973
length scs == 224
map (length . scs_n) [0..12] == [1,1,6,12,29,38,50,38,29,12,6,1,1]
let z12 = map (fmap (map array_to_set)) (enumerate_half array_is_prime 12)
map (length . snd) z12 == [1,1,6,12,29,38,50]

This can become slow, edit z to find out. It doesn't matter about n. This can be edited so that small n would run quickly even for large z.

fmap (map array_to_set) (lookup 5 (enumerate_half array_is_prime 16))

Alternate (reverse) form.

encode :: Integral i => [i] -> Code Source #

Encoder for encode_prime.

encode [0,1,3,6,8,9] == 843

decode :: Integral i => i -> Code -> [i] Source #

Decoder for encode_prime.

decode 12 843 == [0,1,3,6,8,9]

encode_prime :: Integral i => Z i -> [i] -> [i] Source #

Binary encoding prime form algorithm, equalivalent to Rahn.

encode_prime Z.mod12 [0,1,3,6,8,9] == [0,2,3,6,7,9]
Music.Theory.Z12.Rahn_1980.rahn_prime [0,1,3,6,8,9] == [0,2,3,6,7,9]