non-integral-1.0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.NonIntegral

Synopsis

Documentation

(***) ∷ (RealFrac a, Enum a, Show a) ⇒ a → a → a Source #

Exponentiation

exp' ∷ (RealFrac a, Show a) ⇒ a → a Source #

ln' ∷ (RealFrac a, Enum a, Show a) ⇒ a → a Source #

Compute natural logarithm via continued fraction, first splitting integral part and then using continued fractions approximation for `ln(1+x)`

findE ∷ RealFrac a ⇒ a → a → Integer Source #

find n with `e^n<=x<e^(n+1)`

splitLn ∷ (RealFrac a, Show a) ⇒ a → (Integer, a) Source #

scaleExp ∷ RealFrac a ⇒ a → (Integer, a) Source #

data CompareResult a Source #

Constructors

BELOW a Int 
ABOVE a Int 
MaxReached Int 

Instances

Instances details
Show a ⇒ Show (CompareResult a) Source # 
Instance details

Defined in Cardano.Ledger.NonIntegral

Methods

showsPrec ∷ Int → CompareResult a → ShowS

showCompareResult a → String

showList ∷ [CompareResult a] → ShowS

Eq a ⇒ Eq (CompareResult a) Source # 
Instance details

Defined in Cardano.Ledger.NonIntegral

Methods

(==)CompareResult a → CompareResult a → Bool

(/=)CompareResult a → CompareResult a → Bool

taylorExpCmp ∷ RealFrac a ⇒ a → a → a → CompareResult a Source #

Efficient way to compare the result of the Taylor expansion of the exponential function to a threshold value. Using error estimation one can stop early, once it's known the result will certainly be above or below the target value.