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

Music.Theory.Metric.Polansky_1996

Description

Larry Polansky. "Morphological Metrics". Journal of New Music Research, 25(4):289-368, 1996.

Synopsis

Documentation

type Interval a n = a -> a -> n Source #

Distance function, ordinarily n below is in Num, Fractional or Real.

dif_i :: (Integral a, Num b) => a -> a -> b Source #

dif_r :: (Real a, Fractional b) => a -> a -> b Source #

abs_of :: Num n => Interval a n -> a -> a -> n Source #

abs . f.

sqr :: Num a => a -> a Source #

Square.

sqr_of :: Num n => Interval a n -> a -> a -> n Source #

sqr . f.

sqr_abs_of :: Num n => Interval a n -> a -> a -> n Source #

sqr . abs . f.

sqrt_abs_of :: Floating c => Interval a c -> a -> a -> c Source #

sqrt . abs . f.

city_block_metric :: Num n => Interval a n -> (a, a) -> (a, a) -> n Source #

City block metric, p.296

city_block_metric (-) (1,2) (3,5) == 2+3

euclidean_metric_2 :: Floating n => Interval a n -> (a, a) -> (a, a) -> n Source #

Two-dimensional euclidean metric, p.297.

euclidean_metric_2 (-) (1,2) (3,5) == sqrt (4+9)

euclidean_metric_l :: Floating c => Interval b c -> [b] -> [b] -> c Source #

n-dimensional euclidean metric

euclidean_metric_l (-) [1,2] [3,5] == sqrt (4+9)
euclidean_metric_l (-) [1,2,3] [2,4,6] == sqrt (1+4+9)

cbrt :: Floating a => a -> a Source #

Cube root.

map cbrt [1,8,27] == [1,2,3]

nthrt :: Floating a => a -> a -> a Source #

n-th root

map (nthrt 4) [1,16,81] == [1,2,3]

minkowski_metric_2 :: Floating a => Interval t a -> a -> (t, t) -> (t, t) -> a Source #

Two-dimensional Minkowski metric, p.297

minkowski_metric_2 (-) 1 (1,2) (3,5) == 5
minkowski_metric_2 (-) 2 (1,2) (3,5) == sqrt (4+9)
minkowski_metric_2 (-) 3 (1,2) (3,5) == cbrt (8+27)

minkowski_metric_l :: Floating a => Interval t a -> a -> [t] -> [t] -> a Source #

n-dimensional Minkowski metric

minkowski_metric_l (-) 2 [1,2,3] [2,4,6] == sqrt (1+4+9)
minkowski_metric_l (-) 3 [1,2,3] [2,4,6] == cbrt (1+8+27)

d_dx_abs :: Num n => Interval a n -> [a] -> [n] Source #

map abs . d_dx_by.

d_dx_abs (-) [0,2,4,1,0] == [2,2,3,1]
d_dx_abs (-) [2,3,0,4,1] == [1,3,4,3]

olm_no_delta' :: Fractional a => [a] -> [a] -> a Source #

Ordered linear magnitude (no delta), p.300

olm_no_delta' [0,2,4,1,0] [2,3,0,4,1] == 1.25

olm_general :: Fractional n => Interval a n -> [a] -> [a] -> n Source #

Ordered linear magintude (general form) p.302

