Portability | portable |
---|---|
Stability | experimental |
Maintainer | mik@konecny.aow.cz |
Classes abstracting function arithmetic with directed rounding. Instances are used to describe a boundary for an approximation to a real function on the interval [-1,1]^n.
To be imported qualified, usually with the synonym UFB.
Documentation
class (ERRealBase b, ERIntApprox ra, Ord ufb, DomainBox boxb varid b, DomainIntBox boxra varid ra) => ERUnitFnBase boxb boxra varid b ra ufb | ufb -> boxb boxra varid b ra whereSource
initialiseBaseArithmetic :: ufb -> IO ()Source
This should be evaluated before using any of the following operations.
:: ufb | this parameter is not used except for type checking |
-> ra | |
-> (b, b) |
Convert from the associated interval type to the base type. (The types are determined by the given example function.)
:: ufb | this parameter is not used except for type checking |
-> (b, b) | |
-> ra |
Convert from the base type to the associated interval type. (The types are determined by the given example function.)
compareApprox :: ufb -> ufb -> OrderingSource
A linear ordering on basic functions, which can be syntactic and rather arbitrary.
:: Int | number of decimal digits to show |
-> Bool | whether to show granularity |
-> Bool | whether to show internal structure |
-> ufb | |
-> String |
Check internal consistency of the basic function, typically absence of NaN.
:: String | indentification of caller location for easier debugging |
-> ufb | |
-> ufb |
Check internal consistency of the basic function and report problem if any.
getGranularity :: ufb -> GranularitySource
Get the granularity of the coefficients inside this basic function.
setMinGranularity :: Granularity -> ufb -> ufbSource
setGranularity :: Granularity -> ufb -> ufbSource
Get the degree of this basic function.
If the function is a polynomial, this function should return its degree.
reduceDegreeUp :: Int -> ufb -> ufbSource
Decrease the degree of a basic function, rounding pointwise upwards.
Get the term size of this basic function.
If the function is a polynomial, this function should return the number of terms in the polynomial.
reduceSizeUp :: Int -> ufb -> ufbSource
Decrease the size of this basic function, rounding pointwise upwards.
getVariables :: ufb -> [varid]Source
Get a list of all variables featured in this basic function.
Construct a constant basic function.
:: b | value at 0 |
-> Map varid b | ascent of each base vector |
-> ufb |
Construct an affine basic function.
bounds :: EffortIndex -> ufb -> (b, b)Source
Find an upper bound of a basic function over [-1,1]^n
.
upperBound :: EffortIndex -> ufb -> bSource
Find an upper bound of a basic function over [-1,1]^n
.
upperBoundPrecise :: EffortIndex -> ufb -> bSource
Find an upper bound of a basic function over [-1,1]^n
.
Approximate the function max(f1,f2)
from above.
Approximate the function min(f1,f2)
from above.
Approximate the function max(f1,f2)
from below.
Approximate the function min(f1,f2)
from below.
Pointwise exact negation of a basic function
addConstUp :: b -> ufb -> ufbSource
Add a scalar to a basic function, rounding upwards.
scaleUp :: b -> ufb -> ufbSource
Multiply a basic function by a scalar, rounding upwards.
Multiply a basic function by an approximation of a scalar, rounding upwards.
(+^) :: ufb -> ufb -> ufbSource
Pointwise upwards rounded addition
(-^) :: ufb -> ufb -> ufbSource
Pointwise upwards rounded subtraction
(*^) :: ufb -> ufb -> ufbSource
Pointwise upwards rounded multiplication
recipUp :: Int -> Int -> EffortIndex -> ufb -> ufbSource
Approximate the function 1/f
from above, assuming
f
does not hit zero in the unit domain.
evalUp :: boxb -> ufb -> bSource
Evaluate a basic function at a point rounding upwards using a basic number for both the point and the result.
evalApprox :: boxra -> ufb -> raSource
Evaluate a basic function at a point rounding downwards using a basic number for both the point and the result.
Safely evaluate a basic function at a point using a real number approximation for both the point and the result.
partialEvalApproxUp :: boxra -> ufb -> ufbSource
Partially evaluate a basic function at a lower-dimensional point given using a real number approximation. Approximate the resulting function from above.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> varid | variable |
-> ufb | function |
-> ufb | pointwise upper bound of |
Compose two basic functions, rounding upwards,
assuming f_v
ranges within the domain [-1,1]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> Map varid ufb | variables to substitute and for each variable |
-> ufb | pointwise upper bound of |
Substitute several variables in a basic function with other basic functions,
rounding upwards, assuming each f_v
ranges
within the domain [-1,1]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> varid | variable |
-> ufb | function |
-> ufb | pointwise lower bound of |
Compose two basic functions, rounding downwards,
assuming f_v
ranges within the domain [-1,1]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> Map varid ufb | variables to substitute and for each variable |
-> ufb | pointwise lower bound of |
Substitute several variables in a basic function with other basic functions,
rounding downwards, assuming each f_v
ranges
within the domain [-1,1]
.
:: varid | variable to integrate by |
-> ufb | f |
-> (ufb, ufb) |
Approximate the primitive function of f
from below and from above.
:: varid | variable to differentiate by |
-> ufb | f |
-> (ufb, ufb) |
Approximate the derivative of f
from below and from above.
:: [varid] | dimensions to include in the measuring domain;
have to include all those present in |
-> ufb | f |
-> b |
Measure the volume between a function
and the zero hyperplane on the domain [-1,1]^n
.
(ERRealBase rb, RealFrac rb, DomainBox box varid Int, Ord box, Show varid, DomainBoxMappable boxb boxras varid rb [ERInterval rb], DomainBoxMappable boxra boxras varid (ERInterval rb) [ERInterval rb], DomainIntBox boxra varid (ERInterval rb)) => ERUnitFnBase boxb boxra varid rb (ERInterval rb) (ERChebPoly box rb) |
class ERUnitFnBase boxb boxra varid b ra ufb => ERUnitFnBaseEncl boxb boxra varid b ra ufb | ufb -> boxb boxra varid b ra whereSource
boundsEncl :: EffortIndex -> (ufb, ufb) -> (b, b)Source
constEncl :: (b, b) -> (ufb, ufb)Source
Construct a constant basic enclosure (negated lower bound fn, upper bound fn) from bounds given as coeffients (lower bound, upper bound).
evalEncl :: boxra -> (ufb, ufb) -> raSource
evalEnclInner :: boxra -> (ufb, ufb) -> raSource
Enclosure and base constant addition
IMPORTANT: enclosure = (NEGATED lower bound, upper bound)
Enclosure scaling by a base constant
IMPORTANT: enclosure = (NEGATED lower bound, upper bound)
Enclosure addition
IMPORTANT: enclosure = (NEGATED lower bound, upper bound)
Enclosure multiplication
IMPORTANT: enclosure = (NEGATED lower bound, upper bound)
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | |
-> (ufb, ufb) | enclosure of |
-> (ufb, ufb) |
Approximate the reciprocal of an enclosure, assuming
f
does not hit zero in the unit domain.
IMPORTANT: enclosure = (negated lower bound, upper bound)
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> varid | variable |
-> (ufb, ufb) | enclosure of a function |
-> (ufb, ufb) | enclosure of |
Compose two basic functions, rounding downwards and upwards,
assuming f_v
ranges within the domain [-1,1]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> Map varid (ufb, ufb) | variables to substitute and for each variable |
-> (ufb, ufb) | enclosure of |
Substitute several variables in a basic function with other basic functions,
rounding downwards and upwards, assuming each f_v
ranges
within the domain [-1,1]
.
(ERRealBase rb, RealFrac rb, DomainBox box varid Int, Ord box, Show varid, DomainBoxMappable boxb boxras varid rb [ERInterval rb], DomainBoxMappable boxra boxras varid (ERInterval rb) [ERInterval rb], DomainIntBox boxra varid (ERInterval rb)) => ERUnitFnBaseEncl boxb boxra varid rb (ERInterval rb) (ERChebPoly box rb) |
class ERUnitFnBaseEncl boxb boxra varid b ra ufb => ERUnitFnBaseElementary boxb boxra varid b ra ufb | ufb -> boxb boxra varid b ra whereSource
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating exp as a polynomial |
-> (ufb, ufb) | f |
-> (ufb, ufb) |
Approximate sqrt(f)
for enclosures.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating exp as a polynomial |
-> (ufb, ufb) | f |
-> (ufb, ufb) |
Approximate exp(f)
for enclosures.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating log as a polynomial |
-> (ufb, ufb) | f |
-> (ufb, ufb) |
Approximate log(f)
for enclosures.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating sin as a polynomial |
-> (ufb, ufb) | f |
-> (ufb, ufb) |
Approximate sin(f)
for enclosures,
assuming the range of f
is within [-pi2,pi2]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating cos as a polynomial |
-> (ufb, ufb) | f |
-> (ufb, ufb) |
Approximate cos(f)
for enclosures,
assuming the range of f
is within [-pi2,pi2]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating cos as a polynomial |
-> (ufb, ufb) | f |
-> (ufb, ufb) |
Approximate atan(f)
for enclosures.
(ERRealBase rb, RealFrac rb, DomainBox box varid Int, Ord box, Show varid, DomainBoxMappable boxb boxras varid rb [ERInterval rb], DomainBoxMappable boxra boxras varid (ERInterval rb) [ERInterval rb], DomainIntBox boxra varid (ERInterval rb)) => ERUnitFnBaseElementary boxb boxra varid rb (ERInterval rb) (ERChebPoly box rb) |
class ERUnitFnBase boxb boxra varid b ra ufb => ERUnitFnBaseIEncl boxb boxra varid b ra ufb | ufb -> boxb boxra varid b ra whereSource
constIEncl :: (b, b) -> ((ufb, ufb), Bool)Source
Construct a constant basic inner enclosure
(negated lower bound fn, upper bound fn, is enclosure definitely anticonsistent?)
from bounds given as coeffients (lower bound, upper bound).
An inner enclosure (lnI,hI)
is anticonsistent
iff hI + lnI <= 0
, ie upper bound is never above lower bound.
evalIEncl :: boxra -> ((ufb, ufb), Bool) -> raSource
:: Int | maximum polynomial degree |
-> Int | maximum term count |
-> ((ufb, ufb), Bool) | |
-> ((ufb, ufb), Bool) | |
-> ((ufb, ufb), Bool) |
Inner enclosure addition.
:: Int | maximum polynomial degree |
-> Int | maximum term count |
-> ((ufb, ufb), Bool) | |
-> ((ufb, ufb), Bool) | |
-> ((ufb, ufb), Bool) |
Inner enclosure multiplication.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | |
-> ((ufb, ufb), Bool) | |
-> ((ufb, ufb), Bool) |
Approximate the reciprocal of an inner enclosure, assuming
f
is positive in the unit domain.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> varid | variable |
-> ((ufb, ufb), Bool) | inverse enclosure of a function |
-> ((ufb, ufb), Bool) | inverse enclosure of |
Compose two basic functions, rounding downwards and upwards,
assuming f_v
ranges within the domain [-1,1]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> ufb | function |
-> Map varid ((ufb, ufb), Bool) | variables to substitute and for each variable |
-> ((ufb, ufb), Bool) | inverse enclosure of |
Substitute several variables in a basic function with other basic functions,
rounding downwards and upwards, assuming each f_v
ranges
within the domain [-1,1]
.
(ERRealBase rb, RealFrac rb, DomainBox box varid Int, Ord box, Show varid, DomainBoxMappable boxb boxras varid rb [ERInterval rb], DomainBoxMappable boxra boxras varid (ERInterval rb) [ERInterval rb], DomainIntBox boxra varid (ERInterval rb)) => ERUnitFnBaseIEncl boxb boxra varid rb (ERInterval rb) (ERChebPoly box rb) |
class ERUnitFnBaseIEncl boxb boxra varid b ra ufb => ERUnitFnBaseIElementary boxb boxra varid b ra ufb | ufb -> boxb boxra varid b ra whereSource
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating exp as a polynomial |
-> ((ufb, ufb), Bool) | f |
-> ((ufb, ufb), Bool) |
Approximate sqrt(f)
for enclosures.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating exp as a polynomial |
-> ((ufb, ufb), Bool) | f |
-> ((ufb, ufb), Bool) |
Approximate exp(f)
for enclosures.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating log as a polynomial |
-> ((ufb, ufb), Bool) | f |
-> ((ufb, ufb), Bool) |
Approximate log(f)
for enclosures.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating sin as a polynomial |
-> ((ufb, ufb), Bool) | f |
-> ((ufb, ufb), Bool) |
Approximate sin(f)
for enclosures,
assuming the range of f
is within [-pi2,pi2]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating cos as a polynomial |
-> ((ufb, ufb), Bool) | f |
-> ((ufb, ufb), Bool) |
Approximate cos(f)
for enclosures,
assuming the range of f
is within [-pi2,pi2]
.
:: Int | max degree for result |
-> Int | max approx size for result |
-> EffortIndex | how hard to try when approximating cos as a polynomial |
-> ((ufb, ufb), Bool) | f |
-> ((ufb, ufb), Bool) |
Approximate atan(f)
for enclosures.
(ERRealBase rb, RealFrac rb, DomainBox box varid Int, Ord box, Show varid, DomainBoxMappable boxb boxras varid rb [ERInterval rb], DomainBoxMappable boxra boxras varid (ERInterval rb) [ERInterval rb], DomainIntBox boxra varid (ERInterval rb)) => ERUnitFnBaseIElementary boxb boxra varid rb (ERInterval rb) (ERChebPoly box rb) |