// $CVSHeader: pal8e/src/Extparm_c.c,v 1.4 2005/02/15 01:10:26 indraneel Rel $

#include <Python.h>
#include <math.h>

/* mod fns */

/* log prob gaussian */
static PyObject *
lpg(PyObject *self, PyObject *args)
{
  double fromPython, result;

  if (! PyArg_ParseTuple(args, "d", &fromPython))
    return NULL;
  else{
    double argval, incr = 0.1000;

    argval = fromPython;
    argval = fabs(argval);
    if (argval > 6.0)
      return NULL;
    result = (erf(argval) - erf(argval - incr)) / 2;
    if (result == 0)
      return NULL;
    result = -1 * log(result);
    return Py_BuildValue("d", result);
  }
}



/* reg tab */
static struct PyMethodDef extparm_methods[] = {
  {"lpg", lpg, 1},
  {NULL, NULL}
};

/* mod init */
void initExtparm_c()
{
  (void) Py_InitModule("Extparm_c", extparm_methods);
}