olm_general (abs_of (-)) [0,2,4,1,0] [2,3,0,4,1] == 1.25
olm_general (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 4.6

type Delta n a = [n] -> Int -> a Source #

Delta (Δ) determines an interval given a sequence and an index.

ix_dif :: Interval a t -> Delta a t Source #

f at indices i and i+1 of x.

map (ix_dif (-) [0,1,3,6,10]) [0..3] == [-1,-2,-3,-4]

abs_ix_dif :: Num n => Interval a n -> Delta a n Source #

abs . ix_dif

map (abs_ix_dif (-) [0,2,4,1,0]) [0..3] == [2,2,3,1]

sqr_abs_ix_dif :: Num n => Interval a n -> Delta a n Source #

sqr . abs_ix_dif

map (sqr_abs_ix_dif (-) [0,2,4,1,0]) [0..3] == [4,4,9,1]
map (sqr_abs_ix_dif (-) [2,3,0,4,1]) [0..3] == [1,9,16,9]

type Psi a = a -> a -> a Source #

Psi (Ψ) joins Delta equivalent intervals from morphologies m and n.

olm :: Fractional a => Psi a -> Delta n a -> ([a] -> a) -> [n] -> [n] -> a Source #

Ordered linear magintude (generalised-interval form) p.305

olm (abs_of dif_r) (abs_ix_dif dif_r) (const 1) [1,5,12,2,9,6] [7,6,4,9,8,1] == 4.6
olm (abs_of dif_r) (abs_ix_dif dif_r) maximum [1,5,12,2,9,6] [7,6,4,9,8,1] == 0.46

olm_no_delta :: (Real a, Real n, Fractional n) => [a] -> [a] -> n Source #

olm_no_delta_squared :: Floating a => [a] -> [a] -> a Source #

second_order :: Num n => ([n] -> [n] -> t) -> [n] -> [n] -> t Source #

olm_no_delta_second_order :: (Real a, Fractional a) => [a] -> [a] -> a Source #

second_order_binonial_coefficient :: Fractional a => a -> a Source #

Second order binomial coefficient, p.307

map second_order_binonial_coefficient [2..10] == [1,3,6,10,15,21,28,36,45]

direction_interval :: Ord i => [i] -> [Ordering] Source #

d_dx_by of flip compare.

direction_interval [5,9,3,2] == [LT,GT,GT]
direction_interval [2,5,6,6] == [LT,LT,EQ]

ord_hist :: Integral t => [Ordering] -> (t, t, t) Source #

Histogram of list of Orderings.

ord_hist [LT,GT,GT] == (1,0,2)

direction_vector :: Integral i => Ord a => [a] -> (i, i, i) Source #

Histogram of directions of adjacent elements, p.312.

direction_vector [5,9,3,2] == (1,0,2)
direction_vector [2,5,6,6] == (2,1,0)

uld :: (Integral n, Ord a) => [a] -> [a] -> Ratio n Source #

Unordered linear direction, p.311 (Fig. 5)

uld [5,9,3,2] [2,5,6,6] == 2/3
uld [5,3,6,1,4] [3,6,1,4,2] == 0

old :: (Ord i, Integral a) => [i] -> [i] -> Ratio a Source #

Ordered linear direction, p.312

direction_interval [5,3,6,1,4] == [GT,LT,GT,LT]
direction_interval [3,6,1,4,2] == [LT,GT,LT,GT]
old [5,3,6,1,4] [3,6,1,4,2] == 1

ocd :: (Ord a, Integral i) => [a] -> [a] -> Ratio i Source #

Ordered combinatorial direction, p.314

ocd [5,9,3,2] [2,5,6,6] == 5/6
ocd [5,3,6,1,4] [3,6,1,4,2] == 4/5

ucd :: (Integral n, Ord a) => [a] -> [a] -> Ratio n Source #

Unordered combinatorial direction, p.314

ucd [5,9,3,2] [2,5,6,6] == 5/6
ucd [5,3,6,1,4] [3,6,1,4,2] == 0
ucd [5,3,7,6] [2,1,2,1] == 1/2
ucd [2,1,2,1] [8,3,5,4] == 1/3
ucd [5,3,7,6] [8,3,5,4] == 1/3

combinatorial_magnitude_matrix :: Interval a n -> [a] -> [[n]] Source #

half_matrix_f, Fig.9, p.318

let r = [[2,3,1,4],[1,3,6],[4,7],[3]]
combinatorial_magnitude_matrix (abs_of (-)) [5,3,2,6,9] == r

ulm_simplified :: Fractional n => Interval a n -> [a] -> [a] -> n Source #

Unordered linear magnitude (simplified), p.320-321

let r = abs (sum [5,4,3,6] - sum [12,2,11,7]) / 4
ulm_simplified (abs_of (-)) [1,6,2,5,11] [3,15,13,2,9] == r
ulm_simplified (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 3

ocm_zcm :: Fractional n => Interval a n -> [a] -> [a] -> (n, n, [n]) Source #

ocm :: Fractional n => Interval a n -> [a] -> [a] -> n Source #

Ordered combinatorial magnitude (OCM), p.323

ocm (abs_of (-)) [1,6,2,5,11] [3,15,13,2,9] == 5.2
ocm (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 3.6

ocm_absolute_scaled :: (Ord n, Fractional n) => Interval a n -> [a] -> [a] -> n Source #

Ordered combinatorial magnitude (OCM), p.323

ocm_absolute_scaled (abs_of (-)) [1,6,2,5,11] [3,15,13,2,9] == 0.4
ocm_absolute_scaled (abs_of (-)) [1,5,12,2,9,6] [7,6,4,9,8,1] == 54/(15*11)