Music.Theory.Z

Contents

Description

Z-n functions with modulo function as parameter.

Synopsis

# Documentation

type Z t = t -> t Source #

The modulo function for Z.

is_z_n :: (Num a, Ord a) => a -> a -> Bool Source #

Is n in (0,m-1).

mod5 :: Integral i => Z i Source #

mod7 :: Integral i => Z i Source #

mod12 :: Integral i => Z i Source #

lift_unary_Z :: Z i -> (t -> i) -> t -> i Source #

lift_binary_Z :: Z i -> (s -> t -> i) -> s -> t -> i Source #

z_add :: Integral i => Z i -> i -> i -> i Source #

z_sub :: Integral i => Z i -> i -> i -> i Source #

The underlying type i is presumed to be signed...

z_sub mod12 0 8 == 4
import Data.Word
z_sub mod12 (0::Word8) 8 == 8
((0 - 8) :: Word8) == 248
248 mod 12 == 8

z_mul :: Integral i => Z i -> i -> i -> i Source #

Allowing unsigned i is rather inefficient... z_sub :: Integral i => Z i -> i -> i -> i z_sub z p q = if p > q then z (p - q) else let m = z_modulus z in z (p + m - q)

z_negate :: Integral i => Z i -> i -> i Source #

z_signum :: t -> u -> v Source #

z_abs :: t -> u -> v Source #

to_Z :: Integral i => Z i -> i -> i Source #

from_Z :: (Integral i, Num n) => i -> n Source #

z_modulus :: Integral i => Z i -> i Source #

Modulus of z.

z_modulus mod12 == 12

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

Universe of Z.

z_univ mod12 == [0..11]

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

Z of z_univ not in given set.

z_complement mod5 [0,2,3] == [1,4]
z_complement mod12 [0,2,4,5,7,9,11] == [1,3,6,8,10]

z_quot :: Integral i => Z i -> i -> i -> i Source #

z_rem :: Integral i => Z i -> i -> i -> i Source #

div_err :: Integral i => String -> i -> i -> i Source #

z_div :: Integral i => Z i -> i -> i -> i Source #

z_mod :: Integral i => Z i -> i -> i -> i Source #

z_quotRem :: Integral i => Z i -> i -> i -> (i, i) Source #

z_divMod :: Integral i => Z i -> i -> i -> (i, i) Source #

z_toInteger :: Integral i => Z i -> i -> i Source #

# Z16

mod16 :: Integral i => Z i Source #

is_z16 :: Integral t => t -> Bool Source #