module Music.Theory.Z.Lewin_1980 where
import Data.Int
import Data.List
import qualified Music.Theory.Z.Castren_1994 as Castren
type Z12 = Int8
rel :: Floating n => (Int -> [a] -> [n]) -> [a] -> [a] -> n
rel :: forall n a. Floating n => (Int -> [a] -> [n]) -> [a] -> [a] -> n
rel Int -> [a] -> [n]
ncv [a]
x [a]
y =
let n :: Int
n = forall a. Ord a => a -> a -> a
min (forall i a. Num i => [a] -> i
genericLength [a]
x) (forall i a. Num i => [a] -> i
genericLength [a]
y)
p :: [[n]]
p = forall a b. (a -> b) -> [a] -> [b]
map (Int -> [a] -> [n]
`ncv` [a]
x) [Int
2..Int
n]
q :: [[n]]
q = forall a b. (a -> b) -> [a] -> [b]
map (Int -> [a] -> [n]
`ncv` [a]
y) [Int
2..Int
n]
f :: [n] -> [n] -> [n]
f = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\n
i n
j -> forall a. Floating a => a -> a
sqrt (n
i forall a. Num a => a -> a -> a
* n
j))
pt :: n
pt = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [[n]]
p)
qt :: n
qt = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [[n]]
q)
in forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith [n] -> [n] -> [n]
f [[n]]
p [[n]]
q)) forall a. Fractional a => a -> a -> a
/ forall a. Floating a => a -> a
sqrt (n
pt forall a. Num a => a -> a -> a
* n
qt)
t_rel :: Floating n => [Z12] -> [Z12] -> n
t_rel :: forall n. Floating n => [Z12] -> [Z12] -> n
t_rel = forall n a. Floating n => (Int -> [a] -> [n]) -> [a] -> [a] -> n
rel forall a i. (Num a, Integral i) => i -> [Z12] -> [a]
Castren.t_n_class_vector
ti_rel :: Floating n => [Z12] -> [Z12] -> n
ti_rel :: forall n. Floating n => [Z12] -> [Z12] -> n
ti_rel = forall n a. Floating n => (Int -> [a] -> [n]) -> [a] -> [a] -> n
rel forall a i. (Num a, Integral i) => i -> [Z12] -> [a]
Castren.ti_n_class_vector