/* Routines for standard interval arithmetic */ /****************************************************************************/ /* (C) Copyright 1993 Universidade Estadual de Campinas (UNICAMP) */ /* Campinas, SP, Brazil */ /* */ /* This file can be freely distributed, modified, and used for any */ /* non-commercial purpose, provided that this copyright and authorship */ /* notice be included in any copy or derived version of this file. */ /* */ /* DISCLAIMER: This software is offered ``as is'', without any guarantee */ /* as to fitness for any particular purpose. Neither the copyright */ /* holder nor the authors or their employers can be held responsible for */ /* any damages that may result from its use. */ /****************************************************************************/ #ifndef IA_H #define IA_H #include #include #include typedef struct {Float lo, hi; } Interval; void ia_init (void); /* Initializes the constants (ia_full, etc.) */ /* MUST be called at least once before any of the routines below. */ Interval ia_full (void); /* The "anything" interval, [-Inf .. +Inf] */ int ia_is_full (Interval *x); /* True iff $*x.lo$ is -Inf or $*x.hi$ is +Inf */ void ia_norm_full (Interval *x); /* If $*x.lo$ is -Inf or $*x.hi$ is +Inf, sets $*x$ to [-Inf .. +Inf] */ Interval ia_const (Float x, Float err); /* $x$ plus or minus $err$ */ Interval ia_int_const (int i); /* $i$, with rounding error if too big. */ Interval ia_add (Interval x, Interval y); Interval ia_sub (Interval x, Interval y); Interval ia_neg (Interval x); Interval ia_scale (Interval x, Float alpha, Float zeta); /* $\alpha x / \zeta$ */ Interval ia_shift (Interval x, Float gamma); /* $x + \gamma$ */ Interval ia_mul (Interval x, Interval y); Interval ia_div (Interval x, Interval y); Interval ia_sqr (Interval x); /* same as ia_mul(x,x), only better */ Interval ia_inv (Interval x); Interval ia_sqrt (Interval x); Interval ia_abs (Interval x); Interval ia_max (Interval x, Interval y); Interval ia_min (Interval x, Interval y); Interval ia_affine ( Interval x, Float alpha, Float zeta, Float gamma, Float delta ); /* Computes $\alpha x / \zeta + \gamma \pm \delta. */ Interval ia_affine_2( Interval x, Float alpha, Interval y, Float beta, Float zeta, Float gamma, Float delta ); /* Computes $(\alpha x + \beta y)/ \zeta + \gamma \pm \delta. */ /*** MISCELLANEOUS TOOLS ***/ Interval ia_meet (Interval x, Interval y); /* Intersection of $x$ and $y$; error if disjoint. */ Interval ia_join (Interval x, Interval y); /* Smallest interval contining $x$ and $y$. */ Interval ia_throw (void); /* Returns a random interval, suitable for testing. The client must have called $srandom()$. */ void ia_print (FILE *f, Interval x); /* Prints $x$ on $f$. */ #endif