Portability | ViewPatterns |
---|---|
Stability | provisional |
Maintainer | Johan Kiviniemi <devel@johan.kiviniemi.name> |
Safe Haskell | None |
An implementation of quadratic irrationals with support for conversion from and to periodic continued fractions.
- data QI
- qi :: Integer -> Integer -> Integer -> Integer -> QI
- qi' :: Rational -> Rational -> Integer -> QI
- qiModify :: QI -> (Integer -> Integer -> Integer -> (Integer, Integer, Integer)) -> QI
- runQI :: QI -> (Integer -> Integer -> Integer -> Integer -> a) -> a
- runQI' :: QI -> (Rational -> Rational -> Integer -> a) -> a
- unQI :: QI -> (Integer, Integer, Integer, Integer)
- unQI' :: QI -> (Rational, Rational, Integer)
- qiZero :: QI
- qiOne :: QI
- qiIsZero :: QI -> Bool
- qiToFloat :: Floating a => QI -> a
- qiAddI :: QI -> Integer -> QI
- qiSubI :: QI -> Integer -> QI
- qiMulI :: QI -> Integer -> QI
- qiDivI :: QI -> Integer -> QI
- qiAddR :: QI -> Rational -> QI
- qiSubR :: QI -> Rational -> QI
- qiMulR :: QI -> Rational -> QI
- qiDivR :: QI -> Rational -> QI
- qiNegate :: QI -> QI
- qiRecip :: QI -> Maybe QI
- qiAdd :: QI -> QI -> Maybe QI
- qiSub :: QI -> QI -> Maybe QI
- qiMul :: QI -> QI -> Maybe QI
- qiDiv :: QI -> QI -> Maybe QI
- qiPow :: QI -> Integer -> QI
- qiFloor :: QI -> Integer
- continuedFractionToQI :: (Integer, CycList Integer) -> QI
- qiToContinuedFraction :: QI -> (Integer, CycList Integer)
- module Numeric.QuadraticIrrational.CyclicList
Documentation
Given a
, b
, c
and d
such that n = (a + b √c)/d
, constuct a QI
corresponding to n
.
Given a
, b
and c
such that n = a + b √c
, constuct a QI
corresponding to n
.
qiModify :: QI -> (Integer -> Integer -> Integer -> (Integer, Integer, Integer)) -> QISource
Given a QI
corresponding to n = (a + b √c)/d
, modify (a, b, d)
.
Avoids having to simplify b √c
.
runQI :: QI -> (Integer -> Integer -> Integer -> Integer -> a) -> aSource
Given n
and f
such that n = (a + b √c)/d
, run f a b c d
.
runQI' :: QI -> (Rational -> Rational -> Integer -> a) -> aSource
Given n
and f
such that n = a + b √c
, run f a b c
.
unQI :: QI -> (Integer, Integer, Integer, Integer)Source
Given n
such that n = (a + b √c)/d
, return (a, b, c, d)
.
continuedFractionToQI :: (Integer, CycList Integer) -> QISource
Convert a (possibly periodic) continued fraction to a QI
.