Back to index

python3.2  3.2.2
Functions | Variables
fpetestmodule.c File Reference
#include "Python.h"

Go to the source code of this file.

Functions

PyMODINIT_FUNC PyInit_fpetest (void)
static PyObjecttest (PyObject *self, PyObject *args)
static double db0 (double)
static double overflow (double)
static double nest1 (int, double)
static double nest2 (int, double)
static double nest3 (double)
static void printerr (double)

Variables

static PyObjectfpe_error
static PyMethodDef fpetest_methods []
static struct PyModuleDef

Function Documentation

static double db0 ( double  x) [static]

Definition at line 158 of file fpetestmodule.c.

{
  double a;
  PyFPE_START_PROTECT("Division by zero", return 3.1416)
  a = 1./x;
  PyFPE_END_PROTECT(a)
  return a;
}

Here is the caller graph for this function:

static double nest1 ( int  i,
double  x 
) [static]

Definition at line 113 of file fpetestmodule.c.

{
  double a = 1.0;

  PyFPE_START_PROTECT("Division by zero, outer zone", return 3.1416)
  if(i == 0){
    a = 1./x;
  }else if(i == 1){
    /* This (following) message is never seen. */
    PyFPE_START_PROTECT("Division by zero, inner zone", return 3.1416)
    a = 1./(1. - x);
    PyFPE_END_PROTECT(a)
  }else if(i == 2){
    a = 1./(2. - x);
  }
  PyFPE_END_PROTECT(a)

  return a;
}

Here is the caller graph for this function:

static double nest2 ( int  i,
double  x 
) [static]

Definition at line 133 of file fpetestmodule.c.

{
  double a = 1.0;
  PyFPE_START_PROTECT("Division by zero, prior error", return 3.1416)
  if(i == 0){
    a = 1./x;
  }else if(i == 1){
    a = nest3(x);
  }else if(i == 2){
    a = 1./(2. - x);
  }
  PyFPE_END_PROTECT(a)
  return a;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static double nest3 ( double  x) [static]

Definition at line 148 of file fpetestmodule.c.

{
  double result;
  /* This (following) message is never seen. */
  PyFPE_START_PROTECT("Division by zero, nest3 error", return 3.1416)
  result = 1./(1. - x);
  PyFPE_END_PROTECT(result)
  return result;
}

Here is the caller graph for this function:

static double overflow ( double  b) [static]

Definition at line 167 of file fpetestmodule.c.

{
  double a;
  PyFPE_START_PROTECT("Overflow", return 3.1416)
  a = b*b;
  PyFPE_END_PROTECT(a)
  return a;
}

Here is the caller graph for this function:

static void printerr ( double  r) [static]

Definition at line 102 of file fpetestmodule.c.

{
    if(r == 3.1416){
      fprintf(stderr,"\tPASS\n");
      PyErr_Print();
    }else{
      fprintf(stderr,"\tFAIL\n");
    }
    PyErr_Clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 188 of file fpetestmodule.c.

{
    PyObject *m, *d;

    m = PyModule_Create(&fpetestmodule);
    if (m == NULL)
    return NULL;
    d = PyModule_GetDict(m);
    fpe_error = PyErr_NewException("fpetest.error", NULL, NULL);
    if (fpe_error != NULL)
        PyDict_SetItemString(d, "error", fpe_error);
    return m;
}

Here is the call graph for this function:

static PyObject * test ( PyObject self,
PyObject args 
) [static]

Definition at line 62 of file fpetestmodule.c.

{
    double r;

    fprintf(stderr,"overflow");
    r = overflow(1.e160);
    printerr(r);

    fprintf(stderr,"\ndiv by 0");
    r = db0(0.0);
    printerr(r);

    fprintf(stderr,"\nnested outer");
    r = nest1(0, 0.0);
    printerr(r);

    fprintf(stderr,"\nnested inner");
    r = nest1(1, 1.0);
    printerr(r);

    fprintf(stderr,"\ntrailing outer");
    r = nest1(2, 2.0);
    printerr(r);

    fprintf(stderr,"\nnested prior");
    r = nest2(0, 0.0);
    printerr(r);

    fprintf(stderr,"\nnested interior");
    r = nest2(1, 1.0);
    printerr(r);

    fprintf(stderr,"\nnested trailing");
    r = nest2(2, 2.0);
    printerr(r);

    Py_INCREF (Py_None);
    return Py_None;
}

Here is the call graph for this function:


Variable Documentation

PyObject* fpe_error [static]

Definition at line 46 of file fpetestmodule.c.

Initial value:
 {
    {"test",             (PyCFunction) test,             METH_VARARGS},
    {0,0}
}

Definition at line 57 of file fpetestmodule.c.

struct PyModuleDef [static]
Initial value:
 {
    PyModuleDef_HEAD_INIT,
    "fpetest",
    NULL,
    -1,
    fpetest_methods,
    NULL,
    NULL,
    NULL,
    NULL
}

Definition at line 176 of file fpetestmodule.c.