Index: sansmodels/src/c_models/c_models.cpp
===================================================================
--- sansmodels/src/c_models/c_models.cpp	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/c_models/c_models.cpp	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,329 @@
+/** c_models
+ *
+ * Module containing all SANS model extensions
+ *
+ * @author   M.Doucet / UTK
+ */
+#include <Python.h>
+#include <parameters.hh>
+#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
+#include "arrayobject.h"
+
+
+ // adding generated code 
+void addCBarBellModel(PyObject *module); 
+void addCBCCrystalModel(PyObject *module); 
+void addCBinaryHSModel(PyObject *module); 
+void addCCappedCylinderModel(PyObject *module); 
+void addCCoreShellModel(PyObject *module); 
+void addCCoreShellBicelleModel(PyObject *module); 
+void addCCoreShellCylinderModel(PyObject *module); 
+void addCCoreFourShellModel(PyObject *module); 
+void addCCore2ndMomentModel(PyObject *module); 
+void addCCSParallelepipedModel(PyObject *module); 
+void addCCylinderModel(PyObject *module); 
+void addCDABModel(PyObject *module); 
+void addCDiamCylFunc(PyObject *module); 
+void addCDiamEllipFunc(PyObject *module); 
+void addCEllipsoidModel(PyObject *module); 
+void addCEllipticalCylinderModel(PyObject *module); 
+void addCFCCrystalModel(PyObject *module); 
+void addCFlexCylEllipXModel(PyObject *module); 
+void addCFlexibleCylinderModel(PyObject *module); 
+void addCFractalModel(PyObject *module); 
+void addCFractalO_Z(PyObject *module); 
+void addCFuzzySphereModel(PyObject *module); 
+void addCGaussian(PyObject *module); 
+void addCGelFitModel(PyObject *module); 
+void addCHardsphereStructure(PyObject *module); 
+void addCHayterMSAStructure(PyObject *module); 
+void addCHollowCylinderModel(PyObject *module); 
+void addCLamellarModel(PyObject *module); 
+void addCLamellarFFHGModel(PyObject *module); 
+void addCLamellarPCrystalModel(PyObject *module); 
+void addCLamellarPSModel(PyObject *module); 
+void addCLamellarPSHGModel(PyObject *module); 
+void addCLinearPearlsModel(PyObject *module); 
+void addCLogNormal(PyObject *module); 
+void addCLorentzian(PyObject *module); 
+void addCMassFractalModel(PyObject *module); 
+void addCMassSurfaceFractal(PyObject *module); 
+void addCMultiShellModel(PyObject *module); 
+void addCOnionModel(PyObject *module); 
+void addCParallelepipedModel(PyObject *module); 
+void addCPearlNecklaceModel(PyObject *module); 
+void addCPoly_GaussCoil(PyObject *module); 
+void addCPringlesModel(PyObject *module); 
+void addCRaspBerryModel(PyObject *module); 
+void addCReflModel(PyObject *module); 
+void addCReflAdvModel(PyObject *module); 
+void addCRPAModel(PyObject *module); 
+void addCSCCrystalModel(PyObject *module); 
+void addCSchulz(PyObject *module); 
+void addCSLDCalFunc(PyObject *module); 
+void addCSphereModel(PyObject *module); 
+void addCSphereSLDModel(PyObject *module); 
+void addCCoreShellEllipsoidModel(PyObject *module); 
+void addCSquareWellStructure(PyObject *module); 
+void addCStackedDisksModel(PyObject *module); 
+void addCStarPolymer(PyObject *module); 
+void addCStickyHSStructure(PyObject *module); 
+void addCSurfaceFractalModel(PyObject *module); 
+void addCTeubnerStreyModel(PyObject *module); 
+void addCTriaxialEllipsoidModel(PyObject *module); 
+void addCTwoYukawaModel(PyObject *module); 
+void addCVesicleModel(PyObject *module); 
+ // end generated code 
+
+
+
+extern "C" {
+  void addDisperser(PyObject *module);
+}
+
+/**
+ * Delete a dispersion model object
+ */
+void del_dispersion_model(void *ptr){
+  DispersionModel * disp = static_cast<DispersionModel *>(ptr);
+  delete disp;
+  return;
+}
+
+/**
+ * Create a dispersion model as a python object
+ */
+PyObject * new_dispersion_model(PyObject *, PyObject *args) {
+  DispersionModel *disp = new DispersionModel();
+  return PyCObject_FromVoidPtr(disp, del_dispersion_model);
+}
+
+
+/**
+ * Delete a lognormal dispersion model object
+ */
+void del_lognormal_dispersion(void *ptr){
+  LogNormalDispersion * disp = static_cast<LogNormalDispersion *>(ptr);
+  delete disp;
+  return;
+}
+
+/**
+ * Create a lognormal dispersion model as a python object
+ */
+PyObject * new_lognormal_dispersion(PyObject *, PyObject *args) {
+  LogNormalDispersion *disp = new LogNormalDispersion();
+  return PyCObject_FromVoidPtr(disp, del_lognormal_dispersion);
+}
+
+/**
+ * Delete a gaussian dispersion model object
+ */
+void del_gaussian_dispersion(void *ptr){
+  GaussianDispersion * disp = static_cast<GaussianDispersion *>(ptr);
+  delete disp;
+  return;
+}
+
+/**
+ * Create a gaussian dispersion model as a python object
+ */
+PyObject * new_gaussian_dispersion(PyObject *, PyObject *args) {
+  GaussianDispersion *disp = new GaussianDispersion();
+  return PyCObject_FromVoidPtr(disp, del_gaussian_dispersion);
+}
+
+
+/**
+ * Delete a rectangle dispersion model object
+ */
+void del_rectangle_dispersion(void *ptr){
+  RectangleDispersion * disp = static_cast<RectangleDispersion *>(ptr);
+  delete disp;
+  return;
+}
+
+/**
+ * Create a rectangle dispersion model as a python object
+ */
+PyObject * new_rectangle_dispersion(PyObject *, PyObject *args) {
+  RectangleDispersion *disp = new RectangleDispersion();
+  return PyCObject_FromVoidPtr(disp, del_rectangle_dispersion);
+}
+
+
+/**
+ * Delete a schulz dispersion model object
+ */
+void del_schulz_dispersion(void *ptr){
+  SchulzDispersion * disp = static_cast<SchulzDispersion *>(ptr);
+  delete disp;
+  return;
+}
+/**
+ * Create a schulz dispersion model as a python object
+ */
+PyObject * new_schulz_dispersion(PyObject *, PyObject *args) {
+  SchulzDispersion *disp = new SchulzDispersion();
+  return PyCObject_FromVoidPtr(disp, del_schulz_dispersion);
+}
+
+
+/**
+ * Delete an array dispersion model object
+ */
+void del_array_dispersion(void *ptr){
+  ArrayDispersion * disp = static_cast<ArrayDispersion *>(ptr);
+  delete disp;
+  return;
+}
+
+/**
+ * Create an array dispersion model as a python object
+ */
+PyObject * new_array_dispersion(PyObject *, PyObject *args) {
+  ArrayDispersion *disp = new ArrayDispersion();
+  return PyCObject_FromVoidPtr(disp, del_array_dispersion);
+}
+
+#define INVECTOR(obj,buf,len)										\
+    do { \
+      int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \
+      if (err < 0) return NULL; \
+      len /= sizeof(*buf); \
+    } while (0)
+
+/**
+ * Sets weights from a numpy array
+ */
+PyObject * set_weights(PyObject *, PyObject *args) {
+  PyObject *val_obj;
+  PyObject *wei_obj;
+  PyObject *disp;
+  Py_ssize_t nval;
+  Py_ssize_t nwei;
+  double *values;
+  double *weights;
+  //int i;
+
+  if (!PyArg_ParseTuple(args, "OOO", &disp, &val_obj, &wei_obj)) return NULL;
+  INVECTOR(val_obj, values, nval);
+  INVECTOR(wei_obj, weights, nwei);
+
+  // Sanity check
+  if(nval!=nwei) return NULL;
+
+  // Set the array pointers
+  void *temp = PyCObject_AsVoidPtr(disp);
+  DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
+  dispersion->set_weights(nval, values, weights);
+
+  return Py_BuildValue("i",1);
+}
+
+
+
+/**
+ * Define empty module
+ */
+static PyMethodDef module_methods[] = {
+    {"new_dispersion_model", (PyCFunction)new_dispersion_model     , METH_VARARGS,
+        "Create a new DispersionModel object"},
+        {"new_gaussian_model",   (PyCFunction)new_gaussian_dispersion, METH_VARARGS,
+            "Create a new GaussianDispersion object"},
+            {"new_rectangle_model",   (PyCFunction)new_rectangle_dispersion, METH_VARARGS,
+                "Create a new RectangleDispersion object"},
+                {"new_lognormal_model",   (PyCFunction)new_lognormal_dispersion, METH_VARARGS,
+                    "Create a new LogNormalDispersion object"},
+                    {"new_schulz_model",   (PyCFunction)new_schulz_dispersion, METH_VARARGS,
+                        "Create a new SchulzDispersion object"},
+                        {"new_array_model",      (PyCFunction)new_array_dispersion  , METH_VARARGS,
+                            "Create a new ArrayDispersion object"},
+                            {"set_dispersion_weights",(PyCFunction)set_weights  , METH_VARARGS,
+                                "Create the dispersion weight arrays for an Array Dispersion object"},
+                                {NULL}
+};
+
+
+#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
+#define PyMODINIT_FUNC void
+#endif
+PyMODINIT_FUNC
+initc_models(void)
+{
+  PyObject* m;
+
+  m = Py_InitModule3("c_models", module_methods,
+      "C extension module for SANS scattering models.");
+  import_array();
+
+
+ // adding generated code 
+addCBarBellModel(m); 
+addCBCCrystalModel(m); 
+addCBinaryHSModel(m); 
+addCCappedCylinderModel(m); 
+addCCoreShellModel(m); 
+addCCoreShellBicelleModel(m); 
+addCCoreShellCylinderModel(m); 
+addCCoreFourShellModel(m); 
+addCCore2ndMomentModel(m); 
+addCCSParallelepipedModel(m); 
+addCCylinderModel(m); 
+addCDABModel(m); 
+addCDiamCylFunc(m); 
+addCDiamEllipFunc(m); 
+addCEllipsoidModel(m); 
+addCEllipticalCylinderModel(m); 
+addCFCCrystalModel(m); 
+addCFlexCylEllipXModel(m); 
+addCFlexibleCylinderModel(m); 
+addCFractalModel(m); 
+addCFractalO_Z(m); 
+addCFuzzySphereModel(m); 
+addCGaussian(m); 
+addCGelFitModel(m); 
+addCHardsphereStructure(m); 
+addCHayterMSAStructure(m); 
+addCHollowCylinderModel(m); 
+addCLamellarModel(m); 
+addCLamellarFFHGModel(m); 
+addCLamellarPCrystalModel(m); 
+addCLamellarPSModel(m); 
+addCLamellarPSHGModel(m); 
+addCLinearPearlsModel(m); 
+addCLogNormal(m); 
+addCLorentzian(m); 
+addCMassFractalModel(m); 
+addCMassSurfaceFractal(m); 
+addCMultiShellModel(m); 
+addCOnionModel(m); 
+addCParallelepipedModel(m); 
+addCPearlNecklaceModel(m); 
+addCPoly_GaussCoil(m); 
+addCPringlesModel(m); 
+addCRaspBerryModel(m); 
+addCReflModel(m); 
+addCReflAdvModel(m); 
+addCRPAModel(m); 
+addCSCCrystalModel(m); 
+addCSchulz(m); 
+addCSLDCalFunc(m); 
+addCSphereModel(m); 
+addCSphereSLDModel(m); 
+addCCoreShellEllipsoidModel(m); 
+addCSquareWellStructure(m); 
+addCStackedDisksModel(m); 
+addCStarPolymer(m); 
+addCStickyHSStructure(m); 
+addCSurfaceFractalModel(m); 
+addCTeubnerStreyModel(m); 
+addCTriaxialEllipsoidModel(m); 
+addCTwoYukawaModel(m); 
+addCVesicleModel(m); 
+addDisperser(m); 
+
+ // end generated code 
+
+}
+
Index: sansmodels/src/c_models/pringles.cpp
===================================================================
--- sansmodels/src/c_models/pringles.cpp	(revision a9fec15f74f829e85ab0ebd3b7f671ad70e3c00a)
+++ sansmodels/src/c_models/pringles.cpp	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -10,4 +10,5 @@
 #include "parameters.hh"
 #include "pringles.h"
+#include "cephes.h"
 using namespace std;
 
Index: sansmodels/src/cephes/airy.c
===================================================================
--- sansmodels/src/cephes/airy.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/airy.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,966 @@
+/*							airy.c
+ *
+ *	Airy function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, ai, aip, bi, bip;
+ * int airy();
+ *
+ * airy( x, _&ai, _&aip, _&bi, _&bip );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Solution of the differential equation
+ *
+ *	y"(x) = xy.
+ *
+ * The function returns the two independent solutions Ai, Bi
+ * and their first derivatives Ai'(x), Bi'(x).
+ *
+ * Evaluation is by power series summation for small x,
+ * by rational minimax approximations for large x.
+ *
+ *
+ *
+ * ACCURACY:
+ * Error criterion is absolute when function <= 1, relative
+ * when function > 1, except * denotes relative error criterion.
+ * For large negative x, the absolute error increases as x^1.5.
+ * For large positive x, the relative error increases as x^1.5.
+ *
+ * Arithmetic  domain   function  # trials      peak         rms
+ * IEEE        -10, 0     Ai        10000       1.6e-15     2.7e-16
+ * IEEE          0, 10    Ai        10000       2.3e-14*    1.8e-15*
+ * IEEE        -10, 0     Ai'       10000       4.6e-15     7.6e-16
+ * IEEE          0, 10    Ai'       10000       1.8e-14*    1.5e-15*
+ * IEEE        -10, 10    Bi        30000       4.2e-15     5.3e-16
+ * IEEE        -10, 10    Bi'       30000       4.9e-15     7.3e-16
+ * DEC         -10, 0     Ai         5000       1.7e-16     2.8e-17
+ * DEC           0, 10    Ai         5000       2.1e-15*    1.7e-16*
+ * DEC         -10, 0     Ai'        5000       4.7e-16     7.8e-17
+ * DEC           0, 10    Ai'       12000       1.8e-15*    1.5e-16*
+ * DEC         -10, 10    Bi        10000       5.5e-16     6.8e-17
+ * DEC         -10, 10    Bi'        7000       5.3e-16     8.7e-17
+ *
+ */
+
+/*							airy.c */
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+static double c1 = 0.35502805388781723926;
+static double c2 = 0.258819403792806798405;
+static double sqrt3 = 1.732050807568877293527;
+static double sqpii = 5.64189583547756286948E-1;
+extern double PI;
+
+extern double MAXNUM, MACHEP;
+#ifdef UNK
+#define MAXAIRY 25.77
+#endif
+#ifdef DEC
+#define MAXAIRY 25.77
+#endif
+#ifdef IBMPC
+#define MAXAIRY 103.892
+#endif
+#ifdef MIEEE
+#define MAXAIRY 103.892
+#endif
+
+
+#ifdef UNK
+static double AN[8] = {
+  3.46538101525629032477E-1,
+  1.20075952739645805542E1,
+  7.62796053615234516538E1,
+  1.68089224934630576269E2,
+  1.59756391350164413639E2,
+  7.05360906840444183113E1,
+  1.40264691163389668864E1,
+  9.99999999999999995305E-1,
+};
+static double AD[8] = {
+  5.67594532638770212846E-1,
+  1.47562562584847203173E1,
+  8.45138970141474626562E1,
+  1.77318088145400459522E2,
+  1.64234692871529701831E2,
+  7.14778400825575695274E1,
+  1.40959135607834029598E1,
+  1.00000000000000000470E0,
+};
+#endif
+#ifdef DEC
+static unsigned short AN[32] = {
+0037661,0066561,0024675,0131301,
+0041100,0017434,0034324,0101466,
+0041630,0107450,0067427,0007430,
+0042050,0013327,0071000,0034737,
+0042037,0140642,0156417,0167366,
+0041615,0011172,0075147,0051165,
+0041140,0066152,0160520,0075146,
+0040200,0000000,0000000,0000000,
+};
+static unsigned short AD[32] = {
+0040021,0046740,0011422,0064606,
+0041154,0014640,0024631,0062450,
+0041651,0003435,0101152,0106401,
+0042061,0050556,0034605,0136602,
+0042044,0036024,0152377,0151414,
+0041616,0172247,0072216,0115374,
+0041141,0104334,0124154,0166007,
+0040200,0000000,0000000,0000000,
+};
+#endif
+#ifdef IBMPC
+static unsigned short AN[32] = {
+0xb658,0x2537,0x2dae,0x3fd6,
+0x9067,0x871a,0x03e3,0x4028,
+0xe1e3,0x0de2,0x11e5,0x4053,
+0x073c,0xee40,0x02da,0x4065,
+0xfddf,0x5ba1,0xf834,0x4063,
+0xea4f,0x4f4c,0xa24f,0x4051,
+0x0f4d,0x5c2a,0x0d8d,0x402c,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+static unsigned short AD[32] = {
+0x4d31,0x0262,0x29bc,0x3fe2,
+0x2ca5,0x0533,0x8334,0x402d,
+0x51a0,0xb04d,0x20e3,0x4055,
+0xb7b0,0xc730,0x2a2d,0x4066,
+0xfa61,0x9a9f,0x8782,0x4064,
+0xd35f,0xee91,0xde94,0x4051,
+0x9d81,0x950d,0x311b,0x402c,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+#endif
+#ifdef MIEEE
+static unsigned short AN[32] = {
+0x3fd6,0x2dae,0x2537,0xb658,
+0x4028,0x03e3,0x871a,0x9067,
+0x4053,0x11e5,0x0de2,0xe1e3,
+0x4065,0x02da,0xee40,0x073c,
+0x4063,0xf834,0x5ba1,0xfddf,
+0x4051,0xa24f,0x4f4c,0xea4f,
+0x402c,0x0d8d,0x5c2a,0x0f4d,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+static unsigned short AD[32] = {
+0x3fe2,0x29bc,0x0262,0x4d31,
+0x402d,0x8334,0x0533,0x2ca5,
+0x4055,0x20e3,0xb04d,0x51a0,
+0x4066,0x2a2d,0xc730,0xb7b0,
+0x4064,0x8782,0x9a9f,0xfa61,
+0x4051,0xde94,0xee91,0xd35f,
+0x402c,0x311b,0x950d,0x9d81,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+#endif
+
+#ifdef UNK
+static double APN[8] = {
+  6.13759184814035759225E-1,
+  1.47454670787755323881E1,
+  8.20584123476060982430E1,
+  1.71184781360976385540E2,
+  1.59317847137141783523E2,
+  6.99778599330103016170E1,
+  1.39470856980481566958E1,
+  1.00000000000000000550E0,
+};
+static double APD[8] = {
+  3.34203677749736953049E-1,
+  1.11810297306158156705E1,
+  7.11727352147859965283E1,
+  1.58778084372838313640E2,
+  1.53206427475809220834E2,
+  6.86752304592780337944E1,
+  1.38498634758259442477E1,
+  9.99999999999999994502E-1,
+};
+#endif
+#ifdef DEC
+static unsigned short APN[32] = {
+0040035,0017522,0065145,0054755,
+0041153,0166556,0161471,0057174,
+0041644,0016750,0034445,0046462,
+0042053,0027515,0152316,0046717,
+0042037,0050536,0067023,0023264,
+0041613,0172252,0007240,0131055,
+0041137,0023503,0052472,0002305,
+0040200,0000000,0000000,0000000,
+};
+static unsigned short APD[32] = {
+0037653,0016276,0112106,0126625,
+0041062,0162577,0067111,0111761,
+0041616,0054160,0140004,0137455,
+0042036,0143460,0104626,0157206,
+0042031,0032330,0067131,0114260,
+0041611,0054667,0147207,0134564,
+0041135,0114412,0070653,0146015,
+0040200,0000000,0000000,0000000,
+};
+#endif
+#ifdef IBMPC
+static unsigned short APN[32] = {
+0xab3e,0x4d4c,0xa3ea,0x3fe3,
+0x2bcf,0xdc67,0x7dad,0x402d,
+0xa9a6,0x0724,0x83bd,0x4054,
+0xc9ba,0xba99,0x65e9,0x4065,
+0x64d7,0xcdc2,0xea2b,0x4063,
+0x1646,0x41d4,0x7e95,0x4051,
+0x4099,0x6aa7,0xe4e8,0x402b,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+static unsigned short APD[32] = {
+0xd5b3,0xd288,0x6397,0x3fd5,
+0x327e,0xedc9,0x5caf,0x4026,
+0x97e6,0x1800,0xcb0e,0x4051,
+0xdbd1,0x1132,0xd8e6,0x4063,
+0x3316,0x0dcb,0x269b,0x4063,
+0xf72f,0xf9d0,0x2b36,0x4051,
+0x7982,0x4e35,0xb321,0x402b,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+#endif
+#ifdef MIEEE
+static unsigned short APN[32] = {
+0x3fe3,0xa3ea,0x4d4c,0xab3e,
+0x402d,0x7dad,0xdc67,0x2bcf,
+0x4054,0x83bd,0x0724,0xa9a6,
+0x4065,0x65e9,0xba99,0xc9ba,
+0x4063,0xea2b,0xcdc2,0x64d7,
+0x4051,0x7e95,0x41d4,0x1646,
+0x402b,0xe4e8,0x6aa7,0x4099,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+static unsigned short APD[32] = {
+0x3fd5,0x6397,0xd288,0xd5b3,
+0x4026,0x5caf,0xedc9,0x327e,
+0x4051,0xcb0e,0x1800,0x97e6,
+0x4063,0xd8e6,0x1132,0xdbd1,
+0x4063,0x269b,0x0dcb,0x3316,
+0x4051,0x2b36,0xf9d0,0xf72f,
+0x402b,0xb321,0x4e35,0x7982,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+#endif
+
+#ifdef UNK
+static double BN16[5] = {
+-2.53240795869364152689E-1,
+ 5.75285167332467384228E-1,
+-3.29907036873225371650E-1,
+ 6.44404068948199951727E-2,
+-3.82519546641336734394E-3,
+};
+static double BD16[5] = {
+/* 1.00000000000000000000E0,*/
+-7.15685095054035237902E0,
+ 1.06039580715664694291E1,
+-5.23246636471251500874E0,
+ 9.57395864378383833152E-1,
+-5.50828147163549611107E-2,
+};
+#endif
+#ifdef DEC
+static unsigned short BN16[20] = {
+0137601,0124307,0010213,0035210,
+0040023,0042743,0101621,0016031,
+0137650,0164623,0036056,0074511,
+0037203,0174525,0000473,0142474,
+0136172,0130041,0066726,0064324,
+};
+static unsigned short BD16[20] = {
+/*0040200,0000000,0000000,0000000,*/
+0140745,0002354,0044335,0055276,
+0041051,0124717,0170130,0104013,
+0140647,0070135,0046473,0103501,
+0040165,0013745,0033324,0127766,
+0137141,0117204,0076164,0033107,
+};
+#endif
+#ifdef IBMPC
+static unsigned short BN16[20] = {
+0x6751,0xe211,0x3518,0xbfd0,
+0x2383,0x7072,0x68bc,0x3fe2,
+0xcf29,0x6785,0x1d32,0xbfd5,
+0x78a8,0xa027,0x7f2a,0x3fb0,
+0xcd1b,0x2dba,0x5604,0xbf6f,
+};
+static unsigned short BD16[20] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xab58,0x891b,0xa09d,0xc01c,
+0x1101,0xfe0b,0x3539,0x4025,
+0x70e8,0xa9a7,0xee0b,0xc014,
+0x95ff,0xa6da,0xa2fc,0x3fee,
+0x86c9,0x8f8e,0x33d0,0xbfac,
+};
+#endif
+#ifdef MIEEE
+static unsigned short BN16[20] = {
+0xbfd0,0x3518,0xe211,0x6751,
+0x3fe2,0x68bc,0x7072,0x2383,
+0xbfd5,0x1d32,0x6785,0xcf29,
+0x3fb0,0x7f2a,0xa027,0x78a8,
+0xbf6f,0x5604,0x2dba,0xcd1b,
+};
+static unsigned short BD16[20] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0xc01c,0xa09d,0x891b,0xab58,
+0x4025,0x3539,0xfe0b,0x1101,
+0xc014,0xee0b,0xa9a7,0x70e8,
+0x3fee,0xa2fc,0xa6da,0x95ff,
+0xbfac,0x33d0,0x8f8e,0x86c9,
+};
+#endif
+
+#ifdef UNK
+static double BPPN[5] = {
+ 4.65461162774651610328E-1,
+-1.08992173800493920734E0,
+ 6.38800117371827987759E-1,
+-1.26844349553102907034E-1,
+ 7.62487844342109852105E-3,
+};
+static double BPPD[5] = {
+/* 1.00000000000000000000E0,*/
+-8.70622787633159124240E0,
+ 1.38993162704553213172E1,
+-7.14116144616431159572E0,
+ 1.34008595960680518666E0,
+-7.84273211323341930448E-2,
+};
+#endif
+#ifdef DEC
+static unsigned short BPPN[20] = {
+0037756,0050354,0167531,0135731,
+0140213,0101216,0032767,0020375,
+0040043,0104147,0106312,0177632,
+0137401,0161574,0032015,0043714,
+0036371,0155035,0143165,0142262,
+};
+static unsigned short BPPD[20] = {
+/*0040200,0000000,0000000,0000000,*/
+0141013,0046265,0115005,0161053,
+0041136,0061631,0072445,0156131,
+0140744,0102145,0001127,0065304,
+0040253,0103757,0146453,0102513,
+0137240,0117200,0155402,0113500,
+};
+#endif
+#ifdef IBMPC
+static unsigned short BPPN[20] = {
+0x377b,0x9deb,0xca1d,0x3fdd,
+0xe420,0xc6be,0x7051,0xbff1,
+0x5ff3,0xf199,0x710c,0x3fe4,
+0xa8fa,0x8681,0x3c6f,0xbfc0,
+0xb896,0xb8ce,0x3b43,0x3f7f,
+};
+static unsigned short BPPD[20] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xbc45,0xb340,0x6996,0xc021,
+0xbb8b,0x2ea4,0xcc73,0x402b,
+0xed59,0xa04a,0x908c,0xc01c,
+0x70a9,0xf9a5,0x70fd,0x3ff5,
+0x52e8,0x1b60,0x13d0,0xbfb4,
+};
+#endif
+#ifdef MIEEE
+static unsigned short BPPN[20] = {
+0x3fdd,0xca1d,0x9deb,0x377b,
+0xbff1,0x7051,0xc6be,0xe420,
+0x3fe4,0x710c,0xf199,0x5ff3,
+0xbfc0,0x3c6f,0x8681,0xa8fa,
+0x3f7f,0x3b43,0xb8ce,0xb896,
+};
+static unsigned short BPPD[20] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0xc021,0x6996,0xb340,0xbc45,
+0x402b,0xcc73,0x2ea4,0xbb8b,
+0xc01c,0x908c,0xa04a,0xed59,
+0x3ff5,0x70fd,0xf9a5,0x70a9,
+0xbfb4,0x13d0,0x1b60,0x52e8,
+};
+#endif
+
+#ifdef UNK
+static double AFN[9] = {
+-1.31696323418331795333E-1,
+-6.26456544431912369773E-1,
+-6.93158036036933542233E-1,
+-2.79779981545119124951E-1,
+-4.91900132609500318020E-2,
+-4.06265923594885404393E-3,
+-1.59276496239262096340E-4,
+-2.77649108155232920844E-6,
+-1.67787698489114633780E-8,
+};
+static double AFD[9] = {
+/* 1.00000000000000000000E0,*/
+ 1.33560420706553243746E1,
+ 3.26825032795224613948E1,
+ 2.67367040941499554804E1,
+ 9.18707402907259625840E0,
+ 1.47529146771666414581E0,
+ 1.15687173795188044134E-1,
+ 4.40291641615211203805E-3,
+ 7.54720348287414296618E-5,
+ 4.51850092970580378464E-7,
+};
+#endif
+#ifdef DEC
+static unsigned short AFN[36] = {
+0137406,0155546,0124127,0033732,
+0140040,0057564,0141263,0041222,
+0140061,0071316,0013674,0175754,
+0137617,0037522,0056637,0120130,
+0137111,0075567,0121755,0166122,
+0136205,0020016,0043317,0002201,
+0135047,0001565,0075130,0002334,
+0133472,0051700,0165021,0131551,
+0131620,0020347,0132165,0013215,
+};
+static unsigned short AFD[36] = {
+/*0040200,0000000,0000000,0000000,*/
+0041125,0131131,0025627,0067623,
+0041402,0135342,0021703,0154315,
+0041325,0162305,0016671,0120175,
+0041022,0177101,0053114,0141632,
+0040274,0153131,0147364,0114306,
+0037354,0166545,0120042,0150530,
+0036220,0043127,0000727,0130273,
+0034636,0043275,0075667,0034733,
+0032762,0112715,0146250,0142474,
+};
+#endif
+#ifdef IBMPC
+static unsigned short AFN[36] = {
+0xe6fb,0xd50a,0xdb6c,0xbfc0,
+0x6852,0x9856,0x0bee,0xbfe4,
+0x9f7d,0xc2f7,0x2e59,0xbfe6,
+0xf40b,0x4bb3,0xe7ea,0xbfd1,
+0xbd8a,0xf47d,0x2f6e,0xbfa9,
+0xe090,0xc8d9,0xa401,0xbf70,
+0x009c,0xaf4b,0xe06e,0xbf24,
+0x366d,0x1d42,0x4a78,0xbec7,
+0xa2d2,0xf68e,0x041c,0xbe52,
+};
+static unsigned short AFD[36] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xedf2,0x2572,0xb64b,0x402a,
+0x7b1a,0x4478,0x575c,0x4040,
+0x3410,0xa3b7,0xbc98,0x403a,
+0x9873,0x2ac9,0x5fc8,0x4022,
+0x9319,0x39de,0x9acb,0x3ff7,
+0x5a2b,0xb404,0x9dac,0x3fbd,
+0xf617,0xe03a,0x08ca,0x3f72,
+0xe73b,0xaf76,0xc8d7,0x3f13,
+0x18a7,0xb995,0x52b9,0x3e9e,
+};
+#endif
+#ifdef MIEEE
+static unsigned short AFN[36] = {
+0xbfc0,0xdb6c,0xd50a,0xe6fb,
+0xbfe4,0x0bee,0x9856,0x6852,
+0xbfe6,0x2e59,0xc2f7,0x9f7d,
+0xbfd1,0xe7ea,0x4bb3,0xf40b,
+0xbfa9,0x2f6e,0xf47d,0xbd8a,
+0xbf70,0xa401,0xc8d9,0xe090,
+0xbf24,0xe06e,0xaf4b,0x009c,
+0xbec7,0x4a78,0x1d42,0x366d,
+0xbe52,0x041c,0xf68e,0xa2d2,
+};
+static unsigned short AFD[36] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x402a,0xb64b,0x2572,0xedf2,
+0x4040,0x575c,0x4478,0x7b1a,
+0x403a,0xbc98,0xa3b7,0x3410,
+0x4022,0x5fc8,0x2ac9,0x9873,
+0x3ff7,0x9acb,0x39de,0x9319,
+0x3fbd,0x9dac,0xb404,0x5a2b,
+0x3f72,0x08ca,0xe03a,0xf617,
+0x3f13,0xc8d7,0xaf76,0xe73b,
+0x3e9e,0x52b9,0xb995,0x18a7,
+};
+#endif
+
+#ifdef UNK
+static double AGN[11] = {
+  1.97339932091685679179E-2,
+  3.91103029615688277255E-1,
+  1.06579897599595591108E0,
+  9.39169229816650230044E-1,
+  3.51465656105547619242E-1,
+  6.33888919628925490927E-2,
+  5.85804113048388458567E-3,
+  2.82851600836737019778E-4,
+  6.98793669997260967291E-6,
+  8.11789239554389293311E-8,
+  3.41551784765923618484E-10,
+};
+static double AGD[10] = {
+/*  1.00000000000000000000E0,*/
+  9.30892908077441974853E0,
+  1.98352928718312140417E1,
+  1.55646628932864612953E1,
+  5.47686069422975497931E0,
+  9.54293611618961883998E-1,
+  8.64580826352392193095E-2,
+  4.12656523824222607191E-3,
+  1.01259085116509135510E-4,
+  1.17166733214413521882E-6,
+  4.91834570062930015649E-9,
+};
+#endif
+#ifdef DEC
+static unsigned short AGN[44] = {
+0036641,0124456,0167175,0157354,
+0037710,0037250,0001441,0136671,
+0040210,0066031,0150401,0123532,
+0040160,0066545,0003570,0153133,
+0037663,0171516,0072507,0170345,
+0037201,0151011,0007510,0045702,
+0036277,0172317,0104572,0101030,
+0035224,0045663,0000160,0136422,
+0033752,0074753,0047702,0135160,
+0032256,0052225,0156550,0107103,
+0030273,0142443,0166277,0071720,
+};
+static unsigned short AGD[40] = {
+/*0040200,0000000,0000000,0000000,*/
+0041024,0170537,0117253,0055003,
+0041236,0127256,0003570,0143240,
+0041171,0004333,0172476,0160645,
+0040657,0041161,0055716,0157161,
+0040164,0046226,0006257,0063431,
+0037261,0010357,0065445,0047563,
+0036207,0034043,0057434,0116732,
+0034724,0055416,0130035,0026377,
+0033235,0041056,0154071,0023502,
+0031250,0177071,0167254,0047242,
+};
+#endif
+#ifdef IBMPC
+static unsigned short AGN[44] = {
+0xbbde,0xddcf,0x3525,0x3f94,
+0x37b7,0x0064,0x07d5,0x3fd9,
+0x34eb,0x3a20,0x0d83,0x3ff1,
+0x1acb,0xa0ef,0x0dac,0x3fee,
+0xfe1d,0xcea8,0x7e69,0x3fd6,
+0x0978,0x21e9,0x3a41,0x3fb0,
+0x5043,0xf12f,0xfe99,0x3f77,
+0x17a2,0x600e,0x8976,0x3f32,
+0x574e,0x69f8,0x4f3d,0x3edd,
+0x11c8,0xbbad,0xca92,0x3e75,
+0xee7a,0x7d97,0x78a4,0x3df7,
+};
+static unsigned short AGD[40] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x6b40,0xf3d5,0x9e2b,0x4022,
+0x18d4,0xc0ef,0xd5d5,0x4033,
+0xdc35,0x7ea7,0x211b,0x402f,
+0xdbce,0x2b79,0xe84e,0x4015,
+0xece3,0xc195,0x8992,0x3fee,
+0xa9ee,0xed64,0x221d,0x3fb6,
+0x93bb,0x6be3,0xe704,0x3f70,
+0xa5a0,0xd603,0x8b61,0x3f1a,
+0x24e8,0xdb07,0xa845,0x3eb3,
+0x89d4,0x3dd5,0x1fc7,0x3e35,
+};
+#endif
+#ifdef MIEEE
+static unsigned short AGN[44] = {
+0x3f94,0x3525,0xddcf,0xbbde,
+0x3fd9,0x07d5,0x0064,0x37b7,
+0x3ff1,0x0d83,0x3a20,0x34eb,
+0x3fee,0x0dac,0xa0ef,0x1acb,
+0x3fd6,0x7e69,0xcea8,0xfe1d,
+0x3fb0,0x3a41,0x21e9,0x0978,
+0x3f77,0xfe99,0xf12f,0x5043,
+0x3f32,0x8976,0x600e,0x17a2,
+0x3edd,0x4f3d,0x69f8,0x574e,
+0x3e75,0xca92,0xbbad,0x11c8,
+0x3df7,0x78a4,0x7d97,0xee7a,
+};
+static unsigned short AGD[40] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4022,0x9e2b,0xf3d5,0x6b40,
+0x4033,0xd5d5,0xc0ef,0x18d4,
+0x402f,0x211b,0x7ea7,0xdc35,
+0x4015,0xe84e,0x2b79,0xdbce,
+0x3fee,0x8992,0xc195,0xece3,
+0x3fb6,0x221d,0xed64,0xa9ee,
+0x3f70,0xe704,0x6be3,0x93bb,
+0x3f1a,0x8b61,0xd603,0xa5a0,
+0x3eb3,0xa845,0xdb07,0x24e8,
+0x3e35,0x1fc7,0x3dd5,0x89d4,
+};
+#endif
+
+#ifdef UNK
+static double APFN[9] = {
+  1.85365624022535566142E-1,
+  8.86712188052584095637E-1,
+  9.87391981747398547272E-1,
+  4.01241082318003734092E-1,
+  7.10304926289631174579E-2,
+  5.90618657995661810071E-3,
+  2.33051409401776799569E-4,
+  4.08718778289035454598E-6,
+  2.48379932900442457853E-8,
+};
+static double APFD[9] = {
+/*  1.00000000000000000000E0,*/
+  1.47345854687502542552E1,
+  3.75423933435489594466E1,
+  3.14657751203046424330E1,
+  1.09969125207298778536E1,
+  1.78885054766999417817E0,
+  1.41733275753662636873E-1,
+  5.44066067017226003627E-3,
+  9.39421290654511171663E-5,
+  5.65978713036027009243E-7,
+};
+#endif
+#ifdef DEC
+static unsigned short APFN[36] = {
+0037475,0150174,0071752,0166651,
+0040142,0177621,0164246,0101757,
+0040174,0142670,0106760,0006573,
+0037715,0067570,0116274,0022404,
+0037221,0074157,0053341,0117207,
+0036301,0104257,0015075,0004777,
+0035164,0057502,0164034,0001313,
+0033611,0022254,0176000,0112565,
+0031725,0055523,0025153,0166057,
+};
+static unsigned short APFD[36] = {
+/*0040200,0000000,0000000,0000000,*/
+0041153,0140334,0130506,0061402,
+0041426,0025551,0024440,0070611,
+0041373,0134750,0047147,0176702,
+0041057,0171532,0105430,0017674,
+0040344,0174416,0001726,0047754,
+0037421,0021207,0020167,0136264,
+0036262,0043621,0151321,0124324,
+0034705,0001313,0163733,0016407,
+0033027,0166702,0150440,0170561,
+};
+#endif
+#ifdef IBMPC
+static unsigned short APFN[36] = {
+0x5db5,0x8e7d,0xba0f,0x3fc7,
+0xd07e,0x3d14,0x5ff2,0x3fec,
+0x01af,0x11be,0x98b7,0x3fef,
+0x84a1,0x1397,0xadef,0x3fd9,
+0x33d1,0xeadc,0x2f0d,0x3fb2,
+0xa140,0xe347,0x3115,0x3f78,
+0x8059,0x5d03,0x8be8,0x3f2e,
+0x12af,0x9f80,0x2495,0x3ed1,
+0x7d86,0x654d,0xab6a,0x3e5a,
+};
+static unsigned short APFD[36] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xcc60,0x9628,0x781b,0x402d,
+0x0e31,0x2524,0xc56d,0x4042,
+0xffb8,0x09cc,0x773d,0x403f,
+0x03f7,0x5163,0xfe6b,0x4025,
+0xc9fd,0xc07a,0x9f21,0x3ffc,
+0xf796,0xe40e,0x2450,0x3fc2,
+0x351a,0x3a5a,0x48f2,0x3f76,
+0x63a1,0x7cfb,0xa059,0x3f18,
+0x1e2e,0x5a24,0xfdb8,0x3ea2,
+};
+#endif
+#ifdef MIEEE
+static unsigned short APFN[36] = {
+0x3fc7,0xba0f,0x8e7d,0x5db5,
+0x3fec,0x5ff2,0x3d14,0xd07e,
+0x3fef,0x98b7,0x11be,0x01af,
+0x3fd9,0xadef,0x1397,0x84a1,
+0x3fb2,0x2f0d,0xeadc,0x33d1,
+0x3f78,0x3115,0xe347,0xa140,
+0x3f2e,0x8be8,0x5d03,0x8059,
+0x3ed1,0x2495,0x9f80,0x12af,
+0x3e5a,0xab6a,0x654d,0x7d86,
+};
+static unsigned short APFD[36] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x402d,0x781b,0x9628,0xcc60,
+0x4042,0xc56d,0x2524,0x0e31,
+0x403f,0x773d,0x09cc,0xffb8,
+0x4025,0xfe6b,0x5163,0x03f7,
+0x3ffc,0x9f21,0xc07a,0xc9fd,
+0x3fc2,0x2450,0xe40e,0xf796,
+0x3f76,0x48f2,0x3a5a,0x351a,
+0x3f18,0xa059,0x7cfb,0x63a1,
+0x3ea2,0xfdb8,0x5a24,0x1e2e,
+};
+#endif
+
+#ifdef UNK
+static double APGN[11] = {
+-3.55615429033082288335E-2,
+-6.37311518129435504426E-1,
+-1.70856738884312371053E0,
+-1.50221872117316635393E0,
+-5.63606665822102676611E-1,
+-1.02101031120216891789E-1,
+-9.48396695961445269093E-3,
+-4.60325307486780994357E-4,
+-1.14300836484517375919E-5,
+-1.33415518685547420648E-7,
+-5.63803833958893494476E-10,
+};
+static double APGD[11] = {
+/*  1.00000000000000000000E0,*/
+  9.85865801696130355144E0,
+  2.16401867356585941885E1,
+  1.73130776389749389525E1,
+  6.17872175280828766327E0,
+  1.08848694396321495475E0,
+  9.95005543440888479402E-2,
+  4.78468199683886610842E-3,
+  1.18159633322838625562E-4,
+  1.37480673554219441465E-6,
+  5.79912514929147598821E-9,
+};
+#endif
+#ifdef DEC
+static unsigned short APGN[44] = {
+0137021,0124372,0176075,0075331,
+0140043,0023330,0177672,0161655,
+0140332,0131126,0010413,0171112,
+0140300,0044263,0175560,0054070,
+0140020,0044206,0142603,0073324,
+0137321,0015130,0066144,0144033,
+0136433,0061243,0175542,0103373,
+0135361,0053721,0020441,0053203,
+0134077,0141725,0160277,0130612,
+0132417,0040372,0100363,0060200,
+0130432,0175052,0171064,0034147,
+};
+static unsigned short APGD[40] = {
+/*0040200,0000000,0000000,0000000,*/
+0041035,0136420,0030124,0140220,
+0041255,0017432,0034447,0162256,
+0041212,0100456,0154544,0006321,
+0040705,0134026,0127154,0123414,
+0040213,0051612,0044470,0172607,
+0037313,0143362,0053273,0157051,
+0036234,0144322,0054536,0007264,
+0034767,0146170,0054265,0170342,
+0033270,0102777,0167362,0073631,
+0031307,0040644,0167103,0021763,
+};
+#endif
+#ifdef IBMPC
+static unsigned short APGN[44] = {
+0xaf5b,0x5f87,0x351f,0xbfa2,
+0x5c76,0x1ff7,0x64db,0xbfe4,
+0x7e49,0xc221,0x564a,0xbffb,
+0x0b07,0x7f6e,0x0916,0xbff8,
+0x6edb,0xd8b0,0x0910,0xbfe2,
+0x9903,0x0d8c,0x234b,0xbfba,
+0x50df,0x7f6c,0x6c54,0xbf83,
+0x2ad0,0x2424,0x2afa,0xbf3e,
+0xf631,0xbc17,0xf87a,0xbee7,
+0x6c10,0x501e,0xe81f,0xbe81,
+0x870d,0x5e46,0x5f45,0xbe03,
+};
+static unsigned short APGD[40] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x9812,0x060a,0xb7a2,0x4023,
+0xfc96,0x4724,0xa3e3,0x4035,
+0x819a,0xdb2c,0x5025,0x4031,
+0x94e2,0xd5cd,0xb702,0x4018,
+0x1eb1,0x4927,0x6a71,0x3ff1,
+0x7bc5,0x4ad7,0x78de,0x3fb9,
+0xc1d7,0x4b2b,0x991a,0x3f73,
+0xbe1c,0x0b16,0xf98f,0x3f1e,
+0x4ef3,0xfdde,0x10bf,0x3eb7,
+0x647e,0x9dc8,0xe834,0x3e38,
+};
+#endif
+#ifdef MIEEE
+static unsigned short APGN[44] = {
+0xbfa2,0x351f,0x5f87,0xaf5b,
+0xbfe4,0x64db,0x1ff7,0x5c76,
+0xbffb,0x564a,0xc221,0x7e49,
+0xbff8,0x0916,0x7f6e,0x0b07,
+0xbfe2,0x0910,0xd8b0,0x6edb,
+0xbfba,0x234b,0x0d8c,0x9903,
+0xbf83,0x6c54,0x7f6c,0x50df,
+0xbf3e,0x2afa,0x2424,0x2ad0,
+0xbee7,0xf87a,0xbc17,0xf631,
+0xbe81,0xe81f,0x501e,0x6c10,
+0xbe03,0x5f45,0x5e46,0x870d,
+};
+static unsigned short APGD[40] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4023,0xb7a2,0x060a,0x9812,
+0x4035,0xa3e3,0x4724,0xfc96,
+0x4031,0x5025,0xdb2c,0x819a,
+0x4018,0xb702,0xd5cd,0x94e2,
+0x3ff1,0x6a71,0x4927,0x1eb1,
+0x3fb9,0x78de,0x4ad7,0x7bc5,
+0x3f73,0x991a,0x4b2b,0xc1d7,
+0x3f1e,0xf98f,0x0b16,0xbe1c,
+0x3eb7,0x10bf,0xfdde,0x4ef3,
+0x3e38,0xe834,0x9dc8,0x647e,
+};
+#endif
+
+#ifdef ANSIPROT
+extern double fabs ( double );
+extern double exp ( double );
+extern double sqrt ( double );
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double sin ( double );
+extern double cos ( double );
+#else
+double fabs(), exp(), sqrt();
+double polevl(), p1evl(), sin(), cos();
+#endif
+
+int airy( x, ai, aip, bi, bip )
+double x, *ai, *aip, *bi, *bip;
+{
+double z, zz, t, f, g, uf, ug, k, zeta, theta;
+int domflg;
+
+domflg = 0;
+if( x > MAXAIRY )
+	{
+	*ai = 0;
+	*aip = 0;
+	*bi = MAXNUM;
+	*bip = MAXNUM;
+	return(-1);
+	}
+
+if( x < -2.09 )
+	{
+	domflg = 15;
+	t = sqrt(-x);
+	zeta = -2.0 * x * t / 3.0;
+	t = sqrt(t);
+	k = sqpii / t;
+	z = 1.0/zeta;
+	zz = z * z;
+	uf = 1.0 + zz * polevl( zz, AFN, 8 ) / p1evl( zz, AFD, 9 );
+	ug = z * polevl( zz, AGN, 10 ) / p1evl( zz, AGD, 10 );
+	theta = zeta + 0.25 * PI;
+	f = sin( theta );
+	g = cos( theta );
+	*ai = k * (f * uf - g * ug);
+	*bi = k * (g * uf + f * ug);
+	uf = 1.0 + zz * polevl( zz, APFN, 8 ) / p1evl( zz, APFD, 9 );
+	ug = z * polevl( zz, APGN, 10 ) / p1evl( zz, APGD, 10 );
+	k = sqpii * t;
+	*aip = -k * (g * uf + f * ug);
+	*bip = k * (f * uf - g * ug);
+	return(0);
+	}
+
+if( x >= 2.09 )	/* cbrt(9) */
+	{
+	domflg = 5;
+	t = sqrt(x);
+	zeta = 2.0 * x * t / 3.0;
+	g = exp( zeta );
+	t = sqrt(t);
+	k = 2.0 * t * g;
+	z = 1.0/zeta;
+	f = polevl( z, AN, 7 ) / polevl( z, AD, 7 );
+	*ai = sqpii * f / k;
+	k = -0.5 * sqpii * t / g;
+	f = polevl( z, APN, 7 ) / polevl( z, APD, 7 );
+	*aip = f * k;
+
+	if( x > 8.3203353 )	/* zeta > 16 */
+		{
+		f = z * polevl( z, BN16, 4 ) / p1evl( z, BD16, 5 );
+		k = sqpii * g;
+		*bi = k * (1.0 + f) / t;
+		f = z * polevl( z, BPPN, 4 ) / p1evl( z, BPPD, 5 );
+		*bip = k * t * (1.0 + f);
+		return(0);
+		}
+	}
+
+f = 1.0;
+g = x;
+t = 1.0;
+uf = 1.0;
+ug = x;
+k = 1.0;
+z = x * x * x;
+while( t > MACHEP )
+	{
+	uf *= z;
+	k += 1.0;
+	uf /=k;
+	ug *= z;
+	k += 1.0;
+	ug /=k;
+	uf /=k;
+	f += uf;
+	k += 1.0;
+	ug /=k;
+	g += ug;
+	t = fabs(uf/f);
+	}
+uf = c1 * f;
+ug = c2 * g;
+if( (domflg & 1) == 0 )
+	*ai = uf - ug;
+if( (domflg & 2) == 0 )
+	*bi = sqrt3 * (uf + ug);
+
+/* the deriviative of ai */
+k = 4.0;
+uf = x * x/2.0;
+ug = z/3.0;
+f = uf;
+g = 1.0 + ug;
+uf /= 3.0;
+t = 1.0;
+
+while( t > MACHEP )
+	{
+	uf *= z;
+	ug /=k;
+	k += 1.0;
+	ug *= z;
+	uf /=k;
+	f += uf;
+	k += 1.0;
+	ug /=k;
+	uf /=k;
+	g += ug;
+	k += 1.0;
+	t = fabs(ug/g);
+	}
+
+uf = c1 * f;
+ug = c2 * g;
+if( (domflg & 4) == 0 )
+	*aip = uf - ug;
+if( (domflg & 8) == 0 )
+	*bip = sqrt3 * (uf + ug);
+return(0);
+}
Index: sansmodels/src/cephes/bdtr.c
===================================================================
--- sansmodels/src/cephes/bdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/bdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,266 @@
+/*							bdtr.c
+ *
+ *	Binomial distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k, n;
+ * double p, y, bdtr();
+ *
+ * y = bdtr( k, n, p );
+ *
+ * DESCRIPTION:
+ *
+ * Returns the sum of the terms 0 through k of the Binomial
+ * probability density:
+ *
+ *   k
+ *   --  ( n )   j      n-j
+ *   >   (   )  p  (1-p)
+ *   --  ( j )
+ *  j=0
+ *
+ * The terms are not summed directly; instead the incomplete
+ * beta integral is employed, according to the formula
+ *
+ * y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
+ *
+ * The arguments must be positive, with p ranging from 0 to 1.
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,p), with p between 0 and 1.
+ *
+ *               a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *  For p between 0.001 and 1:
+ *    IEEE     0,100       100000      4.3e-15     2.6e-16
+ * See also incbet.c.
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * bdtr domain         k < 0            0.0
+ *                     n < k
+ *                     x < 0, x > 1
+ */
+
+/*							bdtrc()
+ *
+ *	Complemented binomial distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k, n;
+ * double p, y, bdtrc();
+ *
+ * y = bdtrc( k, n, p );
+ *
+ * DESCRIPTION:
+ *
+ * Returns the sum of the terms k+1 through n of the Binomial
+ * probability density:
+ *
+ *   n
+ *   --  ( n )   j      n-j
+ *   >   (   )  p  (1-p)
+ *   --  ( j )
+ *  j=k+1
+ *
+ * The terms are not summed directly; instead the incomplete
+ * beta integral is employed, according to the formula
+ *
+ * y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
+ *
+ * The arguments must be positive, with p ranging from 0 to 1.
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,p).
+ *
+ *               a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *  For p between 0.001 and 1:
+ *    IEEE     0,100       100000      6.7e-15     8.2e-16
+ *  For p between 0 and .001:
+ *    IEEE     0,100       100000      1.5e-13     2.7e-15
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * bdtrc domain      x<0, x>1, n<k       0.0
+ */
+
+/*							bdtri()
+ *
+ *	Inverse binomial distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k, n;
+ * double p, y, bdtri();
+ *
+ * p = bdtr( k, n, y );
+ *
+ * DESCRIPTION:
+ *
+ * Finds the event probability p such that the sum of the
+ * terms 0 through k of the Binomial probability density
+ * is equal to the given cumulative probability y.
+ *
+ * This is accomplished using the inverse beta integral
+ * function and the relation
+ *
+ * 1 - p = incbi( n-k, k+1, y ).
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,p).
+ *
+ *               a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *  For p between 0.001 and 1:
+ *    IEEE     0,100       100000      2.3e-14     6.4e-16
+ *    IEEE     0,10000     100000      6.6e-12     1.2e-13
+ *  For p between 10^-6 and 0.001:
+ *    IEEE     0,100       100000      2.0e-12     1.3e-14
+ *    IEEE     0,10000     100000      1.5e-12     3.2e-14
+ * See also incbi.c.
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * bdtri domain     k < 0, n <= k         0.0
+ *                  x < 0, x > 1
+ */
+
+
+/*								bdtr() */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double incbet ( double, double, double );
+extern double incbi ( double, double, double );
+extern double pow ( double, double );
+extern double log1p ( double );
+extern double expm1 ( double );
+#else
+double incbet(), incbi(), pow(), log1p(), expm1();
+#endif
+
+double bdtrc( k, n, p )
+int k, n;
+double p;
+{
+double dk, dn;
+
+if( (p < 0.0) || (p > 1.0) )
+	goto domerr;
+if( k < 0 )
+	return( 1.0 );
+
+if( n < k )
+	{
+domerr:
+	mtherr( "bdtrc", DOMAIN );
+	return( 0.0 );
+	}
+
+if( k == n )
+	return( 0.0 );
+dn = n - k;
+if( k == 0 )
+	{
+	if( p < .01 )
+		dk = -expm1( dn * log1p(-p) );
+	else
+		dk = 1.0 - pow( 1.0-p, dn );
+	}
+else
+	{
+	dk = k + 1;
+	dk = incbet( dk, dn, p );
+	}
+return( dk );
+}
+
+
+
+double bdtr( k, n, p )
+int k, n;
+double p;
+{
+double dk, dn;
+
+if( (p < 0.0) || (p > 1.0) )
+	goto domerr;
+if( (k < 0) || (n < k) )
+	{
+domerr:
+	mtherr( "bdtr", DOMAIN );
+	return( 0.0 );
+	}
+
+if( k == n )
+	return( 1.0 );
+
+dn = n - k;
+if( k == 0 )
+	{
+	dk = pow( 1.0-p, dn );
+	}
+else
+	{
+	dk = k + 1;
+	dk = incbet( dn, dk, 1.0 - p );
+	}
+return( dk );
+}
+
+
+double bdtri( k, n, y )
+int k, n;
+double y;
+{
+double dk, dn, p;
+
+if( (y < 0.0) || (y > 1.0) )
+	goto domerr;
+if( (k < 0) || (n <= k) )
+	{
+domerr:
+	mtherr( "bdtri", DOMAIN );
+	return( 0.0 );
+	}
+
+dn = n - k;
+if( k == 0 )
+	{
+	if( y > 0.8 )
+		p = -expm1( log1p(y-1.0) / dn );
+	else
+		p = 1.0 - pow( y, 1.0/dn );
+	}
+else
+	{
+	dk = k + 1;
+	p = incbet( dn, dk, 0.5 );
+	if( p > 0.5 )
+		p = incbi( dk, dn, 1.0-y );
+	else
+		p = 1.0 - incbi( dn, dk, y );
+	}
+return( p );
+}
Index: sansmodels/src/cephes/btdtr.c
===================================================================
--- sansmodels/src/cephes/btdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/btdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,65 @@
+
+/*							btdtr.c
+ *
+ *	Beta distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, x, y, btdtr();
+ *
+ * y = btdtr( a, b, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the area from zero to x under the beta density
+ * function:
+ *
+ *
+ *                          x
+ *            -             -
+ *           | (a+b)       | |  a-1      b-1
+ * P(x)  =  ----------     |   t    (1-t)    dt
+ *           -     -     | |
+ *          | (a) | (b)   -
+ *                         0
+ *
+ *
+ * This function is identical to the incomplete beta
+ * integral function incbet(a, b, x).
+ *
+ * The complemented function is
+ *
+ * 1 - P(1-x)  =  incbet( b, a, x );
+ *
+ *
+ * ACCURACY:
+ *
+ * See incbet.c.
+ *
+ */
+
+
+/*								btdtr()	*/
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double incbet ( double, double, double );
+#else
+double incbet();
+#endif
+
+double btdtr( a, b, x )
+double a, b, x;
+{
+
+return( incbet( a, b, x ) );
+}
Index: sansmodels/src/cephes/cephes.h
===================================================================
--- sansmodels/src/cephes/cephes.h	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/cephes.h	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,10 @@
+/*
+ * header for the selection of cephes routines here.
+ *
+ * used for the bessel functions - some of the rest could be removed.
+ *
+ * AJJ 2013-04-05
+ */
+
+#include "mconf.h"
+#include "protos.h"
Index: sansmodels/src/cephes/chbevl.c
===================================================================
--- sansmodels/src/cephes/chbevl.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/chbevl.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,83 @@
+/*							chbevl.c
+ *
+ *	Evaluate Chebyshev series
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int N;
+ * double x, y, coef[N], chebevl();
+ *
+ * y = chbevl( x, coef, N );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Evaluates the series
+ *
+ *        N-1
+ *         - '
+ *  y  =   >   coef[i] T (x/2)
+ *         -            i
+ *        i=0
+ *
+ * of Chebyshev polynomials Ti at argument x/2.
+ *
+ * Coefficients are stored in reverse order, i.e. the zero
+ * order term is last in the array.  Note N is the number of
+ * coefficients, not the order.
+ *
+ * If coefficients are for the interval a to b, x must
+ * have been transformed to x -> 2(2x - b - a)/(b-a) before
+ * entering the routine.  This maps x from (a, b) to (-1, 1),
+ * over which the Chebyshev polynomials are defined.
+ *
+ * If the coefficients are for the inverted interval, in
+ * which (a, b) is mapped to (1/b, 1/a), the transformation
+ * required is x -> 2(2ab/x - b - a)/(b-a).  If b is infinity,
+ * this becomes x -> 4a/x - 1.
+ *
+ *
+ *
+ * SPEED:
+ *
+ * Taking advantage of the recurrence properties of the
+ * Chebyshev polynomials, the routine requires one more
+ * addition per loop than evaluating a nested polynomial of
+ * the same degree.
+ *
+ */
+
+/*							chbevl.c	*/
+
+/*
+Cephes Math Library Release 2.0:  April, 1987
+Copyright 1985, 1987 by Stephen L. Moshier
+Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+*/
+
+double chbevl( x, array, n )
+double x;
+double array[];
+int n;
+{
+double b0, b1, b2, *p;
+int i;
+
+p = array;
+b0 = *p++;
+b1 = 0.0;
+i = n - 1;
+
+do
+	{
+	b2 = b1;
+	b1 = b0;
+	b0 = x * b1  -  b2  + *p++;
+	}
+while( --i );
+
+return( 0.5*(b0-b2) );
+}
Index: sansmodels/src/cephes/chdtr.c
===================================================================
--- sansmodels/src/cephes/chdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/chdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,203 @@
+/*							chdtr.c
+ *
+ *	Chi-square distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double df, x, y, chdtr();
+ *
+ * y = chdtr( df, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the area under the left hand tail (from 0 to x)
+ * of the Chi square probability density function with
+ * v degrees of freedom.
+ *
+ *
+ *                                  inf.
+ *                                    -
+ *                        1          | |  v/2-1  -t/2
+ *  P( x | v )   =   -----------     |   t      e     dt
+ *                    v/2  -       | |
+ *                   2    | (v/2)   -
+ *                                   x
+ *
+ * where x is the Chi-square variable.
+ *
+ * The incomplete gamma integral is used, according to the
+ * formula
+ *
+ *	y = chdtr( v, x ) = igam( v/2.0, x/2.0 ).
+ *
+ *
+ * The arguments must both be positive.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * See igam().
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * chdtr domain   x < 0 or v < 1        0.0
+ */
+
+/*							chdtrc()
+ *
+ *	Complemented Chi-square distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double v, x, y, chdtrc();
+ *
+ * y = chdtrc( v, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the area under the right hand tail (from x to
+ * infinity) of the Chi square probability density function
+ * with v degrees of freedom:
+ *
+ *
+ *                                  inf.
+ *                                    -
+ *                        1          | |  v/2-1  -t/2
+ *  P( x | v )   =   -----------     |   t      e     dt
+ *                    v/2  -       | |
+ *                   2    | (v/2)   -
+ *                                   x
+ *
+ * where x is the Chi-square variable.
+ *
+ * The incomplete gamma integral is used, according to the
+ * formula
+ *
+ *	y = chdtr( v, x ) = igamc( v/2.0, x/2.0 ).
+ *
+ *
+ * The arguments must both be positive.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * See igamc().
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * chdtrc domain  x < 0 or v < 1        0.0
+ */
+
+/*							chdtri()
+ *
+ *	Inverse of complemented Chi-square distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double df, x, y, chdtri();
+ *
+ * x = chdtri( df, y );
+ *
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Finds the Chi-square argument x such that the integral
+ * from x to infinity of the Chi-square density is equal
+ * to the given cumulative probability y.
+ *
+ * This is accomplished using the inverse gamma integral
+ * function and the relation
+ *
+ *    x/2 = igami( df/2, y );
+ *
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * See igami.c.
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * chdtri domain   y < 0 or y > 1        0.0
+ *                     v < 1
+ *
+ */
+
+
+/*								chdtr() */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double igamc ( double, double );
+extern double igam ( double, double );
+extern double igami ( double, double );
+#else
+double igamc(), igam(), igami();
+#endif
+
+double chdtrc(df,x)
+double df, x;
+{
+
+if( (x < 0.0) || (df < 1.0) )
+	{
+	mtherr( "chdtrc", DOMAIN );
+	return(0.0);
+	}
+return( igamc( df/2.0, x/2.0 ) );
+}
+
+
+
+double chdtr(df,x)
+double df, x;
+{
+
+if( (x < 0.0) || (df < 1.0) )
+	{
+	mtherr( "chdtr", DOMAIN );
+	return(0.0);
+	}
+return( igam( df/2.0, x/2.0 ) );
+}
+
+
+
+double chdtri( df, y )
+double df, y;
+{
+double x;
+
+if( (y < 0.0) || (y > 1.0) || (df < 1.0) )
+	{
+	mtherr( "chdtri", DOMAIN );
+	return(0.0);
+	}
+
+x = igami( 0.5 * df, y );
+return( 2.0 * x );
+}
Index: sansmodels/src/cephes/const.c
===================================================================
--- sansmodels/src/cephes/const.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/const.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,253 @@
+/*							const.c
+ *
+ *	Globally declared constants
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * extern double nameofconstant;
+ *
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * This file contains a number of mathematical constants and
+ * also some needed size parameters of the computer arithmetic.
+ * The values are supplied as arrays of hexadecimal integers
+ * for IEEE arithmetic; arrays of octal constants for DEC
+ * arithmetic; and in a normal decimal scientific notation for
+ * other machines.  The particular notation used is determined
+ * by a symbol (DEC, IBMPC, or UNK) defined in the include file
+ * mconf.h.
+ *
+ * The default size parameters are as follows.
+ *
+ * For DEC and UNK modes:
+ * MACHEP =  1.38777878078144567553E-17       2**-56
+ * MAXLOG =  8.8029691931113054295988E1       log(2**127)
+ * MINLOG = -8.872283911167299960540E1        log(2**-128)
+ * MAXNUM =  1.701411834604692317316873e38    2**127
+ *
+ * For IEEE arithmetic (IBMPC):
+ * MACHEP =  1.11022302462515654042E-16       2**-53
+ * MAXLOG =  7.09782712893383996843E2         log(2**1024)
+ * MINLOG = -7.08396418532264106224E2         log(2**-1022)
+ * MAXNUM =  1.7976931348623158E308           2**1024
+ *
+ * The global symbols for mathematical constants are
+ * PI     =  3.14159265358979323846           pi
+ * PIO2   =  1.57079632679489661923           pi/2
+ * PIO4   =  7.85398163397448309616E-1        pi/4
+ * SQRT2  =  1.41421356237309504880           sqrt(2)
+ * SQRTH  =  7.07106781186547524401E-1        sqrt(2)/2
+ * LOG2E  =  1.4426950408889634073599         1/log(2)
+ * SQ2OPI =  7.9788456080286535587989E-1      sqrt( 2/pi )
+ * LOGE2  =  6.93147180559945309417E-1        log(2)
+ * LOGSQ2 =  3.46573590279972654709E-1        log(2)/2
+ * THPIO4 =  2.35619449019234492885           3*pi/4
+ * TWOOPI =  6.36619772367581343075535E-1     2/pi
+ *
+ * These lists are subject to change.
+ */
+
+
+/*							const.c */
+
+/*
+Cephes Math Library Release 2.3:  March, 1995
+Copyright 1984, 1995 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+#ifdef UNK
+#if 1
+double MACHEP =  1.11022302462515654042E-16;   /* 2**-53 */
+#else
+double MACHEP =  1.38777878078144567553E-17;   /* 2**-56 */
+#endif
+double UFLOWTHRESH =  2.22507385850720138309E-308; /* 2**-1022 */
+#ifdef DENORMAL
+double MAXLOG =  7.09782712893383996732E2;     /* log(MAXNUM) */
+/* double MINLOG = -7.44440071921381262314E2; */     /* log(2**-1074) */
+double MINLOG = -7.451332191019412076235E2;     /* log(2**-1075) */
+#else
+double MAXLOG =  7.08396418532264106224E2;     /* log 2**1022 */
+double MINLOG = -7.08396418532264106224E2;     /* log 2**-1022 */
+#endif
+double MAXNUM =  1.79769313486231570815E308;    /* 2**1024*(1-MACHEP) */
+double PI     =  3.14159265358979323846;       /* pi */
+double PIO2   =  1.57079632679489661923;       /* pi/2 */
+double PIO4   =  7.85398163397448309616E-1;    /* pi/4 */
+double SQRT2  =  1.41421356237309504880;       /* sqrt(2) */
+double SQRTH  =  7.07106781186547524401E-1;    /* sqrt(2)/2 */
+double LOG2E  =  1.4426950408889634073599;     /* 1/log(2) */
+double SQ2OPI =  7.9788456080286535587989E-1;  /* sqrt( 2/pi ) */
+double LOGE2  =  6.93147180559945309417E-1;    /* log(2) */
+double LOGSQ2 =  3.46573590279972654709E-1;    /* log(2)/2 */
+double THPIO4 =  2.35619449019234492885;       /* 3*pi/4 */
+double TWOOPI =  6.36619772367581343075535E-1; /* 2/pi */
+#ifdef INFINITIES
+double INFINITY = 1.0/0.0;  /* 99e999; */
+#else
+double INFINITY =  1.79769313486231570815E308;    /* 2**1024*(1-MACHEP) */
+#endif
+#ifdef NANS
+double NAN = 1.0/0.0 - 1.0/0.0;
+#else
+double NAN = 0.0;
+#endif
+#ifdef MINUSZERO
+double NEGZERO = -0.0;
+#else
+double NEGZERO = 0.0;
+#endif
+#endif
+
+#ifdef IBMPC
+			/* 2**-53 =  1.11022302462515654042E-16 */
+unsigned short MACHEP[4] = {0x0000,0x0000,0x0000,0x3ca0};
+unsigned short UFLOWTHRESH[4] = {0x0000,0x0000,0x0000,0x0010};
+#ifdef DENORMAL
+			/* log(MAXNUM) =  7.09782712893383996732224E2 */
+unsigned short MAXLOG[4] = {0x39ef,0xfefa,0x2e42,0x4086};
+			/* log(2**-1074) = - -7.44440071921381262314E2 */
+/*unsigned short MINLOG[4] = {0x71c3,0x446d,0x4385,0xc087};*/
+unsigned short MINLOG[4] = {0x3052,0xd52d,0x4910,0xc087};
+#else
+			/* log(2**1022) =   7.08396418532264106224E2 */
+unsigned short MAXLOG[4] = {0xbcd2,0xdd7a,0x232b,0x4086};
+			/* log(2**-1022) = - 7.08396418532264106224E2 */
+unsigned short MINLOG[4] = {0xbcd2,0xdd7a,0x232b,0xc086};
+#endif
+			/* 2**1024*(1-MACHEP) =  1.7976931348623158E308 */
+unsigned short MAXNUM[4] = {0xffff,0xffff,0xffff,0x7fef};
+unsigned short PI[4]     = {0x2d18,0x5444,0x21fb,0x4009};
+unsigned short PIO2[4]   = {0x2d18,0x5444,0x21fb,0x3ff9};
+unsigned short PIO4[4]   = {0x2d18,0x5444,0x21fb,0x3fe9};
+unsigned short SQRT2[4]  = {0x3bcd,0x667f,0xa09e,0x3ff6};
+unsigned short SQRTH[4]  = {0x3bcd,0x667f,0xa09e,0x3fe6};
+unsigned short LOG2E[4]  = {0x82fe,0x652b,0x1547,0x3ff7};
+unsigned short SQ2OPI[4] = {0x3651,0x33d4,0x8845,0x3fe9};
+unsigned short LOGE2[4]  = {0x39ef,0xfefa,0x2e42,0x3fe6};
+unsigned short LOGSQ2[4] = {0x39ef,0xfefa,0x2e42,0x3fd6};
+unsigned short THPIO4[4] = {0x21d2,0x7f33,0xd97c,0x4002};
+unsigned short TWOOPI[4] = {0xc883,0x6dc9,0x5f30,0x3fe4};
+#ifdef INFINITIES
+unsigned short INFINITY[4] = {0x0000,0x0000,0x0000,0x7ff0};
+#else
+unsigned short INFINITY[4] = {0xffff,0xffff,0xffff,0x7fef};
+#endif
+#ifdef NANS
+unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x7ffc};
+#else
+unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000};
+#endif
+#ifdef MINUSZERO
+unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x8000};
+#else
+unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000};
+#endif
+#endif
+
+#ifdef MIEEE
+			/* 2**-53 =  1.11022302462515654042E-16 */
+unsigned short MACHEP[4] = {0x3ca0,0x0000,0x0000,0x0000};
+unsigned short UFLOWTHRESH[4] = {0x0010,0x0000,0x0000,0x0000};
+#ifdef DENORMAL
+			/* log(2**1024) =   7.09782712893383996843E2 */
+unsigned short MAXLOG[4] = {0x4086,0x2e42,0xfefa,0x39ef};
+			/* log(2**-1074) = - -7.44440071921381262314E2 */
+/* unsigned short MINLOG[4] = {0xc087,0x4385,0x446d,0x71c3}; */
+unsigned short MINLOG[4] = {0xc087,0x4910,0xd52d,0x3052};
+#else
+			/* log(2**1022) =  7.08396418532264106224E2 */
+unsigned short MAXLOG[4] = {0x4086,0x232b,0xdd7a,0xbcd2};
+			/* log(2**-1022) = - 7.08396418532264106224E2 */
+unsigned short MINLOG[4] = {0xc086,0x232b,0xdd7a,0xbcd2};
+#endif
+			/* 2**1024*(1-MACHEP) =  1.7976931348623158E308 */
+unsigned short MAXNUM[4] = {0x7fef,0xffff,0xffff,0xffff};
+unsigned short PI[4]     = {0x4009,0x21fb,0x5444,0x2d18};
+unsigned short PIO2[4]   = {0x3ff9,0x21fb,0x5444,0x2d18};
+unsigned short PIO4[4]   = {0x3fe9,0x21fb,0x5444,0x2d18};
+unsigned short SQRT2[4]  = {0x3ff6,0xa09e,0x667f,0x3bcd};
+unsigned short SQRTH[4]  = {0x3fe6,0xa09e,0x667f,0x3bcd};
+unsigned short LOG2E[4]  = {0x3ff7,0x1547,0x652b,0x82fe};
+unsigned short SQ2OPI[4] = {0x3fe9,0x8845,0x33d4,0x3651};
+unsigned short LOGE2[4]  = {0x3fe6,0x2e42,0xfefa,0x39ef};
+unsigned short LOGSQ2[4] = {0x3fd6,0x2e42,0xfefa,0x39ef};
+unsigned short THPIO4[4] = {0x4002,0xd97c,0x7f33,0x21d2};
+unsigned short TWOOPI[4] = {0x3fe4,0x5f30,0x6dc9,0xc883};
+#ifdef INFINITIES
+unsigned short INFINITY[4] = {0x7ff0,0x0000,0x0000,0x0000};
+#else
+unsigned short INFINITY[4] = {0x7fef,0xffff,0xffff,0xffff};
+#endif
+#ifdef NANS
+unsigned short NAN[4] = {0x7ff8,0x0000,0x0000,0x0000};
+#else
+unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000};
+#endif
+#ifdef MINUSZERO
+unsigned short NEGZERO[4] = {0x8000,0x0000,0x0000,0x0000};
+#else
+unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000};
+#endif
+#endif
+
+#ifdef DEC
+			/* 2**-56 =  1.38777878078144567553E-17 */
+unsigned short MACHEP[4] = {0022200,0000000,0000000,0000000};
+unsigned short UFLOWTHRESH[4] = {0x0080,0x0000,0x0000,0x0000};
+			/* log 2**127 = 88.029691931113054295988 */
+unsigned short MAXLOG[4] = {041660,007463,0143742,025733,};
+			/* log 2**-128 = -88.72283911167299960540 */
+unsigned short MINLOG[4] = {0141661,071027,0173721,0147572,};
+			/* 2**127 = 1.701411834604692317316873e38 */
+unsigned short MAXNUM[4] = {077777,0177777,0177777,0177777,};
+unsigned short PI[4]     = {040511,007732,0121041,064302,};
+unsigned short PIO2[4]   = {040311,007732,0121041,064302,};
+unsigned short PIO4[4]   = {040111,007732,0121041,064302,};
+unsigned short SQRT2[4]  = {040265,002363,031771,0157145,};
+unsigned short SQRTH[4]  = {040065,002363,031771,0157144,};
+unsigned short LOG2E[4]  = {040270,0125073,024534,013761,};
+unsigned short SQ2OPI[4] = {040114,041051,0117241,0131204,};
+unsigned short LOGE2[4]  = {040061,071027,0173721,0147572,};
+unsigned short LOGSQ2[4] = {037661,071027,0173721,0147572,};
+unsigned short THPIO4[4] = {040426,0145743,0174631,007222,};
+unsigned short TWOOPI[4] = {040042,0174603,067116,042025,};
+/* Approximate infinity by MAXNUM.  */
+unsigned short INFINITY[4] = {077777,0177777,0177777,0177777,};
+unsigned short NAN[4] = {0000000,0000000,0000000,0000000};
+#ifdef MINUSZERO
+unsigned short NEGZERO[4] = {0000000,0000000,0000000,0100000};
+#else
+unsigned short NEGZERO[4] = {0000000,0000000,0000000,0000000};
+#endif
+#endif
+
+#ifndef UNK
+extern unsigned short MACHEP[];
+extern unsigned short UFLOWTHRESH[];
+extern unsigned short MAXLOG[];
+extern unsigned short UNDLOG[];
+extern unsigned short MINLOG[];
+extern unsigned short MAXNUM[];
+extern unsigned short PI[];
+extern unsigned short PIO2[];
+extern unsigned short PIO4[];
+extern unsigned short SQRT2[];
+extern unsigned short SQRTH[];
+extern unsigned short LOG2E[];
+extern unsigned short SQ2OPI[];
+extern unsigned short LOGE2[];
+extern unsigned short LOGSQ2[];
+extern unsigned short THPIO4[];
+extern unsigned short TWOOPI[];
+extern unsigned short INFINITY[];
+extern unsigned short NAN[];
+extern unsigned short NEGZERO[];
+#endif
Index: sansmodels/src/cephes/cprob.mak
===================================================================
--- sansmodels/src/cephes/cprob.mak	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/cprob.mak	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,14 @@
+# Makefile for probability integrals.
+# Be sure to set the type of computer and endianness in mconf.h.
+
+CC = gcc
+CFLAGS = -O2 -Wall
+INCS = mconf.h
+
+OBJS = bdtr.o btdtr.o chdtr.o drand.o expx2.o fdtr.o gamma.o gdtr.o \
+igam.o igami.o incbet.o incbi.o mtherr.o nbdtr.o ndtr.o ndtri.o pdtr.o \
+stdtr.o unity.o polevl.o const.o
+
+libprob.a: $(OBJS) $(INCS)
+	ar rv libprob.a $(OBJS)
+	ranlib libprob.a
Index: sansmodels/src/cephes/drand.c
===================================================================
--- sansmodels/src/cephes/drand.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/drand.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,163 @@
+/*							drand.c
+ *
+ *	Pseudorandom number generator
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double y, drand();
+ *
+ * drand( &y );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Yields a random number 1.0 <= y < 2.0.
+ *
+ * The three-generator congruential algorithm by Brian
+ * Wichmann and David Hill (BYTE magazine, March, 1987,
+ * pp 127-8) is used. The period, given by them, is
+ * 6953607871644.
+ *
+ * Versions invoked by the different arithmetic compile
+ * time options DEC, IBMPC, and MIEEE, produce
+ * approximately the same sequences, differing only in the
+ * least significant bits of the numbers. The UNK option
+ * implements the algorithm as recommended in the BYTE
+ * article.  It may be used on all computers. However,
+ * the low order bits of a double precision number may
+ * not be adequately random, and may vary due to arithmetic
+ * implementation details on different computers.
+ *
+ * The other compile options generate an additional random
+ * integer that overwrites the low order bits of the double
+ * precision number.  This reduces the period by a factor of
+ * two but tends to overcome the problems mentioned.
+ *
+ */
+
+
+
+/*  Three-generator random number algorithm
+ * of Brian Wichmann and David Hill
+ * BYTE magazine, March, 1987 pp 127-8
+ *
+ * The period, given by them, is (p-1)(q-1)(r-1)/4 = 6.95e12.
+ */
+
+#include "mconf.h"
+#ifdef ANSIPROT
+static int ranwh ( void );
+#else
+static int ranwh();
+#endif
+
+static int sx = 1;
+static int sy = 10000;
+static int sz = 3000;
+
+static union {
+ double d;
+ unsigned short s[4];
+} unkans;
+
+/* This function implements the three
+ * congruential generators.
+ */
+ 
+static int ranwh()
+{
+int r, s;
+
+/*  sx = sx * 171 mod 30269 */
+r = sx/177;
+s = sx - 177 * r;
+sx = 171 * s - 2 * r;
+if( sx < 0 )
+	sx += 30269;
+
+
+/* sy = sy * 172 mod 30307 */
+r = sy/176;
+s = sy - 176 * r;
+sy = 172 * s - 35 * r;
+if( sy < 0 )
+	sy += 30307;
+
+/* sz = 170 * sz mod 30323 */
+r = sz/178;
+s = sz - 178 * r;
+sz = 170 * s - 63 * r;
+if( sz < 0 )
+	sz += 30323;
+/* The results are in static sx, sy, sz. */
+return 0;
+}
+
+
+/*	drand.c
+ *
+ * Random double precision floating point number between 1 and 2.
+ *
+ * C callable:
+ *	drand( &x );
+ */
+
+int drand( a )
+double *a;
+{
+unsigned short r;
+#ifdef DEC
+unsigned short s, t;
+#endif
+
+/* This algorithm of Wichmann and Hill computes a floating point
+ * result:
+ */
+ranwh();
+unkans.d = sx/30269.0  +  sy/30307.0  +  sz/30323.0;
+r = unkans.d;
+unkans.d -= r;
+unkans.d += 1.0;
+
+/* if UNK option, do nothing further.
+ * Otherwise, make a random 16 bit integer
+ * to overwrite the least significant word
+ * of unkans.
+ */
+#ifdef UNK
+/* do nothing */
+#else
+ranwh();
+r = sx * sy + sz;
+#endif
+
+#ifdef DEC
+/* To make the numbers as similar as possible
+ * in all arithmetics, the random integer has
+ * to be inserted 3 bits higher up in a DEC number.
+ * An alternative would be put it 3 bits lower down
+ * in all the other number types.
+ */
+s = unkans.s[2];
+t = s & 07;	/* save these bits to put in at the bottom */
+s &= 0177770;
+s |= (r >> 13) & 07;
+unkans.s[2] = s;
+t |= r << 3;
+unkans.s[3] = t;
+#endif
+
+#ifdef IBMPC
+unkans.s[0] = r;
+#endif
+
+#ifdef MIEEE
+unkans.s[3] = r;
+#endif
+
+*a = unkans.d;
+return 0;
+}
Index: sansmodels/src/cephes/expx2.c
===================================================================
--- sansmodels/src/cephes/expx2.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/expx2.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,93 @@
+/*							expx2.c
+ *
+ *	Exponential of squared argument
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, expx2();
+ * int sign;
+ *
+ * y = expx2( x, sign );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Computes y = exp(x*x) while suppressing error amplification
+ * that would ordinarily arise from the inexactness of the
+ * exponential argument x*x.
+ *
+ * If sign < 0, the result is inverted; i.e., y = exp(-x*x) .
+ * 
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic    domain     # trials      peak         rms
+ *   IEEE      -26.6, 26.6    10^7       3.9e-16     8.9e-17
+ *
+ */
+
+/*
+Cephes Math Library Release 2.9:  June, 2000
+Copyright 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+#ifdef ANSIPROT
+extern double fabs (double);
+extern double floor (double);
+extern double exp (double);
+#else
+double fabs();
+double floor();
+double exp();
+#endif
+
+#ifdef DEC
+#define M 32.0
+#define MINV .03125
+#else
+#define M 128.0
+#define MINV .0078125
+#endif
+
+extern double MAXLOG;
+extern double INFINITY;
+
+double expx2 (x, sign)
+     double x;
+     int sign;
+{
+  double u, u1, m, f;
+
+  x = fabs (x);
+  if (sign < 0)
+    x = -x;
+
+  /* Represent x as an exact multiple of M plus a residual.
+     M is a power of 2 chosen so that exp(m * m) does not overflow
+     or underflow and so that |x - m| is small.  */
+  m = MINV * floor(M * x + 0.5);
+  f = x - m;
+
+  /* x^2 = m^2 + 2mf + f^2 */
+  u = m * m;
+  u1 = 2 * m * f  +  f * f;
+
+  if (sign < 0)
+    {
+      u = -u;
+      u1 = -u1;
+    }
+
+  if ((u+u1) > MAXLOG)
+    return (INFINITY);
+
+  /* u is exact, u1 is small.  */
+  u = exp(u) * exp(u1);
+  return(u);
+}
Index: sansmodels/src/cephes/fdtr.c
===================================================================
--- sansmodels/src/cephes/fdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/fdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,240 @@
+/*							fdtr.c
+ *
+ *	F distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int df1, df2;
+ * double x, y, fdtr();
+ *
+ * y = fdtr( df1, df2, x );
+ *
+ * DESCRIPTION:
+ *
+ * Returns the area from zero to x under the F density
+ * function (also known as Snedcor's density or the
+ * variance ratio density).  This is the density
+ * of x = (u1/df1)/(u2/df2), where u1 and u2 are random
+ * variables having Chi square distributions with df1
+ * and df2 degrees of freedom, respectively.
+ *
+ * The incomplete beta integral is used, according to the
+ * formula
+ *
+ *	P(x) = incbet( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
+ *
+ *
+ * The arguments a and b are greater than zero, and x is
+ * nonnegative.
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,x).
+ *
+ *                x     a,b                     Relative error:
+ * arithmetic  domain  domain     # trials      peak         rms
+ *    IEEE      0,1    0,100       100000      9.8e-15     1.7e-15
+ *    IEEE      1,5    0,100       100000      6.5e-15     3.5e-16
+ *    IEEE      0,1    1,10000     100000      2.2e-11     3.3e-12
+ *    IEEE      1,5    1,10000     100000      1.1e-11     1.7e-13
+ * See also incbet.c.
+ *
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * fdtr domain     a<0, b<0, x<0         0.0
+ *
+ */
+
+/*							fdtrc()
+ *
+ *	Complemented F distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int df1, df2;
+ * double x, y, fdtrc();
+ *
+ * y = fdtrc( df1, df2, x );
+ *
+ * DESCRIPTION:
+ *
+ * Returns the area from x to infinity under the F density
+ * function (also known as Snedcor's density or the
+ * variance ratio density).
+ *
+ *
+ *                      inf.
+ *                       -
+ *              1       | |  a-1      b-1
+ * 1-P(x)  =  ------    |   t    (1-t)    dt
+ *            B(a,b)  | |
+ *                     -
+ *                      x
+ *
+ *
+ * The incomplete beta integral is used, according to the
+ * formula
+ *
+ *	P(x) = incbet( df2/2, df1/2, (df2/(df2 + df1*x) ).
+ *
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,x) in the indicated intervals.
+ *                x     a,b                     Relative error:
+ * arithmetic  domain  domain     # trials      peak         rms
+ *    IEEE      0,1    1,100       100000      3.7e-14     5.9e-16
+ *    IEEE      1,5    1,100       100000      8.0e-15     1.6e-15
+ *    IEEE      0,1    1,10000     100000      1.8e-11     3.5e-13
+ *    IEEE      1,5    1,10000     100000      2.0e-11     3.0e-12
+ * See also incbet.c.
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * fdtrc domain    a<0, b<0, x<0         0.0
+ *
+ */
+
+/*							fdtri()
+ *
+ *	Inverse of complemented F distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int df1, df2;
+ * double x, p, fdtri();
+ *
+ * x = fdtri( df1, df2, p );
+ *
+ * DESCRIPTION:
+ *
+ * Finds the F density argument x such that the integral
+ * from x to infinity of the F density is equal to the
+ * given probability p.
+ *
+ * This is accomplished using the inverse beta integral
+ * function and the relations
+ *
+ *      z = incbi( df2/2, df1/2, p )
+ *      x = df2 (1-z) / (df1 z).
+ *
+ * Note: the following relations hold for the inverse of
+ * the uncomplemented F distribution:
+ *
+ *      z = incbi( df1/2, df2/2, p )
+ *      x = df2 z / (df1 (1-z)).
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,p).
+ *
+ *              a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *  For p between .001 and 1:
+ *    IEEE     1,100       100000      8.3e-15     4.7e-16
+ *    IEEE     1,10000     100000      2.1e-11     1.4e-13
+ *  For p between 10^-6 and 10^-3:
+ *    IEEE     1,100        50000      1.3e-12     8.4e-15
+ *    IEEE     1,10000      50000      3.0e-12     4.8e-14
+ * See also fdtrc.c.
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * fdtri domain   p <= 0 or p > 1       0.0
+ *                     v < 1
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double incbet ( double, double, double );
+extern double incbi ( double, double, double );
+#else
+double incbet(), incbi();
+#endif
+
+double fdtrc( ia, ib, x )
+int ia, ib;
+double x;
+{
+double a, b, w;
+
+if( (ia < 1) || (ib < 1) || (x < 0.0) )
+	{
+	mtherr( "fdtrc", DOMAIN );
+	return( 0.0 );
+	}
+a = ia;
+b = ib;
+w = b / (b + a * x);
+return( incbet( 0.5*b, 0.5*a, w ) );
+}
+
+
+
+double fdtr( ia, ib, x )
+int ia, ib;
+double x;
+{
+double a, b, w;
+
+if( (ia < 1) || (ib < 1) || (x < 0.0) )
+	{
+	mtherr( "fdtr", DOMAIN );
+	return( 0.0 );
+	}
+a = ia;
+b = ib;
+w = a * x;
+w = w / (b + w);
+return( incbet(0.5*a, 0.5*b, w) );
+}
+
+
+double fdtri( ia, ib, y )
+int ia, ib;
+double y;
+{
+double a, b, w, x;
+
+if( (ia < 1) || (ib < 1) || (y <= 0.0) || (y > 1.0) )
+	{
+	mtherr( "fdtri", DOMAIN );
+	return( 0.0 );
+	}
+a = ia;
+b = ib;
+/* Compute probability for x = 0.5.  */
+w = incbet( 0.5*b, 0.5*a, 0.5 );
+/* If that is greater than y, then the solution w < .5.
+   Otherwise, solve at 1-y to remove cancellation in (b - b*w).  */
+if( w > y || y < 0.001)
+	{
+	w = incbi( 0.5*b, 0.5*a, y );
+	x = (b - b*w)/(a*w);
+	}
+else
+	{
+	w = incbi( 0.5*a, 0.5*b, 1.0-y );
+	x = b*w/(a*(1.0-w));
+	}
+return(x);
+}
Index: sansmodels/src/cephes/gamma.c
===================================================================
--- sansmodels/src/cephes/gamma.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/gamma.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,687 @@
+/*							gamma.c
+ *
+ *	Gamma function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, gamma();
+ * extern int sgngam;
+ *
+ * y = gamma( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns gamma function of the argument.  The result is
+ * correctly signed, and the sign (+1 or -1) is also
+ * returned in a global (extern) variable named sgngam.
+ * This variable is also filled in by the logarithmic gamma
+ * function lgam().
+ *
+ * Arguments |x| <= 34 are reduced by recurrence and the function
+ * approximated by a rational function of degree 6/7 in the
+ * interval (2,3).  Large arguments are handled by Stirling's
+ * formula. Large negative arguments are made positive using
+ * a reflection formula.  
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC      -34, 34      10000       1.3e-16     2.5e-17
+ *    IEEE    -170,-33      20000       2.3e-15     3.3e-16
+ *    IEEE     -33,  33     20000       9.4e-16     2.2e-16
+ *    IEEE      33, 171.6   20000       2.3e-15     3.2e-16
+ *
+ * Error for arguments outside the test range will be larger
+ * owing to error amplification by the exponential function.
+ *
+ */
+
+/*							lgam()
+ *
+ *	Natural logarithm of gamma function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, lgam();
+ * extern int sgngam;
+ *
+ * y = lgam( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the base e (2.718...) logarithm of the absolute
+ * value of the gamma function of the argument.
+ * The sign (+1 or -1) of the gamma function is returned in a
+ * global (extern) variable named sgngam.
+ *
+ * For arguments greater than 13, the logarithm of the gamma
+ * function is approximated by the logarithmic version of
+ * Stirling's formula using a polynomial approximation of
+ * degree 4. Arguments between -33 and +33 are reduced by
+ * recurrence to the interval [2,3] of a rational approximation.
+ * The cosecant reflection formula is employed for arguments
+ * less than -33.
+ *
+ * Arguments greater than MAXLGM return MAXNUM and an error
+ * message.  MAXLGM = 2.035093e36 for DEC
+ * arithmetic or 2.556348e305 for IEEE arithmetic.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *
+ * arithmetic      domain        # trials     peak         rms
+ *    DEC     0, 3                  7000     5.2e-17     1.3e-17
+ *    DEC     2.718, 2.035e36       5000     3.9e-17     9.9e-18
+ *    IEEE    0, 3                 28000     5.4e-16     1.1e-16
+ *    IEEE    2.718, 2.556e305     40000     3.5e-16     8.3e-17
+ * The error criterion was relative when the function magnitude
+ * was greater than one but absolute when it was less than one.
+ *
+ * The following test used the relative error criterion, though
+ * at certain points the relative error could be much higher than
+ * indicated.
+ *    IEEE    -200, -4             10000     4.8e-16     1.3e-16
+ *
+ */
+
+
+/*							gamma.c	*/
+/*	gamma function	*/
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier
+*/
+
+
+#include "mconf.h"
+
+#ifdef UNK
+static double P[] = {
+  1.60119522476751861407E-4,
+  1.19135147006586384913E-3,
+  1.04213797561761569935E-2,
+  4.76367800457137231464E-2,
+  2.07448227648435975150E-1,
+  4.94214826801497100753E-1,
+  9.99999999999999996796E-1
+};
+static double Q[] = {
+-2.31581873324120129819E-5,
+ 5.39605580493303397842E-4,
+-4.45641913851797240494E-3,
+ 1.18139785222060435552E-2,
+ 3.58236398605498653373E-2,
+-2.34591795718243348568E-1,
+ 7.14304917030273074085E-2,
+ 1.00000000000000000320E0
+};
+#define MAXGAM 171.624376956302725
+static double LOGPI = 1.14472988584940017414;
+#endif
+
+#ifdef DEC
+static unsigned short P[] = {
+0035047,0162701,0146301,0005234,
+0035634,0023437,0032065,0176530,
+0036452,0137157,0047330,0122574,
+0037103,0017310,0143041,0017232,
+0037524,0066516,0162563,0164605,
+0037775,0004671,0146237,0014222,
+0040200,0000000,0000000,0000000
+};
+static unsigned short Q[] = {
+0134302,0041724,0020006,0116565,
+0035415,0072121,0044251,0025634,
+0136222,0003447,0035205,0121114,
+0036501,0107552,0154335,0104271,
+0037022,0135717,0014776,0171471,
+0137560,0034324,0165024,0037021,
+0037222,0045046,0047151,0161213,
+0040200,0000000,0000000,0000000
+};
+#define MAXGAM 34.84425627277176174
+static unsigned short LPI[4] = {
+0040222,0103202,0043475,0006750,
+};
+#define LOGPI *(double *)LPI
+#endif
+
+#ifdef IBMPC
+static unsigned short P[] = {
+0x2153,0x3998,0xfcb8,0x3f24,
+0xbfab,0xe686,0x84e3,0x3f53,
+0x14b0,0xe9db,0x57cd,0x3f85,
+0x23d3,0x18c4,0x63d9,0x3fa8,
+0x7d31,0xdcae,0x8da9,0x3fca,
+0xe312,0x3993,0xa137,0x3fdf,
+0x0000,0x0000,0x0000,0x3ff0
+};
+static unsigned short Q[] = {
+0xd3af,0x8400,0x487a,0xbef8,
+0x2573,0x2915,0xae8a,0x3f41,
+0xb44a,0xe750,0x40e4,0xbf72,
+0xb117,0x5b1b,0x31ed,0x3f88,
+0xde67,0xe33f,0x5779,0x3fa2,
+0x87c2,0x9d42,0x071a,0xbfce,
+0x3c51,0xc9cd,0x4944,0x3fb2,
+0x0000,0x0000,0x0000,0x3ff0
+};
+#define MAXGAM 171.624376956302725
+static unsigned short LPI[4] = {
+0xa1bd,0x48e7,0x50d0,0x3ff2,
+};
+#define LOGPI *(double *)LPI
+#endif 
+
+#ifdef MIEEE
+static unsigned short P[] = {
+0x3f24,0xfcb8,0x3998,0x2153,
+0x3f53,0x84e3,0xe686,0xbfab,
+0x3f85,0x57cd,0xe9db,0x14b0,
+0x3fa8,0x63d9,0x18c4,0x23d3,
+0x3fca,0x8da9,0xdcae,0x7d31,
+0x3fdf,0xa137,0x3993,0xe312,
+0x3ff0,0x0000,0x0000,0x0000
+};
+static unsigned short Q[] = {
+0xbef8,0x487a,0x8400,0xd3af,
+0x3f41,0xae8a,0x2915,0x2573,
+0xbf72,0x40e4,0xe750,0xb44a,
+0x3f88,0x31ed,0x5b1b,0xb117,
+0x3fa2,0x5779,0xe33f,0xde67,
+0xbfce,0x071a,0x9d42,0x87c2,
+0x3fb2,0x4944,0xc9cd,0x3c51,
+0x3ff0,0x0000,0x0000,0x0000
+};
+#define MAXGAM 171.624376956302725
+static unsigned short LPI[4] = {
+0x3ff2,0x50d0,0x48e7,0xa1bd,
+};
+#define LOGPI *(double *)LPI
+#endif 
+
+/* Stirling's formula for the gamma function */
+#if UNK
+static double STIR[5] = {
+ 7.87311395793093628397E-4,
+-2.29549961613378126380E-4,
+-2.68132617805781232825E-3,
+ 3.47222221605458667310E-3,
+ 8.33333333333482257126E-2,
+};
+#define MAXSTIR 143.01608
+static double SQTPI = 2.50662827463100050242E0;
+#endif
+#if DEC
+static unsigned short STIR[20] = {
+0035516,0061622,0144553,0112224,
+0135160,0131531,0037460,0165740,
+0136057,0134460,0037242,0077270,
+0036143,0107070,0156306,0027751,
+0037252,0125252,0125252,0146064,
+};
+#define MAXSTIR 26.77
+static unsigned short SQT[4] = {
+0040440,0066230,0177661,0034055,
+};
+#define SQTPI *(double *)SQT
+#endif
+#if IBMPC
+static unsigned short STIR[20] = {
+0x7293,0x592d,0xcc72,0x3f49,
+0x1d7c,0x27e6,0x166b,0xbf2e,
+0x4fd7,0x07d4,0xf726,0xbf65,
+0xc5fd,0x1b98,0x71c7,0x3f6c,
+0x5986,0x5555,0x5555,0x3fb5,
+};
+#define MAXSTIR 143.01608
+static unsigned short SQT[4] = {
+0x2706,0x1ff6,0x0d93,0x4004,
+};
+#define SQTPI *(double *)SQT
+#endif
+#if MIEEE
+static unsigned short STIR[20] = {
+0x3f49,0xcc72,0x592d,0x7293,
+0xbf2e,0x166b,0x27e6,0x1d7c,
+0xbf65,0xf726,0x07d4,0x4fd7,
+0x3f6c,0x71c7,0x1b98,0xc5fd,
+0x3fb5,0x5555,0x5555,0x5986,
+};
+#define MAXSTIR 143.01608
+static unsigned short SQT[4] = {
+0x4004,0x0d93,0x1ff6,0x2706,
+};
+#define SQTPI *(double *)SQT
+#endif
+
+int sgngam = 0;
+extern int sgngam;
+extern double MAXLOG, MAXNUM, PI;
+#ifdef ANSIPROT
+extern double pow ( double, double );
+extern double log ( double );
+extern double exp ( double );
+extern double sin ( double );
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double floor ( double );
+extern double fabs ( double );
+extern int isnan ( double );
+extern int isfinite ( double );
+static double stirf ( double );
+double lgam ( double );
+#else
+double pow(), log(), exp(), sin(), polevl(), p1evl(), floor(), fabs();
+int isnan(), isfinite();
+static double stirf();
+double lgam();
+#endif
+#ifdef INFINITIES
+extern double INFINITY;
+#endif
+#ifdef NANS
+extern double NAN;
+#endif
+
+/* Gamma function computed by Stirling's formula.
+ * The polynomial STIR is valid for 33 <= x <= 172.
+ */
+static double stirf(x)
+double x;
+{
+double y, w, v;
+
+w = 1.0/x;
+w = 1.0 + w * polevl( w, STIR, 4 );
+y = exp(x);
+if( x > MAXSTIR )
+	{ /* Avoid overflow in pow() */
+	v = pow( x, 0.5 * x - 0.25 );
+	y = v * (v / y);
+	}
+else
+	{
+	y = pow( x, x - 0.5 ) / y;
+	}
+y = SQTPI * y * w;
+return( y );
+}
+
+
+
+double gamma(x)
+double x;
+{
+double p, q, z;
+int i;
+
+sgngam = 1;
+#ifdef NANS
+if( isnan(x) )
+	return(x);
+#endif
+#ifdef INFINITIES
+#ifdef NANS
+if( x == INFINITY )
+	return(x);
+if( x == -INFINITY )
+	return(NAN);
+#else
+if( !isfinite(x) )
+	return(x);
+#endif
+#endif
+q = fabs(x);
+
+if( q > 33.0 )
+	{
+	if( x < 0.0 )
+		{
+		p = floor(q);
+		if( p == q )
+			{
+#ifdef NANS
+gamnan:
+			mtherr( "gamma", DOMAIN );
+			return (NAN);
+#else
+			goto goverf;
+#endif
+			}
+		i = p;
+		if( (i & 1) == 0 )
+			sgngam = -1;
+		z = q - p;
+		if( z > 0.5 )
+			{
+			p += 1.0;
+			z = q - p;
+			}
+		z = q * sin( PI * z );
+		if( z == 0.0 )
+			{
+#ifdef INFINITIES
+			return( sgngam * INFINITY);
+#else
+goverf:
+			mtherr( "gamma", OVERFLOW );
+			return( sgngam * MAXNUM);
+#endif
+			}
+		z = fabs(z);
+		z = PI/(z * stirf(q) );
+		}
+	else
+		{
+		z = stirf(x);
+		}
+	return( sgngam * z );
+	}
+
+z = 1.0;
+while( x >= 3.0 )
+	{
+	x -= 1.0;
+	z *= x;
+	}
+
+while( x < 0.0 )
+	{
+	if( x > -1.E-9 )
+		goto small;
+	z /= x;
+	x += 1.0;
+	}
+
+while( x < 2.0 )
+	{
+	if( x < 1.e-9 )
+		goto small;
+	z /= x;
+	x += 1.0;
+	}
+
+if( x == 2.0 )
+	return(z);
+
+x -= 2.0;
+p = polevl( x, P, 6 );
+q = polevl( x, Q, 7 );
+return( z * p / q );
+
+small:
+if( x == 0.0 )
+	{
+#ifdef INFINITIES
+#ifdef NANS
+	  goto gamnan;
+#else
+	  return( INFINITY );
+#endif
+#else
+	mtherr( "gamma", SING );
+	return( MAXNUM );
+#endif
+	}
+else
+	return( z/((1.0 + 0.5772156649015329 * x) * x) );
+}
+
+
+
+/* A[]: Stirling's formula expansion of log gamma
+ * B[], C[]: log gamma function between 2 and 3
+ */
+#ifdef UNK
+static double A[] = {
+ 8.11614167470508450300E-4,
+-5.95061904284301438324E-4,
+ 7.93650340457716943945E-4,
+-2.77777777730099687205E-3,
+ 8.33333333333331927722E-2
+};
+static double B[] = {
+-1.37825152569120859100E3,
+-3.88016315134637840924E4,
+-3.31612992738871184744E5,
+-1.16237097492762307383E6,
+-1.72173700820839662146E6,
+-8.53555664245765465627E5
+};
+static double C[] = {
+/* 1.00000000000000000000E0, */
+-3.51815701436523470549E2,
+-1.70642106651881159223E4,
+-2.20528590553854454839E5,
+-1.13933444367982507207E6,
+-2.53252307177582951285E6,
+-2.01889141433532773231E6
+};
+/* log( sqrt( 2*pi ) ) */
+static double LS2PI  =  0.91893853320467274178;
+#define MAXLGM 2.556348e305
+#endif
+
+#ifdef DEC
+static unsigned short A[] = {
+0035524,0141201,0034633,0031405,
+0135433,0176755,0126007,0045030,
+0035520,0006371,0003342,0172730,
+0136066,0005540,0132605,0026407,
+0037252,0125252,0125252,0125132
+};
+static unsigned short B[] = {
+0142654,0044014,0077633,0035410,
+0144027,0110641,0125335,0144760,
+0144641,0165637,0142204,0047447,
+0145215,0162027,0146246,0155211,
+0145322,0026110,0010317,0110130,
+0145120,0061472,0120300,0025363
+};
+static unsigned short C[] = {
+/*0040200,0000000,0000000,0000000*/
+0142257,0164150,0163630,0112622,
+0143605,0050153,0156116,0135272,
+0144527,0056045,0145642,0062332,
+0145213,0012063,0106250,0001025,
+0145432,0111254,0044577,0115142,
+0145366,0071133,0050217,0005122
+};
+/* log( sqrt( 2*pi ) ) */
+static unsigned short LS2P[] = {040153,037616,041445,0172645,};
+#define LS2PI *(double *)LS2P
+#define MAXLGM 2.035093e36
+#endif
+
+#ifdef IBMPC
+static unsigned short A[] = {
+0x6661,0x2733,0x9850,0x3f4a,
+0xe943,0xb580,0x7fbd,0xbf43,
+0x5ebb,0x20dc,0x019f,0x3f4a,
+0xa5a1,0x16b0,0xc16c,0xbf66,
+0x554b,0x5555,0x5555,0x3fb5
+};
+static unsigned short B[] = {
+0x6761,0x8ff3,0x8901,0xc095,
+0xb93e,0x355b,0xf234,0xc0e2,
+0x89e5,0xf890,0x3d73,0xc114,
+0xdb51,0xf994,0xbc82,0xc131,
+0xf20b,0x0219,0x4589,0xc13a,
+0x055e,0x5418,0x0c67,0xc12a
+};
+static unsigned short C[] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x12b2,0x1cf3,0xfd0d,0xc075,
+0xd757,0x7b89,0xaa0d,0xc0d0,
+0x4c9b,0xb974,0xeb84,0xc10a,
+0x0043,0x7195,0x6286,0xc131,
+0xf34c,0x892f,0x5255,0xc143,
+0xe14a,0x6a11,0xce4b,0xc13e
+};
+/* log( sqrt( 2*pi ) ) */
+static unsigned short LS2P[] = {
+0xbeb5,0xc864,0x67f1,0x3fed
+};
+#define LS2PI *(double *)LS2P
+#define MAXLGM 2.556348e305
+#endif
+
+#ifdef MIEEE
+static unsigned short A[] = {
+0x3f4a,0x9850,0x2733,0x6661,
+0xbf43,0x7fbd,0xb580,0xe943,
+0x3f4a,0x019f,0x20dc,0x5ebb,
+0xbf66,0xc16c,0x16b0,0xa5a1,
+0x3fb5,0x5555,0x5555,0x554b
+};
+static unsigned short B[] = {
+0xc095,0x8901,0x8ff3,0x6761,
+0xc0e2,0xf234,0x355b,0xb93e,
+0xc114,0x3d73,0xf890,0x89e5,
+0xc131,0xbc82,0xf994,0xdb51,
+0xc13a,0x4589,0x0219,0xf20b,
+0xc12a,0x0c67,0x5418,0x055e
+};
+static unsigned short C[] = {
+0xc075,0xfd0d,0x1cf3,0x12b2,
+0xc0d0,0xaa0d,0x7b89,0xd757,
+0xc10a,0xeb84,0xb974,0x4c9b,
+0xc131,0x6286,0x7195,0x0043,
+0xc143,0x5255,0x892f,0xf34c,
+0xc13e,0xce4b,0x6a11,0xe14a
+};
+/* log( sqrt( 2*pi ) ) */
+static unsigned short LS2P[] = {
+0x3fed,0x67f1,0xc864,0xbeb5
+};
+#define LS2PI *(double *)LS2P
+#define MAXLGM 2.556348e305
+#endif
+
+
+/* Logarithm of gamma function */
+
+
+double lgam(x)
+double x;
+{
+double p, q, u, w, z;
+int i;
+
+sgngam = 1;
+#ifdef NANS
+if( isnan(x) )
+	return(x);
+#endif
+
+#ifdef INFINITIES
+if( !isfinite(x) )
+	return(INFINITY);
+#endif
+
+if( x < -34.0 )
+	{
+	q = -x;
+	w = lgam(q); /* note this modifies sgngam! */
+	p = floor(q);
+	if( p == q )
+		{
+lgsing:
+#ifdef INFINITIES
+		mtherr( "lgam", SING );
+		return (INFINITY);
+#else
+		goto loverf;
+#endif
+		}
+	i = p;
+	if( (i & 1) == 0 )
+		sgngam = -1;
+	else
+		sgngam = 1;
+	z = q - p;
+	if( z > 0.5 )
+		{
+		p += 1.0;
+		z = p - q;
+		}
+	z = q * sin( PI * z );
+	if( z == 0.0 )
+		goto lgsing;
+/*	z = log(PI) - log( z ) - w;*/
+	z = LOGPI - log( z ) - w;
+	return( z );
+	}
+
+if( x < 13.0 )
+	{
+	z = 1.0;
+	p = 0.0;
+	u = x;
+	while( u >= 3.0 )
+		{
+		p -= 1.0;
+		u = x + p;
+		z *= u;
+		}
+	while( u < 2.0 )
+		{
+		if( u == 0.0 )
+			goto lgsing;
+		z /= u;
+		p += 1.0;
+		u = x + p;
+		}
+	if( z < 0.0 )
+		{
+		sgngam = -1;
+		z = -z;
+		}
+	else
+		sgngam = 1;
+	if( u == 2.0 )
+		return( log(z) );
+	p -= 2.0;
+	x = x + p;
+	p = x * polevl( x, B, 5 ) / p1evl( x, C, 6);
+	return( log(z) + p );
+	}
+
+if( x > MAXLGM )
+	{
+#ifdef INFINITIES
+	return( sgngam * INFINITY );
+#else
+loverf:
+	mtherr( "lgam", OVERFLOW );
+	return( sgngam * MAXNUM );
+#endif
+	}
+
+q = ( x - 0.5 ) * log(x) - x + LS2PI;
+if( x > 1.0e8 )
+	return( q );
+
+p = 1.0/(x*x);
+if( x >= 1000.0 )
+	q += ((   7.9365079365079365079365e-4 * p
+		- 2.7777777777777777777778e-3) *p
+		+ 0.0833333333333333333333) / x;
+else
+	q += polevl( p, A, 4 ) / x;
+return( q );
+}
Index: sansmodels/src/cephes/gdtr.c
===================================================================
--- sansmodels/src/cephes/gdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/gdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,132 @@
+/*							gdtr.c
+ *
+ *	Gamma distribution function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, x, y, gdtr();
+ *
+ * y = gdtr( a, b, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the integral from zero to x of the gamma probability
+ * density function:
+ *
+ *
+ *                x
+ *        b       -
+ *       a       | |   b-1  -at
+ * y =  -----    |    t    e    dt
+ *       -     | |
+ *      | (b)   -
+ *               0
+ *
+ *  The incomplete gamma integral is used, according to the
+ * relation
+ *
+ * y = igam( b, ax ).
+ *
+ *
+ * ACCURACY:
+ *
+ * See igam().
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * gdtr domain         x < 0            0.0
+ *
+ */
+
+/*							gdtrc.c
+ *
+ *	Complemented gamma distribution function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, x, y, gdtrc();
+ *
+ * y = gdtrc( a, b, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the integral from x to infinity of the gamma
+ * probability density function:
+ *
+ *
+ *               inf.
+ *        b       -
+ *       a       | |   b-1  -at
+ * y =  -----    |    t    e    dt
+ *       -     | |
+ *      | (b)   -
+ *               x
+ *
+ *  The incomplete gamma integral is used, according to the
+ * relation
+ *
+ * y = igamc( b, ax ).
+ *
+ *
+ * ACCURACY:
+ *
+ * See igamc().
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * gdtrc domain         x < 0            0.0
+ *
+ */
+
+
+/*							gdtr()  */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double igam ( double, double );
+extern double igamc ( double, double );
+#else
+double igam(), igamc();
+#endif
+
+double gdtr( a, b, x )
+double a, b, x;
+{
+
+if( x < 0.0 )
+	{
+	mtherr( "gdtr", DOMAIN );
+	return( 0.0 );
+	}
+return(  igam( b, a * x )  );
+}
+
+
+
+double gdtrc( a, b, x )
+double a, b, x;
+{
+
+if( x < 0.0 )
+	{
+	mtherr( "gdtrc", DOMAIN );
+	return( 0.0 );
+	}
+return(  igamc( b, a * x )  );
+}
Index: sansmodels/src/cephes/hyp2f1.c
===================================================================
--- sansmodels/src/cephes/hyp2f1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/hyp2f1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,461 @@
+/*							hyp2f1.c
+ *
+ *	Gauss hypergeometric function   F
+ *	                               2 1
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, c, x, y, hyp2f1();
+ *
+ * y = hyp2f1( a, b, c, x );
+ *
+ *
+ * DESCRIPTION:
+ *
+ *
+ *  hyp2f1( a, b, c, x )  =   F ( a, b; c; x )
+ *                           2 1
+ *
+ *           inf.
+ *            -   a(a+1)...(a+k) b(b+1)...(b+k)   k+1
+ *   =  1 +   >   -----------------------------  x   .
+ *            -         c(c+1)...(c+k) (k+1)!
+ *          k = 0
+ *
+ *  Cases addressed are
+ *	Tests and escapes for negative integer a, b, or c
+ *	Linear transformation if c - a or c - b negative integer
+ *	Special case c = a or c = b
+ *	Linear transformation for  x near +1
+ *	Transformation for x < -0.5
+ *	Psi function expansion if x > 0.5 and c - a - b integer
+ *      Conditionally, a recurrence on c to make c-a-b > 0
+ *
+ * |x| > 1 is rejected.
+ *
+ * The parameters a, b, c are considered to be integer
+ * valued if they are within 1.0e-14 of the nearest integer
+ * (1.0e-13 for IEEE arithmetic).
+ *
+ * ACCURACY:
+ *
+ *
+ *               Relative error (-1 < x < 1):
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      -1,7        230000      1.2e-11     5.2e-14
+ *
+ * Several special cases also tested with a, b, c in
+ * the range -7 to 7.
+ *
+ * ERROR MESSAGES:
+ *
+ * A "partial loss of precision" message is printed if
+ * the internally estimated relative error exceeds 1^-12.
+ * A "singularity" message is printed on overflow or
+ * in cases not addressed (such as x < -1).
+ */
+
+
+/*							hyp2f1	*/
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1992, 2000 by Stephen L. Moshier
+*/
+
+
+#include "mconf.h"
+
+#ifdef DEC
+#define EPS 1.0e-14
+#define EPS2 1.0e-11
+#endif
+
+#ifdef IBMPC
+#define EPS 1.0e-13
+#define EPS2 1.0e-10
+#endif
+
+#ifdef MIEEE
+#define EPS 1.0e-13
+#define EPS2 1.0e-10
+#endif
+
+#ifdef UNK
+#define EPS 1.0e-13
+#define EPS2 1.0e-10
+#endif
+
+#define ETHRESH 1.0e-12
+
+#ifdef ANSIPROT
+extern double fabs ( double );
+extern double pow ( double, double );
+extern double round ( double );
+extern double gamma ( double );
+extern double log ( double );
+extern double exp ( double );
+extern double psi ( double );
+static double hyt2f1(double, double, double, double, double *);
+static double hys2f1(double, double, double, double, double *);
+double hyp2f1(double, double, double, double);
+#else
+double fabs(), pow(), round(), gamma(), log(), exp(), psi();
+static double hyt2f1();
+static double hys2f1();
+double hyp2f1();
+#endif
+extern double MAXNUM, MACHEP;
+
+double hyp2f1( a, b, c, x )
+double a, b, c, x;
+{
+double d, d1, d2, e;
+double p, q, r, s, y, ax;
+double ia, ib, ic, id, err;
+int flag, i, aid;
+
+err = 0.0;
+ax = fabs(x);
+s = 1.0 - x;
+flag = 0;
+ia = round(a); /* nearest integer to a */
+ib = round(b);
+
+if( a <= 0 )
+	{
+	if( fabs(a-ia) < EPS )		/* a is a negative integer */
+		flag |= 1;
+	}
+
+if( b <= 0 )
+	{
+	if( fabs(b-ib) < EPS )		/* b is a negative integer */
+		flag |= 2;
+	}
+
+if( ax < 1.0 )
+	{
+	if( fabs(b-c) < EPS )		/* b = c */
+		{
+		y = pow( s, -a );	/* s to the -a power */
+		goto hypdon;
+		}
+	if( fabs(a-c) < EPS )		/* a = c */
+		{
+		y = pow( s, -b );	/* s to the -b power */
+		goto hypdon;
+		}
+	}
+
+
+
+if( c <= 0.0 )
+	{
+	ic = round(c); 	/* nearest integer to c */
+	if( fabs(c-ic) < EPS )		/* c is a negative integer */
+		{
+		/* check if termination before explosion */
+		if( (flag & 1) && (ia > ic) )
+			goto hypok;
+		if( (flag & 2) && (ib > ic) )
+			goto hypok;
+		goto hypdiv;
+		}
+	}
+
+if( flag )			/* function is a polynomial */
+	goto hypok;
+
+if( ax > 1.0 )			/* series diverges	*/
+	goto hypdiv;
+
+p = c - a;
+ia = round(p); /* nearest integer to c-a */
+if( (ia <= 0.0) && (fabs(p-ia) < EPS) )	/* negative int c - a */
+	flag |= 4;
+
+r = c - b;
+ib = round(r); /* nearest integer to c-b */
+if( (ib <= 0.0) && (fabs(r-ib) < EPS) )	/* negative int c - b */
+	flag |= 8;
+
+d = c - a - b;
+id = round(d); /* nearest integer to d */
+q = fabs(d-id);
+
+/* Thanks to Christian Burger <BURGER@DMRHRZ11.HRZ.Uni-Marburg.DE>
+ * for reporting a bug here.  */
+if( fabs(ax-1.0) < EPS )			/* |x| == 1.0	*/
+	{
+	if( x > 0.0 )
+		{
+		if( flag & 12 ) /* negative int c-a or c-b */
+			{
+			if( d >= 0.0 )
+				goto hypf;
+			else
+				goto hypdiv;
+			}
+		if( d <= 0.0 )
+			goto hypdiv;
+		y = gamma(c)*gamma(d)/(gamma(p)*gamma(r));
+		goto hypdon;
+		}
+
+	if( d <= -1.0 )
+		goto hypdiv;
+
+	}
+
+/* Conditionally make d > 0 by recurrence on c
+ * AMS55 #15.2.27
+ */
+if( d < 0.0 )
+	{
+/* Try the power series first */
+	y = hyt2f1( a, b, c, x, &err );
+	if( err < ETHRESH )
+		goto hypdon;
+/* Apply the recurrence if power series fails */
+	err = 0.0;
+	aid = 2 - id;
+	e = c + aid;
+	d2 = hyp2f1(a,b,e,x);
+	d1 = hyp2f1(a,b,e+1.0,x);
+	q = a + b + 1.0;
+	for( i=0; i<aid; i++ )
+		{
+		r = e - 1.0;
+		y = (e*(r-(2.0*e-q)*x)*d2 + (e-a)*(e-b)*x*d1)/(e*r*s);
+		e = r;
+		d1 = d2;
+		d2 = y;
+		}
+	goto hypdon;
+	}
+
+
+if( flag & 12 )
+	goto hypf; /* negative integer c-a or c-b */
+
+hypok:
+y = hyt2f1( a, b, c, x, &err );
+
+
+hypdon:
+if( err > ETHRESH )
+	{
+	mtherr( "hyp2f1", PLOSS );
+/*	printf( "Estimated err = %.2e\n", err ); */
+	}
+return(y);
+
+/* The transformation for c-a or c-b negative integer
+ * AMS55 #15.3.3
+ */
+hypf:
+y = pow( s, d ) * hys2f1( c-a, c-b, c, x, &err );
+goto hypdon;
+
+/* The alarm exit */
+hypdiv:
+mtherr( "hyp2f1", OVERFLOW );
+return( MAXNUM );
+}
+
+
+
+
+
+
+/* Apply transformations for |x| near 1
+ * then call the power series
+ */
+static double hyt2f1( a, b, c, x, loss )
+double a, b, c, x;
+double *loss;
+{
+double p, q, r, s, t, y, d, err, err1;
+double ax, id, d1, d2, e, y1;
+int i, aid;
+
+err = 0.0;
+s = 1.0 - x;
+if( x < -0.5 )
+	{
+	if( b > a )
+		y = pow( s, -a ) * hys2f1( a, c-b, c, -x/s, &err );
+
+	else
+		y = pow( s, -b ) * hys2f1( c-a, b, c, -x/s, &err );
+
+	goto done;
+	}
+
+d = c - a - b;
+id = round(d);	/* nearest integer to d */
+
+if( x > 0.9 )
+{
+if( fabs(d-id) > EPS ) /* test for integer c-a-b */
+	{
+/* Try the power series first */
+	y = hys2f1( a, b, c, x, &err );
+	if( err < ETHRESH )
+		goto done;
+/* If power series fails, then apply AMS55 #15.3.6 */
+	q = hys2f1( a, b, 1.0-d, s, &err );	
+	q *= gamma(d) /(gamma(c-a) * gamma(c-b));
+	r = pow(s,d) * hys2f1( c-a, c-b, d+1.0, s, &err1 );
+	r *= gamma(-d)/(gamma(a) * gamma(b));
+	y = q + r;
+
+	q = fabs(q); /* estimate cancellation error */
+	r = fabs(r);
+	if( q > r )
+		r = q;
+	err += err1 + (MACHEP*r)/y;
+
+	y *= gamma(c);
+	goto done;
+	}
+else
+	{
+/* Psi function expansion, AMS55 #15.3.10, #15.3.11, #15.3.12 */
+	if( id >= 0.0 )
+		{
+		e = d;
+		d1 = d;
+		d2 = 0.0;
+		aid = id;
+		}
+	else
+		{
+		e = -d;
+		d1 = 0.0;
+		d2 = d;
+		aid = -id;
+		}
+
+	ax = log(s);
+
+	/* sum for t = 0 */
+	y = psi(1.0) + psi(1.0+e) - psi(a+d1) - psi(b+d1) - ax;
+	y /= gamma(e+1.0);
+
+	p = (a+d1) * (b+d1) * s / gamma(e+2.0);	/* Poch for t=1 */
+	t = 1.0;
+	do
+		{
+		r = psi(1.0+t) + psi(1.0+t+e) - psi(a+t+d1)
+			- psi(b+t+d1) - ax;
+		q = p * r;
+		y += q;
+		p *= s * (a+t+d1) / (t+1.0);
+		p *= (b+t+d1) / (t+1.0+e);
+		t += 1.0;
+		}
+	while( fabs(q/y) > EPS );
+
+
+	if( id == 0.0 )
+		{
+		y *= gamma(c)/(gamma(a)*gamma(b));
+		goto psidon;
+		}
+
+	y1 = 1.0;
+
+	if( aid == 1 )
+		goto nosum;
+
+	t = 0.0;
+	p = 1.0;
+	for( i=1; i<aid; i++ )
+		{
+		r = 1.0-e+t;
+		p *= s * (a+t+d2) * (b+t+d2) / r;
+		t += 1.0;
+		p /= t;
+		y1 += p;
+		}
+nosum:
+	p = gamma(c);
+	y1 *= gamma(e) * p / (gamma(a+d1) * gamma(b+d1));
+
+	y *= p / (gamma(a+d2) * gamma(b+d2));
+	if( (aid & 1) != 0 )
+		y = -y;
+
+	q = pow( s, id );	/* s to the id power */
+	if( id > 0.0 )
+		y *= q;
+	else
+		y1 *= q;
+
+	y += y1;
+psidon:
+	goto done;
+	}
+
+}
+
+/* Use defining power series if no special cases */
+y = hys2f1( a, b, c, x, &err );
+
+done:
+*loss = err;
+return(y);
+}
+
+
+
+
+
+/* Defining power series expansion of Gauss hypergeometric function */
+
+static double hys2f1( a, b, c, x, loss )
+double a, b, c, x;
+double *loss; /* estimates loss of significance */
+{
+double f, g, h, k, m, s, u, umax;
+int i;
+
+i = 0;
+umax = 0.0;
+f = a;
+g = b;
+h = c;
+s = 1.0;
+u = 1.0;
+k = 0.0;
+do
+	{
+	if( fabs(h) < EPS )
+		{
+		*loss = 1.0;
+		return( MAXNUM );
+		}
+	m = k + 1.0;
+	u = u * ((f+k) * (g+k) * x / ((h+k) * m));
+	s += u;
+	k = fabs(u);  /* remember largest term summed */
+	if( k > umax )
+		umax = k;
+	k = m;
+	if( ++i > 10000 ) /* should never happen */
+		{
+		*loss = 1.0;
+		return(s);
+		}
+	}
+while( fabs(u/s) > MACHEP );
+
+/* return estimated relative error */
+*loss = (MACHEP*umax)/fabs(s) + (MACHEP*i);
+
+return(s);
+}
Index: sansmodels/src/cephes/hyperg.c
===================================================================
--- sansmodels/src/cephes/hyperg.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/hyperg.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,388 @@
+/*							hyperg.c
+ *
+ *	Confluent hypergeometric function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, x, y, hyperg();
+ *
+ * y = hyperg( a, b, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Computes the confluent hypergeometric function
+ *
+ *                          1           2
+ *                       a x    a(a+1) x
+ *   F ( a,b;x )  =  1 + ---- + --------- + ...
+ *  1 1                  b 1!   b(b+1) 2!
+ *
+ * Many higher transcendental functions are special cases of
+ * this power series.
+ *
+ * As is evident from the formula, b must not be a negative
+ * integer or zero unless a is an integer with 0 >= a > b.
+ *
+ * The routine attempts both a direct summation of the series
+ * and an asymptotic expansion.  In each case error due to
+ * roundoff, cancellation, and nonconvergence is estimated.
+ * The result with smaller estimated error is returned.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a, b, x), all three variables
+ * ranging from 0 to 30.
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0,30         2000       1.2e-15     1.3e-16
+ qtst1:
+ 21800   max =  1.4200E-14   rms =  1.0841E-15  ave = -5.3640E-17 
+ ltstd:
+ 25500   max = 1.2759e-14   rms = 3.7155e-16  ave = 1.5384e-18 
+ *    IEEE      0,30        30000       1.8e-14     1.1e-15
+ *
+ * Larger errors can be observed when b is near a negative
+ * integer or zero.  Certain combinations of arguments yield
+ * serious cancellation error in the power series summation
+ * and also are not in the region of near convergence of the
+ * asymptotic series.  An error message is printed if the
+ * self-estimated relative error is greater than 1.0e-12.
+ *
+ */
+
+
+/*							hyperg.c */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1988, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+#ifdef ANSIPROT
+extern double exp ( double );
+extern double log ( double );
+extern double gamma ( double );
+extern double lgam ( double );
+extern double fabs ( double );
+double hyp2f0 ( double, double, double, int, double * );
+static double hy1f1p(double, double, double, double *);
+static double hy1f1a(double, double, double, double *);
+double hyperg (double, double, double);
+#else
+double exp(), log(), gamma(), lgam(), fabs(), hyp2f0();
+static double hy1f1p();
+static double hy1f1a();
+double hyperg();
+#endif
+extern double MAXNUM, MACHEP;
+
+double hyperg( a, b, x)
+double a, b, x;
+{
+double asum, psum, acanc, pcanc, temp;
+
+/* See if a Kummer transformation will help */
+temp = b - a;
+if( fabs(temp) < 0.001 * fabs(a) )
+	return( exp(x) * hyperg( temp, b, -x )  );
+
+
+psum = hy1f1p( a, b, x, &pcanc );
+if( pcanc < 1.0e-15 )
+	goto done;
+
+
+/* try asymptotic series */
+
+asum = hy1f1a( a, b, x, &acanc );
+
+
+/* Pick the result with less estimated error */
+
+if( acanc < pcanc )
+	{
+	pcanc = acanc;
+	psum = asum;
+	}
+
+done:
+if( pcanc > 1.0e-12 )
+	mtherr( "hyperg", PLOSS );
+
+return( psum );
+}
+
+
+
+
+/* Power series summation for confluent hypergeometric function		*/
+
+
+static double hy1f1p( a, b, x, err )
+double a, b, x;
+double *err;
+{
+double n, a0, sum, t, u, temp;
+double an, bn, maxt, pcanc;
+
+
+/* set up for power series summation */
+an = a;
+bn = b;
+a0 = 1.0;
+sum = 1.0;
+n = 1.0;
+t = 1.0;
+maxt = 0.0;
+
+
+while( t > MACHEP )
+	{
+	if( bn == 0 )			/* check bn first since if both	*/
+		{
+		mtherr( "hyperg", SING );
+		return( MAXNUM );	/* an and bn are zero it is	*/
+		}
+	if( an == 0 )			/* a singularity		*/
+		return( sum );
+	if( n > 200 )
+		goto pdone;
+	u = x * ( an / (bn * n) );
+
+	/* check for blowup */
+	temp = fabs(u);
+	if( (temp > 1.0 ) && (maxt > (MAXNUM/temp)) )
+		{
+		pcanc = 1.0;	/* estimate 100% error */
+		goto blowup;
+		}
+
+	a0 *= u;
+	sum += a0;
+	t = fabs(a0);
+	if( t > maxt )
+		maxt = t;
+/*
+	if( (maxt/fabs(sum)) > 1.0e17 )
+		{
+		pcanc = 1.0;
+		goto blowup;
+		}
+*/
+	an += 1.0;
+	bn += 1.0;
+	n += 1.0;
+	}
+
+pdone:
+
+/* estimate error due to roundoff and cancellation */
+if( sum != 0.0 )
+	maxt /= fabs(sum);
+maxt *= MACHEP; 	/* this way avoids multiply overflow */
+pcanc = fabs( MACHEP * n  +  maxt );
+
+blowup:
+
+*err = pcanc;
+
+return( sum );
+}
+
+
+/*							hy1f1a()	*/
+/* asymptotic formula for hypergeometric function:
+ *
+ *        (    -a                         
+ *  --    ( |z|                           
+ * |  (b) ( -------- 2f0( a, 1+a-b, -1/x )
+ *        (  --                           
+ *        ( |  (b-a)                      
+ *
+ *
+ *                                x    a-b                     )
+ *                               e  |x|                        )
+ *                             + -------- 2f0( b-a, 1-a, 1/x ) )
+ *                                --                           )
+ *                               |  (a)                        )
+ */
+
+static double hy1f1a( a, b, x, err )
+double a, b, x;
+double *err;
+{
+double h1, h2, t, u, temp, acanc, asum, err1, err2;
+
+if( x == 0 )
+	{
+	acanc = 1.0;
+	asum = MAXNUM;
+	goto adone;
+	}
+temp = log( fabs(x) );
+t = x + temp * (a-b);
+u = -temp * a;
+
+if( b > 0 )
+	{
+	temp = lgam(b);
+	t += temp;
+	u += temp;
+	}
+
+h1 = hyp2f0( a, a-b+1, -1.0/x, 1, &err1 );
+
+temp = exp(u) / gamma(b-a);
+h1 *= temp;
+err1 *= temp;
+
+h2 = hyp2f0( b-a, 1.0-a, 1.0/x, 2, &err2 );
+
+if( a < 0 )
+	temp = exp(t) / gamma(a);
+else
+	temp = exp( t - lgam(a) );
+
+h2 *= temp;
+err2 *= temp;
+
+if( x < 0.0 )
+	asum = h1;
+else
+	asum = h2;
+
+acanc = fabs(err1) + fabs(err2);
+
+
+if( b < 0 )
+	{
+	temp = gamma(b);
+	asum *= temp;
+	acanc *= fabs(temp);
+	}
+
+
+if( asum != 0.0 )
+	acanc /= fabs(asum);
+
+acanc *= 30.0;	/* fudge factor, since error of asymptotic formula
+		 * often seems this much larger than advertised */
+
+adone:
+
+
+*err = acanc;
+return( asum );
+}
+
+
+/*							hyp2f0()	*/
+
+double hyp2f0( a, b, x, type, err )
+double a, b, x;
+int type;	/* determines what converging factor to use */
+double *err;
+{
+double a0, alast, t, tlast, maxt;
+double n, an, bn, u, sum, temp;
+
+an = a;
+bn = b;
+a0 = 1.0e0;
+alast = 1.0e0;
+sum = 0.0;
+n = 1.0e0;
+t = 1.0e0;
+tlast = 1.0e9;
+maxt = 0.0;
+
+do
+	{
+	if( an == 0 )
+		goto pdone;
+	if( bn == 0 )
+		goto pdone;
+
+	u = an * (bn * x / n);
+
+	/* check for blowup */
+	temp = fabs(u);
+	if( (temp > 1.0 ) && (maxt > (MAXNUM/temp)) )
+		goto error;
+
+	a0 *= u;
+	t = fabs(a0);
+
+	/* terminating condition for asymptotic series */
+	if( t > tlast )
+		goto ndone;
+
+	tlast = t;
+	sum += alast;	/* the sum is one term behind */
+	alast = a0;
+
+	if( n > 200 )
+		goto ndone;
+
+	an += 1.0e0;
+	bn += 1.0e0;
+	n += 1.0e0;
+	if( t > maxt )
+		maxt = t;
+	}
+while( t > MACHEP );
+
+
+pdone:	/* series converged! */
+
+/* estimate error due to roundoff and cancellation */
+*err = fabs(  MACHEP * (n + maxt)  );
+
+alast = a0;
+goto done;
+
+ndone:	/* series did not converge */
+
+/* The following "Converging factors" are supposed to improve accuracy,
+ * but do not actually seem to accomplish very much. */
+
+n -= 1.0;
+x = 1.0/x;
+
+switch( type )	/* "type" given as subroutine argument */
+{
+case 1:
+	alast *= ( 0.5 + (0.125 + 0.25*b - 0.5*a + 0.25*x - 0.25*n)/x );
+	break;
+
+case 2:
+	alast *= 2.0/3.0 - b + 2.0*a + x - n;
+	break;
+
+default:
+	;
+}
+
+/* estimate error due to roundoff, cancellation, and nonconvergence */
+*err = MACHEP * (n + maxt)  +  fabs ( a0 );
+
+
+done:
+sum += alast;
+return( sum );
+
+/* series blew up: */
+error:
+*err = MAXNUM;
+mtherr( "hyperg", TLOSS );
+return( sum );
+}
Index: sansmodels/src/cephes/i0.c
===================================================================
--- sansmodels/src/cephes/i0.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/i0.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,399 @@
+/*							i0.c
+ *
+ *	Modified Bessel function of order zero
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, i0();
+ *
+ * y = i0( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns modified Bessel function of order zero of the
+ * argument.
+ *
+ * The function is defined as i0(x) = j0( ix ).
+ *
+ * The range is partitioned into the two intervals [0,8] and
+ * (8, infinity).  Chebyshev polynomial expansions are employed
+ * in each interval.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0,30         6000       8.2e-17     1.9e-17
+ *    IEEE      0,30        30000       5.8e-16     1.4e-16
+ *
+ */
+
+/*							i0e.c
+ *
+ *	Modified Bessel function of order zero,
+ *	exponentially scaled
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, i0e();
+ *
+ * y = i0e( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns exponentially scaled modified Bessel function
+ * of order zero of the argument.
+ *
+ * The function is defined as i0e(x) = exp(-|x|) j0( ix ).
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0,30        30000       5.4e-16     1.2e-16
+ * See i0().
+ *
+ */
+
+
+/*							i0.c		*/
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+/* Chebyshev coefficients for exp(-x) I0(x)
+ * in the interval [0,8].
+ *
+ * lim(x->0){ exp(-x) I0(x) } = 1.
+ */
+
+#ifdef UNK
+static double A[] =
+{
+-4.41534164647933937950E-18,
+ 3.33079451882223809783E-17,
+-2.43127984654795469359E-16,
+ 1.71539128555513303061E-15,
+-1.16853328779934516808E-14,
+ 7.67618549860493561688E-14,
+-4.85644678311192946090E-13,
+ 2.95505266312963983461E-12,
+-1.72682629144155570723E-11,
+ 9.67580903537323691224E-11,
+-5.18979560163526290666E-10,
+ 2.65982372468238665035E-9,
+-1.30002500998624804212E-8,
+ 6.04699502254191894932E-8,
+-2.67079385394061173391E-7,
+ 1.11738753912010371815E-6,
+-4.41673835845875056359E-6,
+ 1.64484480707288970893E-5,
+-5.75419501008210370398E-5,
+ 1.88502885095841655729E-4,
+-5.76375574538582365885E-4,
+ 1.63947561694133579842E-3,
+-4.32430999505057594430E-3,
+ 1.05464603945949983183E-2,
+-2.37374148058994688156E-2,
+ 4.93052842396707084878E-2,
+-9.49010970480476444210E-2,
+ 1.71620901522208775349E-1,
+-3.04682672343198398683E-1,
+ 6.76795274409476084995E-1
+};
+#endif
+
+#ifdef DEC
+static unsigned short A[] = {
+0121642,0162671,0004646,0103567,
+0022431,0115424,0135755,0026104,
+0123214,0023533,0110365,0156635,
+0023767,0033304,0117662,0172716,
+0124522,0100426,0012277,0157531,
+0025254,0155062,0054461,0030465,
+0126010,0131143,0013560,0153604,
+0026517,0170577,0006336,0114437,
+0127227,0162253,0152243,0052734,
+0027724,0142766,0061641,0160200,
+0130416,0123760,0116564,0125262,
+0031066,0144035,0021246,0054641,
+0131537,0053664,0060131,0102530,
+0032201,0155664,0165153,0020652,
+0132617,0061434,0074423,0176145,
+0033225,0174444,0136147,0122542,
+0133624,0031576,0056453,0020470,
+0034211,0175305,0172321,0041314,
+0134561,0054462,0147040,0165315,
+0035105,0124333,0120203,0162532,
+0135427,0013750,0174257,0055221,
+0035726,0161654,0050220,0100162,
+0136215,0131361,0000325,0041110,
+0036454,0145417,0117357,0017352,
+0136702,0072367,0104415,0133574,
+0037111,0172126,0072505,0014544,
+0137302,0055601,0120550,0033523,
+0037457,0136543,0136544,0043002,
+0137633,0177536,0001276,0066150,
+0040055,0041164,0100655,0010521
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short A[] = {
+0xd0ef,0x2134,0x5cb7,0xbc54,
+0xa589,0x977d,0x3362,0x3c83,
+0xbbb4,0x721e,0x84eb,0xbcb1,
+0x5eba,0x93f6,0xe6d8,0x3cde,
+0xfbeb,0xc297,0x5022,0xbd0a,
+0x2627,0x4b26,0x9b46,0x3d35,
+0x1af0,0x62ee,0x164c,0xbd61,
+0xd324,0xe19b,0xfe2f,0x3d89,
+0x6abc,0x7a94,0xfc95,0xbdb2,
+0x3c10,0xcc74,0x98be,0x3dda,
+0x9556,0x13ae,0xd4fe,0xbe01,
+0xcb34,0xa454,0xd903,0x3e26,
+0x30ab,0x8c0b,0xeaf6,0xbe4b,
+0x6435,0x9d4d,0x3b76,0x3e70,
+0x7f8d,0x8f22,0xec63,0xbe91,
+0xf4ac,0x978c,0xbf24,0x3eb2,
+0x6427,0xcba5,0x866f,0xbed2,
+0x2859,0xbe9a,0x3f58,0x3ef1,
+0x1d5a,0x59c4,0x2b26,0xbf0e,
+0x7cab,0x7410,0xb51b,0x3f28,
+0xeb52,0x1f15,0xe2fd,0xbf42,
+0x100e,0x8a12,0xdc75,0x3f5a,
+0xa849,0x201a,0xb65e,0xbf71,
+0xe3dd,0xf3dd,0x9961,0x3f85,
+0xb6f0,0xf121,0x4e9e,0xbf98,
+0xa32d,0xcea8,0x3e8a,0x3fa9,
+0x06ea,0x342d,0x4b70,0xbfb8,
+0x88c0,0x77ac,0xf7ac,0x3fc5,
+0xcd8d,0xc057,0x7feb,0xbfd3,
+0xa22a,0x9035,0xa84e,0x3fe5,
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short A[] = {
+0xbc54,0x5cb7,0x2134,0xd0ef,
+0x3c83,0x3362,0x977d,0xa589,
+0xbcb1,0x84eb,0x721e,0xbbb4,
+0x3cde,0xe6d8,0x93f6,0x5eba,
+0xbd0a,0x5022,0xc297,0xfbeb,
+0x3d35,0x9b46,0x4b26,0x2627,
+0xbd61,0x164c,0x62ee,0x1af0,
+0x3d89,0xfe2f,0xe19b,0xd324,
+0xbdb2,0xfc95,0x7a94,0x6abc,
+0x3dda,0x98be,0xcc74,0x3c10,
+0xbe01,0xd4fe,0x13ae,0x9556,
+0x3e26,0xd903,0xa454,0xcb34,
+0xbe4b,0xeaf6,0x8c0b,0x30ab,
+0x3e70,0x3b76,0x9d4d,0x6435,
+0xbe91,0xec63,0x8f22,0x7f8d,
+0x3eb2,0xbf24,0x978c,0xf4ac,
+0xbed2,0x866f,0xcba5,0x6427,
+0x3ef1,0x3f58,0xbe9a,0x2859,
+0xbf0e,0x2b26,0x59c4,0x1d5a,
+0x3f28,0xb51b,0x7410,0x7cab,
+0xbf42,0xe2fd,0x1f15,0xeb52,
+0x3f5a,0xdc75,0x8a12,0x100e,
+0xbf71,0xb65e,0x201a,0xa849,
+0x3f85,0x9961,0xf3dd,0xe3dd,
+0xbf98,0x4e9e,0xf121,0xb6f0,
+0x3fa9,0x3e8a,0xcea8,0xa32d,
+0xbfb8,0x4b70,0x342d,0x06ea,
+0x3fc5,0xf7ac,0x77ac,0x88c0,
+0xbfd3,0x7feb,0xc057,0xcd8d,
+0x3fe5,0xa84e,0x9035,0xa22a
+};
+#endif
+
+
+/* Chebyshev coefficients for exp(-x) sqrt(x) I0(x)
+ * in the inverted interval [8,infinity].
+ *
+ * lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi).
+ */
+
+#ifdef UNK
+static double B[] =
+{
+-7.23318048787475395456E-18,
+-4.83050448594418207126E-18,
+ 4.46562142029675999901E-17,
+ 3.46122286769746109310E-17,
+-2.82762398051658348494E-16,
+-3.42548561967721913462E-16,
+ 1.77256013305652638360E-15,
+ 3.81168066935262242075E-15,
+-9.55484669882830764870E-15,
+-4.15056934728722208663E-14,
+ 1.54008621752140982691E-14,
+ 3.85277838274214270114E-13,
+ 7.18012445138366623367E-13,
+-1.79417853150680611778E-12,
+-1.32158118404477131188E-11,
+-3.14991652796324136454E-11,
+ 1.18891471078464383424E-11,
+ 4.94060238822496958910E-10,
+ 3.39623202570838634515E-9,
+ 2.26666899049817806459E-8,
+ 2.04891858946906374183E-7,
+ 2.89137052083475648297E-6,
+ 6.88975834691682398426E-5,
+ 3.36911647825569408990E-3,
+ 8.04490411014108831608E-1
+};
+#endif
+
+#ifdef DEC
+static unsigned short B[] = {
+0122005,0066672,0123124,0054311,
+0121662,0033323,0030214,0104602,
+0022515,0170300,0113314,0020413,
+0022437,0117350,0035402,0007146,
+0123243,0000135,0057220,0177435,
+0123305,0073476,0144106,0170702,
+0023777,0071755,0017527,0154373,
+0024211,0052214,0102247,0033270,
+0124454,0017763,0171453,0012322,
+0125072,0166316,0075505,0154616,
+0024612,0133770,0065376,0025045,
+0025730,0162143,0056036,0001632,
+0026112,0015077,0150464,0063542,
+0126374,0101030,0014274,0065457,
+0127150,0077271,0125763,0157617,
+0127412,0104350,0040713,0120445,
+0027121,0023765,0057500,0001165,
+0030407,0147146,0003643,0075644,
+0031151,0061445,0044422,0156065,
+0031702,0132224,0003266,0125551,
+0032534,0000076,0147153,0005555,
+0033502,0004536,0004016,0026055,
+0034620,0076433,0142314,0171215,
+0036134,0146145,0013454,0101104,
+0040115,0171425,0062500,0047133
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short B[] = {
+0x8b19,0x54ca,0xadb7,0xbc60,
+0x9130,0x6611,0x46da,0xbc56,
+0x8421,0x12d9,0xbe18,0x3c89,
+0x41cd,0x0760,0xf3dd,0x3c83,
+0x1fe4,0xabd2,0x600b,0xbcb4,
+0xde38,0xd908,0xaee7,0xbcb8,
+0xfb1f,0xa3ea,0xee7d,0x3cdf,
+0xe6d7,0x9094,0x2a91,0x3cf1,
+0x629a,0x7e65,0x83fe,0xbd05,
+0xbb32,0xcf68,0x5d99,0xbd27,
+0xc545,0x0d5f,0x56ff,0x3d11,
+0xc073,0x6b83,0x1c8c,0x3d5b,
+0x8cec,0xfa26,0x4347,0x3d69,
+0x8d66,0x0317,0x9043,0xbd7f,
+0x7bf2,0x357e,0x0fd7,0xbdad,
+0x7425,0x0839,0x511d,0xbdc1,
+0x004f,0xabe8,0x24fe,0x3daa,
+0x6f75,0xc0f4,0xf9cc,0x3e00,
+0x5b87,0xa922,0x2c64,0x3e2d,
+0xd56d,0x80d6,0x5692,0x3e58,
+0x616e,0xd9cd,0x8007,0x3e8b,
+0xc586,0xc101,0x412b,0x3ec8,
+0x9e52,0x7899,0x0fa3,0x3f12,
+0x9049,0xa2e5,0x998c,0x3f6b,
+0x09cb,0xaca8,0xbe62,0x3fe9
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short B[] = {
+0xbc60,0xadb7,0x54ca,0x8b19,
+0xbc56,0x46da,0x6611,0x9130,
+0x3c89,0xbe18,0x12d9,0x8421,
+0x3c83,0xf3dd,0x0760,0x41cd,
+0xbcb4,0x600b,0xabd2,0x1fe4,
+0xbcb8,0xaee7,0xd908,0xde38,
+0x3cdf,0xee7d,0xa3ea,0xfb1f,
+0x3cf1,0x2a91,0x9094,0xe6d7,
+0xbd05,0x83fe,0x7e65,0x629a,
+0xbd27,0x5d99,0xcf68,0xbb32,
+0x3d11,0x56ff,0x0d5f,0xc545,
+0x3d5b,0x1c8c,0x6b83,0xc073,
+0x3d69,0x4347,0xfa26,0x8cec,
+0xbd7f,0x9043,0x0317,0x8d66,
+0xbdad,0x0fd7,0x357e,0x7bf2,
+0xbdc1,0x511d,0x0839,0x7425,
+0x3daa,0x24fe,0xabe8,0x004f,
+0x3e00,0xf9cc,0xc0f4,0x6f75,
+0x3e2d,0x2c64,0xa922,0x5b87,
+0x3e58,0x5692,0x80d6,0xd56d,
+0x3e8b,0x8007,0xd9cd,0x616e,
+0x3ec8,0x412b,0xc101,0xc586,
+0x3f12,0x0fa3,0x7899,0x9e52,
+0x3f6b,0x998c,0xa2e5,0x9049,
+0x3fe9,0xbe62,0xaca8,0x09cb
+};
+#endif
+
+#ifdef ANSIPROT
+extern double chbevl ( double, void *, int );
+extern double exp ( double );
+extern double sqrt ( double );
+#else
+double chbevl(), exp(), sqrt();
+#endif
+
+double i0(x)
+double x;
+{
+double y;
+
+if( x < 0 )
+	x = -x;
+if( x <= 8.0 )
+	{
+	y = (x/2.0) - 2.0;
+	return( exp(x) * chbevl( y, A, 30 ) );
+	}
+
+return(  exp(x) * chbevl( 32.0/x - 2.0, B, 25 ) / sqrt(x) );
+
+}
+
+
+
+
+double i0e( x )
+double x;
+{
+double y;
+
+if( x < 0 )
+	x = -x;
+if( x <= 8.0 )
+	{
+	y = (x/2.0) - 2.0;
+	return( chbevl( y, A, 30 ) );
+	}
+
+return(  chbevl( 32.0/x - 2.0, B, 25 ) / sqrt(x) );
+
+}
Index: sansmodels/src/cephes/i1.c
===================================================================
--- sansmodels/src/cephes/i1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/i1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,407 @@
+/*							i1.c
+ *
+ *	Modified Bessel function of order one
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, i1();
+ *
+ * y = i1( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns modified Bessel function of order one of the
+ * argument.
+ *
+ * The function is defined as i1(x) = -i j1( ix ).
+ *
+ * The range is partitioned into the two intervals [0,8] and
+ * (8, infinity).  Chebyshev polynomial expansions are employed
+ * in each interval.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0, 30        3400       1.2e-16     2.3e-17
+ *    IEEE      0, 30       30000       1.9e-15     2.1e-16
+ *
+ *
+ */
+
+/*							i1e.c
+ *
+ *	Modified Bessel function of order one,
+ *	exponentially scaled
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, i1e();
+ *
+ * y = i1e( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns exponentially scaled modified Bessel function
+ * of order one of the argument.
+ *
+ * The function is defined as i1(x) = -i exp(-|x|) j1( ix ).
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0, 30       30000       2.0e-15     2.0e-16
+ * See i1().
+ *
+ */
+
+
+/*							i1.c 2		*/
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1985, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+/* Chebyshev coefficients for exp(-x) I1(x) / x
+ * in the interval [0,8].
+ *
+ * lim(x->0){ exp(-x) I1(x) / x } = 1/2.
+ */
+
+#ifdef UNK
+static double A[] =
+{
+ 2.77791411276104639959E-18,
+-2.11142121435816608115E-17,
+ 1.55363195773620046921E-16,
+-1.10559694773538630805E-15,
+ 7.60068429473540693410E-15,
+-5.04218550472791168711E-14,
+ 3.22379336594557470981E-13,
+-1.98397439776494371520E-12,
+ 1.17361862988909016308E-11,
+-6.66348972350202774223E-11,
+ 3.62559028155211703701E-10,
+-1.88724975172282928790E-9,
+ 9.38153738649577178388E-9,
+-4.44505912879632808065E-8,
+ 2.00329475355213526229E-7,
+-8.56872026469545474066E-7,
+ 3.47025130813767847674E-6,
+-1.32731636560394358279E-5,
+ 4.78156510755005422638E-5,
+-1.61760815825896745588E-4,
+ 5.12285956168575772895E-4,
+-1.51357245063125314899E-3,
+ 4.15642294431288815669E-3,
+-1.05640848946261981558E-2,
+ 2.47264490306265168283E-2,
+-5.29459812080949914269E-2,
+ 1.02643658689847095384E-1,
+-1.76416518357834055153E-1,
+ 2.52587186443633654823E-1
+};
+#endif
+
+#ifdef DEC
+static unsigned short A[] = {
+0021514,0174520,0060742,0000241,
+0122302,0137206,0016120,0025663,
+0023063,0017437,0026235,0176536,
+0123637,0052523,0170150,0125632,
+0024410,0165770,0030251,0044134,
+0125143,0012160,0162170,0054727,
+0025665,0075702,0035716,0145247,
+0126413,0116032,0176670,0015462,
+0027116,0073425,0110351,0105242,
+0127622,0104034,0137530,0037364,
+0030307,0050645,0120776,0175535,
+0131001,0130331,0043523,0037455,
+0031441,0026160,0010712,0100174,
+0132076,0164761,0022706,0017500,
+0032527,0015045,0115076,0104076,
+0133146,0001714,0015434,0144520,
+0033550,0161166,0124215,0077050,
+0134136,0127715,0143365,0157170,
+0034510,0106652,0013070,0064130,
+0135051,0117126,0117264,0123761,
+0035406,0045355,0133066,0175751,
+0135706,0061420,0054746,0122440,
+0036210,0031232,0047235,0006640,
+0136455,0012373,0144235,0011523,
+0036712,0107437,0036731,0015111,
+0137130,0156742,0115744,0172743,
+0037322,0033326,0124667,0124740,
+0137464,0123210,0021510,0144556,
+0037601,0051433,0111123,0177721
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short A[] = {
+0x4014,0x0c3c,0x9f2a,0x3c49,
+0x0576,0xc38a,0x57d0,0xbc78,
+0xbfac,0xe593,0x63e3,0x3ca6,
+0x1573,0x7e0d,0xeaaa,0xbcd3,
+0x290c,0x0615,0x1d7f,0x3d01,
+0x0b3b,0x1c8f,0x628e,0xbd2c,
+0xd955,0x4779,0xaf78,0x3d56,
+0x0366,0x5fb7,0x7383,0xbd81,
+0x3154,0xb21d,0xcee2,0x3da9,
+0x07de,0x97eb,0x5103,0xbdd2,
+0xdf6c,0xb43f,0xea34,0x3df8,
+0x67e6,0x28ea,0x361b,0xbe20,
+0x5010,0x0239,0x258e,0x3e44,
+0xc3e8,0x24b8,0xdd3e,0xbe67,
+0xd108,0xb347,0xe344,0x3e8a,
+0x992a,0x8363,0xc079,0xbeac,
+0xafc5,0xd511,0x1c4e,0x3ecd,
+0xbbcf,0xb8de,0xd5f9,0xbeeb,
+0x0d0b,0x42c7,0x11b5,0x3f09,
+0x94fe,0xd3d6,0x33ca,0xbf25,
+0xdf7d,0xb6c6,0xc95d,0x3f40,
+0xd4a4,0x0b3c,0xcc62,0xbf58,
+0xa1b4,0x49d3,0x0653,0x3f71,
+0xa26a,0x7913,0xa29f,0xbf85,
+0x2349,0xe7bb,0x51e3,0x3f99,
+0x9ebc,0x537c,0x1bbc,0xbfab,
+0xf53c,0xd536,0x46da,0x3fba,
+0x192e,0x0469,0x94d1,0xbfc6,
+0x7ffa,0x724a,0x2a63,0x3fd0
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short A[] = {
+0x3c49,0x9f2a,0x0c3c,0x4014,
+0xbc78,0x57d0,0xc38a,0x0576,
+0x3ca6,0x63e3,0xe593,0xbfac,
+0xbcd3,0xeaaa,0x7e0d,0x1573,
+0x3d01,0x1d7f,0x0615,0x290c,
+0xbd2c,0x628e,0x1c8f,0x0b3b,
+0x3d56,0xaf78,0x4779,0xd955,
+0xbd81,0x7383,0x5fb7,0x0366,
+0x3da9,0xcee2,0xb21d,0x3154,
+0xbdd2,0x5103,0x97eb,0x07de,
+0x3df8,0xea34,0xb43f,0xdf6c,
+0xbe20,0x361b,0x28ea,0x67e6,
+0x3e44,0x258e,0x0239,0x5010,
+0xbe67,0xdd3e,0x24b8,0xc3e8,
+0x3e8a,0xe344,0xb347,0xd108,
+0xbeac,0xc079,0x8363,0x992a,
+0x3ecd,0x1c4e,0xd511,0xafc5,
+0xbeeb,0xd5f9,0xb8de,0xbbcf,
+0x3f09,0x11b5,0x42c7,0x0d0b,
+0xbf25,0x33ca,0xd3d6,0x94fe,
+0x3f40,0xc95d,0xb6c6,0xdf7d,
+0xbf58,0xcc62,0x0b3c,0xd4a4,
+0x3f71,0x0653,0x49d3,0xa1b4,
+0xbf85,0xa29f,0x7913,0xa26a,
+0x3f99,0x51e3,0xe7bb,0x2349,
+0xbfab,0x1bbc,0x537c,0x9ebc,
+0x3fba,0x46da,0xd536,0xf53c,
+0xbfc6,0x94d1,0x0469,0x192e,
+0x3fd0,0x2a63,0x724a,0x7ffa
+};
+#endif
+
+
+/*							i1.c	*/
+
+/* Chebyshev coefficients for exp(-x) sqrt(x) I1(x)
+ * in the inverted interval [8,infinity].
+ *
+ * lim(x->inf){ exp(-x) sqrt(x) I1(x) } = 1/sqrt(2pi).
+ */
+
+#ifdef UNK
+static double B[] =
+{
+ 7.51729631084210481353E-18,
+ 4.41434832307170791151E-18,
+-4.65030536848935832153E-17,
+-3.20952592199342395980E-17,
+ 2.96262899764595013876E-16,
+ 3.30820231092092828324E-16,
+-1.88035477551078244854E-15,
+-3.81440307243700780478E-15,
+ 1.04202769841288027642E-14,
+ 4.27244001671195135429E-14,
+-2.10154184277266431302E-14,
+-4.08355111109219731823E-13,
+-7.19855177624590851209E-13,
+ 2.03562854414708950722E-12,
+ 1.41258074366137813316E-11,
+ 3.25260358301548823856E-11,
+-1.89749581235054123450E-11,
+-5.58974346219658380687E-10,
+-3.83538038596423702205E-9,
+-2.63146884688951950684E-8,
+-2.51223623787020892529E-7,
+-3.88256480887769039346E-6,
+-1.10588938762623716291E-4,
+-9.76109749136146840777E-3,
+ 7.78576235018280120474E-1
+};
+#endif
+
+#ifdef DEC
+static unsigned short B[] = {
+0022012,0125555,0115227,0043456,
+0021642,0156127,0052075,0145203,
+0122526,0072435,0111231,0011664,
+0122424,0001544,0161671,0114403,
+0023252,0144257,0163532,0142121,
+0023276,0132162,0174045,0013204,
+0124007,0077154,0057046,0110517,
+0124211,0066650,0116127,0157073,
+0024473,0133413,0130551,0107504,
+0025100,0064741,0032631,0040364,
+0124675,0045101,0071551,0012400,
+0125745,0161054,0071637,0011247,
+0126112,0117410,0035525,0122231,
+0026417,0037237,0131034,0176427,
+0027170,0100373,0024742,0025725,
+0027417,0006417,0105303,0141446,
+0127246,0163716,0121202,0060137,
+0130431,0123122,0120436,0166000,
+0131203,0144134,0153251,0124500,
+0131742,0005234,0122732,0033006,
+0132606,0157751,0072362,0121031,
+0133602,0043372,0047120,0015626,
+0134747,0165774,0001125,0046462,
+0136437,0166402,0117746,0155137,
+0040107,0050305,0125330,0124241
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short B[] = {
+0xe8e6,0xb352,0x556d,0x3c61,
+0xb950,0xea87,0x5b8a,0x3c54,
+0x2277,0xb253,0xcea3,0xbc8a,
+0x3320,0x9c77,0x806c,0xbc82,
+0x588a,0xfceb,0x5915,0x3cb5,
+0xa2d1,0x5f04,0xd68e,0x3cb7,
+0xd22a,0x8bc4,0xefcd,0xbce0,
+0xfbc7,0x138a,0x2db5,0xbcf1,
+0x31e8,0x762d,0x76e1,0x3d07,
+0x281e,0x26b3,0x0d3c,0x3d28,
+0x22a0,0x2e6d,0xa948,0xbd17,
+0xe255,0x8e73,0xbc45,0xbd5c,
+0xb493,0x076a,0x53e1,0xbd69,
+0x9fa3,0xf643,0xe7d3,0x3d81,
+0x457b,0x653c,0x101f,0x3daf,
+0x7865,0xf158,0xe1a1,0x3dc1,
+0x4c0c,0xd450,0xdcf9,0xbdb4,
+0xdd80,0x5423,0x34ca,0xbe03,
+0x3528,0x9ad5,0x790b,0xbe30,
+0x46c1,0x94bb,0x4153,0xbe5c,
+0x5443,0x2e9e,0xdbfd,0xbe90,
+0x0373,0x49ca,0x48df,0xbed0,
+0xa9a6,0x804a,0xfd7f,0xbf1c,
+0xdb4c,0x53fc,0xfda0,0xbf83,
+0x1514,0xb55b,0xea18,0x3fe8
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short B[] = {
+0x3c61,0x556d,0xb352,0xe8e6,
+0x3c54,0x5b8a,0xea87,0xb950,
+0xbc8a,0xcea3,0xb253,0x2277,
+0xbc82,0x806c,0x9c77,0x3320,
+0x3cb5,0x5915,0xfceb,0x588a,
+0x3cb7,0xd68e,0x5f04,0xa2d1,
+0xbce0,0xefcd,0x8bc4,0xd22a,
+0xbcf1,0x2db5,0x138a,0xfbc7,
+0x3d07,0x76e1,0x762d,0x31e8,
+0x3d28,0x0d3c,0x26b3,0x281e,
+0xbd17,0xa948,0x2e6d,0x22a0,
+0xbd5c,0xbc45,0x8e73,0xe255,
+0xbd69,0x53e1,0x076a,0xb493,
+0x3d81,0xe7d3,0xf643,0x9fa3,
+0x3daf,0x101f,0x653c,0x457b,
+0x3dc1,0xe1a1,0xf158,0x7865,
+0xbdb4,0xdcf9,0xd450,0x4c0c,
+0xbe03,0x34ca,0x5423,0xdd80,
+0xbe30,0x790b,0x9ad5,0x3528,
+0xbe5c,0x4153,0x94bb,0x46c1,
+0xbe90,0xdbfd,0x2e9e,0x5443,
+0xbed0,0x48df,0x49ca,0x0373,
+0xbf1c,0xfd7f,0x804a,0xa9a6,
+0xbf83,0xfda0,0x53fc,0xdb4c,
+0x3fe8,0xea18,0xb55b,0x1514
+};
+#endif
+
+
+/*							i1.c	*/
+#ifdef ANSIPROT
+extern double chbevl ( double, void *, int );
+extern double exp ( double );
+extern double sqrt ( double );
+extern double fabs ( double );
+#else
+double chbevl(), exp(), sqrt(), fabs();
+#endif
+
+double i1(x)
+double x;
+{ 
+double y, z;
+
+z = fabs(x);
+if( z <= 8.0 )
+	{
+	y = (z/2.0) - 2.0;
+	z = chbevl( y, A, 29 ) * z * exp(z);
+	}
+else
+	{
+	z = exp(z) * chbevl( 32.0/z - 2.0, B, 25 ) / sqrt(z);
+	}
+if( x < 0.0 )
+	z = -z;
+return( z );
+}
+
+
+/*							i1e()	*/
+
+double i1e( x )
+double x;
+{ 
+double y, z;
+
+z = fabs(x);
+if( z <= 8.0 )
+	{
+	y = (z/2.0) - 2.0;
+	z = chbevl( y, A, 29 ) * z;
+	}
+else
+	{
+	z = chbevl( 32.0/z - 2.0, B, 25 ) / sqrt(z);
+	}
+if( x < 0.0 )
+	z = -z;
+return( z );
+}
Index: sansmodels/src/cephes/igam.c
===================================================================
--- sansmodels/src/cephes/igam.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/igam.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,212 @@
+/*							igam.c
+ *
+ *	Incomplete gamma integral
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, x, y, igam();
+ *
+ * y = igam( a, x );
+ *
+ * DESCRIPTION:
+ *
+ * The function is defined by
+ *
+ *                           x
+ *                            -
+ *                   1       | |  -t  a-1
+ *  igam(a,x)  =   -----     |   e   t   dt.
+ *                  -      | |
+ *                 | (a)    -
+ *                           0
+ *
+ *
+ * In this implementation both arguments must be positive.
+ * The integral is evaluated by either a power series or
+ * continued fraction expansion, depending on the relative
+ * values of a and x.
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0,30       200000       3.6e-14     2.9e-15
+ *    IEEE      0,100      300000       9.9e-14     1.5e-14
+ */
+
+/*							igamc()
+ *
+ *	Complemented incomplete gamma integral
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, x, y, igamc();
+ *
+ * y = igamc( a, x );
+ *
+ * DESCRIPTION:
+ *
+ * The function is defined by
+ *
+ *
+ *  igamc(a,x)   =   1 - igam(a,x)
+ *
+ *                            inf.
+ *                              -
+ *                     1       | |  -t  a-1
+ *               =   -----     |   e   t   dt.
+ *                    -      | |
+ *                   | (a)    -
+ *                             x
+ *
+ *
+ * In this implementation both arguments must be positive.
+ * The integral is evaluated by either a power series or
+ * continued fraction expansion, depending on the relative
+ * values of a and x.
+ *
+ * ACCURACY:
+ *
+ * Tested at random a, x.
+ *                a         x                      Relative error:
+ * arithmetic   domain   domain     # trials      peak         rms
+ *    IEEE     0.5,100   0,100      200000       1.9e-14     1.7e-15
+ *    IEEE     0.01,0.5  0,100      200000       1.4e-13     1.6e-15
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1985, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double lgam ( double );
+extern double exp ( double );
+extern double log ( double );
+extern double fabs ( double );
+extern double igam ( double, double );
+extern double igamc ( double, double );
+#else
+double lgam(), exp(), log(), fabs(), igam(), igamc();
+#endif
+
+extern double MACHEP, MAXLOG;
+static double big = 4.503599627370496e15;
+static double biginv =  2.22044604925031308085e-16;
+
+double igamc( a, x )
+double a, x;
+{
+double ans, ax, c, yc, r, t, y, z;
+double pk, pkm1, pkm2, qk, qkm1, qkm2;
+
+if( (x <= 0) || ( a <= 0) )
+	return( 1.0 );
+
+if( (x < 1.0) || (x < a) )
+	return( 1.0 - igam(a,x) );
+
+ax = a * log(x) - x - lgam(a);
+if( ax < -MAXLOG )
+	{
+	mtherr( "igamc", UNDERFLOW );
+	return( 0.0 );
+	}
+ax = exp(ax);
+
+/* continued fraction */
+y = 1.0 - a;
+z = x + y + 1.0;
+c = 0.0;
+pkm2 = 1.0;
+qkm2 = x;
+pkm1 = x + 1.0;
+qkm1 = z * x;
+ans = pkm1/qkm1;
+
+do
+	{
+	c += 1.0;
+	y += 1.0;
+	z += 2.0;
+	yc = y * c;
+	pk = pkm1 * z  -  pkm2 * yc;
+	qk = qkm1 * z  -  qkm2 * yc;
+	if( qk != 0 )
+		{
+		r = pk/qk;
+		t = fabs( (ans - r)/r );
+		ans = r;
+		}
+	else
+		t = 1.0;
+	pkm2 = pkm1;
+	pkm1 = pk;
+	qkm2 = qkm1;
+	qkm1 = qk;
+	if( fabs(pk) > big )
+		{
+		pkm2 *= biginv;
+		pkm1 *= biginv;
+		qkm2 *= biginv;
+		qkm1 *= biginv;
+		}
+	}
+while( t > MACHEP );
+
+return( ans * ax );
+}
+
+
+
+/* left tail of incomplete gamma function:
+ *
+ *          inf.      k
+ *   a  -x   -       x
+ *  x  e     >   ----------
+ *           -     -
+ *          k=0   | (a+k+1)
+ *
+ */
+
+double igam( a, x )
+double a, x;
+{
+double ans, ax, c, r;
+
+if( (x <= 0) || ( a <= 0) )
+	return( 0.0 );
+
+if( (x > 1.0) && (x > a ) )
+	return( 1.0 - igamc(a,x) );
+
+/* Compute  x**a * exp(-x) / gamma(a)  */
+ax = a * log(x) - x - lgam(a);
+if( ax < -MAXLOG )
+	{
+	mtherr( "igam", UNDERFLOW );
+	return( 0.0 );
+	}
+ax = exp(ax);
+
+/* power series */
+r = a;
+c = 1.0;
+ans = 1.0;
+
+do
+	{
+	r += 1.0;
+	c *= x/r;
+	ans += c;
+	}
+while( c/ans > MACHEP );
+
+return( ans * ax/a );
+}
Index: sansmodels/src/cephes/igami.c
===================================================================
--- sansmodels/src/cephes/igami.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/igami.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,188 @@
+/*							igami()
+ *
+ *      Inverse of complemented imcomplete gamma integral
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, x, p, igami();
+ *
+ * x = igami( a, p );
+ *
+ * DESCRIPTION:
+ *
+ * Given p, the function finds x such that
+ *
+ *  igamc( a, x ) = p.
+ *
+ * Starting with the approximate value
+ *
+ *         3
+ *  x = a t
+ *
+ *  where
+ *
+ *  t = 1 - d - ndtri(p) sqrt(d)
+ * 
+ * and
+ *
+ *  d = 1/9a,
+ *
+ * the routine performs up to 10 Newton iterations to find the
+ * root of igamc(a,x) - p = 0.
+ *
+ * ACCURACY:
+ *
+ * Tested at random a, p in the intervals indicated.
+ *
+ *                a        p                      Relative error:
+ * arithmetic   domain   domain     # trials      peak         rms
+ *    IEEE     0.5,100   0,0.5       100000       1.0e-14     1.7e-15
+ *    IEEE     0.01,0.5  0,0.5       100000       9.0e-14     3.4e-15
+ *    IEEE    0.5,10000  0,0.5        20000       2.3e-13     3.8e-14
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+extern double MACHEP, MAXNUM, MAXLOG, MINLOG;
+#ifdef ANSIPROT
+extern double igamc ( double, double );
+extern double ndtri ( double );
+extern double exp ( double );
+extern double fabs ( double );
+extern double log ( double );
+extern double sqrt ( double );
+extern double lgam ( double );
+#else
+double igamc(), ndtri(), exp(), fabs(), log(), sqrt(), lgam();
+#endif
+
+double igami( a, y0 )
+double a, y0;
+{
+double x0, x1, x, yl, yh, y, d, lgm, dithresh;
+int i, dir;
+
+/* bound the solution */
+x0 = MAXNUM;
+yl = 0;
+x1 = 0;
+yh = 1.0;
+dithresh = 5.0 * MACHEP;
+
+/* approximation to inverse function */
+d = 1.0/(9.0*a);
+y = ( 1.0 - d - ndtri(y0) * sqrt(d) );
+x = a * y * y * y;
+
+lgm = lgam(a);
+
+for( i=0; i<10; i++ )
+	{
+	if( x > x0 || x < x1 )
+		goto ihalve;
+	y = igamc(a,x);
+	if( y < yl || y > yh )
+		goto ihalve;
+	if( y < y0 )
+		{
+		x0 = x;
+		yl = y;
+		}
+	else
+		{
+		x1 = x;
+		yh = y;
+		}
+/* compute the derivative of the function at this point */
+	d = (a - 1.0) * log(x) - x - lgm;
+	if( d < -MAXLOG )
+		goto ihalve;
+	d = -exp(d);
+/* compute the step to the next approximation of x */
+	d = (y - y0)/d;
+	if( fabs(d/x) < MACHEP )
+		goto done;
+	x = x - d;
+	}
+
+/* Resort to interval halving if Newton iteration did not converge. */
+ihalve:
+
+d = 0.0625;
+if( x0 == MAXNUM )
+	{
+	if( x <= 0.0 )
+		x = 1.0;
+	while( x0 == MAXNUM )
+		{
+		x = (1.0 + d) * x;
+		y = igamc( a, x );
+		if( y < y0 )
+			{
+			x0 = x;
+			yl = y;
+			break;
+			}
+		d = d + d;
+		}
+	}
+d = 0.5;
+dir = 0;
+
+for( i=0; i<400; i++ )
+	{
+	x = x1  +  d * (x0 - x1);
+	y = igamc( a, x );
+	lgm = (x0 - x1)/(x1 + x0);
+	if( fabs(lgm) < dithresh )
+		break;
+	lgm = (y - y0)/y0;
+	if( fabs(lgm) < dithresh )
+		break;
+	if( x <= 0.0 )
+		break;
+	if( y >= y0 )
+		{
+		x1 = x;
+		yh = y;
+		if( dir < 0 )
+			{
+			dir = 0;
+			d = 0.5;
+			}
+		else if( dir > 1 )
+			d = 0.5 * d + 0.5; 
+		else
+			d = (y0 - yl)/(yh - yl);
+		dir += 1;
+		}
+	else
+		{
+		x0 = x;
+		yl = y;
+		if( dir > 0 )
+			{
+			dir = 0;
+			d = 0.5;
+			}
+		else if( dir < -1 )
+			d = 0.5 * d;
+		else
+			d = (y0 - yl)/(yh - yl);
+		dir -= 1;
+		}
+	}
+if( x == 0.0 )
+	mtherr( "igami", UNDERFLOW );
+
+done:
+return( x );
+}
Index: sansmodels/src/cephes/incbet.c
===================================================================
--- sansmodels/src/cephes/incbet.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/incbet.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,413 @@
+/*							incbet.c
+ *
+ *	Incomplete beta integral
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, x, y, incbet();
+ *
+ * y = incbet( a, b, x );
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns incomplete beta integral of the arguments, evaluated
+ * from zero to x.  The function is defined as
+ *
+ *                  x
+ *     -            -
+ *    | (a+b)      | |  a-1     b-1
+ *  -----------    |   t   (1-t)   dt.
+ *   -     -     | |
+ *  | (a) | (b)   -
+ *                 0
+ *
+ * The domain of definition is 0 <= x <= 1.  In this
+ * implementation a and b are restricted to positive values.
+ * The integral from x to 1 may be obtained by the symmetry
+ * relation
+ *
+ *    1 - incbet( a, b, x )  =  incbet( b, a, 1-x ).
+ *
+ * The integral is evaluated by a continued fraction expansion
+ * or, when b*x is small, by a power series.
+ *
+ * ACCURACY:
+ *
+ * Tested at uniformly distributed random points (a,b,x) with a and b
+ * in "domain" and x between 0 and 1.
+ *                                        Relative error
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0,5         10000       6.9e-15     4.5e-16
+ *    IEEE      0,85       250000       2.2e-13     1.7e-14
+ *    IEEE      0,1000      30000       5.3e-12     6.3e-13
+ *    IEEE      0,10000    250000       9.3e-11     7.1e-12
+ *    IEEE      0,100000    10000       8.7e-10     4.8e-11
+ * Outputs smaller than the IEEE gradual underflow threshold
+ * were excluded from these statistics.
+ *
+ * ERROR MESSAGES:
+ *   message         condition      value returned
+ * incbet domain      x<0, x>1          0.0
+ * incbet underflow                     0.0
+ */
+
+
+
+/*
+Cephes Math Library, Release 2.8:  June, 2000
+Copyright 1984, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+#ifdef DEC
+#define MAXGAM 34.84425627277176174
+#else
+#define MAXGAM 171.624376956302725
+#endif
+
+extern double MACHEP, MINLOG, MAXLOG;
+#ifdef ANSIPROT
+extern double gamma ( double );
+extern double lgam ( double );
+extern double exp ( double );
+extern double log ( double );
+extern double pow ( double, double );
+extern double fabs ( double );
+static double incbcf(double, double, double);
+static double incbd(double, double, double);
+static double pseries(double, double, double);
+#else
+double gamma(), lgam(), exp(), log(), pow(), fabs();
+static double incbcf(), incbd(), pseries();
+#endif
+
+static double big = 4.503599627370496e15;
+static double biginv =  2.22044604925031308085e-16;
+
+
+double incbet( aa, bb, xx )
+double aa, bb, xx;
+{
+double a, b, t, x, xc, w, y;
+int flag;
+
+if( aa <= 0.0 || bb <= 0.0 )
+	goto domerr;
+
+if( (xx <= 0.0) || ( xx >= 1.0) )
+	{
+	if( xx == 0.0 )
+		return(0.0);
+	if( xx == 1.0 )
+		return( 1.0 );
+domerr:
+	mtherr( "incbet", DOMAIN );
+	return( 0.0 );
+	}
+
+flag = 0;
+if( (bb * xx) <= 1.0 && xx <= 0.95)
+	{
+	t = pseries(aa, bb, xx);
+		goto done;
+	}
+
+w = 1.0 - xx;
+
+/* Reverse a and b if x is greater than the mean. */
+if( xx > (aa/(aa+bb)) )
+	{
+	flag = 1;
+	a = bb;
+	b = aa;
+	xc = xx;
+	x = w;
+	}
+else
+	{
+	a = aa;
+	b = bb;
+	xc = w;
+	x = xx;
+	}
+
+if( flag == 1 && (b * x) <= 1.0 && x <= 0.95)
+	{
+	t = pseries(a, b, x);
+	goto done;
+	}
+
+/* Choose expansion for better convergence. */
+y = x * (a+b-2.0) - (a-1.0);
+if( y < 0.0 )
+	w = incbcf( a, b, x );
+else
+	w = incbd( a, b, x ) / xc;
+
+/* Multiply w by the factor
+     a      b   _             _     _
+    x  (1-x)   | (a+b) / ( a | (a) | (b) ) .   */
+
+y = a * log(x);
+t = b * log(xc);
+if( (a+b) < MAXGAM && fabs(y) < MAXLOG && fabs(t) < MAXLOG )
+	{
+	t = pow(xc,b);
+	t *= pow(x,a);
+	t /= a;
+	t *= w;
+	t *= gamma(a+b) / (gamma(a) * gamma(b));
+	goto done;
+	}
+/* Resort to logarithms.  */
+y += t + lgam(a+b) - lgam(a) - lgam(b);
+y += log(w/a);
+if( y < MINLOG )
+	t = 0.0;
+else
+	t = exp(y);
+
+done:
+
+if( flag == 1 )
+	{
+	if( t <= MACHEP )
+		t = 1.0 - MACHEP;
+	else
+		t = 1.0 - t;
+	}
+return( t );
+}
+
+
+/* Continued fraction expansion #1
+ * for incomplete beta integral
+ */
+
+static double incbcf( a, b, x )
+double a, b, x;
+{
+double xk, pk, pkm1, pkm2, qk, qkm1, qkm2;
+double k1, k2, k3, k4, k5, k6, k7, k8;
+double r, t, ans, thresh;
+int n;
+
+k1 = a;
+k2 = a + b;
+k3 = a;
+k4 = a + 1.0;
+k5 = 1.0;
+k6 = b - 1.0;
+k7 = k4;
+k8 = a + 2.0;
+
+pkm2 = 0.0;
+qkm2 = 1.0;
+pkm1 = 1.0;
+qkm1 = 1.0;
+ans = 1.0;
+r = 1.0;
+n = 0;
+thresh = 3.0 * MACHEP;
+do
+	{
+	
+	xk = -( x * k1 * k2 )/( k3 * k4 );
+	pk = pkm1 +  pkm2 * xk;
+	qk = qkm1 +  qkm2 * xk;
+	pkm2 = pkm1;
+	pkm1 = pk;
+	qkm2 = qkm1;
+	qkm1 = qk;
+
+	xk = ( x * k5 * k6 )/( k7 * k8 );
+	pk = pkm1 +  pkm2 * xk;
+	qk = qkm1 +  qkm2 * xk;
+	pkm2 = pkm1;
+	pkm1 = pk;
+	qkm2 = qkm1;
+	qkm1 = qk;
+
+	if( qk != 0 )
+		r = pk/qk;
+	if( r != 0 )
+		{
+		t = fabs( (ans - r)/r );
+		ans = r;
+		}
+	else
+		t = 1.0;
+
+	if( t < thresh )
+		goto cdone;
+
+	k1 += 1.0;
+	k2 += 1.0;
+	k3 += 2.0;
+	k4 += 2.0;
+	k5 += 1.0;
+	k6 -= 1.0;
+	k7 += 2.0;
+	k8 += 2.0;
+
+	if( (fabs(qk) + fabs(pk)) > big )
+		{
+		pkm2 *= biginv;
+		pkm1 *= biginv;
+		qkm2 *= biginv;
+		qkm1 *= biginv;
+		}
+	if( (fabs(qk) < biginv) || (fabs(pk) < biginv) )
+		{
+		pkm2 *= big;
+		pkm1 *= big;
+		qkm2 *= big;
+		qkm1 *= big;
+		}
+	}
+while( ++n < 300 );
+
+cdone:
+return(ans);
+}
+
+
+
+/* Continued fraction expansion #2
+ * for incomplete beta integral
+ */
+
+static double incbd( a, b, x )
+double a, b, x;
+{
+double xk, pk, pkm1, pkm2, qk, qkm1, qkm2;
+double k1, k2, k3, k4, k5, k6, k7, k8;
+double r, t, ans, z, thresh;
+int n;
+
+k1 = a;
+k2 = b - 1.0;
+k3 = a;
+k4 = a + 1.0;
+k5 = 1.0;
+k6 = a + b;
+k7 = a + 1.0;;
+k8 = a + 2.0;
+
+pkm2 = 0.0;
+qkm2 = 1.0;
+pkm1 = 1.0;
+qkm1 = 1.0;
+z = x / (1.0-x);
+ans = 1.0;
+r = 1.0;
+n = 0;
+thresh = 3.0 * MACHEP;
+do
+	{
+	
+	xk = -( z * k1 * k2 )/( k3 * k4 );
+	pk = pkm1 +  pkm2 * xk;
+	qk = qkm1 +  qkm2 * xk;
+	pkm2 = pkm1;
+	pkm1 = pk;
+	qkm2 = qkm1;
+	qkm1 = qk;
+
+	xk = ( z * k5 * k6 )/( k7 * k8 );
+	pk = pkm1 +  pkm2 * xk;
+	qk = qkm1 +  qkm2 * xk;
+	pkm2 = pkm1;
+	pkm1 = pk;
+	qkm2 = qkm1;
+	qkm1 = qk;
+
+	if( qk != 0 )
+		r = pk/qk;
+	if( r != 0 )
+		{
+		t = fabs( (ans - r)/r );
+		ans = r;
+		}
+	else
+		t = 1.0;
+
+	if( t < thresh )
+		goto cdone;
+
+	k1 += 1.0;
+	k2 -= 1.0;
+	k3 += 2.0;
+	k4 += 2.0;
+	k5 += 1.0;
+	k6 += 1.0;
+	k7 += 2.0;
+	k8 += 2.0;
+
+	if( (fabs(qk) + fabs(pk)) > big )
+		{
+		pkm2 *= biginv;
+		pkm1 *= biginv;
+		qkm2 *= biginv;
+		qkm1 *= biginv;
+		}
+	if( (fabs(qk) < biginv) || (fabs(pk) < biginv) )
+		{
+		pkm2 *= big;
+		pkm1 *= big;
+		qkm2 *= big;
+		qkm1 *= big;
+		}
+	}
+while( ++n < 300 );
+cdone:
+return(ans);
+}
+
+
+/* Power series for incomplete beta integral.
+   Use when b*x is small and x not too close to 1.  */
+
+static double pseries( a, b, x )
+double a, b, x;
+{
+double s, t, u, v, n, t1, z, ai;
+
+ai = 1.0 / a;
+u = (1.0 - b) * x;
+v = u / (a + 1.0);
+t1 = v;
+t = u;
+n = 2.0;
+s = 0.0;
+z = MACHEP * ai;
+while( fabs(v) > z )
+	{
+	u = (n - b) * x / n;
+	t *= u;
+	v = t / (a + n);
+	s += v; 
+	n += 1.0;
+	}
+s += t1;
+s += ai;
+
+u = a * log(x);
+if( (a+b) < MAXGAM && fabs(u) < MAXLOG )
+	{
+	t = gamma(a+b)/(gamma(a)*gamma(b));
+	s = s * t * pow(x,a);
+	}
+else
+	{
+	t = lgam(a+b) - lgam(a) - lgam(b) + u + log(s);
+	if( t < MINLOG )
+		s = 0.0;
+	else
+	s = exp(t);
+	}
+return(s);
+}
Index: sansmodels/src/cephes/incbi.c
===================================================================
--- sansmodels/src/cephes/incbi.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/incbi.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,314 @@
+/*							incbi()
+ *
+ *      Inverse of imcomplete beta integral
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double a, b, x, y, incbi();
+ *
+ * x = incbi( a, b, y );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Given y, the function finds x such that
+ *
+ *  incbet( a, b, x ) = y .
+ *
+ * The routine performs interval halving or Newton iterations to find the
+ * root of incbet(a,b,x) - y = 0.
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ *                x     a,b
+ * arithmetic   domain  domain  # trials    peak       rms
+ *    IEEE      0,1    .5,10000   50000    5.8e-12   1.3e-13
+ *    IEEE      0,1   .25,100    100000    1.8e-13   3.9e-15
+ *    IEEE      0,1     0,5       50000    1.1e-12   5.5e-15
+ *    VAX       0,1    .5,100     25000    3.5e-14   1.1e-15
+ * With a and b constrained to half-integer or integer values:
+ *    IEEE      0,1    .5,10000   50000    5.8e-12   1.1e-13
+ *    IEEE      0,1    .5,100    100000    1.7e-14   7.9e-16
+ * With a = .5, b constrained to half-integer or integer values:
+ *    IEEE      0,1    .5,10000   10000    8.3e-11   1.0e-11
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1996, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+extern double MACHEP, MAXNUM, MAXLOG, MINLOG;
+#ifdef ANSIPROT
+extern double ndtri ( double );
+extern double exp ( double );
+extern double fabs ( double );
+extern double log ( double );
+extern double sqrt ( double );
+extern double lgam ( double );
+extern double incbet ( double, double, double );
+#else
+double ndtri(), exp(), fabs(), log(), sqrt(), lgam(), incbet();
+#endif
+
+double incbi( aa, bb, yy0 )
+double aa, bb, yy0;
+{
+double a, b, y0, d, y, x, x0, x1, lgm, yp, di, dithresh, yl, yh, xt;
+int i, rflg, dir, nflg;
+
+
+i = 0;
+if( yy0 <= 0 )
+	return(0.0);
+if( yy0 >= 1.0 )
+	return(1.0);
+x0 = 0.0;
+yl = 0.0;
+x1 = 1.0;
+yh = 1.0;
+nflg = 0;
+
+if( aa <= 1.0 || bb <= 1.0 )
+	{
+	dithresh = 1.0e-6;
+	rflg = 0;
+	a = aa;
+	b = bb;
+	y0 = yy0;
+	x = a/(a+b);
+	y = incbet( a, b, x );
+	goto ihalve;
+	}
+else
+	{
+	dithresh = 1.0e-4;
+	}
+/* approximation to inverse function */
+
+yp = -ndtri(yy0);
+
+if( yy0 > 0.5 )
+	{
+	rflg = 1;
+	a = bb;
+	b = aa;
+	y0 = 1.0 - yy0;
+	yp = -yp;
+	}
+else
+	{
+	rflg = 0;
+	a = aa;
+	b = bb;
+	y0 = yy0;
+	}
+
+lgm = (yp * yp - 3.0)/6.0;
+x = 2.0/( 1.0/(2.0*a-1.0)  +  1.0/(2.0*b-1.0) );
+d = yp * sqrt( x + lgm ) / x
+	- ( 1.0/(2.0*b-1.0) - 1.0/(2.0*a-1.0) )
+	* (lgm + 5.0/6.0 - 2.0/(3.0*x));
+d = 2.0 * d;
+if( d < MINLOG )
+	{
+	x = 1.0;
+	goto under;
+	}
+x = a/( a + b * exp(d) );
+y = incbet( a, b, x );
+yp = (y - y0)/y0;
+if( fabs(yp) < 0.2 )
+	goto newt;
+
+/* Resort to interval halving if not close enough. */
+ihalve:
+
+dir = 0;
+di = 0.5;
+for( i=0; i<100; i++ )
+	{
+	if( i != 0 )
+		{
+		x = x0  +  di * (x1 - x0);
+		if( x == 1.0 )
+			x = 1.0 - MACHEP;
+		if( x == 0.0 )
+			{
+			di = 0.5;
+			x = x0  +  di * (x1 - x0);
+			if( x == 0.0 )
+				goto under;
+			}
+		y = incbet( a, b, x );
+		yp = (x1 - x0)/(x1 + x0);
+		if( fabs(yp) < dithresh )
+			goto newt;
+		yp = (y-y0)/y0;
+		if( fabs(yp) < dithresh )
+			goto newt;
+		}
+	if( y < y0 )
+		{
+		x0 = x;
+		yl = y;
+		if( dir < 0 )
+			{
+			dir = 0;
+			di = 0.5;
+			}
+		else if( dir > 3 )
+			di = 1.0 - (1.0 - di) * (1.0 - di);
+		else if( dir > 1 )
+			di = 0.5 * di + 0.5; 
+		else
+			di = (y0 - y)/(yh - yl);
+		dir += 1;
+		if( x0 > 0.75 )
+			{
+			if( rflg == 1 )
+				{
+				rflg = 0;
+				a = aa;
+				b = bb;
+				y0 = yy0;
+				}
+			else
+				{
+				rflg = 1;
+				a = bb;
+				b = aa;
+				y0 = 1.0 - yy0;
+				}
+			x = 1.0 - x;
+			y = incbet( a, b, x );
+			x0 = 0.0;
+			yl = 0.0;
+			x1 = 1.0;
+			yh = 1.0;
+			goto ihalve;
+			}
+		}
+	else
+		{
+		x1 = x;
+		if( rflg == 1 && x1 < MACHEP )
+			{
+			x = 0.0;
+			goto done;
+			}
+		yh = y;
+		if( dir > 0 )
+			{
+			dir = 0;
+			di = 0.5;
+			}
+		else if( dir < -3 )
+			di = di * di;
+		else if( dir < -1 )
+			di = 0.5 * di;
+		else
+			di = (y - y0)/(yh - yl);
+		dir -= 1;
+		}
+	}
+mtherr( "incbi", PLOSS );
+if( x0 >= 1.0 )
+	{
+	x = 1.0 - MACHEP;
+	goto done;
+	}
+if( x <= 0.0 )
+	{
+under:
+	mtherr( "incbi", UNDERFLOW );
+	x = 0.0;
+	goto done;
+	}
+
+newt:
+
+if( nflg )
+	goto done;
+nflg = 1;
+lgm = lgam(a+b) - lgam(a) - lgam(b);
+
+for( i=0; i<8; i++ )
+	{
+	/* Compute the function at this point. */
+	if( i != 0 )
+		y = incbet(a,b,x);
+	if( y < yl )
+		{
+		x = x0;
+		y = yl;
+		}
+	else if( y > yh )
+		{
+		x = x1;
+		y = yh;
+		}
+	else if( y < y0 )
+		{
+		x0 = x;
+		yl = y;
+		}
+	else
+		{
+		x1 = x;
+		yh = y;
+		}
+	if( x == 1.0 || x == 0.0 )
+		break;
+	/* Compute the derivative of the function at this point. */
+	d = (a - 1.0) * log(x) + (b - 1.0) * log(1.0-x) + lgm;
+	if( d < MINLOG )
+		goto done;
+	if( d > MAXLOG )
+		break;
+	d = exp(d);
+	/* Compute the step to the next approximation of x. */
+	d = (y - y0)/d;
+	xt = x - d;
+	if( xt <= x0 )
+		{
+		y = (x - x0) / (x1 - x0);
+		xt = x0 + 0.5 * y * (x - x0);
+		if( xt <= 0.0 )
+			break;
+		}
+	if( xt >= x1 )
+		{
+		y = (x1 - x) / (x1 - x0);
+		xt = x1 - 0.5 * y * (x1 - x);
+		if( xt >= 1.0 )
+			break;
+		}
+	x = xt;
+	if( fabs(d/x) < 128.0 * MACHEP )
+		goto done;
+	}
+/* Did not converge.  */
+dithresh = 256.0 * MACHEP;
+goto ihalve;
+
+done:
+
+if( rflg )
+	{
+	if( x <= MACHEP )
+		x = 1.0 - MACHEP;
+	else
+		x = 1.0 - x;
+	}
+return( x );
+}
Index: sansmodels/src/cephes/iv.c
===================================================================
--- sansmodels/src/cephes/iv.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/iv.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,117 @@
+/*							iv.c
+ *
+ *	Modified Bessel function of noninteger order
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double v, x, y, iv();
+ *
+ * y = iv( v, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns modified Bessel function of order v of the
+ * argument.  If x is negative, v must be integer valued.
+ *
+ * The function is defined as Iv(x) = Jv( ix ).  It is
+ * here computed in terms of the confluent hypergeometric
+ * function, according to the formula
+ *
+ *              v  -x
+ * Iv(x) = (x/2)  e   hyperg( v+0.5, 2v+1, 2x ) / gamma(v+1)
+ *
+ * If v is a negative integer, then v is replaced by -v.
+ *
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (v, x), with v between 0 and
+ * 30, x between 0 and 28.
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0,30          2000      3.1e-15     5.4e-16
+ *    IEEE      0,30         10000      1.7e-14     2.7e-15
+ *
+ * Accuracy is diminished if v is near a negative integer.
+ *
+ * See also hyperg.c.
+ *
+ */
+
+/*							iv.c	*/
+/*	Modified Bessel function of noninteger order		*/
+/* If x < 0, then v must be an integer. */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1988, 2000 by Stephen L. Moshier
+*/
+
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double hyperg ( double, double, double );
+extern double exp ( double );
+extern double gamma ( double );
+extern double log ( double );
+extern double fabs ( double );
+extern double floor ( double );
+#else
+double hyperg(), exp(), gamma(), log(), fabs(), floor();
+#endif
+extern double MACHEP, MAXNUM;
+
+double iv( v, x )
+double v, x;
+{
+int sign;
+double t, ax;
+
+/* If v is a negative integer, invoke symmetry */
+t = floor(v);
+if( v < 0.0 )
+	{
+	if( t == v )
+		{
+		v = -v;	/* symmetry */
+		t = -t;
+		}
+	}
+/* If x is negative, require v to be an integer */
+sign = 1;
+if( x < 0.0 )
+	{
+	if( t != v )
+		{
+		mtherr( "iv", DOMAIN );
+		return( 0.0 );
+		}
+	if( v != 2.0 * floor(v/2.0) )
+		sign = -1;
+	}
+
+/* Avoid logarithm singularity */
+if( x == 0.0 )
+	{
+	if( v == 0.0 )
+		return( 1.0 );
+	if( v < 0.0 )
+		{
+		mtherr( "iv", OVERFLOW );
+		return( MAXNUM );
+		}
+	else
+		return( 0.0 );
+	}
+
+ax = fabs(x);
+t = v * log( 0.5 * ax )  -  x;
+t = sign * exp(t) / gamma( v + 1.0 );
+ax = v + 0.5;
+return( t * hyperg( ax,  2.0 * ax,  2.0 * x ) );
+}
Index: sansmodels/src/cephes/j0.c
===================================================================
--- sansmodels/src/cephes/j0.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/j0.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,546 @@
+/*							j0.c
+ *
+ *	Bessel function of order zero
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, j0();
+ *
+ * y = j0( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of order zero of the argument.
+ *
+ * The domain is divided into the intervals [0, 5] and
+ * (5, infinity). In the first interval the following rational
+ * approximation is used:
+ *
+ *
+ *        2         2
+ * (w - r  ) (w - r  ) P (w) / Q (w)
+ *       1         2    3       8
+ *
+ *            2
+ * where w = x  and the two r's are zeros of the function.
+ *
+ * In the second interval, the Hankel asymptotic expansion
+ * is employed with two rational functions of degree 6/6
+ * and 7/7.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Absolute error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0, 30       10000       4.4e-17     6.3e-18
+ *    IEEE      0, 30       60000       4.2e-16     1.1e-16
+ *
+ */
+
+/*							y0.c
+ *
+ *	Bessel function of the second kind, order zero
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, y0();
+ *
+ * y = y0( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of the second kind, of order
+ * zero, of the argument.
+ *
+ * The domain is divided into the intervals [0, 5] and
+ * (5, infinity). In the first interval a rational approximation
+ * R(x) is employed to compute
+ *   y0(x)  = R(x)  +   2 * log(x) * j0(x) / PI.
+ * Thus a call to j0() is required.
+ *
+ * In the second interval, the Hankel asymptotic expansion
+ * is employed with two rational functions of degree 6/6
+ * and 7/7.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *  Absolute error, when y0(x) < 1; else relative error:
+ *
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0, 30        9400       7.0e-17     7.9e-18
+ *    IEEE      0, 30       30000       1.3e-15     1.6e-16
+ *
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
+*/
+
+/* Note: all coefficients satisfy the relative error criterion
+ * except YP, YQ which are designed for absolute error. */
+
+#include "mconf.h"
+
+#ifdef UNK
+static double PP[7] = {
+  7.96936729297347051624E-4,
+  8.28352392107440799803E-2,
+  1.23953371646414299388E0,
+  5.44725003058768775090E0,
+  8.74716500199817011941E0,
+  5.30324038235394892183E0,
+  9.99999999999999997821E-1,
+};
+static double PQ[7] = {
+  9.24408810558863637013E-4,
+  8.56288474354474431428E-2,
+  1.25352743901058953537E0,
+  5.47097740330417105182E0,
+  8.76190883237069594232E0,
+  5.30605288235394617618E0,
+  1.00000000000000000218E0,
+};
+#endif
+#ifdef DEC
+static unsigned short PP[28] = {
+0035520,0164604,0140733,0054470,
+0037251,0122605,0115356,0107170,
+0040236,0124412,0071500,0056303,
+0040656,0047737,0045720,0045263,
+0041013,0172143,0045004,0142103,
+0040651,0132045,0026241,0026406,
+0040200,0000000,0000000,0000000,
+};
+static unsigned short PQ[28] = {
+0035562,0052006,0070034,0134666,
+0037257,0057055,0055242,0123424,
+0040240,0071626,0046630,0032371,
+0040657,0011077,0032013,0012731,
+0041014,0030307,0050331,0006414,
+0040651,0145457,0065021,0150304,
+0040200,0000000,0000000,0000000,
+};
+#endif
+#ifdef IBMPC
+static unsigned short PP[28] = {
+0x6b27,0x983b,0x1d30,0x3f4a,
+0xd1cf,0xb35d,0x34b0,0x3fb5,
+0x0b98,0x4e68,0xd521,0x3ff3,
+0x0956,0xe97a,0xc9fb,0x4015,
+0x9888,0x6940,0x7e8c,0x4021,
+0x25a1,0xa594,0x3684,0x4015,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+static unsigned short PQ[28] = {
+0x9737,0xce03,0x4a80,0x3f4e,
+0x54e3,0xab54,0xebc5,0x3fb5,
+0x069f,0xc9b3,0x0e72,0x3ff4,
+0x62bb,0xe681,0xe247,0x4015,
+0x21a1,0xea1b,0x8618,0x4021,
+0x3a19,0xed42,0x3965,0x4015,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+#endif
+#ifdef MIEEE
+static unsigned short PP[28] = {
+0x3f4a,0x1d30,0x983b,0x6b27,
+0x3fb5,0x34b0,0xb35d,0xd1cf,
+0x3ff3,0xd521,0x4e68,0x0b98,
+0x4015,0xc9fb,0xe97a,0x0956,
+0x4021,0x7e8c,0x6940,0x9888,
+0x4015,0x3684,0xa594,0x25a1,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+static unsigned short PQ[28] = {
+0x3f4e,0x4a80,0xce03,0x9737,
+0x3fb5,0xebc5,0xab54,0x54e3,
+0x3ff4,0x0e72,0xc9b3,0x069f,
+0x4015,0xe247,0xe681,0x62bb,
+0x4021,0x8618,0xea1b,0x21a1,
+0x4015,0x3965,0xed42,0x3a19,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+#endif
+
+#ifdef UNK
+static double QP[8] = {
+-1.13663838898469149931E-2,
+-1.28252718670509318512E0,
+-1.95539544257735972385E1,
+-9.32060152123768231369E1,
+-1.77681167980488050595E2,
+-1.47077505154951170175E2,
+-5.14105326766599330220E1,
+-6.05014350600728481186E0,
+};
+static double QQ[7] = {
+/*  1.00000000000000000000E0,*/
+  6.43178256118178023184E1,
+  8.56430025976980587198E2,
+  3.88240183605401609683E3,
+  7.24046774195652478189E3,
+  5.93072701187316984827E3,
+  2.06209331660327847417E3,
+  2.42005740240291393179E2,
+};
+#endif
+#ifdef DEC
+static unsigned short QP[32] = {
+0136472,0035021,0142451,0141115,
+0140244,0024731,0150620,0105642,
+0141234,0067177,0124161,0060141,
+0141672,0064572,0151557,0043036,
+0142061,0127141,0003127,0043517,
+0142023,0011727,0060271,0144544,
+0141515,0122142,0126620,0143150,
+0140701,0115306,0106715,0007344,
+};
+static unsigned short QQ[28] = {
+/*0040200,0000000,0000000,0000000,*/
+0041600,0121272,0004741,0026544,
+0042526,0015605,0105654,0161771,
+0043162,0123155,0165644,0062645,
+0043342,0041675,0167576,0130756,
+0043271,0052720,0165631,0154214,
+0043000,0160576,0034614,0172024,
+0042162,0000570,0030500,0051235,
+};
+#endif
+#ifdef IBMPC
+static unsigned short QP[32] = {
+0x384a,0x38a5,0x4742,0xbf87,
+0x1174,0x3a32,0x853b,0xbff4,
+0x2c0c,0xf50e,0x8dcf,0xc033,
+0xe8c4,0x5a6d,0x4d2f,0xc057,
+0xe8ea,0x20ca,0x35cc,0xc066,
+0x392d,0xec17,0x627a,0xc062,
+0x18cd,0x55b2,0xb48c,0xc049,
+0xa1dd,0xd1b9,0x3358,0xc018,
+};
+static unsigned short QQ[28] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x25ac,0x413c,0x1457,0x4050,
+0x9c7f,0xb175,0xc370,0x408a,
+0x8cb5,0xbd74,0x54cd,0x40ae,
+0xd63e,0xbdef,0x4877,0x40bc,
+0x3b11,0x1d73,0x2aba,0x40b7,
+0x9e82,0xc731,0x1c2f,0x40a0,
+0x0a54,0x0628,0x402f,0x406e,
+};
+#endif
+#ifdef MIEEE
+static unsigned short QP[32] = {
+0xbf87,0x4742,0x38a5,0x384a,
+0xbff4,0x853b,0x3a32,0x1174,
+0xc033,0x8dcf,0xf50e,0x2c0c,
+0xc057,0x4d2f,0x5a6d,0xe8c4,
+0xc066,0x35cc,0x20ca,0xe8ea,
+0xc062,0x627a,0xec17,0x392d,
+0xc049,0xb48c,0x55b2,0x18cd,
+0xc018,0x3358,0xd1b9,0xa1dd,
+};
+static unsigned short QQ[28] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4050,0x1457,0x413c,0x25ac,
+0x408a,0xc370,0xb175,0x9c7f,
+0x40ae,0x54cd,0xbd74,0x8cb5,
+0x40bc,0x4877,0xbdef,0xd63e,
+0x40b7,0x2aba,0x1d73,0x3b11,
+0x40a0,0x1c2f,0xc731,0x9e82,
+0x406e,0x402f,0x0628,0x0a54,
+};
+#endif
+
+
+#ifdef UNK
+static double YP[8] = {
+ 1.55924367855235737965E4,
+-1.46639295903971606143E7,
+ 5.43526477051876500413E9,
+-9.82136065717911466409E11,
+ 8.75906394395366999549E13,
+-3.46628303384729719441E15,
+ 4.42733268572569800351E16,
+-1.84950800436986690637E16,
+};
+static double YQ[7] = {
+/* 1.00000000000000000000E0,*/
+ 1.04128353664259848412E3,
+ 6.26107330137134956842E5,
+ 2.68919633393814121987E8,
+ 8.64002487103935000337E10,
+ 2.02979612750105546709E13,
+ 3.17157752842975028269E15,
+ 2.50596256172653059228E17,
+};
+#endif
+#ifdef DEC
+static unsigned short YP[32] = {
+0043563,0120677,0042264,0046166,
+0146137,0140371,0113444,0042260,
+0050241,0175707,0100502,0063344,
+0152144,0125737,0007265,0164526,
+0053637,0051621,0163035,0060546,
+0155105,0004416,0107306,0060023,
+0056035,0045133,0030132,0000024,
+0155603,0065132,0144061,0131732,
+};
+static unsigned short YQ[28] = {
+/*0040200,0000000,0000000,0000000,*/
+0042602,0024422,0135557,0162663,
+0045030,0155665,0044075,0160135,
+0047200,0035432,0105446,0104005,
+0051240,0167331,0056063,0022743,
+0053223,0127746,0025764,0012160,
+0055064,0044206,0177532,0145545,
+0056536,0111375,0163715,0127201,
+};
+#endif
+#ifdef IBMPC
+static unsigned short YP[32] = {
+0x898f,0xe896,0x7437,0x40ce,
+0x8896,0x32e4,0xf81f,0xc16b,
+0x4cdd,0xf028,0x3f78,0x41f4,
+0xbd2b,0xe1d6,0x957b,0xc26c,
+0xac2d,0x3cc3,0xea72,0x42d3,
+0xcc02,0xd1d8,0xa121,0xc328,
+0x4003,0x660b,0xa94b,0x4363,
+0x367b,0x5906,0x6d4b,0xc350,
+};
+static unsigned short YQ[28] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xfcb6,0x576d,0x4522,0x4090,
+0xbc0c,0xa907,0x1b76,0x4123,
+0xd101,0x5164,0x0763,0x41b0,
+0x64bc,0x2b86,0x1ddb,0x4234,
+0x828e,0xc57e,0x75fc,0x42b2,
+0x596d,0xdfeb,0x8910,0x4326,
+0xb5d0,0xbcf9,0xd25f,0x438b,
+};
+#endif
+#ifdef MIEEE
+static unsigned short YP[32] = {
+0x40ce,0x7437,0xe896,0x898f,
+0xc16b,0xf81f,0x32e4,0x8896,
+0x41f4,0x3f78,0xf028,0x4cdd,
+0xc26c,0x957b,0xe1d6,0xbd2b,
+0x42d3,0xea72,0x3cc3,0xac2d,
+0xc328,0xa121,0xd1d8,0xcc02,
+0x4363,0xa94b,0x660b,0x4003,
+0xc350,0x6d4b,0x5906,0x367b,
+};
+static unsigned short YQ[28] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4090,0x4522,0x576d,0xfcb6,
+0x4123,0x1b76,0xa907,0xbc0c,
+0x41b0,0x0763,0x5164,0xd101,
+0x4234,0x1ddb,0x2b86,0x64bc,
+0x42b2,0x75fc,0xc57e,0x828e,
+0x4326,0x8910,0xdfeb,0x596d,
+0x438b,0xd25f,0xbcf9,0xb5d0,
+};
+#endif
+
+#ifdef UNK
+/*  5.783185962946784521175995758455807035071 */
+static double DR1 = 5.78318596294678452118E0;
+/* 30.47126234366208639907816317502275584842 */
+static double DR2 = 3.04712623436620863991E1;
+#endif
+
+#ifdef DEC
+static unsigned short R1[] = {0040671,0007734,0001061,0056734};
+#define DR1 *(double *)R1
+static unsigned short R2[] = {0041363,0142445,0030416,0165567};
+#define DR2 *(double *)R2
+#endif
+
+#ifdef IBMPC
+static unsigned short R1[] = {0x2bbb,0x8046,0x21fb,0x4017};
+#define DR1 *(double *)R1
+static unsigned short R2[] = {0xdd6f,0xa621,0x78a4,0x403e};
+#define DR2 *(double *)R2
+#endif
+
+#ifdef MIEEE
+static unsigned short R1[] = {0x4017,0x21fb,0x8046,0x2bbb};
+#define DR1 *(double *)R1
+static unsigned short R2[] = {0x403e,0x78a4,0xa621,0xdd6f};
+#define DR2 *(double *)R2
+#endif
+
+#ifdef UNK
+static double RP[4] = {
+-4.79443220978201773821E9,
+ 1.95617491946556577543E12,
+-2.49248344360967716204E14,
+ 9.70862251047306323952E15,
+};
+static double RQ[8] = {
+/* 1.00000000000000000000E0,*/
+ 4.99563147152651017219E2,
+ 1.73785401676374683123E5,
+ 4.84409658339962045305E7,
+ 1.11855537045356834862E10,
+ 2.11277520115489217587E12,
+ 3.10518229857422583814E14,
+ 3.18121955943204943306E16,
+ 1.71086294081043136091E18,
+};
+#endif
+#ifdef DEC
+static unsigned short RP[16] = {
+0150216,0161235,0064344,0014450,
+0052343,0135216,0035624,0144153,
+0154142,0130247,0003310,0003667,
+0055411,0173703,0047772,0176635,
+};
+static unsigned short RQ[32] = {
+/*0040200,0000000,0000000,0000000,*/
+0042371,0144025,0032265,0136137,
+0044451,0133131,0132420,0151466,
+0046470,0144641,0072540,0030636,
+0050446,0126600,0045042,0044243,
+0052365,0172633,0110301,0071063,
+0054215,0032424,0062272,0043513,
+0055742,0005013,0171731,0072335,
+0057275,0170646,0036663,0013134,
+};
+#endif
+#ifdef IBMPC
+static unsigned short RP[16] = {
+0x8325,0xad1c,0xdc53,0xc1f1,
+0x990d,0xc772,0x7751,0x427c,
+0x00f7,0xe0d9,0x5614,0xc2ec,
+0x5fb4,0x69ff,0x3ef8,0x4341,
+};
+static unsigned short RQ[32] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xb78c,0xa696,0x3902,0x407f,
+0x1a67,0x36a2,0x36cb,0x4105,
+0x0634,0x2eac,0x1934,0x4187,
+0x4914,0x0944,0xd5b0,0x4204,
+0x2e46,0x7218,0xbeb3,0x427e,
+0x48e9,0x8c97,0xa6a2,0x42f1,
+0x2e9c,0x7e7b,0x4141,0x435c,
+0x62cc,0xc7b6,0xbe34,0x43b7,
+};
+#endif
+#ifdef MIEEE
+static unsigned short RP[16] = {
+0xc1f1,0xdc53,0xad1c,0x8325,
+0x427c,0x7751,0xc772,0x990d,
+0xc2ec,0x5614,0xe0d9,0x00f7,
+0x4341,0x3ef8,0x69ff,0x5fb4,
+};
+static unsigned short RQ[32] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x407f,0x3902,0xa696,0xb78c,
+0x4105,0x36cb,0x36a2,0x1a67,
+0x4187,0x1934,0x2eac,0x0634,
+0x4204,0xd5b0,0x0944,0x4914,
+0x427e,0xbeb3,0x7218,0x2e46,
+0x42f1,0xa6a2,0x8c97,0x48e9,
+0x435c,0x4141,0x7e7b,0x2e9c,
+0x43b7,0xbe34,0xc7b6,0x62cc,
+};
+#endif
+
+#ifdef ANSIPROT
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double log ( double );
+extern double sin ( double );
+extern double cos ( double );
+extern double sqrt ( double );
+double j0 ( double );
+#else
+double polevl(), p1evl(), log(), sin(), cos(), sqrt();
+double j0();
+#endif
+extern double TWOOPI, SQ2OPI, PIO4;
+
+double j0(x)
+double x;
+{
+double w, z, p, q, xn;
+
+if( x < 0 )
+	x = -x;
+
+if( x <= 5.0 )
+	{
+	z = x * x;
+	if( x < 1.0e-5 )
+		return( 1.0 - z/4.0 );
+
+	p = (z - DR1) * (z - DR2);
+	p = p * polevl( z, RP, 3)/p1evl( z, RQ, 8 );
+	return( p );
+	}
+
+w = 5.0/x;
+q = 25.0/(x*x);
+p = polevl( q, PP, 6)/polevl( q, PQ, 6 );
+q = polevl( q, QP, 7)/p1evl( q, QQ, 7 );
+xn = x - PIO4;
+p = p * cos(xn) - w * q * sin(xn);
+return( p * SQ2OPI / sqrt(x) );
+}
+
+
+/*							y0() 2	*/
+/* Bessel function of second kind, order zero	*/
+
+/* Rational approximation coefficients YP[], YQ[] are used here.
+ * The function computed is  y0(x)  -  2 * log(x) * j0(x) / PI,
+ * whose value at x = 0 is  2 * ( log(0.5) + EUL ) / PI
+ * = 0.073804295108687225.
+ */
+
+/*
+#define PIO4 .78539816339744830962
+#define SQ2OPI .79788456080286535588
+*/
+extern double MAXNUM;
+
+double y0(x)
+double x;
+{
+double w, z, p, q, xn;
+
+if( x <= 5.0 )
+	{
+	if( x <= 0.0 )
+		{
+		mtherr( "y0", DOMAIN );
+		return( -MAXNUM );
+		}
+	z = x * x;
+	w = polevl( z, YP, 7) / p1evl( z, YQ, 7 );
+	w += TWOOPI * log(x) * j0(x);
+	return( w );
+	}
+
+w = 5.0/x;
+z = 25.0 / (x * x);
+p = polevl( z, PP, 6)/polevl( z, PQ, 6 );
+q = polevl( z, QP, 7)/p1evl( z, QQ, 7 );
+xn = x - PIO4;
+p = p * sin(xn) + w * q * cos(xn);
+return( p * SQ2OPI / sqrt(x) );
+}
Index: sansmodels/src/cephes/j1.c
===================================================================
--- sansmodels/src/cephes/j1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/j1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,517 @@
+/*							j1.c
+ *
+ *	Bessel function of order one
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, j1();
+ *
+ * y = j1( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of order one of the argument.
+ *
+ * The domain is divided into the intervals [0, 8] and
+ * (8, infinity). In the first interval a 24 term Chebyshev
+ * expansion is used. In the second, the asymptotic
+ * trigonometric representation is employed using two
+ * rational functions of degree 5/5.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Absolute error:
+ * arithmetic   domain      # trials      peak         rms
+ *    DEC       0, 30       10000       4.0e-17     1.1e-17
+ *    IEEE      0, 30       30000       2.6e-16     1.1e-16
+ *
+ *
+ */
+
+/*							y1.c
+ *
+ *	Bessel function of second kind of order one
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, y1();
+ *
+ * y = y1( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of the second kind of order one
+ * of the argument.
+ *
+ * The domain is divided into the intervals [0, 8] and
+ * (8, infinity). In the first interval a 25 term Chebyshev
+ * expansion is used, and a call to j1() is required.
+ * In the second, the asymptotic trigonometric representation
+ * is employed using two rational functions of degree 5/5.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Absolute error:
+ * arithmetic   domain      # trials      peak         rms
+ *    DEC       0, 30       10000       8.6e-17     1.3e-17
+ *    IEEE      0, 30       30000       1.0e-15     1.3e-16
+ *
+ * (error criterion relative when |y1| > 1).
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
+*/
+
+/*
+#define PIO4 .78539816339744830962
+#define THPIO4 2.35619449019234492885
+#define SQ2OPI .79788456080286535588
+*/
+
+#include "mconf.h"
+
+#ifdef UNK
+static double RP[4] = {
+-8.99971225705559398224E8,
+ 4.52228297998194034323E11,
+-7.27494245221818276015E13,
+ 3.68295732863852883286E15,
+};
+static double RQ[8] = {
+/* 1.00000000000000000000E0,*/
+ 6.20836478118054335476E2,
+ 2.56987256757748830383E5,
+ 8.35146791431949253037E7,
+ 2.21511595479792499675E10,
+ 4.74914122079991414898E12,
+ 7.84369607876235854894E14,
+ 8.95222336184627338078E16,
+ 5.32278620332680085395E18,
+};
+#endif
+#ifdef DEC
+static unsigned short RP[16] = {
+0147526,0110742,0063322,0077052,
+0051722,0112720,0065034,0061530,
+0153604,0052227,0033147,0105650,
+0055121,0055025,0032276,0022015,
+};
+static unsigned short RQ[32] = {
+/*0040200,0000000,0000000,0000000,*/
+0042433,0032610,0155604,0033473,
+0044572,0173320,0067270,0006616,
+0046637,0045246,0162225,0006606,
+0050645,0004773,0157577,0053004,
+0052612,0033734,0001667,0176501,
+0054462,0054121,0173147,0121367,
+0056237,0002777,0121451,0176007,
+0057623,0136253,0131601,0044710,
+};
+#endif
+#ifdef IBMPC
+static unsigned short RP[16] = {
+0x4fc5,0x4cda,0xd23c,0xc1ca,
+0x8c6b,0x0d43,0x52ba,0x425a,
+0xf175,0xe6cc,0x8a92,0xc2d0,
+0xc482,0xa697,0x2b42,0x432a,
+};
+static unsigned short RQ[32] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x86e7,0x1b70,0x66b1,0x4083,
+0x01b2,0x0dd7,0x5eda,0x410f,
+0xa1b1,0xdc92,0xe954,0x4193,
+0xeac1,0x7bef,0xa13f,0x4214,
+0xffa8,0x8076,0x46fb,0x4291,
+0xf45f,0x3ecc,0x4b0a,0x4306,
+0x3f81,0xf465,0xe0bf,0x4373,
+0x2939,0x7670,0x7795,0x43d2,
+};
+#endif
+#ifdef MIEEE
+static unsigned short RP[16] = {
+0xc1ca,0xd23c,0x4cda,0x4fc5,
+0x425a,0x52ba,0x0d43,0x8c6b,
+0xc2d0,0x8a92,0xe6cc,0xf175,
+0x432a,0x2b42,0xa697,0xc482,
+};
+static unsigned short RQ[32] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4083,0x66b1,0x1b70,0x86e7,
+0x410f,0x5eda,0x0dd7,0x01b2,
+0x4193,0xe954,0xdc92,0xa1b1,
+0x4214,0xa13f,0x7bef,0xeac1,
+0x4291,0x46fb,0x8076,0xffa8,
+0x4306,0x4b0a,0x3ecc,0xf45f,
+0x4373,0xe0bf,0xf465,0x3f81,
+0x43d2,0x7795,0x7670,0x2939,
+};
+#endif
+
+#ifdef UNK
+static double PP[7] = {
+ 7.62125616208173112003E-4,
+ 7.31397056940917570436E-2,
+ 1.12719608129684925192E0,
+ 5.11207951146807644818E0,
+ 8.42404590141772420927E0,
+ 5.21451598682361504063E0,
+ 1.00000000000000000254E0,
+};
+static double PQ[7] = {
+ 5.71323128072548699714E-4,
+ 6.88455908754495404082E-2,
+ 1.10514232634061696926E0,
+ 5.07386386128601488557E0,
+ 8.39985554327604159757E0,
+ 5.20982848682361821619E0,
+ 9.99999999999999997461E-1,
+};
+#endif
+#ifdef DEC
+static unsigned short PP[28] = {
+0035507,0144542,0061543,0024326,
+0037225,0145105,0017766,0022661,
+0040220,0043766,0010254,0133255,
+0040643,0113047,0142611,0151521,
+0041006,0144344,0055351,0074261,
+0040646,0156520,0120574,0006416,
+0040200,0000000,0000000,0000000,
+};
+static unsigned short PQ[28] = {
+0035425,0142330,0115041,0165514,
+0037214,0177352,0145105,0052026,
+0040215,0072515,0141207,0073255,
+0040642,0056427,0137222,0106405,
+0041006,0062716,0166427,0165450,
+0040646,0133352,0035425,0123304,
+0040200,0000000,0000000,0000000,
+};
+#endif
+#ifdef IBMPC
+static unsigned short PP[28] = {
+0x651b,0x4c6c,0xf92c,0x3f48,
+0xc4b6,0xa3fe,0xb948,0x3fb2,
+0x96d6,0xc215,0x08fe,0x3ff2,
+0x3a6a,0xf8b1,0x72c4,0x4014,
+0x2f16,0x8b5d,0xd91c,0x4020,
+0x81a2,0x142f,0xdbaa,0x4014,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+static unsigned short PQ[28] = {
+0x3d69,0x1344,0xb89b,0x3f42,
+0xaa83,0x5948,0x9fdd,0x3fb1,
+0xeed6,0xb850,0xaea9,0x3ff1,
+0x51a1,0xf7d2,0x4ba2,0x4014,
+0xfd65,0xdda2,0xccb9,0x4020,
+0xb4d9,0x4762,0xd6dd,0x4014,
+0x0000,0x0000,0x0000,0x3ff0,
+};
+#endif
+#ifdef MIEEE
+static unsigned short PP[28] = {
+0x3f48,0xf92c,0x4c6c,0x651b,
+0x3fb2,0xb948,0xa3fe,0xc4b6,
+0x3ff2,0x08fe,0xc215,0x96d6,
+0x4014,0x72c4,0xf8b1,0x3a6a,
+0x4020,0xd91c,0x8b5d,0x2f16,
+0x4014,0xdbaa,0x142f,0x81a2,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+static unsigned short PQ[28] = {
+0x3f42,0xb89b,0x1344,0x3d69,
+0x3fb1,0x9fdd,0x5948,0xaa83,
+0x3ff1,0xaea9,0xb850,0xeed6,
+0x4014,0x4ba2,0xf7d2,0x51a1,
+0x4020,0xccb9,0xdda2,0xfd65,
+0x4014,0xd6dd,0x4762,0xb4d9,
+0x3ff0,0x0000,0x0000,0x0000,
+};
+#endif
+
+#ifdef UNK
+static double QP[8] = {
+ 5.10862594750176621635E-2,
+ 4.98213872951233449420E0,
+ 7.58238284132545283818E1,
+ 3.66779609360150777800E2,
+ 7.10856304998926107277E2,
+ 5.97489612400613639965E2,
+ 2.11688757100572135698E2,
+ 2.52070205858023719784E1,
+};
+static double QQ[7] = {
+/* 1.00000000000000000000E0,*/
+ 7.42373277035675149943E1,
+ 1.05644886038262816351E3,
+ 4.98641058337653607651E3,
+ 9.56231892404756170795E3,
+ 7.99704160447350683650E3,
+ 2.82619278517639096600E3,
+ 3.36093607810698293419E2,
+};
+#endif
+#ifdef DEC
+static unsigned short QP[32] = {
+0037121,0037723,0055605,0151004,
+0040637,0066656,0031554,0077264,
+0041627,0122714,0153170,0161466,
+0042267,0061712,0036520,0140145,
+0042461,0133315,0131573,0071176,
+0042425,0057525,0147500,0013201,
+0042123,0130122,0061245,0154131,
+0041311,0123772,0064254,0172650,
+};
+static unsigned short QQ[28] = {
+/*0040200,0000000,0000000,0000000,*/
+0041624,0074603,0002112,0101670,
+0042604,0007135,0010162,0175565,
+0043233,0151510,0157757,0172010,
+0043425,0064506,0112006,0104276,
+0043371,0164125,0032271,0164242,
+0043060,0121425,0122750,0136013,
+0042250,0005773,0053472,0146267,
+};
+#endif
+#ifdef IBMPC
+static unsigned short QP[32] = {
+0xba40,0x6b70,0x27fa,0x3faa,
+0x8fd6,0xc66d,0xedb5,0x4013,
+0x1c67,0x9acf,0xf4b9,0x4052,
+0x180d,0x47aa,0xec79,0x4076,
+0x6e50,0xb66f,0x36d9,0x4086,
+0x02d0,0xb9e8,0xabea,0x4082,
+0xbb0b,0x4c54,0x760a,0x406a,
+0x9eb5,0x4d15,0x34ff,0x4039,
+};
+static unsigned short QQ[28] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x5077,0x6089,0x8f30,0x4052,
+0x5f6f,0xa20e,0x81cb,0x4090,
+0xfe81,0x1bfd,0x7a69,0x40b3,
+0xd118,0xd280,0xad28,0x40c2,
+0x3d14,0xa697,0x3d0a,0x40bf,
+0x1781,0xb4bd,0x1462,0x40a6,
+0x5997,0x6ae7,0x017f,0x4075,
+};
+#endif
+#ifdef MIEEE
+static unsigned short QP[32] = {
+0x3faa,0x27fa,0x6b70,0xba40,
+0x4013,0xedb5,0xc66d,0x8fd6,
+0x4052,0xf4b9,0x9acf,0x1c67,
+0x4076,0xec79,0x47aa,0x180d,
+0x4086,0x36d9,0xb66f,0x6e50,
+0x4082,0xabea,0xb9e8,0x02d0,
+0x406a,0x760a,0x4c54,0xbb0b,
+0x4039,0x34ff,0x4d15,0x9eb5,
+};
+static unsigned short QQ[28] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4052,0x8f30,0x6089,0x5077,
+0x4090,0x81cb,0xa20e,0x5f6f,
+0x40b3,0x7a69,0x1bfd,0xfe81,
+0x40c2,0xad28,0xd280,0xd118,
+0x40bf,0x3d0a,0xa697,0x3d14,
+0x40a6,0x1462,0xb4bd,0x1781,
+0x4075,0x017f,0x6ae7,0x5997,
+};
+#endif
+
+#ifdef UNK
+static double YP[6] = {
+ 1.26320474790178026440E9,
+-6.47355876379160291031E11,
+ 1.14509511541823727583E14,
+-8.12770255501325109621E15,
+ 2.02439475713594898196E17,
+-7.78877196265950026825E17,
+};
+static double YQ[8] = {
+/* 1.00000000000000000000E0,*/
+ 5.94301592346128195359E2,
+ 2.35564092943068577943E5,
+ 7.34811944459721705660E7,
+ 1.87601316108706159478E10,
+ 3.88231277496238566008E12,
+ 6.20557727146953693363E14,
+ 6.87141087355300489866E16,
+ 3.97270608116560655612E18,
+};
+#endif
+#ifdef DEC
+static unsigned short YP[24] = {
+0047626,0112763,0013715,0133045,
+0152026,0134552,0142033,0024411,
+0053720,0045245,0102210,0077565,
+0155347,0000321,0136415,0102031,
+0056463,0146550,0055633,0032605,
+0157054,0171012,0167361,0054265,
+};
+static unsigned short YQ[32] = {
+/*0040200,0000000,0000000,0000000,*/
+0042424,0111515,0044773,0153014,
+0044546,0005405,0171307,0075774,
+0046614,0023575,0047105,0063556,
+0050613,0143034,0101533,0156026,
+0052541,0175367,0166514,0114257,
+0054415,0014466,0134350,0171154,
+0056164,0017436,0025075,0022101,
+0057534,0103614,0103663,0121772,
+};
+#endif
+#ifdef IBMPC
+static unsigned short YP[24] = {
+0xb6c5,0x62f9,0xd2be,0x41d2,
+0x6521,0x5883,0xd72d,0xc262,
+0x0fef,0xb091,0x0954,0x42da,
+0xb083,0x37a1,0xe01a,0xc33c,
+0x66b1,0x0b73,0x79ad,0x4386,
+0x2b17,0x5dde,0x9e41,0xc3a5,
+};
+static unsigned short YQ[32] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x7ac2,0xa93f,0x9269,0x4082,
+0xef7f,0xbe58,0xc160,0x410c,
+0xacee,0xa9c8,0x84ef,0x4191,
+0x7b83,0x906b,0x78c3,0x4211,
+0x9316,0xfda9,0x3f5e,0x428c,
+0x1e4e,0xd71d,0xa326,0x4301,
+0xa488,0xc547,0x83e3,0x436e,
+0x747f,0x90f6,0x90f1,0x43cb,
+};
+#endif
+#ifdef MIEEE
+static unsigned short YP[24] = {
+0x41d2,0xd2be,0x62f9,0xb6c5,
+0xc262,0xd72d,0x5883,0x6521,
+0x42da,0x0954,0xb091,0x0fef,
+0xc33c,0xe01a,0x37a1,0xb083,
+0x4386,0x79ad,0x0b73,0x66b1,
+0xc3a5,0x9e41,0x5dde,0x2b17,
+};
+static unsigned short YQ[32] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4082,0x9269,0xa93f,0x7ac2,
+0x410c,0xc160,0xbe58,0xef7f,
+0x4191,0x84ef,0xa9c8,0xacee,
+0x4211,0x78c3,0x906b,0x7b83,
+0x428c,0x3f5e,0xfda9,0x9316,
+0x4301,0xa326,0xd71d,0x1e4e,
+0x436e,0x83e3,0xc547,0xa488,
+0x43cb,0x90f1,0x90f6,0x747f,
+};
+#endif
+
+
+#ifdef UNK
+static double Z1 = 1.46819706421238932572E1;
+static double Z2 = 4.92184563216946036703E1;
+#endif
+
+#ifdef DEC
+static unsigned short DZ1[] = {0041152,0164532,0006114,0010540};
+static unsigned short DZ2[] = {0041504,0157663,0001625,0020621};
+#define Z1 (*(double *)DZ1)
+#define Z2 (*(double *)DZ2)
+#endif
+
+#ifdef IBMPC
+static unsigned short DZ1[] = {0x822c,0x4189,0x5d2b,0x402d};
+static unsigned short DZ2[] = {0xa432,0x6072,0x9bf6,0x4048};
+#define Z1 (*(double *)DZ1)
+#define Z2 (*(double *)DZ2)
+#endif
+
+#ifdef MIEEE
+static unsigned short DZ1[] = {0x402d,0x5d2b,0x4189,0x822c};
+static unsigned short DZ2[] = {0x4048,0x9bf6,0x6072,0xa432};
+#define Z1 (*(double *)DZ1)
+#define Z2 (*(double *)DZ2)
+#endif
+
+#ifdef ANSIPROT
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double log ( double );
+extern double sin ( double );
+extern double cos ( double );
+extern double sqrt ( double );
+double j1 ( double );
+#else
+double polevl(), p1evl(), log(), sin(), cos(), sqrt();
+double j1();
+#endif
+extern double TWOOPI, THPIO4, SQ2OPI;
+
+double j1(x)
+double x;
+{
+double w, z, p, q, xn;
+
+w = x;
+if( x < 0 )
+	w = -x;
+
+if( w <= 5.0 )
+	{
+	z = x * x;	
+	w = polevl( z, RP, 3 ) / p1evl( z, RQ, 8 );
+	w = w * x * (z - Z1) * (z - Z2);
+	return( w );
+	}
+
+w = 5.0/x;
+z = w * w;
+p = polevl( z, PP, 6)/polevl( z, PQ, 6 );
+q = polevl( z, QP, 7)/p1evl( z, QQ, 7 );
+xn = x - THPIO4;
+p = p * cos(xn) - w * q * sin(xn);
+return( p * SQ2OPI / sqrt(x) );
+}
+
+
+extern double MAXNUM;
+
+double y1(x)
+double x;
+{
+double w, z, p, q, xn;
+
+if( x <= 5.0 )
+	{
+	if( x <= 0.0 )
+		{
+		mtherr( "y1", DOMAIN );
+		return( -MAXNUM );
+		}
+	z = x * x;
+	w = x * (polevl( z, YP, 5 ) / p1evl( z, YQ, 8 ));
+	w += TWOOPI * ( j1(x) * log(x)  -  1.0/x );
+	return( w );
+	}
+
+w = 5.0/x;
+z = w * w;
+p = polevl( z, PP, 6)/polevl( z, PQ, 6 );
+q = polevl( z, QP, 7)/p1evl( z, QQ, 7 );
+xn = x - THPIO4;
+p = p * sin(xn) + w * q * cos(xn);
+return( p * SQ2OPI / sqrt(x) );
+}
Index: sansmodels/src/cephes/jn.c
===================================================================
--- sansmodels/src/cephes/jn.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/jn.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,134 @@
+/*							jn.c
+ *
+ *	Bessel function of integer order
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int n;
+ * double x, y, jn();
+ *
+ * y = jn( n, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of order n, where n is a
+ * (possibly negative) integer.
+ *
+ * The ratio of jn(x) to j0(x) is computed by backward
+ * recurrence.  First the ratio jn/jn-1 is found by a
+ * continued fraction expansion.  Then the recurrence
+ * relating successive orders is applied until j0 or j1 is
+ * reached.
+ *
+ * If n = 0 or 1 the routine for j0 or j1 is called
+ * directly.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Absolute error:
+ * arithmetic   range      # trials      peak         rms
+ *    DEC       0, 30        5500       6.9e-17     9.3e-18
+ *    IEEE      0, 30        5000       4.4e-16     7.9e-17
+ *
+ *
+ * Not suitable for large n or x. Use jv() instead.
+ *
+ */
+
+
+/*							jn.c
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 2000 by Stephen L. Moshier
+*/
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double fabs ( double );
+extern double j0 ( double );
+extern double j1 ( double );
+#else
+double fabs(), j0(), j1();
+#endif
+extern double MACHEP;
+
+double jn( n, x )
+int n;
+double x;
+{
+double pkm2, pkm1, pk, xk, r, ans;
+int k, sign;
+
+if( n < 0 )
+	{
+	n = -n;
+	if( (n & 1) == 0 )	/* -1**n */
+		sign = 1;
+	else
+		sign = -1;
+	}
+else
+	sign = 1;
+
+if( x < 0.0 )
+	{
+	if( n & 1 )
+		sign = -sign;
+	x = -x;
+	}
+
+if( n == 0 )
+	return( sign * j0(x) );
+if( n == 1 )
+	return( sign * j1(x) );
+if( n == 2 )
+	return( sign * (2.0 * j1(x) / x  -  j0(x)) );
+
+if( x < MACHEP )
+	return( 0.0 );
+
+/* continued fraction */
+#ifdef DEC
+k = 56;
+#else
+k = 53;
+#endif
+
+pk = 2 * (n + k);
+ans = pk;
+xk = x * x;
+
+do
+	{
+	pk -= 2.0;
+	ans = pk - (xk/ans);
+	}
+while( --k > 0 );
+ans = x/ans;
+
+/* backward recurrence */
+
+pk = 1.0;
+pkm1 = 1.0/ans;
+k = n-1;
+r = 2 * k;
+
+do
+	{
+	pkm2 = (pkm1 * r  -  pk * x) / x;
+	pk = pkm1;
+	pkm1 = pkm2;
+	r -= 2.0;
+	}
+while( --k > 0 );
+
+if( fabs(pk) > fabs(pkm1) )
+	ans = j1(x)/pk;
+else
+	ans = j0(x)/pkm1;
+return( sign * ans );
+}
Index: sansmodels/src/cephes/jv.c
===================================================================
--- sansmodels/src/cephes/jv.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/jv.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,889 @@
+/*							jv.c
+ *
+ *	Bessel function of noninteger order
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double v, x, y, jv();
+ *
+ * y = jv( v, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of order v of the argument,
+ * where v is real.  Negative x is allowed if v is an integer.
+ *
+ * Several expansions are included: the ascending power
+ * series, the Hankel expansion, and two transitional
+ * expansions for large v.  If v is not too large, it
+ * is reduced by recurrence to a region of best accuracy.
+ * The transitional expansions give 12D accuracy for v > 500.
+ *
+ *
+ *
+ * ACCURACY:
+ * Results for integer v are indicated by *, where x and v
+ * both vary from -125 to +125.  Otherwise,
+ * x ranges from 0 to 125, v ranges as indicated by "domain."
+ * Error criterion is absolute, except relative when |jv()| > 1.
+ *
+ * arithmetic  v domain  x domain    # trials      peak       rms
+ *    IEEE      0,125     0,125      100000      4.6e-15    2.2e-16
+ *    IEEE   -125,0       0,125       40000      5.4e-11    3.7e-13
+ *    IEEE      0,500     0,500       20000      4.4e-15    4.0e-16
+ * Integer v:
+ *    IEEE   -125,125   -125,125      50000      3.5e-15*   1.9e-16*
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier
+*/
+
+
+#include "mconf.h"
+#define DEBUG 0
+
+#ifdef DEC
+#define MAXGAM 34.84425627277176174
+#else
+#define MAXGAM 171.624376956302725
+#endif
+
+#ifdef ANSIPROT
+extern int airy ( double, double *, double *, double *, double * );
+extern double fabs ( double );
+extern double floor ( double );
+extern double frexp ( double, int * );
+extern double polevl ( double, void *, int );
+extern double j0 ( double );
+extern double j1 ( double );
+extern double sqrt ( double );
+extern double cbrt ( double );
+extern double exp ( double );
+extern double log ( double );
+extern double sin ( double );
+extern double cos ( double );
+extern double acos ( double );
+extern double pow ( double, double );
+extern double gamma ( double );
+extern double lgam ( double );
+static double recur(double *, double, double *, int);
+static double jvs(double, double);
+static double hankel(double, double);
+static double jnx(double, double);
+static double jnt(double, double);
+#else
+int airy();
+double fabs(), floor(), frexp(), polevl(), j0(), j1(), sqrt(), cbrt();
+double exp(), log(), sin(), cos(), acos(), pow(), gamma(), lgam();
+static double recur(), jvs(), hankel(), jnx(), jnt();
+#endif
+
+extern double MAXNUM, MACHEP, MINLOG, MAXLOG;
+#define BIG  1.44115188075855872E+17
+
+double jv( n, x )
+double n, x;
+{
+double k, q, t, y, an;
+int i, sign, nint;
+
+nint = 0;	/* Flag for integer n */
+sign = 1;	/* Flag for sign inversion */
+an = fabs( n );
+y = floor( an );
+if( y == an )
+	{
+	nint = 1;
+	i = an - 16384.0 * floor( an/16384.0 );
+	if( n < 0.0 )
+		{
+		if( i & 1 )
+			sign = -sign;
+		n = an;
+		}
+	if( x < 0.0 )
+		{
+		if( i & 1 )
+			sign = -sign;
+		x = -x;
+		}
+	if( n == 0.0 )
+		return( j0(x) );
+	if( n == 1.0 )
+		return( sign * j1(x) );
+	}
+
+if( (x < 0.0) && (y != an) )
+	{
+	mtherr( "Jv", DOMAIN );
+	y = 0.0;
+	goto done;
+ 	}
+
+y = fabs(x);
+
+if( y < MACHEP )
+	goto underf;
+
+k = 3.6 * sqrt(y);
+t = 3.6 * sqrt(an);
+if( (y < t) && (an > 21.0) )
+	return( sign * jvs(n,x) );
+if( (an < k) && (y > 21.0) )
+	return( sign * hankel(n,x) );
+
+if( an < 500.0 )
+	{
+/* Note: if x is too large, the continued
+ * fraction will fail; but then the
+ * Hankel expansion can be used.
+ */
+	if( nint != 0 )
+		{
+		k = 0.0;
+		q = recur( &n, x, &k, 1 );
+		if( k == 0.0 )
+			{
+			y = j0(x)/q;
+			goto done;
+			}
+		if( k == 1.0 )
+			{
+			y = j1(x)/q;
+			goto done;
+			}
+		}
+
+if( an > 2.0 * y )
+	goto rlarger;
+
+	if( (n >= 0.0) && (n < 20.0)
+		&& (y > 6.0) && (y < 20.0) )
+		{
+/* Recur backwards from a larger value of n
+ */
+rlarger:
+		k = n;
+
+		y = y + an + 1.0;
+		if( y < 30.0 )
+			y = 30.0;
+		y = n + floor(y-n);
+		q = recur( &y, x, &k, 0 );
+		y = jvs(y,x) * q;
+		goto done;
+		}
+
+	if( k <= 30.0 )
+		{
+		k = 2.0;
+		}
+	else if( k < 90.0 )
+		{
+		k = (3*k)/4;
+		}
+	if( an > (k + 3.0) )
+		{
+		if( n < 0.0 )
+			k = -k;
+		q = n - floor(n);
+		k = floor(k) + q;
+		if( n > 0.0 )
+			q = recur( &n, x, &k, 1 );
+		else
+			{
+			t = k;
+			k = n;
+			q = recur( &t, x, &k, 1 );
+			k = t;
+			}
+		if( q == 0.0 )
+			{
+underf:
+			y = 0.0;
+			goto done;
+			}
+		}
+	else
+		{
+		k = n;
+		q = 1.0;
+		}
+
+/* boundary between convergence of
+ * power series and Hankel expansion
+ */
+	y = fabs(k);
+	if( y < 26.0 )
+		t = (0.0083*y + 0.09)*y + 12.9;
+	else
+		t = 0.9 * y;
+
+	if( x > t )
+		y = hankel(k,x);
+	else
+		y = jvs(k,x);
+#if DEBUG
+printf( "y = %.16e, recur q = %.16e\n", y, q );
+#endif
+	if( n > 0.0 )
+		y /= q;
+	else
+		y *= q;
+	}
+
+else
+	{
+/* For large n, use the uniform expansion
+ * or the transitional expansion.
+ * But if x is of the order of n**2,
+ * these may blow up, whereas the
+ * Hankel expansion will then work.
+ */
+	if( n < 0.0 )
+		{
+		mtherr( "Jv", TLOSS );
+		y = 0.0;
+		goto done;
+		}
+	t = x/n;
+	t /= n;
+	if( t > 0.3 )
+		y = hankel(n,x);
+	else
+		y = jnx(n,x);
+	}
+
+done:	return( sign * y);
+}
+
+
+/* Reduce the order by backward recurrence.
+ * AMS55 #9.1.27 and 9.1.73.
+ */
+
+static double recur( n, x, newn, cancel )
+double *n;
+double x;
+double *newn;
+int cancel;
+{
+double pkm2, pkm1, pk, qkm2, qkm1;
+/* double pkp1; */
+double k, ans, qk, xk, yk, r, t, kf;
+static double big = BIG;
+int nflag, ctr;
+
+/* continued fraction for Jn(x)/Jn-1(x)  */
+if( *n < 0.0 )
+	nflag = 1;
+else
+	nflag = 0;
+
+fstart:
+
+#if DEBUG
+printf( "recur: n = %.6e, newn = %.6e, cfrac = ", *n, *newn );
+#endif
+
+pkm2 = 0.0;
+qkm2 = 1.0;
+pkm1 = x;
+qkm1 = *n + *n;
+xk = -x * x;
+yk = qkm1;
+ans = 1.0;
+ctr = 0;
+do
+	{
+	yk += 2.0;
+	pk = pkm1 * yk +  pkm2 * xk;
+	qk = qkm1 * yk +  qkm2 * xk;
+	pkm2 = pkm1;
+	pkm1 = pk;
+	qkm2 = qkm1;
+	qkm1 = qk;
+	if( qk != 0 )
+		r = pk/qk;
+	else
+		r = 0.0;
+	if( r != 0 )
+		{
+		t = fabs( (ans - r)/r );
+		ans = r;
+		}
+	else
+		t = 1.0;
+
+	if( ++ctr > 1000 )
+		{
+		mtherr( "jv", UNDERFLOW );
+		goto done;
+		}
+	if( t < MACHEP )
+		goto done;
+
+	if( fabs(pk) > big )
+		{
+		pkm2 /= big;
+		pkm1 /= big;
+		qkm2 /= big;
+		qkm1 /= big;
+		}
+	}
+while( t > MACHEP );
+
+done:
+
+#if DEBUG
+printf( "%.6e\n", ans );
+#endif
+
+/* Change n to n-1 if n < 0 and the continued fraction is small
+ */
+if( nflag > 0 )
+	{
+	if( fabs(ans) < 0.125 )
+		{
+		nflag = -1;
+		*n = *n - 1.0;
+		goto fstart;
+		}
+	}
+
+
+kf = *newn;
+
+/* backward recurrence
+ *              2k
+ *  J   (x)  =  --- J (x)  -  J   (x)
+ *   k-1         x   k         k+1
+ */
+
+pk = 1.0;
+pkm1 = 1.0/ans;
+k = *n - 1.0;
+r = 2 * k;
+do
+	{
+	pkm2 = (pkm1 * r  -  pk * x) / x;
+	/*	pkp1 = pk; */
+	pk = pkm1;
+	pkm1 = pkm2;
+	r -= 2.0;
+/*
+	t = fabs(pkp1) + fabs(pk);
+	if( (k > (kf + 2.5)) && (fabs(pkm1) < 0.25*t) )
+		{
+		k -= 1.0;
+		t = x*x;
+		pkm2 = ( (r*(r+2.0)-t)*pk - r*x*pkp1 )/t;
+		pkp1 = pk;
+		pk = pkm1;
+		pkm1 = pkm2;
+		r -= 2.0;
+		}
+*/
+	k -= 1.0;
+	}
+while( k > (kf + 0.5) );
+
+/* Take the larger of the last two iterates
+ * on the theory that it may have less cancellation error.
+ */
+
+if( cancel )
+	{
+	if( (kf >= 0.0) && (fabs(pk) > fabs(pkm1)) )
+		{
+		k += 1.0;
+		pkm2 = pk;
+		}
+	}
+*newn = k;
+#if DEBUG
+printf( "newn %.6e rans %.6e\n", k, pkm2 );
+#endif
+return( pkm2 );
+}
+
+
+
+/* Ascending power series for Jv(x).
+ * AMS55 #9.1.10.
+ */
+
+extern double PI;
+extern int sgngam;
+
+static double jvs( n, x )
+double n, x;
+{
+double t, u, y, z, k;
+int ex;
+
+z = -x * x / 4.0;
+u = 1.0;
+y = u;
+k = 1.0;
+t = 1.0;
+
+while( t > MACHEP )
+	{
+	u *= z / (k * (n+k));
+	y += u;
+	k += 1.0;
+	if( y != 0 )
+		t = fabs( u/y );
+	}
+#if DEBUG
+printf( "power series=%.5e ", y );
+#endif
+t = frexp( 0.5*x, &ex );
+ex = ex * n;
+if(  (ex > -1023)
+  && (ex < 1023) 
+  && (n > 0.0)
+  && (n < (MAXGAM-1.0)) )
+	{
+	t = pow( 0.5*x, n ) / gamma( n + 1.0 );
+#if DEBUG
+printf( "pow(.5*x, %.4e)/gamma(n+1)=%.5e\n", n, t );
+#endif
+	y *= t;
+	}
+else
+	{
+#if DEBUG
+	z = n * log(0.5*x);
+	k = lgam( n+1.0 );
+	t = z - k;
+	printf( "log pow=%.5e, lgam(%.4e)=%.5e\n", z, n+1.0, k );
+#else
+	t = n * log(0.5*x) - lgam(n + 1.0);
+#endif
+	if( y < 0 )
+		{
+		sgngam = -sgngam;
+		y = -y;
+		}
+	t += log(y);
+#if DEBUG
+printf( "log y=%.5e\n", log(y) );
+#endif
+	if( t < -MAXLOG )
+		{
+		return( 0.0 );
+		}
+	if( t > MAXLOG )
+		{
+		mtherr( "Jv", OVERFLOW );
+		return( MAXNUM );
+		}
+	y = sgngam * exp( t );
+	}
+return(y);
+}
+
+
+/* Hankel's asymptotic expansion
+ * for large x.
+ * AMS55 #9.2.5.
+ */
+
+static double hankel( n, x )
+double n, x;
+{
+double t, u, z, k, sign, conv;
+double p, q, j, m, pp, qq;
+int flag;
+
+m = 4.0*n*n;
+j = 1.0;
+z = 8.0 * x;
+k = 1.0;
+p = 1.0;
+u = (m - 1.0)/z;
+q = u;
+sign = 1.0;
+conv = 1.0;
+flag = 0;
+t = 1.0;
+pp = 1.0e38;
+qq = 1.0e38;
+
+while( t > MACHEP )
+	{
+	k += 2.0;
+	j += 1.0;
+	sign = -sign;
+	u *= (m - k * k)/(j * z);
+	p += sign * u;
+	k += 2.0;
+	j += 1.0;
+	u *= (m - k * k)/(j * z);
+	q += sign * u;
+	t = fabs(u/p);
+	if( t < conv )
+		{
+		conv = t;
+		qq = q;
+		pp = p;
+		flag = 1;
+		}
+/* stop if the terms start getting larger */
+	if( (flag != 0) && (t > conv) )
+		{
+#if DEBUG
+		printf( "Hankel: convergence to %.4E\n", conv );
+#endif
+		goto hank1;
+		}
+	}	
+
+hank1:
+u = x - (0.5*n + 0.25) * PI;
+t = sqrt( 2.0/(PI*x) ) * ( pp * cos(u) - qq * sin(u) );
+#if DEBUG
+printf( "hank: %.6e\n", t );
+#endif
+return( t );
+}
+
+
+
+/* Asymptotic expansion for large n.
+ * AMS55 #9.3.35.
+ */
+
+static double lambda[] = {
+  1.0,
+  1.041666666666666666666667E-1,
+  8.355034722222222222222222E-2,
+  1.282265745563271604938272E-1,
+  2.918490264641404642489712E-1,
+  8.816272674437576524187671E-1,
+  3.321408281862767544702647E+0,
+  1.499576298686255465867237E+1,
+  7.892301301158651813848139E+1,
+  4.744515388682643231611949E+2,
+  3.207490090890661934704328E+3
+};
+static double mu[] = {
+  1.0,
+ -1.458333333333333333333333E-1,
+ -9.874131944444444444444444E-2,
+ -1.433120539158950617283951E-1,
+ -3.172272026784135480967078E-1,
+ -9.424291479571202491373028E-1,
+ -3.511203040826354261542798E+0,
+ -1.572726362036804512982712E+1,
+ -8.228143909718594444224656E+1,
+ -4.923553705236705240352022E+2,
+ -3.316218568547972508762102E+3
+};
+static double P1[] = {
+ -2.083333333333333333333333E-1,
+  1.250000000000000000000000E-1
+};
+static double P2[] = {
+  3.342013888888888888888889E-1,
+ -4.010416666666666666666667E-1,
+  7.031250000000000000000000E-2
+};
+static double P3[] = {
+ -1.025812596450617283950617E+0,
+  1.846462673611111111111111E+0,
+ -8.912109375000000000000000E-1,
+  7.324218750000000000000000E-2
+};
+static double P4[] = {
+  4.669584423426247427983539E+0,
+ -1.120700261622299382716049E+1,
+  8.789123535156250000000000E+0,
+ -2.364086914062500000000000E+0,
+  1.121520996093750000000000E-1
+};
+static double P5[] = {
+ -2.8212072558200244877E1,
+  8.4636217674600734632E1,
+ -9.1818241543240017361E1,
+  4.2534998745388454861E1,
+ -7.3687943594796316964E0,
+  2.27108001708984375E-1
+};
+static double P6[] = {
+  2.1257013003921712286E2,
+ -7.6525246814118164230E2,
+  1.0599904525279998779E3,
+ -6.9957962737613254123E2,
+  2.1819051174421159048E2,
+ -2.6491430486951555525E1,
+  5.7250142097473144531E-1
+};
+static double P7[] = {
+ -1.9194576623184069963E3,
+  8.0617221817373093845E3,
+ -1.3586550006434137439E4,
+  1.1655393336864533248E4,
+ -5.3056469786134031084E3,
+  1.2009029132163524628E3,
+ -1.0809091978839465550E2,
+  1.7277275025844573975E0
+};
+
+
+static double jnx( n, x )
+double n, x;
+{
+double zeta, sqz, zz, zp, np;
+double cbn, n23, t, z, sz;
+double pp, qq, z32i, zzi;
+double ak, bk, akl, bkl;
+int sign, doa, dob, nflg, k, s, tk, tkp1, m;
+static double u[8];
+static double ai, aip, bi, bip;
+
+/* Test for x very close to n.
+ * Use expansion for transition region if so.
+ */
+cbn = cbrt(n);
+z = (x - n)/cbn;
+if( fabs(z) <= 0.7 )
+	return( jnt(n,x) );
+
+z = x/n;
+zz = 1.0 - z*z;
+if( zz == 0.0 )
+	return(0.0);
+
+if( zz > 0.0 )
+	{
+	sz = sqrt( zz );
+	t = 1.5 * (log( (1.0+sz)/z ) - sz );	/* zeta ** 3/2		*/
+	zeta = cbrt( t * t );
+	nflg = 1;
+	}
+else
+	{
+	sz = sqrt(-zz);
+	t = 1.5 * (sz - acos(1.0/z));
+	zeta = -cbrt( t * t );
+	nflg = -1;
+	}
+z32i = fabs(1.0/t);
+sqz = cbrt(t);
+
+/* Airy function */
+n23 = cbrt( n * n );
+t = n23 * zeta;
+
+#if DEBUG
+printf("zeta %.5E, Airy(%.5E)\n", zeta, t );
+#endif
+airy( t, &ai, &aip, &bi, &bip );
+
+/* polynomials in expansion */
+u[0] = 1.0;
+zzi = 1.0/zz;
+u[1] = polevl( zzi, P1, 1 )/sz;
+u[2] = polevl( zzi, P2, 2 )/zz;
+u[3] = polevl( zzi, P3, 3 )/(sz*zz);
+pp = zz*zz;
+u[4] = polevl( zzi, P4, 4 )/pp;
+u[5] = polevl( zzi, P5, 5 )/(pp*sz);
+pp *= zz;
+u[6] = polevl( zzi, P6, 6 )/pp;
+u[7] = polevl( zzi, P7, 7 )/(pp*sz);
+
+#if DEBUG
+for( k=0; k<=7; k++ )
+	printf( "u[%d] = %.5E\n", k, u[k] );
+#endif
+
+pp = 0.0;
+qq = 0.0;
+np = 1.0;
+/* flags to stop when terms get larger */
+doa = 1;
+dob = 1;
+akl = MAXNUM;
+bkl = MAXNUM;
+
+for( k=0; k<=3; k++ )
+	{
+	tk = 2 * k;
+	tkp1 = tk + 1;
+	zp = 1.0;
+	ak = 0.0;
+	bk = 0.0;
+	for( s=0; s<=tk; s++ )
+		{
+		if( doa )
+			{
+			if( (s & 3) > 1 )
+				sign = nflg;
+			else
+				sign = 1;
+			ak += sign * mu[s] * zp * u[tk-s];
+			}
+
+		if( dob )
+			{
+			m = tkp1 - s;
+			if( ((m+1) & 3) > 1 )
+				sign = nflg;
+			else
+				sign = 1;
+			bk += sign * lambda[s] * zp * u[m];
+			}
+		zp *= z32i;
+		}
+
+	if( doa )
+		{
+		ak *= np;
+		t = fabs(ak);
+		if( t < akl )
+			{
+			akl = t;
+			pp += ak;
+			}
+		else
+			doa = 0;
+		}
+
+	if( dob )
+		{
+		bk += lambda[tkp1] * zp * u[0];
+		bk *= -np/sqz;
+		t = fabs(bk);
+		if( t < bkl )
+			{
+			bkl = t;
+			qq += bk;
+			}
+		else
+			dob = 0;
+		}
+#if DEBUG
+	printf("a[%d] %.5E, b[%d] %.5E\n", k, ak, k, bk );
+#endif
+	if( np < MACHEP )
+		break;
+	np /= n*n;
+	}
+
+/* normalizing factor ( 4*zeta/(1 - z**2) )**1/4	*/
+t = 4.0 * zeta/zz;
+t = sqrt( sqrt(t) );
+
+t *= ai*pp/cbrt(n)  +  aip*qq/(n23*n);
+return(t);
+}
+
+
+/* Asymptotic expansion for transition region,
+ * n large and x close to n.
+ * AMS55 #9.3.23.
+ */
+
+static double PF2[] = {
+ -9.0000000000000000000e-2,
+  8.5714285714285714286e-2
+};
+static double PF3[] = {
+  1.3671428571428571429e-1,
+ -5.4920634920634920635e-2,
+ -4.4444444444444444444e-3
+};
+static double PF4[] = {
+  1.3500000000000000000e-3,
+ -1.6036054421768707483e-1,
+  4.2590187590187590188e-2,
+  2.7330447330447330447e-3
+};
+static double PG1[] = {
+ -2.4285714285714285714e-1,
+  1.4285714285714285714e-2
+};
+static double PG2[] = {
+ -9.0000000000000000000e-3,
+  1.9396825396825396825e-1,
+ -1.1746031746031746032e-2
+};
+static double PG3[] = {
+  1.9607142857142857143e-2,
+ -1.5983694083694083694e-1,
+  6.3838383838383838384e-3
+};
+
+
+static double jnt( n, x )
+double n, x;
+{
+double z, zz, z3;
+double cbn, n23, cbtwo;
+double ai, aip, bi, bip;	/* Airy functions */
+double nk, fk, gk, pp, qq;
+double F[5], G[4];
+int k;
+
+cbn = cbrt(n);
+z = (x - n)/cbn;
+cbtwo = cbrt( 2.0 );
+
+/* Airy function */
+zz = -cbtwo * z;
+airy( zz, &ai, &aip, &bi, &bip );
+
+/* polynomials in expansion */
+zz = z * z;
+z3 = zz * z;
+F[0] = 1.0;
+F[1] = -z/5.0;
+F[2] = polevl( z3, PF2, 1 ) * zz;
+F[3] = polevl( z3, PF3, 2 );
+F[4] = polevl( z3, PF4, 3 ) * z;
+G[0] = 0.3 * zz;
+G[1] = polevl( z3, PG1, 1 );
+G[2] = polevl( z3, PG2, 2 ) * z;
+G[3] = polevl( z3, PG3, 2 ) * zz;
+#if DEBUG
+for( k=0; k<=4; k++ )
+	printf( "F[%d] = %.5E\n", k, F[k] );
+for( k=0; k<=3; k++ )
+	printf( "G[%d] = %.5E\n", k, G[k] );
+#endif
+pp = 0.0;
+qq = 0.0;
+nk = 1.0;
+n23 = cbrt( n * n );
+
+for( k=0; k<=4; k++ )
+	{
+	fk = F[k]*nk;
+	pp += fk;
+	if( k != 4 )
+		{
+		gk = G[k]*nk;
+		qq += gk;
+		}
+#if DEBUG
+	printf("fk[%d] %.5E, gk[%d] %.5E\n", k, fk, k, gk );
+#endif
+	nk /= n23;
+	}
+
+fk = cbtwo * ai * pp/cbn  +  cbrt(4.0) * aip * qq/n;
+return(fk);
+}
Index: sansmodels/src/cephes/k0.c
===================================================================
--- sansmodels/src/cephes/k0.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/k0.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,335 @@
+/*							k0.c
+ *
+ *	Modified Bessel function, third kind, order zero
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, k0();
+ *
+ * y = k0( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns modified Bessel function of the third kind
+ * of order zero of the argument.
+ *
+ * The range is partitioned into the two intervals [0,8] and
+ * (8, infinity).  Chebyshev polynomial expansions are employed
+ * in each interval.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Tested at 2000 random points between 0 and 8.  Peak absolute
+ * error (relative when K0 > 1) was 1.46e-14; rms, 4.26e-15.
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0, 30        3100       1.3e-16     2.1e-17
+ *    IEEE      0, 30       30000       1.2e-15     1.6e-16
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ *  K0 domain          x <= 0          MAXNUM
+ *
+ */
+
+/*							k0e()
+ *
+ *	Modified Bessel function, third kind, order zero,
+ *	exponentially scaled
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, k0e();
+ *
+ * y = k0e( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns exponentially scaled modified Bessel function
+ * of the third kind of order zero of the argument.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0, 30       30000       1.4e-15     1.4e-16
+ * See k0().
+ *
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+/* Chebyshev coefficients for K0(x) + log(x/2) I0(x)
+ * in the interval [0,2].  The odd order coefficients are all
+ * zero; only the even order coefficients are listed.
+ * 
+ * lim(x->0){ K0(x) + log(x/2) I0(x) } = -EUL.
+ */
+
+#ifdef UNK
+static double A[] =
+{
+ 1.37446543561352307156E-16,
+ 4.25981614279661018399E-14,
+ 1.03496952576338420167E-11,
+ 1.90451637722020886025E-9,
+ 2.53479107902614945675E-7,
+ 2.28621210311945178607E-5,
+ 1.26461541144692592338E-3,
+ 3.59799365153615016266E-2,
+ 3.44289899924628486886E-1,
+-5.35327393233902768720E-1
+};
+#endif
+
+#ifdef DEC
+static unsigned short A[] = {
+0023036,0073417,0032477,0165673,
+0025077,0154126,0016046,0012517,
+0027066,0011342,0035211,0005041,
+0031002,0160233,0037454,0050224,
+0032610,0012747,0037712,0173741,
+0034277,0144007,0172147,0162375,
+0035645,0140563,0125431,0165626,
+0037023,0057662,0125124,0102051,
+0037660,0043304,0004411,0166707,
+0140011,0005467,0047227,0130370
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short A[] = {
+0xfd77,0xe6a7,0xcee1,0x3ca3,
+0xc2aa,0xc384,0xfb0a,0x3d27,
+0x2144,0x4751,0xc25c,0x3da6,
+0x8a13,0x67e5,0x5c13,0x3e20,
+0x5efc,0xe7f9,0x02bc,0x3e91,
+0xfca0,0xfe8c,0xf900,0x3ef7,
+0x3d73,0x7563,0xb82e,0x3f54,
+0x9085,0x554a,0x6bf6,0x3fa2,
+0x3db9,0x8121,0x08d8,0x3fd6,
+0xf61f,0xe9d2,0x2166,0xbfe1
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short A[] = {
+0x3ca3,0xcee1,0xe6a7,0xfd77,
+0x3d27,0xfb0a,0xc384,0xc2aa,
+0x3da6,0xc25c,0x4751,0x2144,
+0x3e20,0x5c13,0x67e5,0x8a13,
+0x3e91,0x02bc,0xe7f9,0x5efc,
+0x3ef7,0xf900,0xfe8c,0xfca0,
+0x3f54,0xb82e,0x7563,0x3d73,
+0x3fa2,0x6bf6,0x554a,0x9085,
+0x3fd6,0x08d8,0x8121,0x3db9,
+0xbfe1,0x2166,0xe9d2,0xf61f
+};
+#endif
+
+
+
+/* Chebyshev coefficients for exp(x) sqrt(x) K0(x)
+ * in the inverted interval [2,infinity].
+ * 
+ * lim(x->inf){ exp(x) sqrt(x) K0(x) } = sqrt(pi/2).
+ */
+
+#ifdef UNK
+static double B[] = {
+ 5.30043377268626276149E-18,
+-1.64758043015242134646E-17,
+ 5.21039150503902756861E-17,
+-1.67823109680541210385E-16,
+ 5.51205597852431940784E-16,
+-1.84859337734377901440E-15,
+ 6.34007647740507060557E-15,
+-2.22751332699166985548E-14,
+ 8.03289077536357521100E-14,
+-2.98009692317273043925E-13,
+ 1.14034058820847496303E-12,
+-4.51459788337394416547E-12,
+ 1.85594911495471785253E-11,
+-7.95748924447710747776E-11,
+ 3.57739728140030116597E-10,
+-1.69753450938905987466E-9,
+ 8.57403401741422608519E-9,
+-4.66048989768794782956E-8,
+ 2.76681363944501510342E-7,
+-1.83175552271911948767E-6,
+ 1.39498137188764993662E-5,
+-1.28495495816278026384E-4,
+ 1.56988388573005337491E-3,
+-3.14481013119645005427E-2,
+ 2.44030308206595545468E0
+};
+#endif
+
+#ifdef DEC
+static unsigned short B[] = {
+0021703,0106456,0076144,0173406,
+0122227,0173144,0116011,0030033,
+0022560,0044562,0006506,0067642,
+0123101,0076243,0123273,0131013,
+0023436,0157713,0056243,0141331,
+0124005,0032207,0063726,0164664,
+0024344,0066342,0051756,0162300,
+0124710,0121365,0154053,0077022,
+0025264,0161166,0066246,0077420,
+0125647,0141671,0006443,0103212,
+0026240,0076431,0077147,0160445,
+0126636,0153741,0174002,0105031,
+0027243,0040102,0035375,0163073,
+0127656,0176256,0113476,0044653,
+0030304,0125544,0006377,0130104,
+0130751,0047257,0110537,0127324,
+0031423,0046400,0014772,0012164,
+0132110,0025240,0155247,0112570,
+0032624,0105314,0007437,0021574,
+0133365,0155243,0174306,0116506,
+0034152,0004776,0061643,0102504,
+0135006,0136277,0036104,0175023,
+0035715,0142217,0162474,0115022,
+0137000,0147671,0065177,0134356,
+0040434,0026754,0175163,0044070
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short B[] = {
+0x9ee1,0xcf8c,0x71a5,0x3c58,
+0x2603,0x9381,0xfecc,0xbc72,
+0xcdf4,0x41a8,0x092e,0x3c8e,
+0x7641,0x74d7,0x2f94,0xbca8,
+0x785b,0x6b94,0xdbf9,0x3cc3,
+0xdd36,0xecfa,0xa690,0xbce0,
+0xdc98,0x4a7d,0x8d9c,0x3cfc,
+0x6fc2,0xbb05,0x145e,0xbd19,
+0xcfe2,0xcd94,0x9c4e,0x3d36,
+0x70d1,0x21a4,0xf877,0xbd54,
+0xfc25,0x2fcc,0x0fa3,0x3d74,
+0x5143,0x3f00,0xdafc,0xbd93,
+0xbcc7,0x475f,0x6808,0x3db4,
+0xc935,0xd2e7,0xdf95,0xbdd5,
+0xf608,0x819f,0x956c,0x3df8,
+0xf5db,0xf22b,0x29d5,0xbe1d,
+0x428e,0x033f,0x69a0,0x3e42,
+0xf2af,0x1b54,0x0554,0xbe69,
+0xe46f,0x81e3,0x9159,0x3e92,
+0xd3a9,0x7f18,0xbb54,0xbebe,
+0x70a9,0xcc74,0x413f,0x3eed,
+0x9f42,0xe788,0xd797,0xbf20,
+0x9342,0xfca7,0xb891,0x3f59,
+0xf71e,0x2d4f,0x19f7,0xbfa0,
+0x6907,0x9f4e,0x85bd,0x4003
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short B[] = {
+0x3c58,0x71a5,0xcf8c,0x9ee1,
+0xbc72,0xfecc,0x9381,0x2603,
+0x3c8e,0x092e,0x41a8,0xcdf4,
+0xbca8,0x2f94,0x74d7,0x7641,
+0x3cc3,0xdbf9,0x6b94,0x785b,
+0xbce0,0xa690,0xecfa,0xdd36,
+0x3cfc,0x8d9c,0x4a7d,0xdc98,
+0xbd19,0x145e,0xbb05,0x6fc2,
+0x3d36,0x9c4e,0xcd94,0xcfe2,
+0xbd54,0xf877,0x21a4,0x70d1,
+0x3d74,0x0fa3,0x2fcc,0xfc25,
+0xbd93,0xdafc,0x3f00,0x5143,
+0x3db4,0x6808,0x475f,0xbcc7,
+0xbdd5,0xdf95,0xd2e7,0xc935,
+0x3df8,0x956c,0x819f,0xf608,
+0xbe1d,0x29d5,0xf22b,0xf5db,
+0x3e42,0x69a0,0x033f,0x428e,
+0xbe69,0x0554,0x1b54,0xf2af,
+0x3e92,0x9159,0x81e3,0xe46f,
+0xbebe,0xbb54,0x7f18,0xd3a9,
+0x3eed,0x413f,0xcc74,0x70a9,
+0xbf20,0xd797,0xe788,0x9f42,
+0x3f59,0xb891,0xfca7,0x9342,
+0xbfa0,0x19f7,0x2d4f,0xf71e,
+0x4003,0x85bd,0x9f4e,0x6907
+};
+#endif
+
+/*							k0.c	*/
+#ifdef ANSIPROT 
+extern double chbevl ( double, void *, int );
+extern double exp ( double );
+extern double i0 ( double );
+extern double log ( double );
+extern double sqrt ( double );
+#else
+double chbevl(), exp(), i0(), log(), sqrt();
+#endif
+extern double PI;
+extern double MAXNUM;
+
+double k0(x)
+double x;
+{
+double y, z;
+
+if( x <= 0.0 )
+	{
+	mtherr( "k0", DOMAIN );
+	return( MAXNUM );
+	}
+
+if( x <= 2.0 )
+	{
+	y = x * x - 2.0;
+	y = chbevl( y, A, 10 ) - log( 0.5 * x ) * i0(x);
+	return( y );
+	}
+z = 8.0/x - 2.0;
+y = exp(-x) * chbevl( z, B, 25 ) / sqrt(x);
+return(y);
+}
+
+
+
+
+double k0e( x )
+double x;
+{
+double y;
+
+if( x <= 0.0 )
+	{
+	mtherr( "k0e", DOMAIN );
+	return( MAXNUM );
+	}
+
+if( x <= 2.0 )
+	{
+	y = x * x - 2.0;
+	y = chbevl( y, A, 10 ) - log( 0.5 * x ) * i0(x);
+	return( y * exp(x) );
+	}
+
+y = chbevl( 8.0/x - 2.0, B, 25 ) / sqrt(x);
+return(y);
+}
Index: sansmodels/src/cephes/k1.c
===================================================================
--- sansmodels/src/cephes/k1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/k1.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,337 @@
+/*							k1.c
+ *
+ *	Modified Bessel function, third kind, order one
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, k1();
+ *
+ * y = k1( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Computes the modified Bessel function of the third kind
+ * of order one of the argument.
+ *
+ * The range is partitioned into the two intervals [0,2] and
+ * (2, infinity).  Chebyshev polynomial expansions are employed
+ * in each interval.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0, 30        3300       8.9e-17     2.2e-17
+ *    IEEE      0, 30       30000       1.2e-15     1.6e-16
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * k1 domain          x <= 0          MAXNUM
+ *
+ */
+
+/*							k1e.c
+ *
+ *	Modified Bessel function, third kind, order one,
+ *	exponentially scaled
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, k1e();
+ *
+ * y = k1e( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns exponentially scaled modified Bessel function
+ * of the third kind of order one of the argument:
+ *
+ *      k1e(x) = exp(x) * k1(x).
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0, 30       30000       7.8e-16     1.2e-16
+ * See k1().
+ *
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+/* Chebyshev coefficients for x(K1(x) - log(x/2) I1(x))
+ * in the interval [0,2].
+ * 
+ * lim(x->0){ x(K1(x) - log(x/2) I1(x)) } = 1.
+ */
+
+#ifdef UNK
+static double A[] =
+{
+-7.02386347938628759343E-18,
+-2.42744985051936593393E-15,
+-6.66690169419932900609E-13,
+-1.41148839263352776110E-10,
+-2.21338763073472585583E-8,
+-2.43340614156596823496E-6,
+-1.73028895751305206302E-4,
+-6.97572385963986435018E-3,
+-1.22611180822657148235E-1,
+-3.53155960776544875667E-1,
+ 1.52530022733894777053E0
+};
+#endif
+
+#ifdef DEC
+static unsigned short A[] = {
+0122001,0110501,0164746,0151255,
+0124056,0165213,0150034,0147377,
+0126073,0124026,0167207,0001044,
+0130033,0030735,0141061,0033116,
+0131676,0020350,0121341,0107175,
+0133443,0046631,0062031,0070716,
+0135065,0067427,0026435,0164022,
+0136344,0112234,0165752,0006222,
+0137373,0015622,0017016,0155636,
+0137664,0150333,0125730,0067240,
+0040303,0036411,0130200,0043120
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short A[] = {
+0xda56,0x3d3c,0x3228,0xbc60,
+0x99e0,0x7a03,0xdd51,0xbce5,
+0xe045,0xddd0,0x7502,0xbd67,
+0x26ca,0xb846,0x663b,0xbde3,
+0x31d0,0x145c,0xc41d,0xbe57,
+0x2e3a,0x2c83,0x69b3,0xbec4,
+0xbd02,0xe5a3,0xade2,0xbf26,
+0x4192,0x9d7d,0x9293,0xbf7c,
+0xdb74,0x43c1,0x6372,0xbfbf,
+0x0dd4,0x757b,0x9a1b,0xbfd6,
+0x08ca,0x3610,0x67a1,0x3ff8
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short A[] = {
+0xbc60,0x3228,0x3d3c,0xda56,
+0xbce5,0xdd51,0x7a03,0x99e0,
+0xbd67,0x7502,0xddd0,0xe045,
+0xbde3,0x663b,0xb846,0x26ca,
+0xbe57,0xc41d,0x145c,0x31d0,
+0xbec4,0x69b3,0x2c83,0x2e3a,
+0xbf26,0xade2,0xe5a3,0xbd02,
+0xbf7c,0x9293,0x9d7d,0x4192,
+0xbfbf,0x6372,0x43c1,0xdb74,
+0xbfd6,0x9a1b,0x757b,0x0dd4,
+0x3ff8,0x67a1,0x3610,0x08ca
+};
+#endif
+
+
+
+/* Chebyshev coefficients for exp(x) sqrt(x) K1(x)
+ * in the interval [2,infinity].
+ *
+ * lim(x->inf){ exp(x) sqrt(x) K1(x) } = sqrt(pi/2).
+ */
+
+#ifdef UNK
+static double B[] =
+{
+-5.75674448366501715755E-18,
+ 1.79405087314755922667E-17,
+-5.68946255844285935196E-17,
+ 1.83809354436663880070E-16,
+-6.05704724837331885336E-16,
+ 2.03870316562433424052E-15,
+-7.01983709041831346144E-15,
+ 2.47715442448130437068E-14,
+-8.97670518232499435011E-14,
+ 3.34841966607842919884E-13,
+-1.28917396095102890680E-12,
+ 5.13963967348173025100E-12,
+-2.12996783842756842877E-11,
+ 9.21831518760500529508E-11,
+-4.19035475934189648750E-10,
+ 2.01504975519703286596E-9,
+-1.03457624656780970260E-8,
+ 5.74108412545004946722E-8,
+-3.50196060308781257119E-7,
+ 2.40648494783721712015E-6,
+-1.93619797416608296024E-5,
+ 1.95215518471351631108E-4,
+-2.85781685962277938680E-3,
+ 1.03923736576817238437E-1,
+ 2.72062619048444266945E0
+};
+#endif
+
+#ifdef DEC
+static unsigned short B[] = {
+0121724,0061352,0013041,0150076,
+0022245,0074324,0016172,0173232,
+0122603,0030250,0135670,0165221,
+0023123,0165362,0023561,0060124,
+0123456,0112436,0141654,0073623,
+0024022,0163557,0077564,0006753,
+0124374,0165221,0131014,0026524,
+0024737,0017512,0144250,0175451,
+0125312,0021456,0123136,0076633,
+0025674,0077720,0020125,0102607,
+0126265,0067543,0007744,0043701,
+0026664,0152702,0033002,0074202,
+0127273,0055234,0120016,0071733,
+0027712,0133200,0042441,0075515,
+0130346,0057000,0015456,0074470,
+0031012,0074441,0051636,0111155,
+0131461,0136444,0177417,0002101,
+0032166,0111743,0032176,0021410,
+0132674,0001224,0076555,0027060,
+0033441,0077430,0135226,0106663,
+0134242,0065610,0167155,0113447,
+0035114,0131304,0043664,0102163,
+0136073,0045065,0171465,0122123,
+0037324,0152767,0147401,0017732,
+0040456,0017275,0050061,0062120,
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short B[] = {
+0x3a08,0x42c4,0x8c5d,0xbc5a,
+0x5ed3,0x838f,0xaf1a,0x3c74,
+0x1d52,0x1777,0x6615,0xbc90,
+0x2c0b,0x44ee,0x7d5e,0x3caa,
+0x8ef2,0xd875,0xd2a3,0xbcc5,
+0x81bd,0xefee,0x5ced,0x3ce2,
+0x85ab,0x3641,0x9d52,0xbcff,
+0x1f65,0x5915,0xe3e9,0x3d1b,
+0xcfb3,0xd4cb,0x4465,0xbd39,
+0xb0b1,0x040a,0x8ffa,0x3d57,
+0x88f8,0x61fc,0xadec,0xbd76,
+0x4f10,0x46c0,0x9ab8,0x3d96,
+0xce7b,0x9401,0x6b53,0xbdb7,
+0x2f6a,0x08a4,0x56d0,0x3dd9,
+0xcf27,0x0365,0xcbc0,0xbdfc,
+0xd24e,0x2a73,0x4f24,0x3e21,
+0xe088,0x9fe1,0x37a4,0xbe46,
+0xc461,0x668f,0xd27c,0x3e6e,
+0xa5c6,0x8fad,0x8052,0xbe97,
+0xd1b6,0x1752,0x2fe3,0x3ec4,
+0xb2e5,0x1dcd,0x4d71,0xbef4,
+0x908e,0x88f6,0x9658,0x3f29,
+0xb48a,0xbe66,0x6946,0xbf67,
+0x23fb,0xf9e0,0x9abe,0x3fba,
+0x2c8a,0xaa06,0xc3d7,0x4005
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short B[] = {
+0xbc5a,0x8c5d,0x42c4,0x3a08,
+0x3c74,0xaf1a,0x838f,0x5ed3,
+0xbc90,0x6615,0x1777,0x1d52,
+0x3caa,0x7d5e,0x44ee,0x2c0b,
+0xbcc5,0xd2a3,0xd875,0x8ef2,
+0x3ce2,0x5ced,0xefee,0x81bd,
+0xbcff,0x9d52,0x3641,0x85ab,
+0x3d1b,0xe3e9,0x5915,0x1f65,
+0xbd39,0x4465,0xd4cb,0xcfb3,
+0x3d57,0x8ffa,0x040a,0xb0b1,
+0xbd76,0xadec,0x61fc,0x88f8,
+0x3d96,0x9ab8,0x46c0,0x4f10,
+0xbdb7,0x6b53,0x9401,0xce7b,
+0x3dd9,0x56d0,0x08a4,0x2f6a,
+0xbdfc,0xcbc0,0x0365,0xcf27,
+0x3e21,0x4f24,0x2a73,0xd24e,
+0xbe46,0x37a4,0x9fe1,0xe088,
+0x3e6e,0xd27c,0x668f,0xc461,
+0xbe97,0x8052,0x8fad,0xa5c6,
+0x3ec4,0x2fe3,0x1752,0xd1b6,
+0xbef4,0x4d71,0x1dcd,0xb2e5,
+0x3f29,0x9658,0x88f6,0x908e,
+0xbf67,0x6946,0xbe66,0xb48a,
+0x3fba,0x9abe,0xf9e0,0x23fb,
+0x4005,0xc3d7,0xaa06,0x2c8a
+};
+#endif
+
+#ifdef ANSIPROT
+extern double chbevl ( double, void *, int );
+extern double exp ( double );
+extern double i1 ( double );
+extern double log ( double );
+extern double sqrt ( double );
+#else
+double chbevl(), exp(), i1(), log(), sqrt();
+#endif
+extern double PI;
+extern double MINLOG, MAXNUM;
+
+double k1(x)
+double x;
+{
+double y, z;
+
+z = 0.5 * x;
+if( z <= 0.0 )
+	{
+	mtherr( "k1", DOMAIN );
+	return( MAXNUM );
+	}
+
+if( x <= 2.0 )
+	{
+	y = x * x - 2.0;
+	y =  log(z) * i1(x)  +  chbevl( y, A, 11 ) / x;
+	return( y );
+	}
+
+return(  exp(-x) * chbevl( 8.0/x - 2.0, B, 25 ) / sqrt(x) );
+}
+
+
+
+
+double k1e( x )
+double x;
+{
+double y;
+
+if( x <= 0.0 )
+	{
+	mtherr( "k1e", DOMAIN );
+	return( MAXNUM );
+	}
+
+if( x <= 2.0 )
+	{
+	y = x * x - 2.0;
+	y =  log( 0.5 * x ) * i1(x)  +  chbevl( y, A, 11 ) / x;
+	return( y * exp(x) );
+	}
+
+return(  chbevl( 8.0/x - 2.0, B, 25 ) / sqrt(x) );
+}
Index: sansmodels/src/cephes/kn.c
===================================================================
--- sansmodels/src/cephes/kn.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/kn.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,257 @@
+/*							kn.c
+ *
+ *	Modified Bessel function, third kind, integer order
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, kn();
+ * int n;
+ *
+ * y = kn( n, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns modified Bessel function of the third kind
+ * of order n of the argument.
+ *
+ * The range is partitioned into the two intervals [0,9.55] and
+ * (9.55, infinity).  An ascending power series is used in the
+ * low range, and an asymptotic expansion in the high range.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0,30         3000       1.3e-9      5.8e-11
+ *    IEEE      0,30        90000       1.8e-8      3.0e-10
+ *
+ *  Error is high only near the crossover point x = 9.55
+ * between the two expansions used.
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1988, 2000 by Stephen L. Moshier
+*/
+
+
+/*
+Algorithm for Kn.
+                       n-1 
+                   -n   -  (n-k-1)!    2   k
+K (x)  =  0.5 (x/2)     >  -------- (-x /4)
+ n                      -     k!
+                       k=0
+
+                    inf.                                   2   k
+       n         n   -                                   (x /4)
+ + (-1)  0.5(x/2)    >  {p(k+1) + p(n+k+1) - 2log(x/2)} ---------
+                     -                                  k! (n+k)!
+                    k=0
+
+where  p(m) is the psi function: p(1) = -EUL and
+
+                      m-1
+                       -
+      p(m)  =  -EUL +  >  1/k
+                       -
+                      k=1
+
+For large x,
+                                         2        2     2
+                                      u-1     (u-1 )(u-3 )
+K (z)  =  sqrt(pi/2z) exp(-z) { 1 + ------- + ------------ + ...}
+ v                                        1            2
+                                    1! (8z)     2! (8z)
+asymptotically, where
+
+           2
+    u = 4 v .
+
+*/
+
+
+#include "mconf.h"
+
+#define EUL 5.772156649015328606065e-1
+#define MAXFAC 31
+#ifdef ANSIPROT
+extern double fabs ( double );
+extern double exp ( double );
+extern double log ( double );
+extern double sqrt ( double );
+#else
+double fabs(), exp(), log(), sqrt();
+#endif
+extern double MACHEP, MAXNUM, MAXLOG, PI;
+
+double kn( nn, x )
+int nn;
+double x;
+{
+double k, kf, nk1f, nkf, zn, t, s, z0, z;
+double ans, fn, pn, pk, zmn, tlg, tox;
+int i, n;
+
+if( nn < 0 )
+	n = -nn;
+else
+	n = nn;
+
+if( n > MAXFAC )
+	{
+overf:
+	mtherr( "kn", OVERFLOW );
+	return( MAXNUM );
+	}
+
+if( x <= 0.0 )
+	{
+	if( x < 0.0 )
+		mtherr( "kn", DOMAIN );
+	else
+		mtherr( "kn", SING );
+	return( MAXNUM );
+	}
+
+
+if( x > 9.55 )
+	goto asymp;
+
+ans = 0.0;
+z0 = 0.25 * x * x;
+fn = 1.0;
+pn = 0.0;
+zmn = 1.0;
+tox = 2.0/x;
+
+if( n > 0 )
+	{
+	/* compute factorial of n and psi(n) */
+	pn = -EUL;
+	k = 1.0;
+	for( i=1; i<n; i++ )
+		{
+		pn += 1.0/k;
+		k += 1.0;
+		fn *= k;
+		}
+
+	zmn = tox;
+
+	if( n == 1 )
+		{
+		ans = 1.0/x;
+		}
+	else
+		{
+		nk1f = fn/n;
+		kf = 1.0;
+		s = nk1f;
+		z = -z0;
+		zn = 1.0;
+		for( i=1; i<n; i++ )
+			{
+			nk1f = nk1f/(n-i);
+			kf = kf * i;
+			zn *= z;
+			t = nk1f * zn / kf;
+			s += t;   
+			if( (MAXNUM - fabs(t)) < fabs(s) )
+				goto overf;
+			if( (tox > 1.0) && ((MAXNUM/tox) < zmn) )
+				goto overf;
+			zmn *= tox;
+			}
+		s *= 0.5;
+		t = fabs(s);
+		if( (zmn > 1.0) && ((MAXNUM/zmn) < t) )
+			goto overf;
+		if( (t > 1.0) && ((MAXNUM/t) < zmn) )
+			goto overf;
+		ans = s * zmn;
+		}
+	}
+
+
+tlg = 2.0 * log( 0.5 * x );
+pk = -EUL;
+if( n == 0 )
+	{
+	pn = pk;
+	t = 1.0;
+	}
+else
+	{
+	pn = pn + 1.0/n;
+	t = 1.0/fn;
+	}
+s = (pk+pn-tlg)*t;
+k = 1.0;
+do
+	{
+	t *= z0 / (k * (k+n));
+	pk += 1.0/k;
+	pn += 1.0/(k+n);
+	s += (pk+pn-tlg)*t;
+	k += 1.0;
+	}
+while( fabs(t/s) > MACHEP );
+
+s = 0.5 * s / zmn;
+if( n & 1 )
+	s = -s;
+ans += s;
+
+return(ans);
+
+
+
+/* Asymptotic expansion for Kn(x) */
+/* Converges to 1.4e-17 for x > 18.4 */
+
+asymp:
+
+if( x > MAXLOG )
+	{
+	mtherr( "kn", UNDERFLOW );
+	return(0.0);
+	}
+k = n;
+pn = 4.0 * k * k;
+pk = 1.0;
+z0 = 8.0 * x;
+fn = 1.0;
+t = 1.0;
+s = t;
+nkf = MAXNUM;
+i = 0;
+do
+	{
+	z = pn - pk * pk;
+	t = t * z /(fn * z0);
+	nk1f = fabs(t);
+	if( (i >= n) && (nk1f > nkf) )
+		{
+		goto adone;
+		}
+	nkf = nk1f;
+	s += t;
+	fn += 1.0;
+	pk += 2.0;
+	i += 1;
+	}
+while( fabs(t/s) > MACHEP );
+
+adone:
+ans = exp(-x) * sqrt( PI/(2.0*x) ) * s;
+return(ans);
+}
Index: sansmodels/src/cephes/kolmogorov.c
===================================================================
--- sansmodels/src/cephes/kolmogorov.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/kolmogorov.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,243 @@
+
+/* Re Kolmogorov statistics, here is Birnbaum and Tingey's formula for the
+   distribution of D+, the maximum of all positive deviations between a
+   theoretical distribution function P(x) and an empirical one Sn(x)
+   from n samples.
+
+     +
+    D  =         sup     [P(x) - S (x)]
+     n     -inf < x < inf         n
+
+
+                  [n(1-e)]
+        +            -                    v-1              n-v
+    Pr{D   > e} =    >    C    e (e + v/n)    (1 - e - v/n)
+        n            -   n v
+                    v=0
+
+    [n(1-e)] is the largest integer not exceeding n(1-e).
+    nCv is the number of combinations of n things taken v at a time.  */
+
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double pow ( double, double );
+extern double floor ( double );
+extern double lgam ( double );
+extern double exp ( double );
+extern double sqrt ( double );
+extern double log ( double );
+extern double fabs ( double );
+double smirnov ( int, double );
+double kolmogorov ( double );
+#else
+double pow (), floor (), lgam (), exp (), sqrt (), log (), fabs ();
+double smirnov (), kolmogorov ();
+#endif
+extern double MAXLOG;
+
+/* Exact Smirnov statistic, for one-sided test.  */
+double
+smirnov (n, e)
+     int n;
+     double e;
+{
+  int v, nn;
+  double evn, omevn, p, t, c, lgamnp1;
+
+  if (n <= 0 || e < 0.0 || e > 1.0)
+    return (-1.0);
+  nn = floor ((double) n * (1.0 - e));
+  p = 0.0;
+  if (n < 1013)
+    {
+      c = 1.0;
+      for (v = 0; v <= nn; v++)
+	{
+	  evn = e + ((double) v) / n;
+	  p += c * pow (evn, (double) (v - 1))
+	    * pow (1.0 - evn, (double) (n - v));
+	  /* Next combinatorial term; worst case error = 4e-15.  */
+	  c *= ((double) (n - v)) / (v + 1);
+	}
+    }
+  else
+    {
+      lgamnp1 = lgam ((double) (n + 1));
+      for (v = 0; v <= nn; v++)
+	{
+	  evn = e + ((double) v) / n;
+	  omevn = 1.0 - evn;
+	  if (fabs (omevn) > 0.0)
+	    {
+	      t = lgamnp1
+		- lgam ((double) (v + 1))
+		- lgam ((double) (n - v + 1))
+		+ (v - 1) * log (evn)
+		+ (n - v) * log (omevn);
+	      if (t > -MAXLOG)
+		p += exp (t);
+	    }
+	}
+    }
+  return (p * e);
+}
+
+
+/* Kolmogorov's limiting distribution of two-sided test, returns
+   probability that sqrt(n) * max deviation > y,
+   or that max deviation > y/sqrt(n).
+   The approximation is useful for the tail of the distribution
+   when n is large.  */
+double
+kolmogorov (y)
+     double y;
+{
+  double p, t, r, sign, x;
+
+  x = -2.0 * y * y;
+  sign = 1.0;
+  p = 0.0;
+  r = 1.0;
+  do
+    {
+      t = exp (x * r * r);
+      p += sign * t;
+      if (t == 0.0)
+	break;
+      r += 1.0;
+      sign = -sign;
+    }
+  while ((t / p) > 1.1e-16);
+  return (p + p);
+}
+
+/* Functional inverse of Smirnov distribution
+   finds e such that smirnov(n,e) = p.  */
+double
+smirnovi (n, p)
+     int n;
+     double p;
+{
+  double e, t, dpde;
+
+  if (p <= 0.0 || p > 1.0)
+    {
+      mtherr ("smirnovi", DOMAIN);
+      return 0.0;
+    }
+  /* Start with approximation p = exp(-2 n e^2).  */
+  e = sqrt (-log (p) / (2.0 * n));
+  do
+    {
+      /* Use approximate derivative in Newton iteration. */
+      t = -2.0 * n * e;
+      dpde = 2.0 * t * exp (t * e);
+      if (fabs (dpde) > 0.0)
+	t = (p - smirnov (n, e)) / dpde;
+      else
+	{
+	  mtherr ("smirnovi", UNDERFLOW);
+	  return 0.0;
+	}
+      e = e + t;
+      if (e >= 1.0 || e <= 0.0)
+	{
+	  mtherr ("smirnovi", OVERFLOW);
+	  return 0.0;
+	}
+    }
+  while (fabs (t / e) > 1e-10);
+  return (e);
+}
+
+
+/* Functional inverse of Kolmogorov statistic for two-sided test.
+   Finds y such that kolmogorov(y) = p.
+   If e = smirnovi (n,p), then kolmogi(2 * p) / sqrt(n) should
+   be close to e.  */
+double
+kolmogi (p)
+     double p;
+{
+  double y, t, dpdy;
+
+  if (p <= 0.0 || p > 1.0)
+    {
+      mtherr ("kolmogi", DOMAIN);
+      return 0.0;
+    }
+  /* Start with approximation p = 2 exp(-2 y^2).  */
+  y = sqrt (-0.5 * log (0.5 * p));
+  do
+    {
+      /* Use approximate derivative in Newton iteration. */
+      t = -2.0 * y;
+      dpdy = 4.0 * t * exp (t * y);
+      if (fabs (dpdy) > 0.0)
+	t = (p - kolmogorov (y)) / dpdy;
+      else
+	{
+	  mtherr ("kolmogi", UNDERFLOW);
+	  return 0.0;
+	}
+      y = y + t;
+    }
+  while (fabs (t / y) > 1e-10);
+  return (y);
+}
+
+
+#ifdef SALONE
+/* Type in a number.  */
+void
+getnum (s, px)
+     char *s;
+     double *px;
+{
+  char str[30];
+
+  printf (" %s (%.15e) ? ", s, *px);
+  gets (str);
+  if (str[0] == '\0' || str[0] == '\n')
+    return;
+  sscanf (str, "%lf", px);
+  printf ("%.15e\n", *px);
+}
+
+/* Type in values, get answers.  */
+void
+main ()
+{
+  int n;
+  double e, p, ps, pk, ek, y;
+
+  n = 5;
+  e = 0.0;
+  p = 0.1;
+loop:
+  ps = n;
+  getnum ("n", &ps);
+  n = ps;
+  if (n <= 0)
+    {
+      printf ("? Operator error.\n");
+      goto loop;
+    }
+  /*
+  getnum ("e", &e);
+  ps = smirnov (n, e);
+  y = sqrt ((double) n) * e;
+  printf ("y = %.4e\n", y);
+  pk = kolmogorov (y);
+  printf ("Smirnov = %.15e, Kolmogorov/2 = %.15e\n", ps, pk / 2.0);
+*/
+  getnum ("p", &p);
+  e = smirnovi (n, p);
+  printf ("Smirnov e = %.15e\n", e);
+  y = kolmogi (2.0 * p);
+  ek = y / sqrt ((double) n);
+  printf ("Kolmogorov e = %.15e\n", ek);
+  goto loop;
+}
+#endif
Index: sansmodels/src/cephes/mconf.h
===================================================================
--- sansmodels/src/cephes/mconf.h	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/mconf.h	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,200 @@
+/*							mconf.h
+ *
+ *	Common include file for math routines
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * #include "mconf.h"
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * This file contains definitions for error codes that are
+ * passed to the common error handling routine mtherr()
+ * (which see).
+ *
+ * The file also includes a conditional assembly definition
+ * for the type of computer arithmetic (IEEE, DEC, Motorola
+ * IEEE, or UNKnown).
+ * 
+ * For Digital Equipment PDP-11 and VAX computers, certain
+ * IBM systems, and others that use numbers with a 56-bit
+ * significand, the symbol DEC should be defined.  In this
+ * mode, most floating point constants are given as arrays
+ * of octal integers to eliminate decimal to binary conversion
+ * errors that might be introduced by the compiler.
+ *
+ * For little-endian computers, such as IBM PC, that follow the
+ * IEEE Standard for Binary Floating Point Arithmetic (ANSI/IEEE
+ * Std 754-1985), the symbol IBMPC should be defined.  These
+ * numbers have 53-bit significands.  In this mode, constants
+ * are provided as arrays of hexadecimal 16 bit integers.
+ *
+ * Big-endian IEEE format is denoted MIEEE.  On some RISC
+ * systems such as Sun SPARC, double precision constants
+ * must be stored on 8-byte address boundaries.  Since integer
+ * arrays may be aligned differently, the MIEEE configuration
+ * may fail on such machines.
+ *
+ * To accommodate other types of computer arithmetic, all
+ * constants are also provided in a normal decimal radix
+ * which one can hope are correctly converted to a suitable
+ * format by the available C language compiler.  To invoke
+ * this mode, define the symbol UNK.
+ *
+ * An important difference among these modes is a predefined
+ * set of machine arithmetic constants for each.  The numbers
+ * MACHEP (the machine roundoff error), MAXNUM (largest number
+ * represented), and several other parameters are preset by
+ * the configuration symbol.  Check the file const.c to
+ * ensure that these values are correct for your computer.
+ *
+ * Configurations NANS, INFINITIES, MINUSZERO, and DENORMAL
+ * may fail on many systems.  Verify that they are supposed
+ * to work on your computer.
+ */
+/*
+Cephes Math Library Release 2.3:  June, 1995
+Copyright 1984, 1987, 1989, 1995 by Stephen L. Moshier
+*/
+
+
+
+/* Define if the `long double' type works.  */
+#define HAVE_LONG_DOUBLE 1
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
+/* #undef WORDS_BIGENDIAN */
+
+/* Define if floating point words are bigendian.  */
+/* #undef FLOAT_WORDS_BIGENDIAN */
+
+/* The number of bytes in a int.  */
+#define SIZEOF_INT 4
+
+/* Define if you have the <string.h> header file.  */
+#define HAVE_STRING_H 1
+
+/* Name of package */
+#define PACKAGE "cephes"
+
+/* Version number of package */
+#define VERSION "2.7"
+
+/* Constant definitions for math error conditions
+ */
+
+#define DOMAIN		1	/* argument domain error */
+#define SING		2	/* argument singularity */
+#define OVERFLOW	3	/* overflow range error */
+#define UNDERFLOW	4	/* underflow range error */
+#define TLOSS		5	/* total loss of precision */
+#define PLOSS		6	/* partial loss of precision */
+
+#define EDOM		33
+#define ERANGE		34
+/* Complex numeral.  */
+typedef struct
+	{
+	double r;
+	double i;
+	} cmplx;
+
+#ifdef HAVE_LONG_DOUBLE
+/* Long double complex numeral.  */
+typedef struct
+	{
+	long double r;
+	long double i;
+	} cmplxl;
+#endif
+
+
+/* Type of computer arithmetic */
+
+/* PDP-11, Pro350, VAX:
+ */
+/* #define DEC 1 */
+
+/* Intel IEEE, low order words come first:
+ */
+/* #define IBMPC 1 */
+
+/* Motorola IEEE, high order words come first
+ * (Sun 680x0 workstation):
+ */
+/* #define MIEEE 1 */
+
+/* UNKnown arithmetic, invokes coefficients given in
+ * normal decimal format.  Beware of range boundary
+ * problems (MACHEP, MAXLOG, etc. in const.c) and
+ * roundoff problems in pow.c:
+ * (Sun SPARCstation)
+ */
+#define UNK 1
+
+/* If you define UNK, then be sure to set BIGENDIAN properly. */
+#ifdef FLOAT_WORDS_BIGENDIAN
+#define BIGENDIAN 1
+#else
+#define BIGENDIAN 0
+#endif
+/* Define this `volatile' if your compiler thinks
+ * that floating point arithmetic obeys the associative
+ * and distributive laws.  It will defeat some optimizations
+ * (but probably not enough of them).
+ *
+ * #define VOLATILE volatile
+ */
+#define VOLATILE
+
+/* For 12-byte long doubles on an i386, pad a 16-bit short 0
+ * to the end of real constants initialized by integer arrays.
+ *
+ * #define XPD 0,
+ *
+ * Otherwise, the type is 10 bytes long and XPD should be
+ * defined blank (e.g., Microsoft C).
+ *
+ * #define XPD
+ */
+#define XPD 0,
+
+/* Define to support tiny denormal numbers, else undefine. */
+#define DENORMAL 1
+
+/* Define to ask for infinity support, else undefine. */
+#define INFINITIES 1
+
+/* Define to ask for support of numbers that are Not-a-Number,
+   else undefine.  This may automatically define INFINITIES in some files. */
+#define NANS 1
+
+/* Define to distinguish between -0.0 and +0.0.  */
+#define MINUSZERO 1
+
+/* Define 1 for ANSI C atan2() function
+   See atan.c and clog.c. */
+#define ANSIC 1
+
+/* Get ANSI function prototypes, if you want them. */
+#if 1
+/* #ifdef __STDC__ */
+#define ANSIPROT 1
+int mtherr ( char *, int );
+#else
+int mtherr();
+#endif
+
+/* Variable for error reporting.  See mtherr.c.  */
+extern int merror;
Index: sansmodels/src/cephes/msc.mak
===================================================================
--- sansmodels/src/cephes/msc.mak	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/msc.mak	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,83 @@
+# MSDOS Microsoft C makefile for probability integrals.
+# Be sure to disable the XPD pad for long double constants
+# and set the type of computer to IBMPC in mconf.h.
+#
+CC = cl
+
+CFLAGS = /c
+# For large memory model:
+#CFLAGS=/c /AL
+
+INCS = mconf.h
+
+OBJS = bdtr.obj btdtr.obj chdtr.obj const.obj drand.obj fdtr.obj \
+gamma.obj gdtr.obj igam.obj igami.obj incbet.obj incbi.obj \
+mtherr.obj nbdtr.obj ndtr.obj ndtri.obj pdtr.obj polevl.obj \
+stdtr.obj unity.obj
+
+bdtr.obj: bdtr.c $(INCS)
+	$(CC) $(CFLAGS) bdtr.c
+
+btdtr.obj: btdtr.c $(INCS)
+	$(CC) $(CFLAGS) btdtr.c
+
+chdtr.obj: chdtr.c $(INCS)
+	$(CC) $(CFLAGS) chdtr.c
+
+const.obj: const.c $(INCS)
+	$(CC) $(CFLAGS) const.c
+
+drand.obj: drand.c $(INCS)
+	$(CC) $(CFLAGS) drand.c
+
+expx2.obj: expx2.c $(INCS)
+	$(CC) $(CFLAGS) expx2.c
+
+fdtr.obj: fdtr.c $(INCS)
+	$(CC) $(CFLAGS) fdtr.c
+
+gamma.obj: gamma.c $(INCS)
+	$(CC) $(CFLAGS) gamma.c
+
+gdtr.obj: gdtr.c $(INCS)
+	$(CC) $(CFLAGS) gdtr.c
+
+igam.obj: igam.c $(INCS)
+	$(CC) $(CFLAGS) igam.c
+
+igami.obj: igami.c $(INCS)
+	$(CC) $(CFLAGS) igami.c
+
+incbet.obj: incbet.c $(INCS)
+	$(CC) $(CFLAGS) incbet.c
+
+incbi.obj: incbi.c $(INCS)
+	$(CC) $(CFLAGS) incbi.c
+
+mtherr.obj: mtherr.c $(INCS)
+	$(CC) $(CFLAGS) mtherr.c
+
+nbdtr.obj: nbdtr.c $(INCS)
+	$(CC) $(CFLAGS) nbdtr.c
+
+ndtr.obj: ndtr.c $(INCS)
+	$(CC) $(CFLAGS) ndtr.c
+
+ndtri.obj: ndtri.c $(INCS)
+	$(CC) $(CFLAGS) ndtri.c
+
+pdtr.obj: pdtr.c $(INCS)
+	$(CC) $(CFLAGS) pdtr.c
+
+polevl.obj: polevl.c $(INCS)
+	$(CC) $(CFLAGS) polevl.c
+
+stdtr.obj: stdtr.c $(INCS)
+	$(CC) $(CFLAGS) stdtr.c
+
+unity.obj: unity.c $(INCS)
+	$(CC) $(CFLAGS) unity.c
+
+# Delete the library file before attempting to rebuild it.
+prob.lib: $(OBJS)
+	lib @msc.rsp
Index: sansmodels/src/cephes/msc.rsp
===================================================================
--- sansmodels/src/cephes/msc.rsp	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/msc.rsp	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,6 @@
+prob
+y
+bdtr btdtr chdtr drand expx2 fdtr gamma gdtr igam igami incbet &
+incbi mtherr nbdtr ndtr ndtri pdtr stdtr unity polevl const
+prob.lst
+prob
Index: sansmodels/src/cephes/mtherr.c
===================================================================
--- sansmodels/src/cephes/mtherr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/mtherr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,103 @@
+/*							mtherr.c
+ *
+ *	Library common error handling routine
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * char *fctnam;
+ * int code;
+ * int mtherr();
+ *
+ * mtherr( fctnam, code );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * This routine may be called to report one of the following
+ * error conditions (in the include file mconf.h).
+ *  
+ *   Mnemonic        Value          Significance
+ *
+ *    DOMAIN            1       argument domain error
+ *    SING              2       function singularity
+ *    OVERFLOW          3       overflow range error
+ *    UNDERFLOW         4       underflow range error
+ *    TLOSS             5       total loss of precision
+ *    PLOSS             6       partial loss of precision
+ *    EDOM             33       Unix domain error code
+ *    ERANGE           34       Unix range error code
+ *
+ * The default version of the file prints the function name,
+ * passed to it by the pointer fctnam, followed by the
+ * error condition.  The display is directed to the standard
+ * output device.  The routine then returns to the calling
+ * program.  Users may wish to modify the program to abort by
+ * calling exit() under severe error conditions such as domain
+ * errors.
+ *
+ * Since all error conditions pass control to this function,
+ * the display may be easily changed, eliminated, or directed
+ * to an error logging device.
+ *
+ * SEE ALSO:
+ *
+ * mconf.h
+ *
+ */
+
+
+/*
+Cephes Math Library Release 2.0:  April, 1987
+Copyright 1984, 1987 by Stephen L. Moshier
+Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+*/
+
+#include <stdio.h>
+#include "mconf.h"
+
+int merror = 0;
+
+/* Notice: the order of appearance of the following
+ * messages is bound to the error codes defined
+ * in mconf.h.
+ */
+static char *ermsg[7] = {
+"unknown",      /* error code 0 */
+"domain",       /* error code 1 */
+"singularity",  /* et seq.      */
+"overflow",
+"underflow",
+"total loss of precision",
+"partial loss of precision"
+};
+
+
+int mtherr( name, code )
+char *name;
+int code;
+{
+
+/* Display string passed by calling program,
+ * which is supposed to be the name of the
+ * function in which the error occurred:
+ */
+printf( "\n%s ", name );
+
+/* Set global error message word */
+merror = code;
+
+/* Display error message defined
+ * by the code argument.
+ */
+if( (code <= 0) || (code >= 7) )
+	code = 0;
+printf( "%s error\n", ermsg[code] );
+
+/* Return to calling
+ * program
+ */
+return( 0 );
+}
Index: sansmodels/src/cephes/nbdtr.c
===================================================================
--- sansmodels/src/cephes/nbdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/nbdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,189 @@
+/*							nbdtr.c
+ *
+ *	Negative binomial distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k, n;
+ * double p, y, nbdtr();
+ *
+ * y = nbdtr( k, n, p );
+ *
+ * DESCRIPTION:
+ *
+ * Returns the sum of the terms 0 through k of the negative
+ * binomial distribution:
+ *
+ *   k
+ *   --  ( n+j-1 )   n      j
+ *   >   (       )  p  (1-p)
+ *   --  (   j   )
+ *  j=0
+ *
+ * In a sequence of Bernoulli trials, this is the probability
+ * that k or fewer failures precede the nth success.
+ *
+ * The terms are not computed individually; instead the incomplete
+ * beta integral is employed, according to the formula
+ *
+ * y = nbdtr( k, n, p ) = incbet( n, k+1, p ).
+ *
+ * The arguments must be positive, with p ranging from 0 to 1.
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,p), with p between 0 and 1.
+ *
+ *               a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *    IEEE     0,100       100000      1.7e-13     8.8e-15
+ * See also incbet.c.
+ *
+ */
+
+/*							nbdtr.c
+ *
+ *	Complemented negative binomial distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k, n;
+ * double p, y, nbdtrc();
+ *
+ * y = nbdtrc( k, n, p );
+ *
+ * DESCRIPTION:
+ *
+ * Returns the sum of the terms k+1 to infinity of the negative
+ * binomial distribution:
+ *
+ *   inf
+ *   --  ( n+j-1 )   n      j
+ *   >   (       )  p  (1-p)
+ *   --  (   j   )
+ *  j=k+1
+ *
+ * The terms are not computed individually; instead the incomplete
+ * beta integral is employed, according to the formula
+ *
+ * y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
+ *
+ * The arguments must be positive, with p ranging from 0 to 1.
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,p), with p between 0 and 1.
+ *
+ *               a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *    IEEE     0,100       100000      1.7e-13     8.8e-15
+ * See also incbet.c.
+ */
+
+/*							nbdtr.c
+ *
+ *	Functional inverse of negative binomial distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k, n;
+ * double p, y, nbdtri();
+ *
+ * p = nbdtri( k, n, y );
+ *
+ * DESCRIPTION:
+ *
+ * Finds the argument p such that nbdtr(k,n,p) is equal to y.
+ *
+ * ACCURACY:
+ *
+ * Tested at random points (a,b,y), with y between 0 and 1.
+ *
+ *               a,b                     Relative error:
+ * arithmetic  domain     # trials      peak         rms
+ *    IEEE     0,100       100000      1.5e-14     8.5e-16
+ * See also incbi.c.
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double incbet ( double, double, double );
+extern double incbi ( double, double, double );
+#else
+double incbet(), incbi();
+#endif
+
+double nbdtrc( k, n, p )
+int k, n;
+double p;
+{
+double dk, dn;
+
+if( (p < 0.0) || (p > 1.0) )
+	goto domerr;
+if( k < 0 )
+	{
+domerr:
+	mtherr( "nbdtr", DOMAIN );
+	return( 0.0 );
+	}
+
+dk = k+1;
+dn = n;
+return( incbet( dk, dn, 1.0 - p ) );
+}
+
+
+
+double nbdtr( k, n, p )
+int k, n;
+double p;
+{
+double dk, dn;
+
+if( (p < 0.0) || (p > 1.0) )
+	goto domerr;
+if( k < 0 )
+	{
+domerr:
+	mtherr( "nbdtr", DOMAIN );
+	return( 0.0 );
+	}
+dk = k+1;
+dn = n;
+return( incbet( dn, dk, p ) );
+}
+
+
+
+double nbdtri( k, n, p )
+int k, n;
+double p;
+{
+double dk, dn, w;
+
+if( (p < 0.0) || (p > 1.0) )
+	goto domerr;
+if( k < 0 )
+	{
+domerr:
+	mtherr( "nbdtri", DOMAIN );
+	return( 0.0 );
+	}
+dk = k+1;
+dn = n;
+w = incbi( dn, dk, p );
+return( w );
+}
Index: sansmodels/src/cephes/ndtr.c
===================================================================
--- sansmodels/src/cephes/ndtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/ndtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,527 @@
+/*							ndtr.c
+ *
+ *	Normal distribution function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, ndtr();
+ *
+ * y = ndtr( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the area under the Gaussian probability density
+ * function, integrated from minus infinity to x:
+ *
+ *                            x
+ *                             -
+ *                   1        | |          2
+ *    ndtr(x)  = ---------    |    exp( - t /2 ) dt
+ *               sqrt(2pi)  | |
+ *                           -
+ *                          -inf.
+ *
+ *             =  ( 1 + erf(z) ) / 2
+ *             =  erfc(z) / 2
+ *
+ * where z = x/sqrt(2). Computation is via the functions
+ * erf and erfc with care to avoid error amplification in computing exp(-x^2).
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE     -13,0        30000       1.3e-15     2.2e-16
+ *
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition         value returned
+ * erfc underflow    x > 37.519379347       0.0
+ *
+ */
+
+/*							erf.c
+ *
+ *	Error function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, erf();
+ *
+ * y = erf( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * The integral is
+ *
+ *                           x 
+ *                            -
+ *                 2         | |          2
+ *   erf(x)  =  --------     |    exp( - t  ) dt.
+ *              sqrt(pi)   | |
+ *                          -
+ *                           0
+ *
+ * The magnitude of x is limited to 9.231948545 for DEC
+ * arithmetic; 1 or -1 is returned outside this range.
+ *
+ * For 0 <= |x| < 1, erf(x) = x * P4(x**2)/Q5(x**2); otherwise
+ * erf(x) = 1 - erfc(x).
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0,1         14000       4.7e-17     1.5e-17
+ *    IEEE      0,1         30000       3.7e-16     1.0e-16
+ *
+ */
+
+/*							erfc.c
+ *
+ *	Complementary error function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, erfc();
+ *
+ * y = erfc( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ *
+ *  1 - erf(x) =
+ *
+ *                           inf. 
+ *                             -
+ *                  2         | |          2
+ *   erfc(x)  =  --------     |    exp( - t  ) dt
+ *               sqrt(pi)   | |
+ *                           -
+ *                            x
+ *
+ *
+ * For small x, erfc(x) = 1 - erf(x); otherwise rational
+ * approximations are computed.
+ *
+ * A special function expx2.c is used to suppress error amplification
+ * in computing exp(-x^2).
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE      0,26.6417   30000       1.3e-15     2.2e-16
+ *
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition              value returned
+ * erfc underflow    x > 9.231948545 (DEC)       0.0
+ *
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.9:  November, 2000
+Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
+*/
+
+
+#include "mconf.h"
+
+extern double SQRTH;
+extern double MAXLOG;
+
+/* Define this macro to suppress error propagation in exp(x^2)
+   by using the expx2 function.  The tradeoff is that doing so
+   generates two calls to the exponential function instead of one.  */
+#define USE_EXPXSQ 1
+
+#ifdef UNK
+static double P[] = {
+ 2.46196981473530512524E-10,
+ 5.64189564831068821977E-1,
+ 7.46321056442269912687E0,
+ 4.86371970985681366614E1,
+ 1.96520832956077098242E2,
+ 5.26445194995477358631E2,
+ 9.34528527171957607540E2,
+ 1.02755188689515710272E3,
+ 5.57535335369399327526E2
+};
+static double Q[] = {
+/* 1.00000000000000000000E0,*/
+ 1.32281951154744992508E1,
+ 8.67072140885989742329E1,
+ 3.54937778887819891062E2,
+ 9.75708501743205489753E2,
+ 1.82390916687909736289E3,
+ 2.24633760818710981792E3,
+ 1.65666309194161350182E3,
+ 5.57535340817727675546E2
+};
+static double R[] = {
+ 5.64189583547755073984E-1,
+ 1.27536670759978104416E0,
+ 5.01905042251180477414E0,
+ 6.16021097993053585195E0,
+ 7.40974269950448939160E0,
+ 2.97886665372100240670E0
+};
+static double S[] = {
+/* 1.00000000000000000000E0,*/
+ 2.26052863220117276590E0,
+ 9.39603524938001434673E0,
+ 1.20489539808096656605E1,
+ 1.70814450747565897222E1,
+ 9.60896809063285878198E0,
+ 3.36907645100081516050E0
+};
+static double T[] = {
+ 9.60497373987051638749E0,
+ 9.00260197203842689217E1,
+ 2.23200534594684319226E3,
+ 7.00332514112805075473E3,
+ 5.55923013010394962768E4
+};
+static double U[] = {
+/* 1.00000000000000000000E0,*/
+ 3.35617141647503099647E1,
+ 5.21357949780152679795E2,
+ 4.59432382970980127987E3,
+ 2.26290000613890934246E4,
+ 4.92673942608635921086E4
+};
+
+#define UTHRESH 37.519379347
+#endif
+
+#ifdef DEC
+static unsigned short P[] = {
+0030207,0054445,0011173,0021706,
+0040020,0067272,0030661,0122075,
+0040756,0151236,0173053,0067042,
+0041502,0106175,0062555,0151457,
+0042104,0102525,0047401,0003667,
+0042403,0116176,0011446,0075303,
+0042551,0120723,0061641,0123275,
+0042600,0070651,0007264,0134516,
+0042413,0061102,0167507,0176625
+};
+static unsigned short Q[] = {
+/*0040200,0000000,0000000,0000000,*/
+0041123,0123257,0165741,0017142,
+0041655,0065027,0173413,0115450,
+0042261,0074011,0021573,0004150,
+0042563,0166530,0013662,0007200,
+0042743,0176427,0162443,0105214,
+0043014,0062546,0153727,0123772,
+0042717,0012470,0006227,0067424,
+0042413,0061103,0003042,0013254
+};
+static unsigned short R[] = {
+0040020,0067272,0101024,0155421,
+0040243,0037467,0056706,0026462,
+0040640,0116017,0120665,0034315,
+0040705,0020162,0143350,0060137,
+0040755,0016234,0134304,0130157,
+0040476,0122700,0051070,0015473
+};
+static unsigned short S[] = {
+/*0040200,0000000,0000000,0000000,*/
+0040420,0126200,0044276,0070413,
+0041026,0053051,0007302,0063746,
+0041100,0144203,0174051,0061151,
+0041210,0123314,0126343,0177646,
+0041031,0137125,0051431,0033011,
+0040527,0117362,0152661,0066201
+};
+static unsigned short T[] = {
+0041031,0126770,0170672,0166101,
+0041664,0006522,0072360,0031770,
+0043013,0100025,0162641,0126671,
+0043332,0155231,0161627,0076200,
+0044131,0024115,0021020,0117343
+};
+static unsigned short U[] = {
+/*0040200,0000000,0000000,0000000,*/
+0041406,0037461,0177575,0032714,
+0042402,0053350,0123061,0153557,
+0043217,0111227,0032007,0164217,
+0043660,0145000,0004013,0160114,
+0044100,0071544,0167107,0125471
+};
+#define UTHRESH 14.0
+#endif
+
+#ifdef IBMPC
+static unsigned short P[] = {
+0x6479,0xa24f,0xeb24,0x3df0,
+0x3488,0x4636,0x0dd7,0x3fe2,
+0x6dc4,0xdec5,0xda53,0x401d,
+0xba66,0xacad,0x518f,0x4048,
+0x20f7,0xa9e0,0x90aa,0x4068,
+0xcf58,0xc264,0x738f,0x4080,
+0x34d8,0x6c74,0x343a,0x408d,
+0x972a,0x21d6,0x0e35,0x4090,
+0xffb3,0x5de8,0x6c48,0x4081
+};
+static unsigned short Q[] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x23cc,0xfd7c,0x74d5,0x402a,
+0x7365,0xfee1,0xad42,0x4055,
+0x610d,0x246f,0x2f01,0x4076,
+0x41d0,0x02f6,0x7dab,0x408e,
+0x7151,0xfca4,0x7fa2,0x409c,
+0xf4ff,0xdafa,0x8cac,0x40a1,
+0xede2,0x0192,0xe2a7,0x4099,
+0x42d6,0x60c4,0x6c48,0x4081
+};
+static unsigned short R[] = {
+0x9b62,0x5042,0x0dd7,0x3fe2,
+0xc5a6,0xebb8,0x67e6,0x3ff4,
+0xa71a,0xf436,0x1381,0x4014,
+0x0c0c,0x58dd,0xa40e,0x4018,
+0x960e,0x9718,0xa393,0x401d,
+0x0367,0x0a47,0xd4b8,0x4007
+};
+static unsigned short S[] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xce21,0x0917,0x1590,0x4002,
+0x4cfd,0x21d8,0xcac5,0x4022,
+0x2c4d,0x7f05,0x1910,0x4028,
+0x7ff5,0x959c,0x14d9,0x4031,
+0x26c1,0xaa63,0x37ca,0x4023,
+0x2d90,0x5ab6,0xf3de,0x400a
+};
+static unsigned short T[] = {
+0x5d88,0x1e37,0x35bf,0x4023,
+0x067f,0x4e9e,0x81aa,0x4056,
+0x35b7,0xbcb4,0x7002,0x40a1,
+0xef90,0x3c72,0x5b53,0x40bb,
+0x13dc,0xa442,0x2509,0x40eb
+};
+static unsigned short U[] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xa6ba,0x3fef,0xc7e6,0x4040,
+0x3aee,0x14c6,0x4add,0x4080,
+0xfd12,0xe680,0xf252,0x40b1,
+0x7c0a,0x0101,0x1940,0x40d6,
+0xf567,0x9dc8,0x0e6c,0x40e8
+};
+#define UTHRESH 37.519379347
+#endif
+
+#ifdef MIEEE
+static unsigned short P[] = {
+0x3df0,0xeb24,0xa24f,0x6479,
+0x3fe2,0x0dd7,0x4636,0x3488,
+0x401d,0xda53,0xdec5,0x6dc4,
+0x4048,0x518f,0xacad,0xba66,
+0x4068,0x90aa,0xa9e0,0x20f7,
+0x4080,0x738f,0xc264,0xcf58,
+0x408d,0x343a,0x6c74,0x34d8,
+0x4090,0x0e35,0x21d6,0x972a,
+0x4081,0x6c48,0x5de8,0xffb3
+};
+static unsigned short Q[] = {
+0x402a,0x74d5,0xfd7c,0x23cc,
+0x4055,0xad42,0xfee1,0x7365,
+0x4076,0x2f01,0x246f,0x610d,
+0x408e,0x7dab,0x02f6,0x41d0,
+0x409c,0x7fa2,0xfca4,0x7151,
+0x40a1,0x8cac,0xdafa,0xf4ff,
+0x4099,0xe2a7,0x0192,0xede2,
+0x4081,0x6c48,0x60c4,0x42d6
+};
+static unsigned short R[] = {
+0x3fe2,0x0dd7,0x5042,0x9b62,
+0x3ff4,0x67e6,0xebb8,0xc5a6,
+0x4014,0x1381,0xf436,0xa71a,
+0x4018,0xa40e,0x58dd,0x0c0c,
+0x401d,0xa393,0x9718,0x960e,
+0x4007,0xd4b8,0x0a47,0x0367
+};
+static unsigned short S[] = {
+0x4002,0x1590,0x0917,0xce21,
+0x4022,0xcac5,0x21d8,0x4cfd,
+0x4028,0x1910,0x7f05,0x2c4d,
+0x4031,0x14d9,0x959c,0x7ff5,
+0x4023,0x37ca,0xaa63,0x26c1,
+0x400a,0xf3de,0x5ab6,0x2d90
+};
+static unsigned short T[] = {
+0x4023,0x35bf,0x1e37,0x5d88,
+0x4056,0x81aa,0x4e9e,0x067f,
+0x40a1,0x7002,0xbcb4,0x35b7,
+0x40bb,0x5b53,0x3c72,0xef90,
+0x40eb,0x2509,0xa442,0x13dc
+};
+static unsigned short U[] = {
+0x4040,0xc7e6,0x3fef,0xa6ba,
+0x4080,0x4add,0x14c6,0x3aee,
+0x40b1,0xf252,0xe680,0xfd12,
+0x40d6,0x1940,0x0101,0x7c0a,
+0x40e8,0x0e6c,0x9dc8,0xf567
+};
+#define UTHRESH 37.519379347
+#endif
+
+#ifdef ANSIPROT
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double exp ( double );
+extern double log ( double );
+extern double fabs ( double );
+extern double sqrt ( double );
+extern double expx2 ( double, int );
+double erf ( double );
+double erfc ( double );
+static double erfce ( double );
+#else
+double polevl(), p1evl(), exp(), log(), fabs();
+double erf(), erfc(), expx2(), sqrt();
+static double erfce();
+#endif
+
+double ndtr(a)
+double a;
+{
+double x, y, z;
+
+x = a * SQRTH;
+z = fabs(x);
+
+/* if( z < SQRTH ) */
+if( z < 1.0 )
+	y = 0.5 + 0.5 * erf(x);
+
+else
+	{
+#ifdef USE_EXPXSQ
+	/* See below for erfce. */
+	y = 0.5 * erfce(z);
+	/* Multiply by exp(-x^2 / 2)  */
+	z = expx2(a, -1);
+	y = y * sqrt(z);
+#else
+	y = 0.5 * erfc(z);
+#endif
+	if( x > 0 )
+		y = 1.0 - y;
+	}
+
+return(y);
+}
+
+
+double erfc(a)
+double a;
+{
+double p,q,x,y,z;
+
+
+if( a < 0.0 )
+	x = -a;
+else
+	x = a;
+
+if( x < 1.0 )
+	return( 1.0 - erf(a) );
+
+z = -a * a;
+
+if( z < -MAXLOG )
+	{
+under:
+	mtherr( "erfc", UNDERFLOW );
+	if( a < 0 )
+		return( 2.0 );
+	else
+		return( 0.0 );
+	}
+
+#ifdef USE_EXPXSQ
+/* Compute z = exp(z).  */
+z = expx2(a, -1);
+#else
+z = exp(z);
+#endif
+if( x < 8.0 )
+	{
+	p = polevl( x, P, 8 );
+	q = p1evl( x, Q, 8 );
+	}
+else
+	{
+	p = polevl( x, R, 5 );
+	q = p1evl( x, S, 6 );
+	}
+y = (z * p)/q;
+
+if( a < 0 )
+	y = 2.0 - y;
+
+if( y == 0.0 )
+	goto under;
+
+return(y);
+}
+
+
+/* Exponentially scaled erfc function
+   exp(x^2) erfc(x)
+   valid for x > 1.
+   Use with ndtr and expx2.  */
+static double erfce(x)
+double x;
+{
+double p,q;
+
+if( x < 8.0 )
+	{
+	p = polevl( x, P, 8 );
+	q = p1evl( x, Q, 8 );
+	}
+else
+	{
+	p = polevl( x, R, 5 );
+	q = p1evl( x, S, 6 );
+	}
+return (p/q);
+}
+
+
+
+double erf(x)
+double x;
+{
+double y, z;
+
+if( fabs(x) > 1.0 )
+	return( 1.0 - erfc(x) );
+z = x * x;
+y = x * polevl( z, T, 4 ) / p1evl( z, U, 5 );
+return( y );
+
+}
Index: sansmodels/src/cephes/ndtri.c
===================================================================
--- sansmodels/src/cephes/ndtri.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/ndtri.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,418 @@
+/*							ndtri.c
+ *
+ *	Inverse of Normal distribution function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, ndtri();
+ *
+ * x = ndtri( y );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the argument, x, for which the area under the
+ * Gaussian probability density function (integrated from
+ * minus infinity to x) is equal to y.
+ *
+ *
+ * For small arguments 0 < y < exp(-2), the program computes
+ * z = sqrt( -2.0 * log(y) );  then the approximation is
+ * x = z - log(z)/z  - (1/z) P(1/z) / Q(1/z).
+ * There are two rational functions P/Q, one for 0 < y < exp(-32)
+ * and the other for y up to exp(-2).  For larger arguments,
+ * w = y - 0.5, and  x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)).
+ *
+ *
+ * ACCURACY:
+ *
+ *                      Relative error:
+ * arithmetic   domain        # trials      peak         rms
+ *    DEC      0.125, 1         5500       9.5e-17     2.1e-17
+ *    DEC      6e-39, 0.135     3500       5.7e-17     1.3e-17
+ *    IEEE     0.125, 1        20000       7.2e-16     1.3e-16
+ *    IEEE     3e-308, 0.135   50000       4.6e-16     9.8e-17
+ *
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition    value returned
+ * ndtri domain       x <= 0        -MAXNUM
+ * ndtri domain       x >= 1         MAXNUM
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+extern double MAXNUM;
+
+#ifdef UNK
+/* sqrt(2pi) */
+static double s2pi = 2.50662827463100050242E0;
+#endif
+
+#ifdef DEC
+static unsigned short s2p[] = {0040440,0066230,0177661,0034055};
+#define s2pi *(double *)s2p
+#endif
+
+#ifdef IBMPC
+static unsigned short s2p[] = {0x2706,0x1ff6,0x0d93,0x4004};
+#define s2pi *(double *)s2p
+#endif
+
+#ifdef MIEEE
+static unsigned short s2p[] = {
+0x4004,0x0d93,0x1ff6,0x2706
+};
+#define s2pi *(double *)s2p
+#endif
+
+/* approximation for 0 <= |y - 0.5| <= 3/8 */
+#ifdef UNK
+static double P0[5] = {
+-5.99633501014107895267E1,
+ 9.80010754185999661536E1,
+-5.66762857469070293439E1,
+ 1.39312609387279679503E1,
+-1.23916583867381258016E0,
+};
+static double Q0[8] = {
+/* 1.00000000000000000000E0,*/
+ 1.95448858338141759834E0,
+ 4.67627912898881538453E0,
+ 8.63602421390890590575E1,
+-2.25462687854119370527E2,
+ 2.00260212380060660359E2,
+-8.20372256168333339912E1,
+ 1.59056225126211695515E1,
+-1.18331621121330003142E0,
+};
+#endif
+#ifdef DEC
+static unsigned short P0[20] = {
+0141557,0155170,0071360,0120550,
+0041704,0000214,0172417,0067307,
+0141542,0132204,0040066,0156723,
+0041136,0163161,0157276,0007747,
+0140236,0116374,0073666,0051764,
+};
+static unsigned short Q0[32] = {
+/*0040200,0000000,0000000,0000000,*/
+0040372,0026256,0110403,0123707,
+0040625,0122024,0020277,0026661,
+0041654,0134161,0124134,0007244,
+0142141,0073162,0133021,0131371,
+0042110,0041235,0043516,0057767,
+0141644,0011417,0036155,0137305,
+0041176,0076556,0004043,0125430,
+0140227,0073347,0152776,0067251,
+};
+#endif
+#ifdef IBMPC
+static unsigned short P0[20] = {
+0x142d,0x0e5e,0xfb4f,0xc04d,
+0xedd9,0x9ea1,0x8011,0x4058,
+0xdbba,0x8806,0x5690,0xc04c,
+0xc1fd,0x3bd7,0xdcce,0x402b,
+0xca7e,0x8ef6,0xd39f,0xbff3,
+};
+static unsigned short Q0[36] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0x74f9,0xd220,0x4595,0x3fff,
+0xe5b6,0x8417,0xb482,0x4012,
+0x81d4,0x350b,0x970e,0x4055,
+0x365f,0x56c2,0x2ece,0xc06c,
+0xcbff,0xa8e9,0x0853,0x4069,
+0xb7d9,0xe78d,0x8261,0xc054,
+0x7563,0xc104,0xcfad,0x402f,
+0xcdd5,0xfabf,0xeedc,0xbff2,
+};
+#endif
+#ifdef MIEEE
+static unsigned short P0[20] = {
+0xc04d,0xfb4f,0x0e5e,0x142d,
+0x4058,0x8011,0x9ea1,0xedd9,
+0xc04c,0x5690,0x8806,0xdbba,
+0x402b,0xdcce,0x3bd7,0xc1fd,
+0xbff3,0xd39f,0x8ef6,0xca7e,
+};
+static unsigned short Q0[32] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x3fff,0x4595,0xd220,0x74f9,
+0x4012,0xb482,0x8417,0xe5b6,
+0x4055,0x970e,0x350b,0x81d4,
+0xc06c,0x2ece,0x56c2,0x365f,
+0x4069,0x0853,0xa8e9,0xcbff,
+0xc054,0x8261,0xe78d,0xb7d9,
+0x402f,0xcfad,0xc104,0x7563,
+0xbff2,0xeedc,0xfabf,0xcdd5,
+};
+#endif
+
+
+/* Approximation for interval z = sqrt(-2 log y ) between 2 and 8
+ * i.e., y between exp(-2) = .135 and exp(-32) = 1.27e-14.
+ */
+#ifdef UNK
+static double P1[9] = {
+ 4.05544892305962419923E0,
+ 3.15251094599893866154E1,
+ 5.71628192246421288162E1,
+ 4.40805073893200834700E1,
+ 1.46849561928858024014E1,
+ 2.18663306850790267539E0,
+-1.40256079171354495875E-1,
+-3.50424626827848203418E-2,
+-8.57456785154685413611E-4,
+};
+static double Q1[8] = {
+/*  1.00000000000000000000E0,*/
+ 1.57799883256466749731E1,
+ 4.53907635128879210584E1,
+ 4.13172038254672030440E1,
+ 1.50425385692907503408E1,
+ 2.50464946208309415979E0,
+-1.42182922854787788574E-1,
+-3.80806407691578277194E-2,
+-9.33259480895457427372E-4,
+};
+#endif
+#ifdef DEC
+static unsigned short P1[36] = {
+0040601,0143074,0150744,0073326,
+0041374,0031554,0113253,0146016,
+0041544,0123272,0012463,0176771,
+0041460,0051160,0103560,0156511,
+0041152,0172624,0117772,0030755,
+0040413,0170713,0151545,0176413,
+0137417,0117512,0022154,0131671,
+0137017,0104257,0071432,0007072,
+0135540,0143363,0063137,0036166,
+};
+static unsigned short Q1[32] = {
+/*0040200,0000000,0000000,0000000,*/
+0041174,0075325,0004736,0120326,
+0041465,0110044,0047561,0045567,
+0041445,0042321,0012142,0030340,
+0041160,0127074,0166076,0141051,
+0040440,0046055,0040745,0150400,
+0137421,0114146,0067330,0010621,
+0137033,0175162,0025555,0114351,
+0135564,0122773,0145750,0030357,
+};
+#endif
+#ifdef IBMPC
+static unsigned short P1[36] = {
+0x8edb,0x9a3c,0x38c7,0x4010,
+0x7982,0x92d5,0x866d,0x403f,
+0x7fbf,0x42a6,0x94d7,0x404c,
+0x1ba9,0x10ee,0x0a4e,0x4046,
+0x463e,0x93ff,0x5eb2,0x402d,
+0xbfa1,0x7a6c,0x7e39,0x4001,
+0x9677,0x448d,0xf3e9,0xbfc1,
+0x41c7,0xee63,0xf115,0xbfa1,
+0xe78f,0x6ccb,0x18de,0xbf4c,
+};
+static unsigned short Q1[32] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xd41b,0xa13b,0x8f5a,0x402f,
+0x296f,0x89ee,0xb204,0x4046,
+0x461c,0x228c,0xa89a,0x4044,
+0xd845,0x9d87,0x15c7,0x402e,
+0xba20,0xa83c,0x0985,0x4004,
+0x0232,0xcddb,0x330c,0xbfc2,
+0xb31d,0x456d,0x7f4e,0xbfa3,
+0x061e,0x797d,0x94bf,0xbf4e,
+};
+#endif
+#ifdef MIEEE
+static unsigned short P1[36] = {
+0x4010,0x38c7,0x9a3c,0x8edb,
+0x403f,0x866d,0x92d5,0x7982,
+0x404c,0x94d7,0x42a6,0x7fbf,
+0x4046,0x0a4e,0x10ee,0x1ba9,
+0x402d,0x5eb2,0x93ff,0x463e,
+0x4001,0x7e39,0x7a6c,0xbfa1,
+0xbfc1,0xf3e9,0x448d,0x9677,
+0xbfa1,0xf115,0xee63,0x41c7,
+0xbf4c,0x18de,0x6ccb,0xe78f,
+};
+static unsigned short Q1[32] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x402f,0x8f5a,0xa13b,0xd41b,
+0x4046,0xb204,0x89ee,0x296f,
+0x4044,0xa89a,0x228c,0x461c,
+0x402e,0x15c7,0x9d87,0xd845,
+0x4004,0x0985,0xa83c,0xba20,
+0xbfc2,0x330c,0xcddb,0x0232,
+0xbfa3,0x7f4e,0x456d,0xb31d,
+0xbf4e,0x94bf,0x797d,0x061e,
+};
+#endif
+
+/* Approximation for interval z = sqrt(-2 log y ) between 8 and 64
+ * i.e., y between exp(-32) = 1.27e-14 and exp(-2048) = 3.67e-890.
+ */
+
+#ifdef UNK
+static double P2[9] = {
+  3.23774891776946035970E0,
+  6.91522889068984211695E0,
+  3.93881025292474443415E0,
+  1.33303460815807542389E0,
+  2.01485389549179081538E-1,
+  1.23716634817820021358E-2,
+  3.01581553508235416007E-4,
+  2.65806974686737550832E-6,
+  6.23974539184983293730E-9,
+};
+static double Q2[8] = {
+/*  1.00000000000000000000E0,*/
+  6.02427039364742014255E0,
+  3.67983563856160859403E0,
+  1.37702099489081330271E0,
+  2.16236993594496635890E-1,
+  1.34204006088543189037E-2,
+  3.28014464682127739104E-4,
+  2.89247864745380683936E-6,
+  6.79019408009981274425E-9,
+};
+#endif
+#ifdef DEC
+static unsigned short P2[36] = {
+0040517,0033507,0036236,0125641,
+0040735,0044616,0014473,0140133,
+0040574,0012567,0114535,0102541,
+0040252,0120340,0143474,0150135,
+0037516,0051057,0115361,0031211,
+0036512,0131204,0101511,0125144,
+0035236,0016627,0043160,0140216,
+0033462,0060512,0060141,0010641,
+0031326,0062541,0101304,0077706,
+};
+static unsigned short Q2[32] = {
+/*0040200,0000000,0000000,0000000,*/
+0040700,0143322,0132137,0040501,
+0040553,0101155,0053221,0140257,
+0040260,0041071,0052573,0010004,
+0037535,0066472,0177261,0162330,
+0036533,0160475,0066666,0036132,
+0035253,0174533,0027771,0044027,
+0033502,0016147,0117666,0063671,
+0031351,0047455,0141663,0054751,
+};
+#endif
+#ifdef IBMPC
+static unsigned short P2[36] = {
+0xd574,0xe793,0xe6e8,0x4009,
+0x780b,0xc327,0xa931,0x401b,
+0xb0ac,0xf32b,0x82ae,0x400f,
+0x9a0c,0x18e7,0x541c,0x3ff5,
+0x2651,0xf35e,0xca45,0x3fc9,
+0x354d,0x9069,0x5650,0x3f89,
+0x1812,0xe8ce,0xc3b2,0x3f33,
+0x2234,0x4c0c,0x4c29,0x3ec6,
+0x8ff9,0x3058,0xccac,0x3e3a,
+};
+static unsigned short Q2[32] = {
+/*0x0000,0x0000,0x0000,0x3ff0,*/
+0xe828,0x568b,0x18da,0x4018,
+0x3816,0xaad2,0x704d,0x400d,
+0x6200,0x2aaf,0x0847,0x3ff6,
+0x3c9b,0x5fd6,0xada7,0x3fcb,
+0xc78b,0xadb6,0x7c27,0x3f8b,
+0x2903,0x65ff,0x7f2b,0x3f35,
+0xccf7,0xf3f6,0x438c,0x3ec8,
+0x6b3d,0xb876,0x29e5,0x3e3d,
+};
+#endif
+#ifdef MIEEE
+static unsigned short P2[36] = {
+0x4009,0xe6e8,0xe793,0xd574,
+0x401b,0xa931,0xc327,0x780b,
+0x400f,0x82ae,0xf32b,0xb0ac,
+0x3ff5,0x541c,0x18e7,0x9a0c,
+0x3fc9,0xca45,0xf35e,0x2651,
+0x3f89,0x5650,0x9069,0x354d,
+0x3f33,0xc3b2,0xe8ce,0x1812,
+0x3ec6,0x4c29,0x4c0c,0x2234,
+0x3e3a,0xccac,0x3058,0x8ff9,
+};
+static unsigned short Q2[32] = {
+/*0x3ff0,0x0000,0x0000,0x0000,*/
+0x4018,0x18da,0x568b,0xe828,
+0x400d,0x704d,0xaad2,0x3816,
+0x3ff6,0x0847,0x2aaf,0x6200,
+0x3fcb,0xada7,0x5fd6,0x3c9b,
+0x3f8b,0x7c27,0xadb6,0xc78b,
+0x3f35,0x7f2b,0x65ff,0x2903,
+0x3ec8,0x438c,0xf3f6,0xccf7,
+0x3e3d,0x29e5,0xb876,0x6b3d,
+};
+#endif
+
+#ifdef ANSIPROT
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double log ( double );
+extern double sqrt ( double );
+#else
+double polevl(), p1evl(), log(), sqrt();
+#endif
+
+double ndtri(y0)
+double y0;
+{
+double x, y, z, y2, x0, x1;
+int code;
+
+if( y0 <= 0.0 )
+	{
+	mtherr( "ndtri", DOMAIN );
+	return( -MAXNUM );
+	}
+if( y0 >= 1.0 )
+	{
+	mtherr( "ndtri", DOMAIN );
+	return( MAXNUM );
+	}
+code = 1;
+y = y0;
+if( y > (1.0 - 0.13533528323661269189) ) /* 0.135... = exp(-2) */
+	{
+	y = 1.0 - y;
+	code = 0;
+	}
+
+if( y > 0.13533528323661269189 )
+	{
+	y = y - 0.5;
+	y2 = y * y;
+	x = y + y * (y2 * polevl( y2, P0, 4)/p1evl( y2, Q0, 8 ));
+	x = x * s2pi; 
+	return(x);
+	}
+
+x = sqrt( -2.0 * log(y) );
+x0 = x - log(x)/x;
+
+z = 1.0/x;
+if( x < 8.0 ) /* y > exp(-32) = 1.2664165549e-14 */
+	x1 = z * polevl( z, P1, 8 )/p1evl( z, Q1, 8 );
+else
+	x1 = z * polevl( z, P2, 8 )/p1evl( z, Q2, 8 );
+x = x0 - x1;
+if( code != 0 )
+	x = -x;
+return( x );
+}
Index: sansmodels/src/cephes/pdtr.c
===================================================================
--- sansmodels/src/cephes/pdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/pdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,187 @@
+/*							pdtr.c
+ *
+ *	Poisson distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k;
+ * double m, y, pdtr();
+ *
+ * y = pdtr( k, m );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the sum of the first k terms of the Poisson
+ * distribution:
+ *
+ *   k         j
+ *   --   -m  m
+ *   >   e    --
+ *   --       j!
+ *  j=0
+ *
+ * The terms are not summed directly; instead the incomplete
+ * gamma integral is employed, according to the relation
+ *
+ * y = pdtr( k, m ) = igamc( k+1, m ).
+ *
+ * The arguments must both be positive.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * See igamc().
+ *
+ */
+
+/*							pdtrc()
+ *
+ *	Complemented poisson distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k;
+ * double m, y, pdtrc();
+ *
+ * y = pdtrc( k, m );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns the sum of the terms k+1 to infinity of the Poisson
+ * distribution:
+ *
+ *  inf.       j
+ *   --   -m  m
+ *   >   e    --
+ *   --       j!
+ *  j=k+1
+ *
+ * The terms are not summed directly; instead the incomplete
+ * gamma integral is employed, according to the formula
+ *
+ * y = pdtrc( k, m ) = igam( k+1, m ).
+ *
+ * The arguments must both be positive.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * See igam.c.
+ *
+ */
+
+/*							pdtri()
+ *
+ *	Inverse Poisson distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int k;
+ * double m, y, pdtr();
+ *
+ * m = pdtri( k, y );
+ *
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Finds the Poisson variable x such that the integral
+ * from 0 to x of the Poisson density is equal to the
+ * given probability y.
+ *
+ * This is accomplished using the inverse gamma integral
+ * function and the relation
+ *
+ *    m = igami( k+1, y ).
+ *
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * See igami.c.
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * pdtri domain    y < 0 or y >= 1       0.0
+ *                     k < 0
+ *
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double igam ( double, double );
+extern double igamc ( double, double );
+extern double igami ( double, double );
+#else
+double igam(), igamc(), igami();
+#endif
+
+double pdtrc( k, m )
+int k;
+double m;
+{
+double v;
+
+if( (k < 0) || (m <= 0.0) )
+	{
+	mtherr( "pdtrc", DOMAIN );
+	return( 0.0 );
+	}
+v = k+1;
+return( igam( v, m ) );
+}
+
+
+
+double pdtr( k, m )
+int k;
+double m;
+{
+double v;
+
+if( (k < 0) || (m <= 0.0) )
+	{
+	mtherr( "pdtr", DOMAIN );
+	return( 0.0 );
+	}
+v = k+1;
+return( igamc( v, m ) );
+}
+
+
+double pdtri( k, y )
+int k;
+double y;
+{
+double v;
+
+if( (k < 0) || (y < 0.0) || (y >= 1.0) )
+	{
+	mtherr( "pdtri", DOMAIN );
+	return( 0.0 );
+	}
+v = k+1;
+v = igami( v, y );
+return( v );
+}
Index: sansmodels/src/cephes/polevl.c
===================================================================
--- sansmodels/src/cephes/polevl.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/polevl.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,98 @@
+/*							polevl.c
+ *							p1evl.c
+ *
+ *	Evaluate polynomial
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * int N;
+ * double x, y, coef[N+1], polevl[];
+ *
+ * y = polevl( x, coef, N );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Evaluates polynomial of degree N:
+ *
+ *                     2          N
+ * y  =  C  + C x + C x  +...+ C x
+ *        0    1     2          N
+ *
+ * Coefficients are stored in reverse order:
+ *
+ * coef[0] = C  , ..., coef[N] = C  .
+ *            N                   0
+ *
+ *  The function p1evl() assumes that coef[N] = 1.0 and is
+ * omitted from the array.  Its calling arguments are
+ * otherwise the same as polevl().
+ *
+ *
+ * SPEED:
+ *
+ * In the interest of speed, there are no checks for out
+ * of bounds arithmetic.  This routine is used by most of
+ * the functions in the library.  Depending on available
+ * equipment features, the user may wish to rewrite the
+ * program in microcode or assembly language.
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.1:  December, 1988
+Copyright 1984, 1987, 1988 by Stephen L. Moshier
+Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+*/
+
+
+double polevl( x, coef, N )
+double x;
+double coef[];
+int N;
+{
+double ans;
+int i;
+double *p;
+
+p = coef;
+ans = *p++;
+i = N;
+
+do
+	ans = ans * x  +  *p++;
+while( --i );
+
+return( ans );
+}
+
+/*							p1evl()	*/
+/*                                          N
+ * Evaluate polynomial when coefficient of x  is 1.0.
+ * Otherwise same as polevl.
+ */
+
+double p1evl( x, coef, N )
+double x;
+double coef[];
+int N;
+{
+double ans;
+double *p;
+int i;
+
+p = coef;
+ans = x + *p++;
+i = N-1;
+
+do
+	ans = ans * x  + *p++;
+while( --i );
+
+return( ans );
+}
Index: sansmodels/src/cephes/protos.h
===================================================================
--- sansmodels/src/cephes/protos.h	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/protos.h	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,184 @@
+/*
+ *   This file was automatically generated by version 1.7 of cextract.
+ *   Manual editing not recommended.
+ *
+ *   Created: Fri Mar 31 19:17:33 1995
+ */
+extern double acosh ( double x );
+extern int airy ( double, double *, double *, double *, double * );
+extern double asin ( double );
+extern double acos ( double );
+extern double asinh ( double x );
+extern double atan ( double );
+extern double atan2 ( double y, double x );
+extern double atanh ( double );
+extern double bdtrc ( int k, int n, double p );
+extern double bdtr ( int k, int n, double p );
+extern double bdtri ( int k, int n, double y );
+extern double beta ( double a, double b );
+extern double lbeta ( double a, double b );
+extern double btdtr ( double a, double b, double x );
+extern double cbrt ( double );
+extern double chbevl ( double, void *, int );
+extern double chdtrc ( double df, double x );
+extern double chdtr ( double df, double x );
+extern double chdtri ( double df, double y );
+extern void clog ( cmplx *z, cmplx *w );
+extern void cexp ( cmplx *z, cmplx *w );
+extern void csin ( cmplx *z, cmplx *w );
+extern void ccos ( cmplx *z, cmplx *w );
+extern void ctan ( cmplx *z, cmplx *w );
+extern void ccot ( cmplx *z, cmplx *w );
+extern void casin ( cmplx *z, cmplx *w );
+extern void cacos ( cmplx *z, cmplx *w );
+extern void catan ( cmplx *z, cmplx *w );
+extern void cadd ( cmplx *a, cmplx *b, cmplx *c );
+extern void csub ( cmplx *a, cmplx *b, cmplx *c );
+extern void cmul ( cmplx *a, cmplx *b, cmplx *c );
+extern void cdiv ( cmplx *a, cmplx *b, cmplx *c );
+extern void cmov ( void *a, void *b );
+extern void cneg ( cmplx *a );
+extern double cabs ( cmplx *z );
+extern void csqrt ( cmplx *z, cmplx *w );
+extern double hypot ( double, double );
+extern double cosh ( double );
+extern double dawsn ( double xx );
+extern void eigens ( double A[], double RR[], double E[], int N );
+extern double ellie ( double, double );
+extern double ellik ( double, double );
+extern double ellpe ( double );
+extern int ellpj ( double u, double m, double *sn, double *cn, double *dn, double *ph );
+extern double ellpk ( double );
+extern double exp10 ( double );
+extern double exp1m ( double );
+extern double exp2 ( double );
+extern double expn ( int n, double x );
+extern double fac ( int i );
+extern double fdtrc ( int ia, int ib, double x );
+extern double fdtr ( int ia, int ib, double x );
+extern double fdtri ( int ia, int ib, double y );
+extern int fftr ( double x[], int m0, double sine[] );
+extern double ceil ( double x );
+extern double fabs ( double );
+extern double floor ( double );
+extern double frexp ( double, int * );
+extern double ldexp ( double, int );
+//extern int signbit ( double );
+//extern int isnan ( double );
+//extern int isfinite ( double );
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double exp ( double );
+extern double log ( double );
+extern double sin ( double );
+extern double cos ( double );
+extern double sqrt ( double );
+extern int fresnl ( double xxa, double *ssa, double *cca );
+extern double gamma ( double );
+extern double lgam ( double );
+extern double gdtr ( double a, double b, double x );
+extern double gdtrc ( double a, double b, double x );
+extern int gels ( double A[], double R[], int M, double EPS, double AUX[] );
+extern double hyp2f1 ( double a, double b, double c, double x );
+extern double hyperg ( double, double, double );
+extern double hyp2f0 ( double a, double b, double x, int type, double *err );
+extern double i0 ( double );
+extern double i0e ( double x );
+extern double i1 ( double );
+extern double i1e ( double x );
+extern double igamc ( double, double );
+extern double igam ( double, double );
+extern double igami ( double, double );
+extern double incbet ( double, double, double );
+extern double incbi ( double, double, double );
+extern double iv ( double v, double x );
+extern double j0 ( double );
+extern double y0 ( double );
+extern double j1 ( double );
+extern double y1 ( double );
+extern double jn ( int n, double x );
+extern double jv ( double, double );
+extern double k0 ( double x );
+extern double k0e ( double x );
+extern double k1 ( double x );
+extern double k1e ( double x );
+extern double kn ( int nn, double x );
+extern int levnsn ( int n, double r[], double a[], double e[], double refl[] );
+extern double log10 ( double );
+extern double log2 ( double );
+extern long lrand ( void );
+extern long lsqrt ( long x );
+extern int minv ( double A[], double X[], int n, double B[], int IPS[] );
+extern int mmmpy ( int r, int c, double *A, double *B, double *Y );
+extern int mtherr ( char *name, int code );
+extern int mtransp ( int n, double *A, double *T );
+extern int mvmpy ( int r, int c, double *A, double *V, double *Y );
+extern double nbdtrc ( int k, int n, double p );
+extern double nbdtr ( int k, int n, double p );
+extern double nbdtri ( int k, int n, double p );
+extern double ndtr ( double a );
+extern double erfc ( double );
+extern double erf ( double );
+extern double ndtri ( double );
+extern double pdtrc ( int k, double m );
+extern double pdtr ( int k, double m );
+extern double pdtri ( int k, double y );
+extern double pow ( double, double );
+extern double powi ( double, int );
+extern double psi ( double );
+extern void revers ( double y[], double x[], int n );
+extern double rgamma ( double x );
+extern double round ( double );
+extern int sprec ( void );
+extern int dprec ( void );
+extern int ldprec ( void );
+extern int shichi ( double x, double *si, double *ci );
+extern int sici ( double x, double *si, double *ci );
+extern double simpsn ( double f[], double delta );
+extern int simq ( double A[], double B[], double X[], int n, int flag, int IPS[] );
+extern double radian ( double d, double m, double s );
+/*
+extern int sincos ( double x, double *s, double *c, int flg );
+*/
+extern double sindg ( double x );
+extern double cosdg ( double x );
+extern double sinh ( double );
+extern double spence ( double );
+extern double stdtr ( int k, double t );
+extern double stdtri ( int k, double p );
+extern double onef2 ( double a, double b, double c, double x, double *err );
+extern double threef0 ( double a, double b, double c, double x, double *err );
+extern double struve ( double v, double x );
+extern double tan ( double );
+extern double cot ( double );
+extern double tandg ( double x );
+extern double cotdg ( double x );
+extern double tanh ( double );
+extern double log1p ( double );
+extern double exmp1 ( double );
+extern double cosm1 ( double x );
+extern double yn ( int, double );
+extern double zeta ( double x, double q );
+extern double zetac ( double );
+extern int drand ( double *a );
+double smirnov ( int, double );
+double smirnovi ( int, double );
+double kolmogorov ( double );
+double kolmogi ( double );
+
+/* polyn.c */
+extern void polini ( int maxdeg );
+extern void polprt ( double a[], int na, int d );
+extern void polclr ( double *a, int n );
+extern void polmov ( double *a, int na, double *b );
+extern void polmul ( double a[], int na, double b[], int nb, double c[] );
+extern void poladd ( double a[], int na, double b[], int nb, double c[] );
+extern void polsub ( double a[], int na, double b[], int nb, double c[] );
+extern int poldiv ( double a[], int na, double b[], int nb, double c[] );
+extern void polsbt ( double a[], int na, double b[], int nb, double c[] );
+extern double poleva ( double a[], int na, double x );
+/* polmisc.c */
+extern void polatn ( double num[], double den[], double ans[], int nn );
+extern void polsqt ( double pol[], double ans[], int nn );
+extern void polsin ( double x[], double y[], int nn );
+extern void polcos ( double x[], double y[], int nn );
Index: sansmodels/src/cephes/psi.c
===================================================================
--- sansmodels/src/cephes/psi.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/psi.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,202 @@
+/*							psi.c
+ *
+ *	Psi (digamma) function
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, psi();
+ *
+ * y = psi( x );
+ *
+ *
+ * DESCRIPTION:
+ *
+ *              d      -
+ *   psi(x)  =  -- ln | (x)
+ *              dx
+ *
+ * is the logarithmic derivative of the gamma function.
+ * For integer x,
+ *                   n-1
+ *                    -
+ * psi(n) = -EUL  +   >  1/k.
+ *                    -
+ *                   k=1
+ *
+ * This formula is used for 0 < n <= 10.  If x is negative, it
+ * is transformed to a positive argument by the reflection
+ * formula  psi(1-x) = psi(x) + pi cot(pi x).
+ * For general positive x, the argument is made greater than 10
+ * using the recurrence  psi(x+1) = psi(x) + 1/x.
+ * Then the following asymptotic expansion is applied:
+ *
+ *                           inf.   B
+ *                            -      2k
+ * psi(x) = log(x) - 1/2x -   >   -------
+ *                            -        2k
+ *                           k=1   2k x
+ *
+ * where the B2k are Bernoulli numbers.
+ *
+ * ACCURACY:
+ *    Relative error (except absolute when |psi| < 1):
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0,30         2500       1.7e-16     2.0e-17
+ *    IEEE      0,30        30000       1.3e-15     1.4e-16
+ *    IEEE      -30,0       40000       1.5e-15     2.2e-16
+ *
+ * ERROR MESSAGES:
+ *     message         condition      value returned
+ * psi singularity    x integer <=0      MAXNUM
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1992, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+#ifdef UNK
+static double A[] = {
+ 8.33333333333333333333E-2,
+-2.10927960927960927961E-2,
+ 7.57575757575757575758E-3,
+-4.16666666666666666667E-3,
+ 3.96825396825396825397E-3,
+-8.33333333333333333333E-3,
+ 8.33333333333333333333E-2
+};
+#endif
+
+#ifdef DEC
+static unsigned short A[] = {
+0037252,0125252,0125252,0125253,
+0136654,0145314,0126312,0146255,
+0036370,0037017,0101740,0174076,
+0136210,0104210,0104210,0104211,
+0036202,0004040,0101010,0020202,
+0136410,0104210,0104210,0104211,
+0037252,0125252,0125252,0125253
+};
+#endif
+
+#ifdef IBMPC
+static unsigned short A[] = {
+0x5555,0x5555,0x5555,0x3fb5,
+0x5996,0x9599,0x9959,0xbf95,
+0x1f08,0xf07c,0x07c1,0x3f7f,
+0x1111,0x1111,0x1111,0xbf71,
+0x0410,0x1041,0x4104,0x3f70,
+0x1111,0x1111,0x1111,0xbf81,
+0x5555,0x5555,0x5555,0x3fb5
+};
+#endif
+
+#ifdef MIEEE
+static unsigned short A[] = {
+0x3fb5,0x5555,0x5555,0x5555,
+0xbf95,0x9959,0x9599,0x5996,
+0x3f7f,0x07c1,0xf07c,0x1f08,
+0xbf71,0x1111,0x1111,0x1111,
+0x3f70,0x4104,0x1041,0x0410,
+0xbf81,0x1111,0x1111,0x1111,
+0x3fb5,0x5555,0x5555,0x5555
+};
+#endif
+
+#define EUL 0.57721566490153286061
+
+#ifdef ANSIPROT
+extern double floor ( double );
+extern double log ( double );
+extern double tan ( double );
+extern double polevl ( double, void *, int );
+#else
+double floor(), log(), tan(), polevl();
+#endif
+extern double PI, MAXNUM;
+
+
+double psi(x)
+double x;
+{
+double p, q, nz, s, w, y, z;
+int i, n, negative;
+
+negative = 0;
+nz = 0.0;
+
+if( x <= 0.0 )
+	{
+	negative = 1;
+	q = x;
+	p = floor(q);
+	if( p == q )
+		{
+		mtherr( "psi", SING );
+		return( MAXNUM );
+		}
+/* Remove the zeros of tan(PI x)
+ * by subtracting the nearest integer from x
+ */
+	nz = q - p;
+	if( nz != 0.5 )
+		{
+		if( nz > 0.5 )
+			{
+			p += 1.0;
+			nz = q - p;
+			}
+		nz = PI/tan(PI*nz);
+		}
+	else
+		{
+		nz = 0.0;
+		}
+	x = 1.0 - x;
+	}
+
+/* check for positive integer up to 10 */
+if( (x <= 10.0) && (x == floor(x)) )
+	{
+	y = 0.0;
+	n = x;
+	for( i=1; i<n; i++ )
+		{
+		w = i;
+		y += 1.0/w;
+		}
+	y -= EUL;
+	goto done;
+	}
+
+s = x;
+w = 0.0;
+while( s < 10.0 )
+	{
+	w += 1.0/s;
+	s += 1.0;
+	}
+
+if( s < 1.0e17 )
+	{
+	z = 1.0/(s * s);
+	y = z * polevl( z, A, 6 );
+	}
+else
+	y = 0.0;
+
+y = log(s)  -  (0.5/s)  -  y  -  w;
+
+done:
+
+if( negative )
+	{
+	y -= nz;
+	}
+
+return(y);
+}
Index: sansmodels/src/cephes/stdtr.c
===================================================================
--- sansmodels/src/cephes/stdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/stdtr.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,227 @@
+/*							stdtr.c
+ *
+ *	Student's t distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double t, stdtr();
+ * short k;
+ *
+ * y = stdtr( k, t );
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Computes the integral from minus infinity to t of the Student
+ * t distribution with integer k > 0 degrees of freedom:
+ *
+ *                                      t
+ *                                      -
+ *                                     | |
+ *              -                      |         2   -(k+1)/2
+ *             | ( (k+1)/2 )           |  (     x   )
+ *       ----------------------        |  ( 1 + --- )        dx
+ *                     -               |  (      k  )
+ *       sqrt( k pi ) | ( k/2 )        |
+ *                                   | |
+ *                                    -
+ *                                   -inf.
+ * 
+ * Relation to incomplete beta integral:
+ *
+ *        1 - stdtr(k,t) = 0.5 * incbet( k/2, 1/2, z )
+ * where
+ *        z = k/(k + t**2).
+ *
+ * For t < -2, this is the method of computation.  For higher t,
+ * a direct method is derived from integration by parts.
+ * Since the function is symmetric about t=0, the area under the
+ * right tail of the density is found by calling the function
+ * with -t instead of t.
+ * 
+ * ACCURACY:
+ *
+ * Tested at random 1 <= k <= 25.  The "domain" refers to t.
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE     -100,-2      50000       5.9e-15     1.4e-15
+ *    IEEE     -2,100      500000       2.7e-15     4.9e-17
+ */
+
+
+/*							stdtri.c
+ *
+ *	Functional inverse of Student's t distribution
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double p, t, stdtri();
+ * int k;
+ *
+ * t = stdtri( k, p );
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Given probability p, finds the argument t such that stdtr(k,t)
+ * is equal to p.
+ * 
+ * ACCURACY:
+ *
+ * Tested at random 1 <= k <= 100.  The "domain" refers to p:
+ *                      Relative error:
+ * arithmetic   domain     # trials      peak         rms
+ *    IEEE    .001,.999     25000       5.7e-15     8.0e-16
+ *    IEEE    10^-6,.001    25000       2.0e-12     2.9e-14
+ */
+
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+
+extern double PI, MACHEP, MAXNUM;
+#ifdef ANSIPROT
+extern double sqrt ( double );
+extern double atan ( double );
+extern double incbet ( double, double, double );
+extern double incbi ( double, double, double );
+extern double fabs ( double );
+#else
+double sqrt(), atan(), incbet(), incbi(), fabs();
+#endif
+
+double stdtr( k, t )
+int k;
+double t;
+{
+double x, rk, z, f, tz, p, xsqk;
+int j;
+
+if( k <= 0 )
+	{
+	mtherr( "stdtr", DOMAIN );
+	return(0.0);
+	}
+
+if( t == 0 )
+	return( 0.5 );
+
+if( t < -2.0 )
+	{
+	rk = k;
+	z = rk / (rk + t * t);
+	p = 0.5 * incbet( 0.5*rk, 0.5, z );
+	return( p );
+	}
+
+/*	compute integral from -t to + t */
+
+if( t < 0 )
+	x = -t;
+else
+	x = t;
+
+rk = k;	/* degrees of freedom */
+z = 1.0 + ( x * x )/rk;
+
+/* test if k is odd or even */
+if( (k & 1) != 0)
+	{
+
+	/*	computation for odd k	*/
+
+	xsqk = x/sqrt(rk);
+	p = atan( xsqk );
+	if( k > 1 )
+		{
+		f = 1.0;
+		tz = 1.0;
+		j = 3;
+		while(  (j<=(k-2)) && ( (tz/f) > MACHEP )  )
+			{
+			tz *= (j-1)/( z * j );
+			f += tz;
+			j += 2;
+			}
+		p += f * xsqk/z;
+		}
+	p *= 2.0/PI;
+	}
+
+
+else
+	{
+
+	/*	computation for even k	*/
+
+	f = 1.0;
+	tz = 1.0;
+	j = 2;
+
+	while(  ( j <= (k-2) ) && ( (tz/f) > MACHEP )  )
+		{
+		tz *= (j - 1)/( z * j );
+		f += tz;
+		j += 2;
+		}
+	p = f * x/sqrt(z*rk);
+	}
+
+/*	common exit	*/
+
+
+if( t < 0 )
+	p = -p;	/* note destruction of relative accuracy */
+
+	p = 0.5 + 0.5 * p;
+return(p);
+}
+
+double stdtri( k, p )
+int k;
+double p;
+{
+double t, rk, z;
+int rflg;
+
+if( k <= 0 || p <= 0.0 || p >= 1.0 )
+	{
+	mtherr( "stdtri", DOMAIN );
+	return(0.0);
+	}
+
+rk = k;
+
+if( p > 0.25 && p < 0.75 )
+	{
+	if( p == 0.5 )
+		return( 0.0 );
+	z = 1.0 - 2.0 * p;
+	z = incbi( 0.5, 0.5*rk, fabs(z) );
+	t = sqrt( rk*z/(1.0-z) );
+	if( p < 0.5 )
+		t = -t;
+	return( t );
+	}
+rflg = -1;
+if( p >= 0.5)
+	{
+	p = 1.0 - p;
+	rflg = 1;
+	}
+z = incbi( 0.5*rk, 0.5, 2.0*p );
+
+if( MAXNUM * z < rk )
+	return(rflg* MAXNUM);
+t = sqrt( rk/z - rk );
+return( rflg * t );
+}
Index: sansmodels/src/cephes/struve.c
===================================================================
--- sansmodels/src/cephes/struve.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/struve.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,313 @@
+/*							struve.c
+ *
+ *      Struve function
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double v, x, y, struve();
+ *
+ * y = struve( v, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Computes the Struve function Hv(x) of order v, argument x.
+ * Negative x is rejected unless v is an integer.
+ *
+ * This module also contains the hypergeometric functions 1F2
+ * and 3F0 and a routine for the Bessel function Yv(x) with
+ * noninteger v.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Not accurately characterized, but spot checked against tables.
+ *
+ */
+
+
+
+/*
+Cephes Math Library Release 2.81:  June, 2000
+Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier
+*/
+#include "mconf.h"
+#define DEBUG 0
+#ifdef ANSIPROT
+extern double gamma ( double );
+extern double pow ( double, double );
+extern double sqrt ( double );
+extern double yn ( int, double );
+extern double jv ( double, double );
+extern double fabs ( double );
+extern double floor ( double );
+extern double sin ( double );
+extern double cos ( double );
+double yv ( double, double );
+double onef2 (double, double, double, double, double * );
+double threef0 (double, double, double, double, double * );
+#else
+double gamma(), pow(), sqrt(), yn(), yv(), jv(), fabs(), floor();
+double sin(), cos();
+double onef2(), threef0();
+#endif
+static double stop = 1.37e-17;
+extern double MACHEP;
+
+double onef2( a, b, c, x, err )
+double a, b, c, x;
+double *err;
+{
+double n, a0, sum, t;
+double an, bn, cn, max, z;
+
+an = a;
+bn = b;
+cn = c;
+a0 = 1.0;
+sum = 1.0;
+n = 1.0;
+t = 1.0;
+max = 0.0;
+
+do
+	{
+	if( an == 0 )
+		goto done;
+	if( bn == 0 )
+		goto error;
+	if( cn == 0 )
+		goto error;
+	if( (a0 > 1.0e34) || (n > 200) )
+		goto error;
+	a0 *= (an * x) / (bn * cn * n);
+	sum += a0;
+	an += 1.0;
+	bn += 1.0;
+	cn += 1.0;
+	n += 1.0;
+	z = fabs( a0 );
+	if( z > max )
+		max = z;
+	if( sum != 0 )
+		t = fabs( a0 / sum );
+	else
+		t = z;
+	}
+while( t > stop );
+
+done:
+
+*err = fabs( MACHEP*max /sum );
+
+#if DEBUG
+	printf(" onef2 cancellation error %.5E\n", *err );
+#endif
+
+goto xit;
+
+error:
+#if DEBUG
+printf("onef2 does not converge\n");
+#endif
+*err = 1.0e38;
+
+xit:
+
+#if DEBUG
+printf("onef2( %.2E %.2E %.2E %.5E ) =  %.3E  %.6E\n", a, b, c, x, n, sum);
+#endif
+return(sum);
+}
+
+
+
+
+double threef0( a, b, c, x, err )
+double a, b, c, x;
+double *err;
+{
+double n, a0, sum, t, conv, conv1;
+double an, bn, cn, max, z;
+
+an = a;
+bn = b;
+cn = c;
+a0 = 1.0;
+sum = 1.0;
+n = 1.0;
+t = 1.0;
+max = 0.0;
+conv = 1.0e38;
+conv1 = conv;
+
+do
+	{
+	if( an == 0.0 )
+		goto done;
+	if( bn == 0.0 )
+		goto done;
+	if( cn == 0.0 )
+		goto done;
+	if( (a0 > 1.0e34) || (n > 200) )
+		goto error;
+	a0 *= (an * bn * cn * x) / n;
+	an += 1.0;
+	bn += 1.0;
+	cn += 1.0;
+	n += 1.0;
+	z = fabs( a0 );
+	if( z > max )
+		max = z;
+	if( z >= conv )
+		{
+		if( (z < max) && (z > conv1) )
+			goto done;
+		}
+	conv1 = conv;
+	conv = z;
+	sum += a0;
+	if( sum != 0 )
+		t = fabs( a0 / sum );
+	else
+		t = z;
+	}
+while( t > stop );
+
+done:
+
+t = fabs( MACHEP*max/sum );
+#if DEBUG
+	printf(" threef0 cancellation error %.5E\n", t );
+#endif
+
+max = fabs( conv/sum );
+if( max > t )
+	t = max;
+#if DEBUG
+	printf(" threef0 convergence %.5E\n", max );
+#endif
+
+goto xit;
+
+error:
+#if DEBUG
+printf("threef0 does not converge\n");
+#endif
+t = 1.0e38;
+
+xit:
+
+#if DEBUG
+printf("threef0( %.2E %.2E %.2E %.5E ) =  %.3E  %.6E\n", a, b, c, x, n, sum);
+#endif
+
+*err = t;
+return(sum);
+}
+
+
+
+
+extern double PI;
+
+double struve( v, x )
+double v, x;
+{
+double y, ya, f, g, h, t;
+double onef2err, threef0err;
+
+f = floor(v);
+if( (v < 0) && ( v-f == 0.5 ) )
+	{
+	y = jv( -v, x );
+	f = 1.0 - f;
+	g =  2.0 * floor(f/2.0);
+	if( g != f )
+		y = -y;
+	return(y);
+	}
+t = 0.25*x*x;
+f = fabs(x);
+g = 1.5 * fabs(v);
+if( (f > 30.0) && (f > g) )
+	{
+	onef2err = 1.0e38;
+	y = 0.0;
+	}
+else
+	{
+	y = onef2( 1.0, 1.5, 1.5+v, -t, &onef2err );
+	}
+
+if( (f < 18.0) || (x < 0.0) )
+	{
+	threef0err = 1.0e38;
+	ya = 0.0;
+	}
+else
+	{
+	ya = threef0( 1.0, 0.5, 0.5-v, -1.0/t, &threef0err );
+	}
+
+f = sqrt( PI );
+h = pow( 0.5*x, v-1.0 );
+
+if( onef2err <= threef0err )
+	{
+	g = gamma( v + 1.5 );
+	y = y * h * t / ( 0.5 * f * g );
+	return(y);
+	}
+else
+	{
+	g = gamma( v + 0.5 );
+	ya = ya * h / ( f * g );
+	ya = ya + yv( v, x );
+	return(ya);
+	}
+}
+
+
+
+
+/* Bessel function of noninteger order
+ */
+
+double yv( v, x )
+double v, x;
+{
+double y, t;
+int n;
+
+y = floor( v );
+if( y == v )
+	{
+	n = v;
+	y = yn( n, x );
+	return( y );
+	}
+t = PI * v;
+y = (cos(t) * jv( v, x ) - jv( -v, x ))/sin(t);
+return( y );
+}
+
+/* Crossover points between ascending series and asymptotic series
+ * for Struve function
+ *
+ *	 v	 x
+ * 
+ *	 0	19.2
+ *	 1	18.95
+ *	 2	19.15
+ *	 3	19.3
+ *	 5	19.7
+ *	10	21.35
+ *	20	26.35
+ *	30	32.31
+ *	40	40.0
+ */
Index: sansmodels/src/cephes/unity.c
===================================================================
--- sansmodels/src/cephes/unity.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/unity.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,138 @@
+/*							unity.c
+ *
+ * Relative error approximations for function arguments near
+ * unity.
+ *
+ *    log1p(x) = log(1+x)
+ *    expm1(x) = exp(x) - 1
+ *    cosm1(x) = cos(x) - 1
+ *
+ */
+
+#include "mconf.h"
+
+#ifdef ANSIPROT
+extern int isnan (double);
+extern int isfinite (double);
+extern double log ( double );
+extern double polevl ( double, void *, int );
+extern double p1evl ( double, void *, int );
+extern double exp ( double );
+extern double cos ( double );
+#else
+double log(), polevl(), p1evl(), exp(), cos();
+int isnan(), isfinite();
+#endif
+extern double INFINITY;
+
+/* log1p(x) = log(1 + x)  */
+
+/* Coefficients for log(1+x) = x - x**2/2 + x**3 P(x)/Q(x)
+ * 1/sqrt(2) <= x < sqrt(2)
+ * Theoretical peak relative error = 2.32e-20
+ */
+static double LP[] = {
+ 4.5270000862445199635215E-5,
+ 4.9854102823193375972212E-1,
+ 6.5787325942061044846969E0,
+ 2.9911919328553073277375E1,
+ 6.0949667980987787057556E1,
+ 5.7112963590585538103336E1,
+ 2.0039553499201281259648E1,
+};
+static double LQ[] = {
+/* 1.0000000000000000000000E0,*/
+ 1.5062909083469192043167E1,
+ 8.3047565967967209469434E1,
+ 2.2176239823732856465394E2,
+ 3.0909872225312059774938E2,
+ 2.1642788614495947685003E2,
+ 6.0118660497603843919306E1,
+};
+
+#define SQRTH 0.70710678118654752440
+#define SQRT2 1.41421356237309504880
+
+double log1p(x)
+double x;
+{
+double z;
+
+z = 1.0 + x;
+if( (z < SQRTH) || (z > SQRT2) )
+	return( log(z) );
+z = x*x;
+z = -0.5 * z + x * ( z * polevl( x, LP, 6 ) / p1evl( x, LQ, 6 ) );
+return (x + z);
+}
+
+
+
+/* expm1(x) = exp(x) - 1  */
+
+/*  e^x =  1 + 2x P(x^2)/( Q(x^2) - P(x^2) )
+ * -0.5 <= x <= 0.5
+ */
+
+static double EP[3] = {
+ 1.2617719307481059087798E-4,
+ 3.0299440770744196129956E-2,
+ 9.9999999999999999991025E-1,
+};
+static double EQ[4] = {
+ 3.0019850513866445504159E-6,
+ 2.5244834034968410419224E-3,
+ 2.2726554820815502876593E-1,
+ 2.0000000000000000000897E0,
+};
+
+double expm1(x)
+double x;
+{
+double r, xx;
+
+#ifdef NANS
+if( isnan(x) )
+	return(x);
+#endif
+#ifdef INFINITIES
+if( x == INFINITY )
+	return(INFINITY);
+if( x == -INFINITY )
+	return(-1.0);
+#endif
+if( (x < -0.5) || (x > 0.5) )
+	return( exp(x) - 1.0 );
+xx = x * x;
+r = x * polevl( xx, EP, 2 );
+r = r/( polevl( xx, EQ, 3 ) - r );
+return (r + r);
+}
+
+
+
+/* cosm1(x) = cos(x) - 1  */
+
+static double coscof[7] = {
+ 4.7377507964246204691685E-14,
+-1.1470284843425359765671E-11,
+ 2.0876754287081521758361E-9,
+-2.7557319214999787979814E-7,
+ 2.4801587301570552304991E-5,
+-1.3888888888888872993737E-3,
+ 4.1666666666666666609054E-2,
+};
+
+extern double PIO4;
+
+double cosm1(x)
+double x;
+{
+double xx;
+
+if( (x < -PIO4) || (x > PIO4) )
+	return( cos(x) - 1.0 );
+xx = x * x;
+xx = -0.5*xx + xx * xx * polevl( xx, coscof, 6 );
+return xx;
+}
Index: sansmodels/src/cephes/yn.c
===================================================================
--- sansmodels/src/cephes/yn.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
+++ sansmodels/src/cephes/yn.c	(revision 431c9e09a140ccd7d782bfe0778c2b51d45cc094)
@@ -0,0 +1,115 @@
+/*							yn.c
+ *
+ *	Bessel function of second kind of integer order
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * double x, y, yn();
+ * int n;
+ *
+ * y = yn( n, x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns Bessel function of order n, where n is a
+ * (possibly negative) integer.
+ *
+ * The function is evaluated by forward recurrence on
+ * n, starting with values computed by the routines
+ * y0() and y1().
+ *
+ * If n = 0 or 1 the routine for y0 or y1 is called
+ * directly.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ *
+ *                      Absolute error, except relative
+ *                      when y > 1:
+ * arithmetic   domain     # trials      peak         rms
+ *    DEC       0, 30        2200       2.9e-16     5.3e-17
+ *    IEEE      0, 30       30000       3.4e-15     4.3e-16
+ *
+ *
+ * ERROR MESSAGES:
+ *
+ *   message         condition      value returned
+ * yn singularity   x = 0              MAXNUM
+ * yn overflow                         MAXNUM
+ *
+ * Spot checked against tables for x, n between 0 and 100.
+ *
+ */
+
+
+/*
+Cephes Math Library Release 2.8:  June, 2000
+Copyright 1984, 1987, 2000 by Stephen L. Moshier
+*/
+
+#include "mconf.h"
+#ifdef ANSIPROT
+extern double y0 ( double );
+extern double y1 ( double );
+extern double log ( double );
+#else
+double y0(), y1(), log();
+#endif
+extern double MAXNUM, MAXLOG;
+
+double yn( n, x )
+int n;
+double x;
+{
+double an, anm1, anm2, r;
+int k, sign;
+
+if( n < 0 )
+	{
+	n = -n;
+	if( (n & 1) == 0 )	/* -1**n */
+		sign = 1;
+	else
+		sign = -1;
+	}
+else
+	sign = 1;
+
+
+if( n == 0 )
+	return( sign * y0(x) );
+if( n == 1 )
+	return( sign * y1(x) );
+
+/* test for overflow */
+if( x <= 0.0 )
+	{
+	mtherr( "yn", SING );
+	return( -MAXNUM );
+	}
+
+/* forward recurrence on n */
+
+anm2 = y0(x);
+anm1 = y1(x);
+k = 1;
+r = 2 * k;
+do
+	{
+	an = r * anm1 / x  -  anm2;
+	anm2 = anm1;
+	anm1 = an;
+	r += 2.0;
+	++k;
+	}
+while( k < n );
+
+
+return( sign * an );
+}
