hmt-0.16: Haskell Music Theory

Safe HaskellSafe
LanguageHaskell98

Music.Theory.Array

Contents

Synopsis

Association List (List Array)

larray_bounds :: Ord k => [(k, v)] -> (k, k) Source #

larray :: Ix k => [(k, v)] -> Array k v Source #

List Table

make_regular :: t -> [[t]] -> [[t]] Source #

Append a sequence of nil (or default) values to each row of tbl so to make it regular (ie. all rows of equal length).

Matrix Indices

type Dimensions i = (i, i) Source #

Matrix dimensions are written (rows,columns).

type Ix i = (i, i) Source #

Matrix indices are written (row,column) & are here _zero_ indexed.

ix_translate :: Num t => (t, t) -> Ix t -> Ix t Source #

Translate Ix by row and column delta.

ix_translate (1,2) (3,4) == (4,6)

ix_modulo :: Integral t => Dimensions t -> Ix t -> Ix t Source #

Modulo Ix by Dimensions.

ix_modulo (4,4) (3,7) == (3,3)

row_indices :: (Enum t, Num t) => t -> t -> [Ix t] Source #

Given number of columns and row index, list row indices.

row_indices 3 1 == [(1,0),(1,1),(1,2)]

column_indices :: (Enum t, Num t) => t -> t -> [Ix t] Source #

Given number of rows and column index, list column indices.

column_indices 3 1 == [(0,1),(1,1),(2,1)]

matrix_indices :: (Enum t, Num t) => Dimensions t -> [Ix t] Source #

All zero-indexed matrix indices, in row order. This is the order given by sort.

matrix_indices (2,3) == [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]
sort (matrix_indices (2,3)) == matrix_indices (2,3)

matrix_corner_indices :: Num t => Dimensions t -> [Ix t] Source #

Corner indices of given Dimensions, in row order.

matrix_corner_indices (2,3) == [(0,0),(0,2),(1,0),(1,2)]

parallelogram_corner_indices :: Num t => (Dimensions t, t) -> [Ix t] Source #

Parallelogram corner indices, given as rectangular Dimensions with an offset for the lower indices.

parallelogram_corner_indices ((2,3),2) == [(0,0),(0,2),(1,2),(1,4)]

all_ix_translations :: Integral t => Dimensions t -> [Ix t] -> [[Ix t]] Source #

Apply ix_modulo and ix_translate for all matrix_indices, ie. all translations of a shape in row order. The resulting Ix sets are not sorted and may have duplicates.

concat (all_ix_translations (2,3) [(0,0)]) == matrix_indices (2,3)

all_ix_translations_uniq :: Integral t => Dimensions t -> [Ix t] -> [[Ix t]] Source #

Sort sets into row order and remove duplicates.