hmt-0.20: Haskell Music Theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Array.Square

Description

Square arrays, where the number of rows and columns are equal.

Synopsis

Documentation

type Square t = [[t]] Source #

Square as list of lists.

sq_map :: (t -> t) -> Square t -> Square t Source #

Squares are functors

sq_scale :: Num t => t -> Square t -> Square t Source #

sq_map of * n

sq_zip :: (t -> t -> t) -> Square t -> Square t -> Square t Source #

f pointwise at two squares (of equal size, un-checked)

sq_mul :: Num t => Square t -> Square t -> Square t Source #

sq_add :: Num t => Square t -> Square t -> Square t Source #

sq_is_square :: Square t -> Bool Source #

Predicate to determine if Square is actually square.

type Square_Linear t = [t] Source #

Square as row order list

sq_from_list :: Int -> Square_Linear t -> Square t Source #

Given degree of square, form Square from Square_Linear.

sq_is_linear_square :: Square_Linear t -> Bool Source #

True if list can form a square, ie. if length is a square.

sq_is_linear_square T.a126710 == True

sq_linear_degree :: Square_Linear t -> Int Source #

Calculate degree of linear square, ie. square root of length.

sq_linear_degree T.a126710 == 4

sq_transpose :: Square t -> Square t Source #

Type specialised transpose

sq_diagonals_ul_lr :: Square t -> Square t Source #

Full upper-left (ul) to lower-right (lr) diagonals of a square.

sq = sq_from_list 4 T.a126710
sq_wr $ sq
sq_wr $ sq_diagonals_ul_lr sq
sq_wr $ sq_diagonals_ll_ur sq
sq_undiagonals_ul_lr (sq_diagonals_ul_lr sq) == sq
sq_undiagonals_ll_ur (sq_diagonals_ll_ur sq) == sq
sq_diagonal_ul_lr sq == sq_diagonals_ul_lr sq !! 0
sq_diagonal_ll_ur sq == sq_diagonals_ll_ur sq !! 0

sq_diagonals_ll_ur :: Square t -> Square t Source #

Full lower-left (ll) to upper-right (ur) diagonals of a square.

sq_undiagonals_ul_lr :: Square t -> Square t Source #

Inverse of diagonals_ul_lr

sq_undiagonals_ll_ur :: Square t -> Square t Source #

Inverse of diagonals_ll_ur

sq_diagonal_ul_lr :: Square t -> [t] Source #

Main diagonal (upper-left -> lower-right)

sq_diagonal_ll_ur :: Square t -> [t] Source #

Main diagonal (lower-left -> upper-right)

sq_h_reflection :: Square t -> Square t Source #

Horizontal reflection (ie. map reverse).

sq = sq_from_list 4 T.a126710
sq_wr $ sq
sq_wr $ sq_h_reflection sq

sq_is_normal :: Integral n => Square n -> Bool Source #

An n×n square is normal if it has the elements (1 .. n×n).

sq_sums :: Num n => Square n -> ([n], [n], [n], [n]) Source #

Sums of (rows, columns, left-right-diagonals, right-left-diagonals)

PP

sq_wr :: Show t => Square t -> IO () Source #

sq_wr_m :: Show t => String -> Square (Maybe t) -> IO () Source #

Square Map

type Square_Ix = Ix Int Source #

(row,column) index.

type Square_Map t = Map Square_Ix t Source #

Map from Square_Ix to value.

sqm_ix :: Square_Map t -> Square_Ix -> t Source #

Alias for !

sqm_to_partial_sq :: Int -> Square_Map t -> [Square_Ix] -> Square (Maybe t) Source #

Make a Square of dimension dm that has elements from m at indicated indices, else Nothing.

TRS SEQ