summaryrefslogtreecommitdiff
path: root/esolid/wrapper/include/fpfilter.h
blob: 67022678098c2d93b185a9388240951a71043841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//  file:    fpfilter.h
//  update:  10/04/02

#ifndef _FPFILTER_H
#define _FPFILTER_H

#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <iostream>

#define RAT_TO_DBL_ERR 4 * DBL_EPSILON

using namespace std;

int round_nearest();
int round_down();
int round_up();
int round_zero();
//  Set rounding mode.

int
horner_with_err(
  const double* const poly,        //  coefficients of a univariate polynomial
                                   //  in decreasing degree order
  const unsigned long deg,         //  degree of poly
  const double        coeff_err,   //  error bound for coeffs
  const double        in_val,      //  evaluate poly here
  const double        in_err,      //  error bound for in_val
  double&             out_val,     //  value of poly
  double&             out_err      //  bound on absolute error
  );
//  Evaluate poly at in_val. Also, compute a bound on error.

int sign_given_err(const double val, const double err);
//  Returns the sign of val if val might be off from 0.0 by as much as err.
//  Returns 0 if we can't tell.

double newton_for_pseudoroot(const double* const poly,
                             const unsigned long deg,
                             const double coeff_err,
                             const double* const deriv,
                             const double low,
                             const double high);

#endif