hops-0.7.2: Handy Operations on Power Series

CopyrightAnders Claesson 2015
MaintainerAnders Claesson <anders.claesson@gmail.com>
Safe HaskellNone
LanguageHaskell98

HOPS.GF.Rat

Description

License : BSD-3

Rational numbers extended with two elements representing a finite but indeterminate value and divison by zero, respectively.

Synopsis

Documentation

data Rat Source #

Rationals extended with two elements:

Constructors

Val !Rational

A known rational value.

Indet

An unknown value.

DZ

Division by zero.

Instances

Eq Rat Source # 

Methods

(==) :: Rat -> Rat -> Bool #

(/=) :: Rat -> Rat -> Bool #

Floating Rat Source # 

Methods

pi :: Rat #

exp :: Rat -> Rat #

log :: Rat -> Rat #

sqrt :: Rat -> Rat #

(**) :: Rat -> Rat -> Rat #

logBase :: Rat -> Rat -> Rat #

sin :: Rat -> Rat #

cos :: Rat -> Rat #

tan :: Rat -> Rat #

asin :: Rat -> Rat #

acos :: Rat -> Rat #

atan :: Rat -> Rat #

sinh :: Rat -> Rat #

cosh :: Rat -> Rat #

tanh :: Rat -> Rat #

asinh :: Rat -> Rat #

acosh :: Rat -> Rat #

atanh :: Rat -> Rat #

log1p :: Rat -> Rat #

expm1 :: Rat -> Rat #

log1pexp :: Rat -> Rat #

log1mexp :: Rat -> Rat #

Fractional Rat Source #

Division table:

   /  | Val 0 | Val b     | Indet | DZ
------+-------+-----------+-------+----
Val 0 | DZ    | Val 0     | Val 0 | DZ
Val a | DZ    | Val (a/b) | Indet | DZ
Indet | DZ    | Indet     | Indet | DZ
DZ    | DZ    | DZ        | DZ    | DZ

Methods

(/) :: Rat -> Rat -> Rat #

recip :: Rat -> Rat #

fromRational :: Rational -> Rat #

Num Rat Source #

Addition and multiplication tables:

   +  | Val b     | Indet | DZ
------+-----------+-------+----
Val a | Val (a+b) | Indet | DZ
Indet | Indet     | Indet | DZ
DZ    | DZ        | DZ    | DZ

   *  | Val 0 | Val b     | Indet | DZ
------+-------+-----------+-------+----
Val 0 | Val 0 | Val 0     | Val 0 | DZ
Val a | Val 0 | Val (a*b) | Indet | DZ
Indet | Val 0 | Indet     | Indet | DZ
DZ    | DZ    | DZ        | DZ    | DZ

Methods

(+) :: Rat -> Rat -> Rat #

(-) :: Rat -> Rat -> Rat #

(*) :: Rat -> Rat -> Rat #

negate :: Rat -> Rat #

abs :: Rat -> Rat #

signum :: Rat -> Rat #

fromInteger :: Integer -> Rat #

Ord Rat Source # 

Methods

compare :: Rat -> Rat -> Ordering #

(<) :: Rat -> Rat -> Bool #

(<=) :: Rat -> Rat -> Bool #

(>) :: Rat -> Rat -> Bool #

(>=) :: Rat -> Rat -> Bool #

max :: Rat -> Rat -> Rat #

min :: Rat -> Rat -> Rat #

Read Rat Source # 
Show Rat Source # 

Methods

showsPrec :: Int -> Rat -> ShowS #

show :: Rat -> String #

showList :: [Rat] -> ShowS #

Pretty Rat Source # 

maybeRational :: Rat -> Maybe Rational Source #

maybeRational of Val x is Just x, otherwise it is Nothing.

maybeInteger :: Rat -> Maybe Integer Source #

maybeInteger of Val x is Just the numerator of x if the denominator of x is 1, otherwise it is Nothing.

maybeInt :: Rat -> Maybe Int Source #

Like maybeInteger but return Nothing when the integer is out of range for an Int.

isRational :: Rat -> Bool Source #

Is the given element a rational?

isInteger :: Rat -> Bool Source #

Is the given element an Integer?

isInt :: Rat -> Bool Source #

Is the given element an Int?

factorial :: Rat -> Rat Source #

If the given value represents a nonnegative integer, then the factorial of that integer is returned. If given DZ, return DZ. In all other cases return Indet.

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

multinomial :: (Integral b, Fractional a) => [b] -> a Source #