Index: setup.py
===================================================================
--- setup.py	(revision b22117675e1eedd2a3524d385b11685f20d7d8d6)
+++ setup.py	(revision 79d5b6c6866fe47aa0030d1fa7a21cc644a4be7b)
@@ -193,10 +193,10 @@
 # Sans models
 includedir  = os.path.join("src", "sans", "models", "include")
-igordir = os.path.join("src", "sans", "models", "src", "libigor")
-cephes_dir = os.path.join("src", "sans", "models", "src", "cephes")
-c_model_dir = os.path.join("src", "sans", "models", "src", "c_models")
-smear_dir  = os.path.join("src", "sans", "models", "src", "c_smearer")
-gen_dir  = os.path.join("src", "sans", "models", "src", "c_gen")
-wrapper_dir  = os.path.join("src", "sans", "models", "src", "python_wrapper", "generated")
+igordir = os.path.join("src", "sans", "models", "c_extension", "libigor")
+cephes_dir = os.path.join("src", "sans", "models", "c_extension", "cephes")
+c_model_dir = os.path.join("src", "sans", "models", "c_extension", "c_models")
+smear_dir  = os.path.join("src", "sans", "models", "c_extension", "c_smearer")
+gen_dir  = os.path.join("src", "sans", "models", "c_extension", "c_gen")
+wrapper_dir  = os.path.join("src", "sans", "models", "c_extension", "python_wrapper", "generated")
 model_dir = os.path.join("src", "sans","models")
 
@@ -207,5 +207,5 @@
 else:
     os.makedirs(wrapper_dir)
-sys.path.append(os.path.join("src", "sans", "models", "src", "python_wrapper"))
+sys.path.append(os.path.join("src", "sans", "models", "c_extension", "python_wrapper"))
 from wrapping import generate_wrappers
 generate_wrappers(header_dir = includedir, 
@@ -246,51 +246,4 @@
 smear_sources = []
 append_file(file_list=smear_sources, dir_path=smear_dir)
-
-
-#package_dir["sans.models"] = model_dir
-#package_dir["sans.models.sans_extension"] = os.path.join("src", "sans", "models", "sans_extension")
-#package_data['sans.models'] = [os.path.join('media', "*.*")]
-#package_data['sans.models'] += [os.path.join('media','img', "*.*")]
-#packages.extend(["sans","sans.models","sans.models.sans_extension"])
-#    
-#smearer_sources = [os.path.join(smear_dir, "smearer.cpp"),
-#                  os.path.join(smear_dir, "smearer_module.cpp")]
-#geni_sources = [os.path.join(gen_dir, "sld2i_module.cpp")]
-#if os.name=='nt':
-#    smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
-#    geni_sources.append(os.path.join(igordir, "winFuncs.c"))
-#ext_modules.extend( [ Extension("sans.models.sans_extension.c_models",
-#                                sources=model_sources,                 
-#                                include_dirs=[igordir, includedir, 
-#                                              c_model_dir, numpy_incl_path, cephes_dir],
-#                                ),       
-#                    # Smearer extension
-#                    Extension("sans.models.sans_extension.smearer",
-#                              sources = smearer_sources,
-#                              include_dirs=[igordir, 
-#                                            smear_dir, numpy_incl_path],
-#                              ),
-#                    
-#                    Extension("sans.models.sans_extension.smearer2d_helper",
-#                              sources = [os.path.join(smear_dir, 
-#                                                "smearer2d_helper_module.cpp"),
-#                                         os.path.join(smear_dir, 
-#                                                "smearer2d_helper.cpp"),],
-#                              include_dirs=[smear_dir, numpy_incl_path],
-#                              ),
-#                    
-#                    Extension("sans.models.sans_extension.sld2i",
-#                              sources = [os.path.join(gen_dir, 
-#                                                "sld2i_module.cpp"),
-#                                         os.path.join(gen_dir, 
-#                                                "sld2i.cpp"),
-#                                         os.path.join(c_model_dir, 
-#                                                "libfunc.c"),
-#                                         os.path.join(c_model_dir, 
-#                                                "librefl.c"),],
-#                              include_dirs=[gen_dir, includedir, 
-#                                            c_model_dir, numpy_incl_path],
-#                              )
-#                    ] )
         
 # SasView
Index: c/sans/models/src/Doxyfile
===================================================================
--- src/sans/models/src/Doxyfile	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,266 +1,0 @@
-# Doxyfile 1.5.1-p1
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME           = sansmodeling
-PROJECT_NUMBER         = 
-OUTPUT_DIRECTORY       = ../doc
-CREATE_SUBDIRS         = NO
-OUTPUT_LANGUAGE        = English
-USE_WINDOWS_ENCODING   = NO
-BRIEF_MEMBER_DESC      = YES
-REPEAT_BRIEF           = YES
-ABBREVIATE_BRIEF       = "The $name class" \
-                         "The $name widget" \
-                         "The $name file" \
-                         is \
-                         provides \
-                         specifies \
-                         contains \
-                         represents \
-                         a \
-                         an \
-                         the
-ALWAYS_DETAILED_SEC    = NO
-INLINE_INHERITED_MEMB  = NO
-FULL_PATH_NAMES        = YES
-STRIP_FROM_PATH        = 
-STRIP_FROM_INC_PATH    = 
-SHORT_NAMES            = NO
-JAVADOC_AUTOBRIEF      = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP         = NO
-INHERIT_DOCS           = YES
-SEPARATE_MEMBER_PAGES  = NO
-TAB_SIZE               = 4
-ALIASES                = 
-OPTIMIZE_OUTPUT_FOR_C  = NO
-OPTIMIZE_OUTPUT_JAVA   = YES
-BUILTIN_STL_SUPPORT    = NO
-DISTRIBUTE_GROUP_DOC   = NO
-SUBGROUPING            = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL            = NO
-EXTRACT_PRIVATE        = NO
-EXTRACT_STATIC         = NO
-EXTRACT_LOCAL_CLASSES  = YES
-EXTRACT_LOCAL_METHODS  = NO
-HIDE_UNDOC_MEMBERS     = NO
-HIDE_UNDOC_CLASSES     = NO
-HIDE_FRIEND_COMPOUNDS  = NO
-HIDE_IN_BODY_DOCS      = NO
-INTERNAL_DOCS          = NO
-CASE_SENSE_NAMES       = YES
-HIDE_SCOPE_NAMES       = NO
-SHOW_INCLUDE_FILES     = YES
-INLINE_INFO            = YES
-SORT_MEMBER_DOCS       = YES
-SORT_BRIEF_DOCS        = NO
-SORT_BY_SCOPE_NAME     = NO
-GENERATE_TODOLIST      = YES
-GENERATE_TESTLIST      = YES
-GENERATE_BUGLIST       = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS       = 
-MAX_INITIALIZER_LINES  = 30
-SHOW_USED_FILES        = YES
-SHOW_DIRECTORIES       = YES
-FILE_VERSION_FILTER    = 
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET                  = NO
-WARNINGS               = YES
-WARN_IF_UNDOCUMENTED   = YES
-WARN_IF_DOC_ERROR      = YES
-WARN_NO_PARAMDOC       = NO
-WARN_FORMAT            = "$file:$line: $text"
-WARN_LOGFILE           = 
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT                  = .
-FILE_PATTERNS          = *.c \
-                         *.cc \
-                         *.cxx \
-                         *.cpp \
-                         *.c++ \
-                         *.d \
-                         *.java \
-                         *.ii \
-                         *.ixx \
-                         *.ipp \
-                         *.i++ \
-                         *.inl \
-                         *.h \
-                         *.hh \
-                         *.hxx \
-                         *.hpp \
-                         *.h++ \
-                         *.idl \
-                         *.odl \
-                         *.cs \
-                         *.php \
-                         *.php3 \
-                         *.inc \
-                         *.m \
-                         *.mm \
-                         *.dox \
-                         *.py
-RECURSIVE              = YES
-EXCLUDE                = build \
-                         dist \
-                         sans/models/test \
-                         libigor \
-                         igor_wrapper \
-                         sans/models/prototypes
-EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = 
-EXAMPLE_PATH           = 
-EXAMPLE_PATTERNS       = *
-EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = ../doc
-INPUT_FILTER           = 
-FILTER_PATTERNS        = 
-FILTER_SOURCE_FILES    = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER         = NO
-INLINE_SOURCES         = NO
-STRIP_CODE_COMMENTS    = YES
-REFERENCED_BY_RELATION = NO
-REFERENCES_RELATION    = NO
-REFERENCES_LINK_SOURCE = YES
-USE_HTAGS              = NO
-VERBATIM_HEADERS       = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX     = NO
-COLS_IN_ALPHA_INDEX    = 5
-IGNORE_PREFIX          = 
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML          = YES
-HTML_OUTPUT            = html
-HTML_FILE_EXTENSION    = .html
-HTML_HEADER            = 
-HTML_FOOTER            = 
-HTML_STYLESHEET        = 
-HTML_ALIGN_MEMBERS     = YES
-GENERATE_HTMLHELP      = NO
-CHM_FILE               = 
-HHC_LOCATION           = 
-GENERATE_CHI           = NO
-BINARY_TOC             = NO
-TOC_EXPAND             = NO
-DISABLE_INDEX          = NO
-ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = NO
-TREEVIEW_WIDTH         = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX         = NO
-LATEX_OUTPUT           = latex
-LATEX_CMD_NAME         = latex
-MAKEINDEX_CMD_NAME     = makeindex
-COMPACT_LATEX          = NO
-PAPER_TYPE             = a4wide
-EXTRA_PACKAGES         = 
-LATEX_HEADER           = 
-PDF_HYPERLINKS         = NO
-USE_PDFLATEX           = YES
-LATEX_BATCHMODE        = NO
-LATEX_HIDE_INDICES     = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF           = NO
-RTF_OUTPUT             = rtf
-COMPACT_RTF            = NO
-RTF_HYPERLINKS         = NO
-RTF_STYLESHEET_FILE    = 
-RTF_EXTENSIONS_FILE    = 
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN           = NO
-MAN_OUTPUT             = man
-MAN_EXTENSION          = .3
-MAN_LINKS              = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML           = NO
-XML_OUTPUT             = xml
-XML_SCHEMA             = 
-XML_DTD                = 
-XML_PROGRAMLISTING     = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF   = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD       = NO
-PERLMOD_LATEX          = NO
-PERLMOD_PRETTY         = YES
-PERLMOD_MAKEVAR_PREFIX = 
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
-EXPAND_ONLY_PREDEF     = NO
-SEARCH_INCLUDES        = YES
-INCLUDE_PATH           = 
-INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = 
-EXPAND_AS_DEFINED      = 
-SKIP_FUNCTION_MACROS   = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references   
-#---------------------------------------------------------------------------
-TAGFILES               = 
-GENERATE_TAGFILE       = 
-ALLEXTERNALS           = NO
-EXTERNAL_GROUPS        = YES
-PERL_PATH              = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS         = YES
-HIDE_UNDOC_RELATIONS   = YES
-HAVE_DOT               = YES
-CLASS_GRAPH            = YES
-COLLABORATION_GRAPH    = NO
-GROUP_GRAPHS           = YES
-UML_LOOK               = YES
-TEMPLATE_RELATIONS     = YES
-INCLUDE_GRAPH          = YES
-INCLUDED_BY_GRAPH      = YES
-CALL_GRAPH             = YES
-CALLER_GRAPH           = YES
-GRAPHICAL_HIERARCHY    = YES
-DIRECTORY_GRAPH        = YES
-DOT_IMAGE_FORMAT       = png
-DOT_PATH               = 
-DOTFILE_DIRS           = 
-MAX_DOT_GRAPH_WIDTH    = 1024
-MAX_DOT_GRAPH_HEIGHT   = 1024
-MAX_DOT_GRAPH_DEPTH    = 1000
-DOT_TRANSPARENT        = NO
-DOT_MULTI_TARGETS      = NO
-GENERATE_LEGEND        = YES
-DOT_CLEANUP            = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-SEARCHENGINE           = NO
Index: c/sans/models/src/c_gen/sld2i.cpp
===================================================================
--- src/sans/models/src/c_gen/sld2i.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/**
-Computes the (magnetic) scattering form sld (n and m) profile
- */
-#include "sld2i.hh"
-#include <stdio.h>
-#include <math.h>
-using namespace std;
-extern "C" {
-	#include "libmultifunc/libfunc.h"
-	#include "libmultifunc/librefl.h"
-}
-/**
- * Constructor for GenI
- *
- * binning
- * //@param qx: array of Qx values
- * //@param qy: array of Qy values
- * //@param qz: array of Qz values
- * @param x: array of x values
- * @param y: array of y values
- * @param z: array of z values
- * @param sldn: array of sld n
- * @param mx: array of sld mx
- * @param my: array of sld my
- * @param mz: array of sld mz
- * @param in_spin: ratio of up spin in Iin
- * @param out_spin: ratio of up spin in Iout
- * @param s_theta: angle (from x-axis) of the up spin in degree
- */
-GenI :: GenI(int npix, double* x, double* y, double* z, double* sldn,
-			double* mx, double* my, double* mz, double* voli,
-			double in_spin, double out_spin,
-			double s_theta) {
-	//this->qx_val = qx;
-	//this->qy_val = qy;
-	//this->qz_val = qz;
-	this->n_pix = npix;
-	this->x_val = x;
-	this->y_val = y;
-	this->z_val = z;
-	this->sldn_val = sldn;
-	this->mx_val = mx;
-	this->my_val = my;
-	this->mz_val = mz;
-	this->vol_pix = voli;
-	this->inspin = in_spin;
-	this->outspin = out_spin;
-	this->stheta = s_theta;
-};
-
-/**
- * Compute 2D anisotropic
- */
-void GenI :: genicomXY(int npoints, double *qx, double *qy, double *I_out){
-	//npoints is given negative for angular averaging 
-	// Assumes that q doesn't have qz component and sld_n is all real
-	//double q = 0.0;
-	//double Pi = 4.0*atan(1.0);
-	polar_sld b_sld;
-	double qr = 0.0;
-	complex iqr = cassign(0.0, 0.0);
-	complex ephase = cassign(0.0, 0.0);
-	complex comp_sld = cassign(0.0, 0.0);
-
-	complex sumj_uu;
-	complex sumj_ud;
-	complex sumj_du;
-	complex sumj_dd;
-	complex temp_fi;
-
-	double count = 0.0;
-	//check if this computation is for averaging
-
-	//Assume that pixel volumes are given in vol_pix in A^3 unit
-	//int x_size = 0; //in Ang
-	//int y_size = 0; //in Ang
-	//int z_size = 0; //in Ang
-	
-	// Loop over q-values and multiply apply matrix
-	
-	for(int i=0; i<npoints; i++){
-		//I_out[i] = 0.0;
-		sumj_uu = cassign(0.0, 0.0);
-		sumj_ud = cassign(0.0, 0.0);
-		sumj_du = cassign(0.0, 0.0);
-		sumj_dd = cassign(0.0, 0.0);		
-		//printf ("%d ", i);
-		//q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]);
-
-		for(int j=0; j<n_pix; j++){
-			if (sldn_val[j]!=0.0||mx_val[j]!=0.0||my_val[j]!=0.0||mz_val[j]!=0.0)
-			{	
-				//anisotropic
-				temp_fi = cassign(0.0, 0.0);
-				b_sld = cal_msld(0, qx[i], qy[i], sldn_val[j],
-							 mx_val[j], my_val[j], mz_val[j],
-			 				 inspin, outspin, stheta);
-				qr = (qx[i]*x_val[j] + qy[i]*y_val[j]);
-				iqr = cassign(0.0, qr);
-				ephase = cplx_exp(iqr);
-				
-				//Let's multiply pixel(atomic) volume here
-				ephase = rcmult(vol_pix[j], ephase);
-				//up_up
-				if (inspin > 0.0 && outspin > 0.0){
-					comp_sld = cassign(b_sld.uu, 0.0);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_uu = cplx_add(sumj_uu, temp_fi);
-				}
-				//down_down
-				if (inspin < 1.0 && outspin < 1.0){
-					comp_sld = cassign(b_sld.dd, 0.0);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_dd = cplx_add(sumj_dd, temp_fi);
-				}
-				//up_down
-				if (inspin > 0.0 && outspin < 1.0){
-					comp_sld = cassign(b_sld.re_ud, b_sld.im_ud);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_ud = cplx_add(sumj_ud, temp_fi);
-				}
-				//down_up
-				if (inspin < 1.0 && outspin > 0.0){
-					comp_sld = cassign(b_sld.re_du, b_sld.im_du);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_du = cplx_add(sumj_du, temp_fi);
-				}
-
-
-				if (i == 0){
-					count += vol_pix[j];
-				}
-			}
-		}
-		//printf("aa%d=%g %g %d\n", i, (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im), (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im), count);
-
-		I_out[i] = (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im);
-		I_out[i] += (sumj_ud.re*sumj_ud.re + sumj_ud.im*sumj_ud.im);
-		I_out[i] += (sumj_du.re*sumj_du.re + sumj_du.im*sumj_du.im);
-		I_out[i] += (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im);
-
-		I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix
-	}
-	//printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]);
-}
-/**
- * Compute 1D isotropic
- * Isotropic: Assumes all slds are real (no magnetic)
- * Also assumes there is no polarization: No dependency on spin
- */
-void GenI :: genicom(int npoints, double *q, double *I_out){
-	//npoints is given negative for angular averaging 
-	// Assumes that q doesn't have qz component and sld_n is all real
-	//double Pi = 4.0*atan(1.0);
-	int is_sym = 0;
-	double qr = 0.0;
-	double sumj;
-	double sld_j = 0.0;
-	double count = 0.0;
-	if (n_pix < 0 ){
-		is_sym = 1;
-		n_pix = n_pix * -1;
-	}
-	//Assume that pixel volumes are given in vol_pix in A^3 unit
-	// Loop over q-values and multiply apply matrix
-	for(size_t i=0; i<npoints; i++){
-		sumj =0.0;		
-		for(size_t j=0; j<n_pix; j++){
-			//Isotropic: Assumes all slds are real (no magnetic)
-			//Also assumes there is no polarization: No dependency on spin
-			if (is_sym == 1){
-				// approximation for a spherical symmetric particle
-				qr = sqrt(x_val[j]*x_val[j]+y_val[j]*y_val[j]+z_val[j]*z_val[j])*q[i];
-				if (qr > 0.0){
-					qr = sin(qr) / qr;
-					sumj += sldn_val[j] * vol_pix[j] * qr;
-				}
-				else{
-					sumj += sldn_val[j] * vol_pix[j];
-				}
-			}
-			else{
-				//full calculation
-				//pragma omp parallel for
-				for(size_t k=0; k<n_pix; k++){
-					sld_j =  sldn_val[j] * sldn_val[k] * vol_pix[j] * vol_pix[k];
-					qr = (x_val[j]-x_val[k])*(x_val[j]-x_val[k])+
-						      (y_val[j]-y_val[k])*(y_val[j]-y_val[k])+ 
-						      (z_val[j]-z_val[k])*(z_val[j]-z_val[k]);
-					qr = sqrt(qr) * q[i];
-					if (qr > 0.0){
-						sumj += sld_j*sin(qr)/qr;
-					}
-					else{
-						sumj += sld_j;
-					}
-				}
-			}
-			if (i == 0){
-				count += vol_pix[j];
-			}
-		}
-		I_out[i] = sumj;
-		if (is_sym == 1){
-			I_out[i] *= sumj;
-		}
-		I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix
-	}
-	//printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]);
-}
Index: c/sans/models/src/c_gen/sld2i.hh
===================================================================
--- src/sans/models/src/c_gen/sld2i.hh	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/**
-Computes the (magnetic) scattering form sld (n and m) profile
- */
-#ifndef SLD2I_CLASS_H
-#define SLD2I_CLASS_H
-
-#include <vector>
-
-using namespace std;
-
-/**
- * Base class
- */
-class GenI {
-protected:
-	vector<double>* I_out;
-	// vectors
-	int n_pix;
-	double* qx;
-	double* qy;
-	double* x_val;
-	double* y_val;
-	double* z_val;
-	double* sldn_val;
-	double* mx_val;
-	double* my_val;
-	double* mz_val;
-	double* vol_pix;
-    // spin ratios
-    double inspin;
-    double outspin;
-    double stheta;
-
-public:
-    // Constructor
-	GenI(int npix, double* x, double* y, double* z, double* sldn, 
-			double* mx, double* my, double* mz, double* voli,
-			double in_spin, double out_spin,
-			double s_theta);
-	// compute function
-	virtual void genicomXY(int npoints, double* qx, double* qy, double *I_out);
-	virtual void genicom(int npoints, double* q, double *I_out);
-};
-
-#endif
Index: c/sans/models/src/c_gen/sld2i_module.cpp
===================================================================
--- src/sans/models/src/c_gen/sld2i_module.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,159 +1,0 @@
-/**
-  SLD2I module to perform point and I calculations
- */
-#include <Python.h>
-#include <stdio.h>
-#include <sld2i.hh>
-
-// Utilities
-#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)
-
-#define OUTVECTOR(obj,buf,len) \
-    do { \
-        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
-        if (err < 0) return NULL; \
-        len /= sizeof(*buf); \
-    } while (0)
-
-
-/**
- * Delete a GenI object
- */
-void del_sld2i(void *ptr){
-	GenI* sld2i = static_cast<GenI *>(ptr);
-	delete sld2i;
-	return;
-}
-
-/**
- * Create a GenI as a python object by supplying arrays
- */
-PyObject * new_GenI(PyObject *, PyObject *args) {
-	PyObject *x_val_obj;
-	PyObject *y_val_obj;
-	PyObject *z_val_obj;
-	PyObject *sldn_val_obj;
-	PyObject *mx_val_obj;
-	PyObject *my_val_obj;
-	PyObject *mz_val_obj;
-	PyObject *vol_pix_obj;
-	Py_ssize_t n_x;
-	//PyObject rlimit_obj;
-	//PyObject npoints_obj;
-	//PyObject nrbins_obj;
-	//PyObject nphibins_obj;
-	int n_pix;
-	double* x_val;
-	double* y_val;
-	double* z_val;
-	double* sldn_val;
-	double* mx_val;
-	double* my_val;
-	double* mz_val;
-	double* vol_pix;
-	double inspin;
-	double outspin;
-	double stheta;
-
-	if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &n_pix, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL;
-	OUTVECTOR(x_val_obj, x_val, n_x);
-	OUTVECTOR(y_val_obj, y_val, n_x);
-	OUTVECTOR(z_val_obj, z_val, n_x);
-	OUTVECTOR(sldn_val_obj, sldn_val, n_x);
-	OUTVECTOR(mx_val_obj, mx_val, n_x);
-	OUTVECTOR(my_val_obj, my_val, n_x);
-	OUTVECTOR(mz_val_obj, mz_val, n_x);
-	OUTVECTOR(vol_pix_obj, vol_pix, n_x);
-	GenI* sld2i = new GenI(n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta);
-	return PyCObject_FromVoidPtr(sld2i, del_sld2i);
-}
-
-/**
- * GenI the given input (2D) according to a given object
- */
-PyObject * genicom_inputXY(PyObject *, PyObject *args) {
-	int npoints;
-	PyObject *qx_obj;
-	double *qx;
-	PyObject *qy_obj;
-	double *qy;
-	PyObject *I_out_obj;
-	Py_ssize_t n_out;
-	double *I_out;
-	PyObject *gen_obj;
-
-	if (!PyArg_ParseTuple(args, "OiOOO",  &gen_obj, &npoints, &qx_obj, &qy_obj, &I_out_obj)) return NULL;
-	OUTVECTOR(qx_obj, qx, n_out);
-	OUTVECTOR(qy_obj, qy, n_out);
-	OUTVECTOR(I_out_obj, I_out, n_out);
-
-	// Sanity check
-	//if(n_in!=n_out) return Py_BuildValue("i",-1);
-
-	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(gen_obj);
-	GenI* s = static_cast<GenI *>(temp);
-
-	s->genicomXY(npoints, qx, qy, I_out);
-	//return PyCObject_FromVoidPtr(s, del_genicom);
-	return Py_BuildValue("i",1);
-}
-
-/**
- * GenI the given 1D input according to a given object
- */
-PyObject * genicom_input(PyObject *, PyObject *args) {
-	int npoints;
-	PyObject *q_obj;
-	double *q;
-	PyObject *I_out_obj;
-	Py_ssize_t n_out;
-	double *I_out;
-	PyObject *gen_obj;
-
-	if (!PyArg_ParseTuple(args, "OiOO",  &gen_obj, &npoints, &q_obj, &I_out_obj)) return NULL;
-	OUTVECTOR(q_obj, q, n_out);
-	OUTVECTOR(I_out_obj, I_out, n_out);
-
-	// Sanity check
-	//if(n_in!=n_out) return Py_BuildValue("i",-1);
-
-	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(gen_obj);
-	GenI* s = static_cast<GenI *>(temp);
-
-	s->genicom(npoints, q, I_out);
-	//return PyCObject_FromVoidPtr(s, del_genicom);
-	return Py_BuildValue("i",1);
-}
-
-/**
- * Define module methods
- */
-static PyMethodDef module_methods[] = {
-	{"new_GenI", (PyCFunction)new_GenI, METH_VARARGS,
-		  "Create a new GenI object"},
-	{"genicom",(PyCFunction)genicom_input, METH_VARARGS,
-		  "genicom the given 1d input arrays"},
-	{"genicomXY",(PyCFunction)genicom_inputXY, METH_VARARGS,
-		  "genicomXY the given 2d input arrays"},
-    {NULL}
-};
-
-
-#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
-#endif
-PyMODINIT_FUNC
-initsld2i(void)
-{
-    PyObject* m;
-
-    m = Py_InitModule3("sld2i", module_methods,
-                       "Sld2i module");
-}
Index: c/sans/models/src/c_models/DiamCyl.cpp
===================================================================
--- src/sans/models/src/c_models/DiamCyl.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "DiamCyl.h"
-
-extern "C" {
-	#include "libStructureFactor.h"
-}
-
-DiamCylFunc :: DiamCylFunc() {
-	radius      = Parameter(20.0, true);
-	radius.set_min(0.0);
-	length      = Parameter(400, true);
-	length.set_min(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double DiamCylFunc :: operator()(double q) {
-	double dp[2];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = radius();
-	dp[1] = length();
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Get the dispersion points for the length
-	vector<WeightPoint> weights_len;
-	length.get_weights(weights_len);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[0] = weights_rad[i].value;
-		// Loop over length weight points
-		for(size_t j=0; j<weights_len.size(); j++) {
-			dp[1] = weights_len[j].value;
-
-			sum += weights_rad[i].weight
-						* weights_len[j].weight *DiamCyl(dp[1], dp[0]);
-			norm += weights_rad[i].weight
-				* weights_len[j].weight;
-		}
-	}
-	return sum/norm ;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double DiamCylFunc :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double DiamCylFunc :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double DiamCylFunc :: calculate_ER() {
-//NOT implemented yet!!!
-  return 0.0;
-}
-double DiamCylFunc :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/DiamEllip.cpp
===================================================================
--- src/sans/models/src/c_models/DiamEllip.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "DiamEllip.h"
-
-extern "C" {
-	#include "libStructureFactor.h"
-}
-
-DiamEllipFunc :: DiamEllipFunc() {
-	radius_a      = Parameter(20.0, true);
-	radius_a.set_min(0.0);
-	radius_b      = Parameter(400, true);
-	radius_b.set_min(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double DiamEllipFunc :: operator()(double q) {
-	double dp[2];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = radius_a();
-	dp[1] = radius_b();
-
-	// Get the dispersion points for the radius a
-	vector<WeightPoint> weights_rad_a;
-	radius_a.get_weights(weights_rad_a);
-
-	// Get the dispersion points for the radius b
-	vector<WeightPoint> weights_rad_b;
-	radius_b.get_weights(weights_rad_b);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad_a.size(); i++) {
-		dp[0] = weights_rad_a[i].value;
-		// Loop over length weight points
-		for(size_t j=0; j<weights_rad_b.size(); j++) {
-			dp[1] = weights_rad_b[j].value;
-
-			sum += weights_rad_a[i].weight*weights_rad_b[j].weight
-				* DiamEllip(dp[0], dp[1]);
-			norm += weights_rad_a[i].weight*weights_rad_b[j].weight;
-		}
-	}
-	return sum/norm ;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double DiamEllipFunc :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double DiamEllipFunc :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double DiamEllipFunc :: calculate_ER() {
-//NOT implemented yet!!!
-  return 0.0;
-}
-double DiamEllipFunc :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/FractalQtoN.cpp
===================================================================
--- src/sans/models/src/c_models/FractalQtoN.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,146 +1,0 @@
-
-/*
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
-
-    See Schmidt, J Appl Cryst, 24, (1991), 414-435, Eqn (19)
-    See Hurd, Schaefer & Martin, 35, (1987), 2361-2364
-
-    Ported to C++ from Fortran by Robert Whitley (2012)
-*/
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include "FractalQtoN.h"
-using namespace std;
-
-FractalO_Z::FractalO_Z()
-{
-    scale = Parameter(10000.0, true);
-    m_fractal = Parameter(1.8);
-    cluster_rg = Parameter(3250.0);
-    s_fractal = Parameter(2.5);
-    primary_rg = Parameter(82.0);
-    background = Parameter(0.01);
-}
-
-double FractalO_Z :: operator()(double q)
-{
-    double dp[3];
-    dp[0] = m_fractal();
-    dp[1] = s_fractal();
-    
-    
-    if (dp[0] <= 0)
-    {
-        //std::cout << "\n\nThe mass fractal dimension must be > 0!";
-        //std::cout << "\nWill set to 3.";
-        dp[0] = 3.0;
-    }
-    else 
-    {
-        if (dp[0] > 6)
-        {
-            //std::cout << "\n\nThe mass fractal dimension must be <= 6!";
-            //std::cout << "\nWill be set to 3."; 
-            dp[0] = 3.0;
-        }
-    }
-    
-    if (dp[1] <= 0)
-    {
-        //std::cout << "\n\nThe surface dimension must be > 0!";
-        //std::cout << "\nWill be set to 2.";
-        dp[1] = 2.0;
-    }
-    else
-    {
-        if (dp[1] > 6)
-        {
-            //std::cout << "\n\nThe surface dimension must be <= 6!";
-            //std::cout << "\nWill be set to 2.";
-            dp[1] = 2.0;
-        }
-    }
-    
-    double a(dp[0]/2.0);
-    double b((cluster_rg() * cluster_rg())/(3.0*a) );
-    
-    // If C goes negative, it will crash with undefined exponentiation.
-    // So (Ds + Dm) <= 6
-    // c = ((ds-6.0)/-2.0)-a
-    if ((dp[1] > (6.0-dp[0])) && (primary_rg() > 0.0))
-    {
-        dp[1] = 6.0 - dp[0];
-        //std::cout << "\n\nThe surface fractal dimension must be <= (6-Dm)!\n";
-        //std::cout << setprecision(5) << fixed << dp[1];
-    }
-    
-    // c = (ds -6.0 + dm)/-2.0;
-    double c = (6.0 - dp[1] - dp[0])/2.0;
-    double d(0.0);
-    
-    // If c = 0 then it will crash with a floating divide by zero.
-    if (c == 0)
-    {
-        d = 1.0e+37;
-    }
-    else
-    {
-        d = (primary_rg() * primary_rg()) / (3.0 * c);
-    }
-
-    double eVar = q*q*b;
-    double fVar = q*q*d;
-    double g = pow((1.0+eVar),a);
-    double h = pow((1.0+fVar),c);
-    double i = g*h;
-    double result((scale()/i) + background() );
-    return result;
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double FractalO_Z :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double FractalO_Z :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double FractalO_Z :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double FractalO_Z :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/GelFit.cpp
===================================================================
--- src/sans/models/src/c_models/GelFit.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,109 +1,0 @@
-
-/*
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
-    
-    SHIBAYAMA-GEISSLER TWO-LENGTH SCALE SCATTERING FUNCTION FOR GELS
-
-    See Sibayama, Tanaka & Han, J Chem Phys, (1992), 97(9), 6829-6841
-    or  Mallam, Horkay, Hecht, Rennie & Geissler, Macromol, (1991), 24, 543
-
-    Ported to C++ from Fortran by Robert Whitley (2012)
-*/
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "GelFit.h"
-
-GelFitModel::GelFitModel()
-{
-    lScale = Parameter(3.5);
-    gScale = Parameter(1.7);
-    zeta = Parameter(16.0);
-    radius = Parameter(104.0,true);
-    radius.set_min(2.0);
-    scale = Parameter(2.0,true);
-    background = Parameter(0.01);
-}
-
-double GelFitModel::operator()(double q) 
-{
-    double dp[3];
-    dp[0] = zeta();
-    dp[1] = radius();
-    dp[2] = scale();
-    
-    if (dp[2] <= 0)
-    {
-        //cout << "\n\nThe Scaling Exponent must be > 0";
-        //cout << "\nWill set to 2.0";
-        dp[2] = 2.0;
-    }
-
-    // Lorentzian Term
-    ////////////////////////double a(x[i]*x[i]*zeta*zeta);
-    double a(q*q*dp[0]*dp[0]);
-    double b(1.0 + (((dp[2] + 1.0)/3.0)*a) );
-    double c(pow(b, (dp[2]/2.0) ) );
-    
-    // Exponential Term
-    ////////////////////////double d(x[i]*x[i]*rg*rg);
-    double d(q*q*dp[1]*dp[1]);
-    double e(-1.0*(d/3.0) );
-    double f(exp(e));
-        
-        // Scattering Law
-    double result((lScale()/c) + (gScale()*f) + background());
-    return result;
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double GelFitModel::operator()(double qx, double qy) 
-{
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double GelFitModel::evaluate_rphi(double q, double phi) 
-{
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double GelFitModel::calculate_ER() 
-{
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double GelFitModel::calculate_VR() 
-{
-  return 1.0;
-}
Index: c/sans/models/src/c_models/Hardsphere.cpp
===================================================================
--- src/sans/models/src/c_models/Hardsphere.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,105 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "Hardsphere.h"
-
-extern "C" {
-#include "libStructureFactor.h"
-}
-
-HardsphereStructure :: HardsphereStructure() {
-  effect_radius      = Parameter(50.0, true);
-  effect_radius.set_min(0.0);
-  volfraction = Parameter(0.20, true);
-  volfraction.set_min(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double HardsphereStructure :: operator()(double q) {
-  double dp[2];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = effect_radius();
-  dp[1] = volfraction();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  effect_radius.get_weights(weights_rad);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[0] = weights_rad[i].value;
-
-    sum += weights_rad[i].weight
-        * HardSphereStruct(dp, q);
-    norm += weights_rad[i].weight;
-  }
-  return sum/norm ;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double HardsphereStructure :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double HardsphereStructure :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double HardsphereStructure :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double HardsphereStructure :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/HayterMSA.cpp
===================================================================
--- src/sans/models/src/c_models/HayterMSA.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: refactor so that we pull in the old sansmodels.c_extensions
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "HayterMSA.h"
-
-extern "C" {
-#include "libStructureFactor.h"
-}
-
-HayterMSAStructure :: HayterMSAStructure() {
-  effect_radius      = Parameter(20.75, true);
-  effect_radius.set_min(0.0);
-  charge      = Parameter(19.0, true);
-  volfraction = Parameter(0.0192, true);
-  volfraction.set_min(0.0);
-  temperature = Parameter(318.16, true);
-  temperature.set_min(0.0);
-  saltconc   = Parameter(0.0);
-  dielectconst  = Parameter(71.08);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double HayterMSAStructure :: operator()(double q) {
-  double dp[6];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = 2.0*effect_radius();
-  dp[1] = fabs(charge());
-  dp[2] = volfraction();
-  dp[3] = temperature();
-  dp[4] = saltconc();
-  dp[5] = dielectconst();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  effect_radius.get_weights(weights_rad);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[0] = 2.0*weights_rad[i].value;
-
-    sum += weights_rad[i].weight
-        * HayterPenfoldMSA(dp, q);
-    norm += weights_rad[i].weight;
-  }
-  return sum/norm ;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double HayterMSAStructure :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double HayterMSAStructure :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double HayterMSAStructure :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double HayterMSAStructure :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/SquareWell.cpp
===================================================================
--- src/sans/models/src/c_models/SquareWell.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,109 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "SquareWell.h"
-
-extern "C" {
-#include "libStructureFactor.h"
-}
-
-SquareWellStructure :: SquareWellStructure() {
-  effect_radius      = Parameter(50.0, true);
-  effect_radius.set_min(0.0);
-  volfraction = Parameter(0.04, true);
-  volfraction.set_min(0.0);
-  welldepth   = Parameter(1.50);
-  wellwidth  = Parameter(1.20);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double SquareWellStructure :: operator()(double q) {
-  double dp[4];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = effect_radius();
-  dp[1] = volfraction();
-  dp[2] = welldepth();
-  dp[3] = wellwidth();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  effect_radius.get_weights(weights_rad);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[0] = weights_rad[i].value;
-
-    sum += weights_rad[i].weight
-        * SquareWellStruct(dp, q);
-    norm += weights_rad[i].weight;
-  }
-  return sum/norm ;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double SquareWellStructure :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double SquareWellStructure :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double SquareWellStructure :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double SquareWellStructure :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/StickyHS.cpp
===================================================================
--- src/sans/models/src/c_models/StickyHS.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: refactor so that we pull in the old sansmodels.c_extensions
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "StickyHS.h"
-
-extern "C" {
-	#include "libStructureFactor.h"
-}
-
-StickyHSStructure :: StickyHSStructure() {
-	effect_radius      = Parameter(50.0, true);
-	effect_radius.set_min(0.0);
-	volfraction = Parameter(0.10, true);
-	volfraction.set_min(0.0);
-	perturb = Parameter(0.05, true);
-	perturb.set_min(0.0);
-	stickiness = Parameter(0.20, true);;
-	stickiness.set_min(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double StickyHSStructure :: operator()(double q) {
-	double dp[4];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = effect_radius();
-	dp[1] = volfraction();
-	dp[2] = perturb();
-	dp[3] = stickiness();
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	effect_radius.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[0] = weights_rad[i].value;
-
-		sum += weights_rad[i].weight
-				* StickyHS_Struct(dp, q);
-		norm += weights_rad[i].weight;
-	}
-	return sum/norm ;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double StickyHSStructure :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double StickyHSStructure :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double StickyHSStructure :: calculate_ER() {
-//NOT implemented yet!!!
-  return 0.0;
-}
-double StickyHSStructure :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/TwoYukawa.cpp
===================================================================
--- src/sans/models/src/c_models/TwoYukawa.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-//#include <iostream>
-using namespace std;
-#include "TwoYukawa.h"
-
-extern "C" {
-#include "2Y_TwoYukawa.h"
-}
-
-TwoYukawaModel :: TwoYukawaModel() {
-	// Model parameters
-	volfraction = Parameter(0.2, true);
-	effect_radius = Parameter(50.0, true);
-	effect_radius.set_min(0.0);
-	scale_K1 = Parameter(6.0);
-	decayConst_Z1 = Parameter(10.0);
-	scale_K2 = Parameter(-1.0);
-	decayConst_Z2 = Parameter(2.0); 
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double TwoYukawaModel :: operator()(double q) 
-{
-  double dp[6];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = volfraction();
-  dp[1] = effect_radius();
-  dp[2] = scale_K1();
-  dp[3] = decayConst_Z1();
-  dp[4] = scale_K2();
-  dp[5] = decayConst_Z2();
-  
-  double ZERO = 1.0e-24;
-  if (fabs(dp[2]) < 0.001){
-  	return ZERO;
-  	}
-  if (fabs(dp[3]) < 0.001){
-  	return ZERO;
-  	}
-  if (fabs(dp[4]) < 0.001){
-  	return ZERO;
-  	}
-  if (fabs(dp[5]) < 0.001){
-  	return ZERO;
-  	}
-  	
-  double a, b, c1, c2, d1, d2;
-  int check = 1;
-  double x_in = q * dp[1] *2.0;
-  int ok = 0;
-  
-  ok = TY_SolveEquations(dp[3], dp[5], dp[2], dp[4], dp[0], &a, &b, &c1, &c2, &d1, &d2, 0);
-  if (ok > 0 ){
-	//check = TY_CheckSolution(dp[3], dp[5], dp[2], dp[4], dp[0], &a, &b, &c1, &c2, &d1, &d2);
-    if (check > 0){
-    	return SqTwoYukawa(x_in, dp[3], dp[5], dp[2], dp[4], dp[0], a, b, c1, c2, d1, d2);
-    }
-    else{
-    	return ZERO;
-    }
-  }
-  else{
-     return ZERO;
-  }
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double TwoYukawaModel :: operator()(double qx, double qy)
-{
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double TwoYukawaModel :: evaluate_rphi(double q, double phi)
-{
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double TwoYukawaModel :: calculate_ER()
-{
-  return effect_radius();
-}
-double TwoYukawaModel :: calculate_VR()
-{
-  return 1.0;
-}
-
Index: c/sans/models/src/c_models/barbell.cpp
===================================================================
--- src/sans/models/src/c_models/barbell.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,354 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-
-extern "C" {
-	#include "libCylinder.h"
-  #include "GaussWeights.h"
-	#include "barbell.h"
-}
-
-BarBellModel :: BarBellModel() {
-	scale      = Parameter(1.0);
-	rad_bar		= Parameter(20.0);
-	rad_bar.set_min(0.0);
-	len_bar     = Parameter(400.0, true);
-	len_bar.set_min(0.0);
-	rad_bell = Parameter(40.0);
-	rad_bell.set_min(0.0);
-	sld_barbell   = Parameter(1.0e-6);
-	sld_solv   = Parameter(6.3e-6);
-	background = Parameter(0.0);
-	theta  = Parameter(0.0, true);
-	phi    = Parameter(0.0, true);
-}
-
-double bar2d_kernel(double dp[], double q, double alpha) {
-  int j;
-  double Pi;
-  double scale,contr,bkg,sldc,slds;
-  double len,rad,hDist,endRad;
-  int nordj=76;
-  double zi=alpha,yyy,answer;     //running tally of integration
-  double summj,vaj,vbj,zij;     //for the inner integration
-  double arg1,arg2,inner,be;
-
-
-  scale = dp[0];
-  rad = dp[1];
-  len = dp[2];
-  endRad = dp[3];
-  sldc = dp[4];
-  slds = dp[5];
-  bkg = dp[6];
-
-  hDist = sqrt(fabs(endRad*endRad-rad*rad));    //by definition for this model
-
-  contr = sldc-slds;
-
-  Pi = 4.0*atan(1.0);
-  vaj = -1.0*hDist/endRad;
-  vbj = 1.0;    //endpoints of inner integral
-
-  summj=0.0;
-
-  for(j=0;j<nordj;j++) {
-    //20 gauss points for the inner integral
-    zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;    //the "t" dummy
-    yyy = Gauss76Wt[j] * Dumb_kernel(dp,q,zij,zi);    //uses the same Kernel as the Dumbbell, here L>0
-    summj += yyy;
-  }
-  //now calculate the value of the inner integral
-  inner = (vbj-vaj)/2.0*summj;
-  inner *= 4.0*Pi*endRad*endRad*endRad;
-
-  //now calculate outer integrand
-  arg1 = q*len/2.0*cos(zi);
-  arg2 = q*rad*sin(zi);
-  yyy = inner;
-
-  if(arg2 == 0) {
-    be = 0.5;
-  } else {
-    be = NR_BessJ1(arg2)/arg2;
-  }
-
-  if(arg1 == 0.0) {   //limiting value of sinc(0) is 1; sinc is not defined in math.h
-    yyy += Pi*rad*rad*len*2.0*be;
-  } else {
-    yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-  }
-  yyy *= yyy;   //sin(zi);
-  answer = yyy;
-
-
-  answer /= Pi*rad*rad*len + 2.0*Pi*(2.0*endRad*endRad*endRad/3.0+endRad*endRad*hDist-hDist*hDist*hDist/3.0);   //divide by volume
-  answer *= 1.0e8;    //convert to cm^-1
-  answer *= contr*contr;
-  answer *= scale;
-  answer += bkg;
-
-  return answer;
-}
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double BarBellModel :: operator()(double q) {
-	double dp[7];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = rad_bar();
-	dp[2] = len_bar();
-	dp[3] = rad_bell();
-	dp[4] = sld_barbell();
-	dp[5] = sld_solv();
-	dp[6] = 0.0;
-
-	// Get the dispersion points for the rad_bar
-	vector<WeightPoint> weights_rad_bar;
-	rad_bar.get_weights(weights_rad_bar);
-	// Get the dispersion points for the len_bar
-	vector<WeightPoint> weights_len_bar;
-	len_bar.get_weights(weights_len_bar);
-	// Get the dispersion points for the rad_bell
-	vector<WeightPoint> weights_rad_bell;
-	rad_bell.get_weights(weights_rad_bell);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-	double pi,hDist,result;
-	double vol_i = 0.0;
-	pi = 4.0*atan(1.0);
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad_bar.size(); i++) {
-		dp[1] = weights_rad_bar[i].value;
-		for(size_t j=0; j<weights_len_bar.size(); j++) {
-			dp[2] = weights_len_bar[j].value;
-			for(size_t k=0; k<weights_rad_bell.size(); k++) {
-				dp[3] = weights_rad_bell[k].value;
-
-				//Un-normalize SphereForm by volume
-				hDist = sqrt(fabs(dp[3]*dp[3]-dp[1]*dp[1]));
-				vol_i = pi*dp[1]*dp[1]*dp[2]+2.0*pi*(2.0*dp[3]*dp[3]*dp[3]/3.0
-								+dp[3]*dp[3]*hDist-hDist*hDist*hDist/3.0);
-				result =  Barbell(dp, q) * vol_i;
-				// This FIXES a singualrity the kernel in libigor.
-				if ( result == INFINITY || result == NAN){
-					result = 0.0;
-				}
-				sum += weights_rad_bar[i].weight*weights_len_bar[j].weight*weights_rad_bell[k].weight
-					* result;
-				//Find average volume
-				vol += weights_rad_bar[i].weight*weights_len_bar[j].weight*weights_rad_bell[k].weight
-					* vol_i;
-
-				norm += weights_rad_bar[i].weight*weights_len_bar[j].weight*weights_rad_bell[k].weight;
-			}
-		}
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double BarBellModel :: operator()(double qx, double qy) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = rad_bar();
-  dp[2] = len_bar();
-  dp[3] = rad_bell();
-  dp[4] = sld_barbell();
-  dp[5] = sld_solv();
-  dp[6] = 0.0;
-
-  double _theta = theta();
-  double _phi = phi();
-
-	// Get the dispersion points for the rad_bar
-	vector<WeightPoint> weights_rad_bar;
-	rad_bar.get_weights(weights_rad_bar);
-
-	// Get the dispersion points for the len_bar
-	vector<WeightPoint> weights_len_bar;
-	len_bar.get_weights(weights_len_bar);
-
-	// Get the dispersion points for the rad_bell
-	vector<WeightPoint> weights_rad_bell;
-	rad_bell.get_weights(weights_rad_bell);
-
-	// Get angular averaging for theta
-	vector<WeightPoint> weights_theta;
-	theta.get_weights(weights_theta);
-
-	// Get angular averaging for phi
-	vector<WeightPoint> weights_phi;
-	phi.get_weights(weights_phi);
-
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double norm_vol = 0.0;
-	double vol = 0.0;
-	double pi,hDist;
-	double vol_i = 0.0;
-	pi = 4.0*atan(1.0);
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad_bar.size(); i++) {
-		dp[1] = weights_rad_bar[i].value;
-		for(size_t j=0; j<weights_len_bar.size(); j++) {
-			dp[2] = weights_len_bar[j].value;
-			for(size_t k=0; k<weights_rad_bell.size(); k++) {
-				dp[3] = weights_rad_bell[k].value;
-				// Average over theta distribution
-				for(size_t l=0; l< weights_theta.size(); l++) {
-					_theta = weights_theta[l].value;
-					// Average over phi distribution
-					for(size_t m=0; m< weights_phi.size(); m++) {
-						_phi = weights_phi[m].value;
-						//Un-normalize Form by volume
-						hDist = sqrt(fabs(dp[3]*dp[3]-dp[1]*dp[1]));
-						vol_i = pi*dp[1]*dp[1]*dp[2]+2.0*pi*(2.0*dp[3]*dp[3]*dp[3]/3.0
-										+dp[3]*dp[3]*hDist-hDist*hDist*hDist/3.0);
-
-					  const double q = sqrt(qx*qx+qy*qy);
-					  //convert angle degree to radian
-					  const double pi = 4.0*atan(1.0);
-
-					  // Cylinder orientation
-				    const double cyl_x = cos(_theta * pi/180.0) * cos(_phi * pi/180.0);
-				    const double cyl_y = sin(_theta * pi/180.0);
-
-				    // Compute the angle btw vector q and the
-				    // axis of the cylinder (assume qz = 0)
-				    const double cos_val = cyl_x*qx + cyl_y*qy;
-
-				    // The following test should always pass
-				    if (fabs(cos_val)>1.0) {
-				      return 0;
-				    }
-
-				    // Note: cos(alpha) = 0 and 1 will get an
-				    // undefined value from CylKernel
-				    const double alpha = acos( cos_val );
-
-            // Call the IGOR library function to get the kernel
-            const double output = bar2d_kernel(dp, q, alpha)/sin(alpha);
-
-						double _ptvalue = weights_rad_bar[i].weight
-											* weights_len_bar[j].weight
-											* weights_rad_bell[k].weight
-											* weights_theta[l].weight
-											* weights_phi[m].weight
-											* vol_i
-											* output;
-											//* pow(weights_rad[i].value,3.0);
-
-						// Consider when there is infinte or nan.
-						if ( _ptvalue == INFINITY || _ptvalue == NAN){
-							_ptvalue = 0.0;
-						}
-						if (weights_theta.size()>1) {
-							_ptvalue *= fabs(cos(weights_theta[l].value*pi/180.0));
-						}
-						sum += _ptvalue;
-						// This model dose not need the volume of spheres correction!!!
-						//Find average volume
-						vol += weights_rad_bar[i].weight
-								* weights_len_bar[j].weight
-								* weights_rad_bell[k].weight
-								* vol_i;
-						//Find norm for volume
-						norm_vol += weights_rad_bar[i].weight
-								* weights_len_bar[j].weight
-								* weights_rad_bell[k].weight;
-
-						norm += weights_rad_bar[i].weight
-								* weights_len_bar[j].weight
-								* weights_rad_bell[k].weight
-								* weights_theta[l].weight
-								* weights_phi[m].weight;
-					}
-				}
-			}
-		}
-	}
-	// Averaging in theta needs an extra normalization
-	// factor to account for the sin(theta) term in the
-	// integration (see documentation).
-	if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-	if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm_vol);}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the SCCrystal
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double BarBellModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double BarBellModel :: calculate_ER() {
-	//NOT implemented yet!!!
-	return 0.0;
-}
-/**
- * Function to calculate volf_ratio for shell/tot
- * @return: volf_ratio value
- */
-double BarBellModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/bcc.cpp
===================================================================
--- src/sans/models/src/c_models/bcc.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,342 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "bcc.h"
-
-extern "C" {
-	#include "libSphere.h"
-}
-
-// Convenience structure
-typedef struct {
-  double scale;
-  double dnn;
-  double d_factor;
-  double radius;
-  double sldSph;
-  double sldSolv;
-  double background;
-  double theta;
-  double phi;
-  double psi;
-
-} BCParameters;
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the BCCCrystalModel
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double bc_analytical_2D_scaled(BCParameters *pars, double q, double q_x, double q_y) {
-  double b3_x, b3_y, b1_x, b1_y, b2_x, b2_y; //b3_z,
-  double q_z;
-  double cos_val_b3, cos_val_b2, cos_val_b1;
-  double a1_dot_q, a2_dot_q,a3_dot_q;
-  double answer;
-  double Pi = 4.0*atan(1.0);
-  double aa, Da, qDa_2, latticeScale, Zq, Fkq, Fkq_2;
-
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->theta * pi/180.0;
-  double phi = pars->phi * pi/180.0;
-  double psi = pars->psi * pi/180.0;
-
-  double dp[5];
-  dp[0] = 1.0;
-  dp[1] = pars->radius;
-  dp[2] = pars->sldSph;
-  dp[3] = pars->sldSolv;
-  dp[4] = 0.0;
-
-  aa = pars->dnn;
-  Da = pars->d_factor*aa;
-  qDa_2 = pow(q*Da,2.0);
-
-  //the occupied volume of the lattice
-  latticeScale = 2.0*(4.0/3.0)*Pi*(dp[1]*dp[1]*dp[1])/pow(aa/sqrt(3.0/4.0),3.0);
-  // q vector
-  q_z = 0.0; // for SANS; assuming qz is negligible
-  /// Angles here are respect to detector coordinate
-  ///  instead of against q coordinate(PRB 36(46), 3(6), 1754(3854))
-    // b3 axis orientation
-    b3_x = cos(theta) * cos(phi);
-    b3_y = sin(theta);
-    //b3_z = -cos(theta) * sin(phi);
-    cos_val_b3 =  b3_x*q_x + b3_y*q_y;// + b3_z*q_z;
-
-    //alpha = acos(cos_val_b3);
-    // b1 axis orientation
-    b1_x = -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-    b1_y = sin(psi)*cos(theta);
-    cos_val_b1 = b1_x*q_x + b1_y*q_y;
-    // b2 axis orientation
-    b2_x = -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-  	b2_y = cos(theta)*cos(psi);
-    cos_val_b2 = b2_x*q_x + b2_y*q_y;
-    
-    // The following test should always pass
-    if (fabs(cos_val_b3)>1.0) {
-      //printf("bcc_ana_2D: Unexpected error: cos()>1\n");
-      cos_val_b3 = 1.0;
-    }
-    if (fabs(cos_val_b2)>1.0) {
-      //printf("bcc_ana_2D: Unexpected error: cos()>1\n");
-      cos_val_b2 = 1.0;
-    }
-    if (fabs(cos_val_b1)>1.0) {
-      //printf("bcc_ana_2D: Unexpected error: cos()>1\n");
-      cos_val_b1 = 1.0;
-    }
-    // Compute the angle btw vector q and the a3 axis
-    a3_dot_q = 0.5*aa*q*(cos_val_b2+cos_val_b1-cos_val_b3);
-
-    // a1 axis
-    a1_dot_q = 0.5*aa*q*(cos_val_b3+cos_val_b2-cos_val_b1);
-
-    // a2 axis
-    a2_dot_q = 0.5*aa*q*(cos_val_b3+cos_val_b1-cos_val_b2);
-
-
-    // Get Fkq and Fkq_2
-    Fkq = exp(-0.5*pow(Da/aa,2.0)*(a1_dot_q*a1_dot_q+a2_dot_q*a2_dot_q+a3_dot_q*a3_dot_q));
-    Fkq_2 = Fkq*Fkq;
-    // Call Zq=Z1*Z2*Z3
-    Zq = (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a1_dot_q)+Fkq_2);
-    Zq *= (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a2_dot_q)+Fkq_2);
-    Zq *= (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a3_dot_q)+Fkq_2);
-
-  // Use SphereForm directly from libigor
-  answer = SphereForm(dp,q)*Zq;
-
-  //consider scales
-  answer *= latticeScale * pars->scale;
-
-  // This FIXES a singualrity the kernel in libigor.
-  if ( answer == INFINITY || answer == NAN){
-    answer = 0.0;
-  }
-
-  // add background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the BCC_ParaCrystal
- * @param q: q-value
- * @return: function value
- */
-static double bc_analytical_2DXY(BCParameters *pars, double qx, double qy){
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return bc_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-BCCrystalModel :: BCCrystalModel() {
-	scale      = Parameter(1.0);
-	dnn		= Parameter(220.0);
-	d_factor = Parameter(0.06);
-	radius     = Parameter(40.0, true);
-	radius.set_min(0.0);
-	sldSph   = Parameter(3.0e-6);
-	sldSolv   = Parameter(6.3e-6);
-	background = Parameter(0.0);
-	theta  = Parameter(0.0, true);
-	phi    = Parameter(0.0, true);
-	psi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double BCCrystalModel :: operator()(double q) {
-	double dp[7];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = dnn();
-	dp[2] = d_factor();
-	dp[3] = radius();
-	dp[4] = sldSph();
-	dp[5] = sldSolv();
-	dp[6] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-	double result;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[3] = weights_rad[i].value;
-
-		//Un-normalize SphereForm by volume
-		result = BCC_ParaCrystal(dp, q) * pow(weights_rad[i].value,3);
-		// This FIXES a singualrity in the kernel in libigor.
-		if ( result == INFINITY || result == NAN){
-			result = 0.0;
-		}
-		sum += weights_rad[i].weight
-			* result;
-		//Find average volume
-		vol += weights_rad[i].weight
-			* pow(weights_rad[i].value,3);
-
-		norm += weights_rad[i].weight;
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double BCCrystalModel :: operator()(double qx, double qy) {
-	BCParameters dp;
-	dp.scale      = scale();
-	dp.dnn   = dnn();
-	dp.d_factor   = d_factor();
-	dp.radius  = radius();
-	dp.sldSph   = sldSph();
-	dp.sldSolv   = sldSolv();
-	dp.background = 0.0;
-	dp.theta  = theta();
-	dp.phi    = phi();
-	dp.psi    = psi();
-	double pi = 4.0*atan(1.0);
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Get angular averaging for theta
-	vector<WeightPoint> weights_theta;
-	theta.get_weights(weights_theta);
-
-	// Get angular averaging for phi
-	vector<WeightPoint> weights_phi;
-	phi.get_weights(weights_phi);
-
-	// Get angular averaging for psi
-	vector<WeightPoint> weights_psi;
-	psi.get_weights(weights_psi);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double norm_vol = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp.radius = weights_rad[i].value;
-		// Average over theta distribution
-		for(size_t j=0; j< weights_theta.size(); j++) {
-			dp.theta = weights_theta[j].value;
-			// Average over phi distribution
-			for(size_t k=0; k< weights_phi.size(); k++) {
-				dp.phi = weights_phi[k].value;
-				// Average over phi distribution
-				for(size_t l=0; l< weights_psi.size(); l++) {
-					dp.psi = weights_psi[l].value;
-					//Un-normalize SphereForm by volume
-					double _ptvalue = weights_rad[i].weight
-										* weights_theta[j].weight
-										* weights_phi[k].weight
-										* weights_psi[l].weight
-										* bc_analytical_2DXY(&dp, qx, qy);
-										//* pow(weights_rad[i].value,3.0);
-					// Consider when there is infinity or nan.
-					// Actual value for this singular point are typically zero.
-					if ( _ptvalue == INFINITY || _ptvalue == NAN){
-						_ptvalue = 0.0;
-					}
-					if (weights_theta.size()>1) {
-						_ptvalue *= fabs(cos(weights_theta[j].value*pi/180.0));
-					}
-					sum += _ptvalue;
-					// This model dose not need the volume of spheres correction!!!
-					norm += weights_rad[i].weight
-							* weights_theta[j].weight
-							* weights_phi[k].weight
-							* weights_psi[l].weight;
-				}
-			}
-		}
-	}
-	// Averaging in theta needs an extra normalization
-	// factor to account for the sin(theta) term in the
-	// integration (see documentation).
-	if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-	if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm_vol);}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the BCCCrystal
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double BCCrystalModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double BCCrystalModel :: calculate_ER() {
-	//NOT implemented yet!!!
-	return 0.0;
-}
-double BCCrystalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/binaryHS.cpp
===================================================================
--- src/sans/models/src/c_models/binaryHS.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,127 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "binaryHS.h"
-
-extern "C" {
-#include "libSphere.h"
-}
-
-BinaryHSModel :: BinaryHSModel() {
-
-  l_radius     = Parameter(160.0, true);
-  l_radius.set_min(0.0);
-  s_radius    = Parameter(25.0, true);
-  s_radius.set_min(0.0);
-  vol_frac_ls  = Parameter(0.2);
-  vol_frac_ss  = Parameter(0.1);
-  ls_sld      = Parameter(3.5e-6);
-  ss_sld     = Parameter(5e-7);
-  solvent_sld   = Parameter(6.36e-6);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double BinaryHSModel :: operator()(double q) {
-  double dp[8];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = l_radius();
-  dp[1] = s_radius();
-  dp[2] = vol_frac_ls();
-  dp[3] = vol_frac_ss();
-  dp[4] = ls_sld();
-  dp[5] = ss_sld();
-  dp[6] = solvent_sld();
-  dp[7] = 0.0;
-
-
-  // Get the dispersion points for the large radius
-  vector<WeightPoint> weights_l_radius;
-  l_radius.get_weights(weights_l_radius);
-
-  // Get the dispersion points for the small radius
-  vector<WeightPoint> weights_s_radius;
-  s_radius.get_weights(weights_s_radius);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over larger radius weight points
-  for(int i=0; i< (int)weights_l_radius.size(); i++) {
-    dp[0] = weights_l_radius[i].value;
-
-    // Loop over small radius weight points
-    for(int j=0; j< (int)weights_s_radius.size(); j++) {
-      dp[1] = weights_s_radius[j].value;
-
-
-      sum += weights_l_radius[i].weight *weights_s_radius[j].weight * BinaryHS(dp, q);
-      norm += weights_l_radius[i].weight *weights_s_radius[j].weight;
-    }
-  }
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double BinaryHSModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the vesicle
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double BinaryHSModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double BinaryHSModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double BinaryHSModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/binaryHS_PSF11.cpp
===================================================================
--- src/sans/models/src/c_models/binaryHS_PSF11.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,148 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-
-extern "C" {
-	#include "libSphere.h"
-}
-
-class BinaryHSPSF11Model{
-public:
-  // Model parameters
-  Parameter l_radius;
-  Parameter s_radius;
-  Parameter vol_frac_ls;
-  Parameter vol_frac_ss;
-  Parameter ls_sld;
-  Parameter ss_sld;
-  Parameter solvent_sld;
-  Parameter background;
-
-  //Constructor
-  BinaryHSPSF11Model();
-
-  //Operators to get I(Q)
-  double operator()(double q);
-  double operator()(double qx , double qy);
-  double calculate_ER();
-  double calculate_VR();
-  double evaluate_rphi(double q, double phi);
-};
-
-BinaryHSPSF11Model :: BinaryHSPSF11Model() {
-
-	l_radius     = Parameter(160.0, true);
-	l_radius.set_min(0.0);
-	s_radius    = Parameter(25.0, true);
-	s_radius.set_min(0.0);
-	vol_frac_ls  = Parameter(0.2);
-	vol_frac_ss  = Parameter(0.1);
-	ls_sld      = Parameter(3.5e-6);
-	ss_sld     = Parameter(5e-7);
-	solvent_sld   = Parameter(6.36e-6);
-	background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double BinaryHSPSF11Model :: operator()(double q) {
-	double dp[8];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = l_radius();
-	dp[1] = s_radius();
-	dp[2] = vol_frac_ls();
-	dp[3] = vol_frac_ss();
-	dp[4] = ls_sld();
-	dp[5] = ss_sld();
-	dp[6] = solvent_sld();
-	dp[7] = 0.0;
-
-
-	// Get the dispersion points for the large radius
-	vector<WeightPoint> weights_l_radius;
-	l_radius.get_weights(weights_l_radius);
-
-	// Get the dispersion points for the small radius
-	vector<WeightPoint> weights_s_radius;
-	s_radius.get_weights(weights_s_radius);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over larger radius weight points
-	for(int i=0; i< (int)weights_l_radius.size(); i++) {
-		dp[0] = weights_l_radius[i].value;
-
-		// Loop over small radius weight points
-		for(int j=0; j< (int)weights_s_radius.size(); j++) {
-			dp[1] = weights_s_radius[j].value;
-
-
-			sum += weights_l_radius[i].weight *weights_s_radius[j].weight * BinaryHS_PSF11(dp, q);
-			norm += weights_l_radius[i].weight *weights_s_radius[j].weight;
-		}
-	}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double BinaryHSPSF11Model :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the vesicle
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double BinaryHSPSF11Model :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double BinaryHSPSF11Model :: calculate_ER() {
-//NOT implemented yet!!!
-	return 0.0;
-}
-double BinaryHSPSF11Model :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/c_models.cpp
===================================================================
--- src/sans/models/src/c_models/c_models.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,329 +1,0 @@
-/** 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: c/sans/models/src/c_models/c_models.cpp.template
===================================================================
--- src/sans/models/src/c_models/c_models.cpp.template	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,198 +1,0 @@
-/** 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"
-
-// [TAG_1]
-
-
-
-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();
-
-  // [TAG_2]
-
-}
Index: c/sans/models/src/c_models/capcyl.cpp
===================================================================
--- src/sans/models/src/c_models/capcyl.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,407 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-
-extern "C" {
-  #include "GaussWeights.h"
-	#include "libCylinder.h"
-}
-#include "capcyl.h"
-
-// Convenience parameter structure
-typedef struct {
-    double scale;
-    double rad_cyl;
-    double len_cyl;
-    double rad_cap;
-    double sld_capcyl;
-    double sld_solv;
-    double background;
-    double theta;
-    double phi;
-} CapCylParameters;
-
-CappedCylinderModel :: CappedCylinderModel() {
-	scale      = Parameter(1.0);
-	rad_cyl		= Parameter(20.0);
-	rad_cyl.set_min(0.0);
-	len_cyl     = Parameter(400.0, true);
-	len_cyl.set_min(0.0);
-	rad_cap = Parameter(40.0);
-	rad_cap.set_min(0.0);
-	sld_capcyl  = Parameter(1.0e-6);
-	sld_solv   = Parameter(6.3e-6);
-	background = Parameter(0.0);
-	theta  = Parameter(0.0, true);
-	phi    = Parameter(0.0, true);
-}
-
-static double capcyl2d_kernel(double dp[], double q, double alpha) {
-  int j;
-  double Pi;
-  double scale,contr,bkg,sldc,slds;
-  double len,rad,hDist,endRad;
-  int nordj=76;
-  double zi=alpha,yyy,answer;     //running tally of integration
-  double summj,vaj,vbj,zij;     //for the inner integration
-  double arg1,arg2,inner,be;
-
-
-  scale = dp[0];
-  rad = dp[1];
-  len = dp[2];
-  endRad = dp[3];
-  sldc = dp[4];
-  slds = dp[5];
-  bkg = dp[6];
-
-  hDist = -1.0*sqrt(fabs(endRad*endRad-rad*rad));   //by definition for this model
-
-  contr = sldc-slds;
-
-  Pi = 4.0*atan(1.0);
-  vaj = -1.0*hDist/endRad;
-  vbj = 1.0;    //endpoints of inner integral
-
-  summj=0.0;
-
-  for(j=0;j<nordj;j++) {
-    //20 gauss points for the inner integral
-    zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;    //the "t" dummy
-    yyy = Gauss76Wt[j] * ConvLens_kernel(dp,q,zij,zi);    //uses the same Kernel as the Dumbbell, here L>0
-    summj += yyy;
-  }
-  //now calculate the value of the inner integral
-  inner = (vbj-vaj)/2.0*summj;
-  inner *= 4.0*Pi*endRad*endRad*endRad;
-
-  //now calculate outer integrand
-  arg1 = q*len/2.0*cos(zi);
-  arg2 = q*rad*sin(zi);
-  yyy = inner;
-
-  if(arg2 == 0) {
-    be = 0.5;
-  } else {
-    be = NR_BessJ1(arg2)/arg2;
-  }
-
-  if(arg1 == 0.0) {   //limiting value of sinc(0) is 1; sinc is not defined in math.h
-    yyy += Pi*rad*rad*len*2.0*be;
-  } else {
-    yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-  }
-  yyy *= yyy;   //sin(zi);
-  answer = yyy;
-
-
-  answer /= Pi*rad*rad*len + 2.0*Pi*(2.0*endRad*endRad*endRad/3.0+endRad*endRad*hDist-hDist*hDist*hDist/3.0);   //divide by volume
-  answer *= 1.0e8;    //convert to cm^-1
-  answer *= contr*contr;
-  answer *= scale;
-  answer += bkg;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the BarBell
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double capcyl_analytical_2D_scaled(CapCylParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y;//, cyl_z;
-  //double q_z;
-  double alpha, cos_val;
-  double answer;
-  double dp[7];
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->theta * pi/180.0;
-  double phi = pars->phi * pi/180.0;
-
-  dp[0] = pars->scale;
-  dp[1] = pars->rad_cyl;
-  dp[2] = pars->len_cyl;
-  dp[3] = pars->rad_cap;
-  dp[4] = pars->sld_capcyl;
-  dp[5] = pars->sld_solv;
-  dp[6] = pars->background;
-
-
-  //double Pi = 4.0*atan(1.0);
-    // Cylinder orientation
-    cyl_x = cos(theta) * cos(phi);
-    cyl_y = sin(theta);
-    //cyl_z = -cos(theta) * sin(phi);
-
-    // q vector
-    //q_z = 0;
-
-    // Compute the angle btw vector q and the
-    // axis of the cylinder
-    cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-    // The following test should always pass
-    if (fabs(cos_val)>1.0) {
-      printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
-      return 0;
-    }
-
-    // Note: cos(alpha) = 0 and 1 will get an
-    // undefined value from CylKernel
-  alpha = acos( cos_val );
-
-  // Call the IGOR library function to get the kernel
-  answer = capcyl2d_kernel(dp, q, alpha)/sin(alpha);
-
-
-  return answer;
-
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the BarBell
- * @param q: q-value
- * @return: function value
- */
-static double capcyl_analytical_2DXY(CapCylParameters *pars, double qx, double qy){
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return capcyl_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CappedCylinderModel :: operator()(double q) {
-	double dp[7];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = rad_cyl();
-	dp[2] = len_cyl();
-	dp[3] = rad_cap();
-	dp[4] = sld_capcyl();
-	dp[5] = sld_solv();
-	dp[6] = 0.0;
-
-	// Get the dispersion points for the rad_cyl
-	vector<WeightPoint> weights_rad_cyl;
-	rad_cyl.get_weights(weights_rad_cyl);
-	// Get the dispersion points for the len_cyl
-	vector<WeightPoint> weights_len_cyl;
-	len_cyl.get_weights(weights_len_cyl);
-	// Get the dispersion points for the rad_cap
-	vector<WeightPoint> weights_rad_cap;
-	rad_cap.get_weights(weights_rad_cap);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-	double pi,hDist,result;
-	double vol_i = 0.0;
-	pi = 4.0*atan(1.0);
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad_cyl.size(); i++) {
-		dp[1] = weights_rad_cyl[i].value;
-		for(size_t j=0; j<weights_len_cyl.size(); j++) {
-			dp[2] = weights_len_cyl[j].value;
-			for(size_t k=0; k<weights_rad_cap.size(); k++) {
-				dp[3] = weights_rad_cap[k].value;
-
-				//Un-normalize SphereForm by volume
-				hDist = -1.0*sqrt(fabs(dp[3]*dp[3]-dp[1]*dp[1]));
-				vol_i = pi*dp[1]*dp[1]*dp[2]+2.0*pi/3.0*((dp[3]-hDist)*(dp[3]-hDist)*
-								(2.0*(dp[3]+hDist)));
-				result =  CappedCylinder(dp, q) * vol_i;
-				// This FIXES a singualrity the kernel in libigor.
-				if ( result == INFINITY || result == NAN){
-					result = 0.0;
-				}
-				sum += weights_rad_cyl[i].weight*weights_len_cyl[j].weight*weights_rad_cap[k].weight
-					* result;
-				//Find average volume
-				vol += weights_rad_cyl[i].weight*weights_len_cyl[j].weight*weights_rad_cap[k].weight
-					* vol_i;
-
-				norm += weights_rad_cyl[i].weight*weights_len_cyl[j].weight*weights_rad_cap[k].weight;
-			}
-		}
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CappedCylinderModel :: operator()(double qx, double qy) {
-	CapCylParameters dp;
-
-	dp.scale = scale();
-	dp.rad_cyl = rad_cyl();
-	dp.len_cyl = len_cyl();
-	dp.rad_cap = rad_cap();
-	dp.sld_capcyl = sld_capcyl();
-	dp.sld_solv = sld_solv();
-	dp.background = 0.0;
-	dp.theta  = theta();
-	dp.phi    = phi();
-
-	// Get the dispersion points for the rad_bar
-	vector<WeightPoint> weights_rad_cyl;
-	rad_cyl.get_weights(weights_rad_cyl);
-
-	// Get the dispersion points for the len_bar
-	vector<WeightPoint> weights_len_cyl;
-	len_cyl.get_weights(weights_len_cyl);
-
-	// Get the dispersion points for the rad_bell
-	vector<WeightPoint> weights_rad_cap;
-	rad_cap.get_weights(weights_rad_cap);
-
-	// Get angular averaging for theta
-	vector<WeightPoint> weights_theta;
-	theta.get_weights(weights_theta);
-
-	// Get angular averaging for phi
-	vector<WeightPoint> weights_phi;
-	phi.get_weights(weights_phi);
-
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double norm_vol = 0.0;
-	double vol = 0.0;
-	double pi,hDist;
-	double vol_i = 0.0;
-	pi = 4.0*atan(1.0);
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad_cyl.size(); i++) {
-		dp.rad_cyl = weights_rad_cyl[i].value;
-		for(size_t j=0; j<weights_len_cyl.size(); j++) {
-			dp.len_cyl = weights_len_cyl[j].value;
-			for(size_t k=0; k<weights_rad_cap.size(); k++) {
-				dp.rad_cap = weights_rad_cap[k].value;
-				// Average over theta distribution
-				for(size_t l=0; l< weights_theta.size(); l++) {
-					dp.theta = weights_theta[l].value;
-					// Average over phi distribution
-					for(size_t m=0; m< weights_phi.size(); m++) {
-						dp.phi = weights_phi[m].value;
-						//Un-normalize Form by volume
-						hDist = -1.0*sqrt(fabs(dp.rad_cap*dp.rad_cap-dp.rad_cyl*dp.rad_cyl));
-						vol_i = pi*dp.rad_cyl*dp.rad_cyl*dp.len_cyl+2.0*pi/3.0*((dp.rad_cap-hDist)*(dp.rad_cap-hDist)*
-										(2*dp.rad_cap+hDist));
-
-						double _ptvalue = weights_rad_cyl[i].weight
-											* weights_len_cyl[j].weight
-											* weights_rad_cap[k].weight
-											* weights_theta[l].weight
-											* weights_phi[m].weight
-											* vol_i
-											* capcyl_analytical_2DXY(&dp, qx, qy);
-											//* pow(weights_rad[i].value,3.0);
-						// Consider when there is infinte or nan.
-						if ( _ptvalue == INFINITY || _ptvalue == NAN){
-							_ptvalue = 0.0;
-						}
-						if (weights_theta.size()>1) {
-							_ptvalue *= fabs(cos(weights_theta[l].value*pi/180.0));
-						}
-						sum += _ptvalue;
-						// This model dose not need the volume of spheres correction!!!
-						//Find average volume
-						vol += weights_rad_cyl[i].weight
-								* weights_len_cyl[j].weight
-								* weights_rad_cap[k].weight
-								* vol_i;
-						//Find norm for volume
-						norm_vol += weights_rad_cyl[i].weight
-								* weights_len_cyl[j].weight
-								* weights_rad_cap[k].weight;
-
-						norm += weights_rad_cyl[i].weight
-								* weights_len_cyl[j].weight
-								* weights_rad_cap[k].weight
-								* weights_theta[l].weight
-								* weights_phi[m].weight;
-					}
-				}
-			}
-		}
-	}
-	// Averaging in theta needs an extra normalization
-	// factor to account for the sin(theta) term in the
-	// integration (see documentation).
-	if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-	if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm_vol);}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the SCCrystal
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CappedCylinderModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CappedCylinderModel :: calculate_ER() {
-	//NOT implemented yet!!!
-	return 0.0;
-}
-double CappedCylinderModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/corefourshell.cpp
===================================================================
--- src/sans/models/src/c_models/corefourshell.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,552 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "corefourshell.h"
-
-extern "C" {
-	#include "libSphere.h"
-	#include "libmultifunc/libfunc.h"
-}
-
-typedef struct {
-  double scale;
-  double rad_core0;
-  double sld_core0;
-  double thick_shell1;
-  double sld_shell1;
-  double thick_shell2;
-  double sld_shell2;
-  double thick_shell3;
-  double sld_shell3;
-  double thick_shell4;
-  double sld_shell4;
-  double sld_solv;
-  double background;
-  double M0_sld_shell1;
-  double M_theta_shell1;
-  double M_phi_shell1;
-  double M0_sld_shell2;
-  double M_theta_shell2;
-  double M_phi_shell2;
-  double M0_sld_shell3;
-  double M_theta_shell3;
-  double M_phi_shell3;
-  double M0_sld_shell4;
-  double M_theta_shell4;
-  double M_phi_shell4;
-  double M0_sld_core0;
-  double M_theta_core0;
-  double M_phi_core0;
-  double M0_sld_solv;
-  double M_theta_solv;
-  double M_phi_solv;
-  double Up_frac_i;
-  double Up_frac_f;
-  double Up_theta;
-} CoreFourShellParameters;
-
-CoreFourShellModel :: CoreFourShellModel() {
-	scale      = Parameter(1.0);
-	rad_core0     = Parameter(60.0, true);
-	rad_core0.set_min(0.0);
-	sld_core0   = Parameter(6.4e-6);
-	thick_shell1     = Parameter(10.0, true);
-	thick_shell1.set_min(0.0);
-	sld_shell1   = Parameter(1.0e-6);
-	thick_shell2     = Parameter(10.0, true);
-	thick_shell2.set_min(0.0);
-	sld_shell2   = Parameter(2.0e-6);
-	thick_shell3     = Parameter(10.0, true);
-	thick_shell3.set_min(0.0);
-	sld_shell3   = Parameter(3.0e-6);
-	thick_shell4     = Parameter(10.0, true);
-	thick_shell4.set_min(0.0);
-	sld_shell4   = Parameter(4.0e-6);
-	sld_solv   = Parameter(6.4e-6);
-	background = Parameter(0.001);
-	M0_sld_shell1 = Parameter(0.0e-6);
-	M_theta_shell1 = Parameter(0.0);
-	M_phi_shell1 = Parameter(0.0);
-	M0_sld_shell2 = Parameter(0.0e-6);
-	M_theta_shell2 = Parameter(0.0);
-	M_phi_shell2 = Parameter(0.0);
-	M0_sld_shell3 = Parameter(0.0e-6);
-	M_theta_shell3 = Parameter(0.0);
-	M_phi_shell3 = Parameter(0.0);
-	M0_sld_shell4 = Parameter(0.0e-6);
-	M_theta_shell4 = Parameter(0.0);
-	M_phi_shell4 = Parameter(0.0);
-	M0_sld_core0 = Parameter(0.0e-6);
-	M_theta_core0 = Parameter(0.0);
-	M_phi_core0 = Parameter(0.0);
-	M0_sld_solv = Parameter(0.0e-6);
-	M_theta_solv = Parameter(0.0);
-	M_phi_solv = Parameter(0.0);
-	Up_frac_i = Parameter(0.5);
-	Up_frac_f = Parameter(0.5);
-	Up_theta = Parameter(0.0);
-
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CoreFourShellModel :: operator()(double q) {
-	double dp[13];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-
-	dp[0] = scale();
-	dp[1] = rad_core0();
-	dp[2] = sld_core0();
-	dp[3] = thick_shell1();
-	dp[4] = sld_shell1();
-	dp[5] = thick_shell2();
-	dp[6] = sld_shell2();
-	dp[7] = thick_shell3();
-	dp[8] = sld_shell3();
-	dp[9] = thick_shell4();
-	dp[10] = sld_shell4();
-	dp[11] = sld_solv();
-	dp[12] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	rad_core0.get_weights(weights_rad);
-
-	// Get the dispersion points for the thick 1
-	vector<WeightPoint> weights_s1;
-	thick_shell1.get_weights(weights_s1);
-
-	// Get the dispersion points for the thick 2
-	vector<WeightPoint> weights_s2;
-	thick_shell2.get_weights(weights_s2);
-
-	// Get the dispersion points for the thick 3
-	vector<WeightPoint> weights_s3;
-	thick_shell3.get_weights(weights_s3);
-
-	// Get the dispersion points for the thick 4
-	vector<WeightPoint> weights_s4;
-	thick_shell4.get_weights(weights_s4);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[1] = weights_rad[i].value;
-		// Loop over radius weight points
-		for(size_t j=0; j<weights_s1.size(); j++) {
-			dp[3] = weights_s1[j].value;
-			// Loop over radius weight points
-			for(size_t k=0; k<weights_s2.size(); k++) {
-				dp[5] = weights_s2[k].value;
-				// Loop over radius weight points
-				for(size_t l=0; l<weights_s3.size(); l++) {
-					dp[7] = weights_s3[l].value;
-					// Loop over radius weight points
-					for(size_t m=0; m<weights_s4.size(); m++) {
-						dp[9] = weights_s4[m].value;
-						//Un-normalize FourShell by volume
-						sum += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-							* FourShell(dp, q) * pow((weights_rad[i].value+weights_s1[j].value+weights_s2[k].value+weights_s3[l].value+weights_s4[m].value),3);
-						//Find average volume
-						vol += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-							* pow((weights_rad[i].value+weights_s1[j].value+weights_s2[k].value+weights_s3[l].value+weights_s4[m].value),3);
-
-						norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight;
-					}
-				}
-			}
-		}
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-
-static double corefourshell_analytical_2D_scaled(CoreFourShellParameters *pars, double q, double q_x, double q_y) {
-	double dp[13];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-
-	dp[0] = pars->scale;
-	dp[1] = pars->rad_core0;
-	dp[2] = 0.0; //sld_core0;
-	dp[3] = pars->thick_shell1;
-	dp[4] = 0.0; //sld_shell1;
-	dp[5] = pars->thick_shell2;
-	dp[6] = 0.0; //sld_shell2;
-	dp[7] = pars->thick_shell3;
-	dp[8] = 0.0; //sld_shell3;
-	dp[9] = pars->thick_shell4;
-	dp[10] = 0.0; //sld_shell4;
-	dp[11] = 0.0; //sld_solv;
-	dp[12] = 0.0;
-
-    double sld_core0 = pars->sld_core0;
-    double sld_shell1 = pars->sld_shell1;
-	double sld_shell2 = pars->sld_shell2;
-	double sld_shell3 = pars->sld_shell3;
-	double sld_shell4 = pars->sld_shell4;
-	double sld_solv = pars->sld_solv;
-	double answer = 0.0;
-	double m_max0 = pars->M0_sld_core0;
-	double m_max_shell1 = pars->M0_sld_shell1;
-	double m_max_shell2 = pars->M0_sld_shell2;
-	double m_max_shell3 = pars->M0_sld_shell3;
-	double m_max_shell4 = pars->M0_sld_shell4;
-	double m_max_solv = pars->M0_sld_solv;
-
-	if (m_max0 < 1.0e-32 && m_max_solv < 1.0e-32 && m_max_shell1 < 1.0e-32 && m_max_shell2 <
-						1.0e-32 && m_max_shell3 < 1.0e-32 && m_max_shell4 < 1.0e-32){
-		dp[2] = sld_core0;
-		dp[4] = sld_shell1;
-		dp[6] = sld_shell2;
-		dp[8] = sld_shell3;
-		dp[10] = sld_shell4;
-		dp[11] = sld_solv;
-		answer = FourShell(dp, q);
-	}
-	else{
-		double qx = q_x;
-		double qy = q_y;
-		double s_theta = pars->Up_theta;
-		double m_phi0 = pars->M_phi_core0;
-		double m_theta0 = pars->M_theta_core0;
-		double m_phi_shell1 = pars->M_phi_shell1;
-		double m_theta_shell1 = pars->M_theta_shell1;
-		double m_phi_shell2 = pars->M_phi_shell2;
-		double m_theta_shell2 = pars->M_theta_shell2;
-		double m_phi_shell3 = pars->M_phi_shell3;
-		double m_theta_shell3 = pars->M_theta_shell3;
-		double m_phi_shell4 = pars->M_phi_shell4;
-		double m_theta_shell4 = pars->M_theta_shell4;
-		double m_phi_solv = pars->M_phi_solv;
-		double m_theta_solv = pars->M_theta_solv;
-		double in_spin = pars->Up_frac_i;
-		double out_spin = pars->Up_frac_f;
-		polar_sld p_sld_core0;
-		polar_sld p_sld_shell1;
-		polar_sld p_sld_shell2;
-		polar_sld p_sld_shell3;
-		polar_sld p_sld_shell4;
-		polar_sld p_sld_solv;
-		//Find (b+m) slds
-		p_sld_core0 = cal_msld(1, qx, qy, sld_core0, m_max0, m_theta0, m_phi0,
-								in_spin, out_spin, s_theta);
-		p_sld_shell1 = cal_msld(1, qx, qy, sld_shell1, m_max_shell1, m_theta_shell1, m_phi_shell1,
-								in_spin, out_spin, s_theta);
-		p_sld_shell2 = cal_msld(1, qx, qy, sld_shell2, m_max_shell2, m_theta_shell2, m_phi_shell2,
-								in_spin, out_spin, s_theta);
-		p_sld_shell3 = cal_msld(1, qx, qy, sld_shell3, m_max_shell3, m_theta_shell3, m_phi_shell3,
-								in_spin, out_spin, s_theta);
-		p_sld_shell4 = cal_msld(1, qx, qy, sld_shell4, m_max_shell4, m_theta_shell4, m_phi_shell4,
-								in_spin, out_spin, s_theta);
-		p_sld_solv = cal_msld(1, qx, qy, sld_solv, m_max_solv, m_theta_solv, m_phi_solv,
-						 		in_spin, out_spin, s_theta);
-		//up_up
-		if (in_spin > 0.0 && out_spin > 0.0){
-			dp[2] = p_sld_core0.uu;
-			dp[4] = p_sld_shell1.uu;
-			dp[6] = p_sld_shell2.uu;
-			dp[8] = p_sld_shell3.uu;
-			dp[10] = p_sld_shell4.uu;
-			dp[11] = p_sld_solv.uu;
-			answer += FourShell(dp, q);
-			}
-		//down_down
-		if (in_spin < 1.0 && out_spin < 1.0){
-			dp[2] = p_sld_core0.dd;
-			dp[4] = p_sld_shell1.dd;
-			dp[6] = p_sld_shell2.dd;
-			dp[8] = p_sld_shell3.dd;
-			dp[10] = p_sld_shell4.dd;
-			dp[11] = p_sld_solv.dd;
-			answer += FourShell(dp, q);
-			}
-		//up_down
-		if (in_spin > 0.0 && out_spin < 1.0){
-			dp[2] = p_sld_core0.re_ud;
-			dp[4] = p_sld_shell1.re_ud;
-			dp[6] = p_sld_shell2.re_ud;
-			dp[8] = p_sld_shell3.re_ud;
-			dp[10] = p_sld_shell4.re_ud;
-			dp[11] = p_sld_solv.re_ud;
-			answer += FourShell(dp, q);
-			dp[2] = p_sld_core0.im_ud;
-			dp[4] = p_sld_shell1.im_ud;
-			dp[6] = p_sld_shell2.im_ud;
-			dp[8] = p_sld_shell3.im_ud;
-			dp[10] = p_sld_shell4.im_ud;
-			dp[11] = p_sld_solv.im_ud;
-			answer += FourShell(dp, q);
-			}
-		//down_up
-		if (in_spin < 1.0 && out_spin > 0.0){
-			dp[2] = p_sld_core0.re_du;
-			dp[4] = p_sld_shell1.re_du;
-			dp[6] = p_sld_shell2.re_du;
-			dp[8] = p_sld_shell3.re_du;
-			dp[10] = p_sld_shell4.re_du;
-			dp[11] = p_sld_solv.re_du;
-			answer += FourShell(dp, q);
-			dp[2] = p_sld_core0.im_du;
-			dp[4] = p_sld_shell1.im_du;
-			dp[6] = p_sld_shell2.im_du;
-			dp[8] = p_sld_shell3.im_du;
-			dp[10] = p_sld_shell4.im_du;
-			dp[11] = p_sld_solv.im_du;
-			answer += FourShell(dp, q);
-			}
-	}
-	// Already normalized
-	// add in the background
-	answer += pars->background;
-	return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters
- * @param q: q-value
- * @return: function value
- */
-static double corefourshell_analytical_2DXY(CoreFourShellParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return corefourshell_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-double CoreFourShellModel :: operator()(double qx, double qy) {
-	CoreFourShellParameters dp;
-	dp.scale = scale();
-	dp.rad_core0 = rad_core0();
-	dp.sld_core0 = sld_core0();
-	dp.thick_shell1 = thick_shell1();
-	dp.sld_shell1 = sld_shell1();
-	dp.thick_shell2 = thick_shell2();
-	dp.sld_shell2 = sld_shell2();
-	dp.thick_shell3 = thick_shell3();
-	dp.sld_shell3 = sld_shell3();
-	dp.thick_shell4 = thick_shell4();
-	dp.sld_shell4 = sld_shell4();
-	dp.sld_solv = sld_solv();
-	dp.background = 0.0;
-	dp.M0_sld_shell1 = M0_sld_shell1();
-	dp.M_theta_shell1 = M_theta_shell1();
-	dp.M_phi_shell1 = M_phi_shell1();
-	dp.M0_sld_shell2 = M0_sld_shell2();
-	dp.M_theta_shell2 = M_theta_shell2();
-	dp.M_phi_shell2 = M_phi_shell2();
-	dp.M0_sld_shell3 = M0_sld_shell3();
-	dp.M_theta_shell3 = M_theta_shell3();
-	dp.M_phi_shell3 = M_phi_shell3();
-	dp.M0_sld_shell4 = M0_sld_shell4();
-	dp.M_theta_shell4 = M_theta_shell4();
-	dp.M_phi_shell4 = M_phi_shell4();
-	dp.M0_sld_core0 = M0_sld_core0();
-	dp.M_theta_core0 = M_theta_core0();
-	dp.M_phi_core0 = M_phi_core0();
-	dp.M0_sld_solv = M0_sld_solv();
-	dp.M_theta_solv = M_theta_solv();
-	dp.M_phi_solv = M_phi_solv();
-	dp.Up_frac_i = Up_frac_i();
-	dp.Up_frac_f = Up_frac_f();
-	dp.Up_theta = Up_theta();
-    
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	rad_core0.get_weights(weights_rad);
-
-	// Get the dispersion points for the thick 1
-	vector<WeightPoint> weights_s1;
-	thick_shell1.get_weights(weights_s1);
-
-	// Get the dispersion points for the thick 2
-	vector<WeightPoint> weights_s2;
-	thick_shell2.get_weights(weights_s2);
-
-	// Get the dispersion points for the thick 3
-	vector<WeightPoint> weights_s3;
-	thick_shell3.get_weights(weights_s3);
-
-	// Get the dispersion points for the thick 4
-	vector<WeightPoint> weights_s4;
-	thick_shell4.get_weights(weights_s4);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp.rad_core0 = weights_rad[i].value;
-		// Loop over radius weight points
-		for(size_t j=0; j<weights_s1.size(); j++) {
-			dp.thick_shell1 = weights_s1[j].value;
-			// Loop over radius weight points
-			for(size_t k=0; k<weights_s2.size(); k++) {
-				dp.thick_shell2 = weights_s2[k].value;
-				// Loop over radius weight points
-				for(size_t l=0; l<weights_s3.size(); l++) {
-					dp.thick_shell3 = weights_s3[l].value;
-					// Loop over radius weight points
-					for(size_t m=0; m<weights_s4.size(); m++) {
-						dp.thick_shell4 = weights_s4[m].value;
-						//Un-normalize FourShell by volume
-						sum += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-							* corefourshell_analytical_2DXY(&dp, qx, qy) * pow((weights_rad[i].value+weights_s1[j].value+weights_s2[k].value+weights_s3[l].value+weights_s4[m].value),3);
-						//Find average volume
-						vol += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-							* pow((weights_rad[i].value+weights_s1[j].value+weights_s2[k].value+weights_s3[l].value+weights_s4[m].value),3);
-
-						norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight;
-					}
-				}
-			}
-		}
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CoreFourShellModel :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CoreFourShellModel :: calculate_ER() {
-	CoreFourShellParameters dp;
-
-	dp.scale = scale();
-	dp.rad_core0 = rad_core0();
-	dp.sld_core0 = sld_core0();
-	dp.thick_shell1 = thick_shell1();
-	dp.sld_shell1 = sld_shell1();
-	dp.thick_shell2 = thick_shell2();
-	dp.sld_shell2 = sld_shell2();
-	dp.thick_shell3 = thick_shell3();
-	dp.sld_shell3 = sld_shell3();
-	dp.thick_shell4 = thick_shell4();
-	dp.sld_shell4 = sld_shell4();
-	dp.sld_solv = sld_solv();
-	dp.background = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	rad_core0.get_weights(weights_rad);
-
-	// Get the dispersion points for the thick 1
-	vector<WeightPoint> weights_s1;
-	thick_shell1.get_weights(weights_s1);
-
-	// Get the dispersion points for the thick 2
-	vector<WeightPoint> weights_s2;
-	thick_shell2.get_weights(weights_s2);
-
-	// Get the dispersion points for the thick 3
-	vector<WeightPoint> weights_s3;
-	thick_shell3.get_weights(weights_s3);
-
-	// Get the dispersion points for the thick 4
-	vector<WeightPoint> weights_s4;
-	thick_shell4.get_weights(weights_s4);
-
-	double rad_out = 0.0;
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp.rad_core0 = weights_rad[i].value;
-		// Loop over radius weight points
-		for(size_t j=0; j<weights_s1.size(); j++) {
-			dp.thick_shell1 = weights_s1[j].value;
-			// Loop over radius weight points
-			for(size_t k=0; k<weights_s2.size(); k++) {
-				dp.thick_shell2 = weights_s2[k].value;
-				// Loop over radius weight points
-				for(size_t l=0; l<weights_s3.size(); l++) {
-					dp.thick_shell3 = weights_s3[l].value;
-					// Loop over radius weight points
-					for(size_t m=0; m<weights_s4.size(); m++) {
-						dp.thick_shell4 = weights_s4[m].value;
-						//Un-normalize FourShell by volume
-						sum += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-							* (dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4);
-						norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight;
-					}
-				}
-			}
-		}
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		rad_out = dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4;}
-
-	return rad_out;
-}
-double CoreFourShellModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/coresecondmoment.cpp
===================================================================
--- src/sans/models/src/c_models/coresecondmoment.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/**
- * Scattering model classes
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "coresecondmoment.h"
-
-static double core_secondmoment_kernel(double dp[], double q) {
-  //fit parameters
-  double scale = dp[0];
-  double density_poly = dp[1];
-  double sld_poly = dp[2];
-  double radius_core = dp[3];
-  double volf_cores = dp[4];
-  double ads_amount = dp[5];
-  double second_moment = dp[6];
-  double sld_solv = dp[7];
-  double background = dp[8];
-  // Not valid for very small r
-  if (radius_core < 0.001){
-	  return 0.0;
-  }
-  //others
-  double form_factor = 0.0;
-  double x_val = 0.0;
-  //Pi
-  double pi = 4.0 * atan(1.0);
-  //relative sld
-  double contrast = sld_poly - sld_solv;
-  //x for exp
-  x_val = q*second_moment;
-  x_val *= x_val;
-  //computation
-  form_factor = contrast * ads_amount;
-  form_factor /= (q * density_poly);
-  form_factor *= form_factor;
-  form_factor *= (6.0 * pi * volf_cores * 1.0e+10);
-  form_factor /= radius_core;
-  form_factor *= exp(-x_val);
-
-  // scale and background
-  form_factor *= scale;
-  form_factor += background;
-  return (form_factor);
-}
-
-Core2ndMomentModel :: Core2ndMomentModel() {
-	scale = Parameter(1.0);
-	density_poly = Parameter(0.7);
-	sld_poly = Parameter(1.5e-6);
-	radius_core = Parameter(500.0, true);
-	radius_core.set_min(0.0);
-	volf_cores = Parameter(0.14);
-	ads_amount = Parameter(1.9);
-	second_moment = Parameter(23.0);
-	sld_solv   = Parameter(6.3e-6);
-	background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double Core2ndMomentModel :: operator()(double q) {
-	double dp[9];
-
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = density_poly();
-	dp[2] = sld_poly();
-	dp[3] = radius_core();
-	dp[4] = volf_cores();
-	dp[5] = ads_amount();
-	dp[6] = second_moment();
-	dp[7] = sld_solv();
-	dp[8] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius_core.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[3] = weights_rad[i].value;
-		//weighted sum
-		sum += weights_rad[i].weight
-			* core_secondmoment_kernel(dp, q);
-		norm += weights_rad[i].weight;
-	}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double Core2ndMomentModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double Core2ndMomentModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double Core2ndMomentModel :: calculate_ER() {
-	return 0.0;
-}
-double Core2ndMomentModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/coreshellbicelle.cpp
===================================================================
--- src/sans/models/src/c_models/coreshellbicelle.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,433 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "core_shell_bicelle.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double radius;
-  double rim_thick;
-  double face_thick;
-  double length;
-  double core_sld;
-  double rim_sld;
-  double face_sld;
-  double solvent_sld;
-  double background;
-  double axis_theta;
-  double axis_phi;
-} CoreShellBicelleParameters;
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the core-shell Bicelle
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double core_shell_bicelle_analytical_2D_scaled(CoreShellBicelleParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y;//, cyl_z;
-  //double q_z;
-  double alpha, vol, cos_val;
-  double answer;
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->axis_theta * pi/180.0;
-  double phi = pars->axis_phi * pi/180.0;
-
-  // Cylinder orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0;
-
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("core_shell_bicelle_analytical_2D: Unexpected error: cos(alpha)=%g\n", cos_val);
-    return 0;
-  }
-
-  alpha = acos( cos_val );
-
-  // Call the IGOR library function to get the kernel
-  answer = BicelleKernel(q, pars->radius, pars->rim_thick, pars->face_thick,
-      pars->core_sld,pars->face_sld,pars->rim_sld,
-      pars->solvent_sld, pars->length/2.0, alpha) / fabs(sin(alpha));
-
-  //normalize by cylinder volume
-  vol=pi*(pars->radius+pars->rim_thick)
-          *(pars->radius+pars->rim_thick)
-          *(pars->length+2.0*pars->face_thick);
-  answer /= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the core-shell cylinder
- * @param q: q-value
- * @return: function value
- */
-static double core_shell_bicelle_analytical_2DXY(CoreShellBicelleParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return core_shell_bicelle_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-CoreShellBicelleModel :: CoreShellBicelleModel() {
-  scale      = Parameter(1.0);
-  radius     = Parameter(20.0, true);
-  radius.set_min(0.0);
-  face_thick  = Parameter(10.0, true);
-  face_thick.set_min(0.0);
-  rim_thick  = Parameter(10.0, true);
-  rim_thick.set_min(0.0);
-  length     = Parameter(400.0, true);
-  length.set_min(0.0);
-  core_sld   = Parameter(1.e-6);
-  face_sld  = Parameter(4.e-6);
-  rim_sld  = Parameter(4.e-6);
-  solvent_sld= Parameter(1.e-6);
-  background = Parameter(0.0);
-  axis_theta = Parameter(90.0, true);
-  axis_phi   = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CoreShellBicelleModel :: operator()(double q) {
-  double dp[10];
-
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = rim_thick();
-  dp[3] = face_thick();
-  dp[4] = length();
-  dp[5] = core_sld();
-  dp[6] = face_sld();
-  dp[7] = rim_sld();
-  dp[8] = solvent_sld();
-  dp[9] = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_rthick;
-  rim_thick.get_weights(weights_rthick);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_fthick;
-  face_thick.get_weights(weights_fthick);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[1] = weights_rad[i].value;
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_len.size(); j++) {
-      dp[4] = weights_len[j].value;
-
-      // Loop over thickness weight points
-      for(size_t k=0; k<weights_rthick.size(); k++) {
-        dp[2] = weights_rthick[k].value;
-        for(size_t l=0; l<weights_fthick.size(); l++) {
-            dp[3] = weights_fthick[l].value;
-			//Un-normalize by volume
-			sum += weights_rad[i].weight
-				* weights_len[j].weight
-				* weights_rthick[k].weight
-				* weights_fthick[l].weight
-				* BicelleIntegration(q, dp[1],dp[2], dp[3],
-						dp[5],dp[6],dp[7],dp[8], dp[4]);
-			//* pow(weights_rad[i].value+weights_rthick[k].value,2)
-			//*(weights_len[j].value+2.0*weights_fthick[k].value);
-			//Find average volume
-			vol += weights_rad[i].weight
-				* weights_len[j].weight
-				* weights_rthick[k].weight
-				* weights_fthick[l].weight
-				* pi * pow(weights_rad[i].value+weights_rthick[k].value,2)
-			*(weights_len[j].value+2.0*weights_fthick[l].value);
-			norm += weights_rad[i].weight
-				* weights_len[j].weight
-				* weights_rthick[k].weight
-				* weights_fthick[l].weight;
-        }
-      }
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  //convert to [cm-1]
-  sum *= 1.0e8;
-  sum *= dp[0];
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CoreShellBicelleModel :: operator()(double qx, double qy) {
-  CoreShellBicelleParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.radius     = radius();
-  dp.rim_thick  = rim_thick();
-  dp.face_thick  = face_thick();
-  dp.length     = length();
-  dp.core_sld   = core_sld();
-  dp.rim_sld  = rim_sld();
-  dp.face_sld  = face_sld();
-  dp.solvent_sld= solvent_sld();
-  dp.background = 0.0;
-  dp.axis_theta = axis_theta();
-  dp.axis_phi   = axis_phi();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_rthick;
-  rim_thick.get_weights(weights_rthick);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_fthick;
-  face_thick.get_weights(weights_fthick);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.radius = weights_rad[i].value;
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_len.size(); j++) {
-      dp.length = weights_len[j].value;
-
-      // Loop over thickness weight points
-      for(size_t m=0; m<weights_rthick.size(); m++) {
-        dp.rim_thick = weights_rthick[m].value;
-
-        // Loop over thickness weight points
-        for(size_t n=0; n<weights_fthick.size(); n++) {
-          dp.face_thick = weights_fthick[n].value;
-
-			// Average over theta distribution
-			for(size_t k=0; k<weights_theta.size(); k++) {
-			  dp.axis_theta = weights_theta[k].value;
-
-			  // Average over phi distribution
-			  for(size_t l=0; l<weights_phi.size(); l++) {
-				dp.axis_phi = weights_phi[l].value;
-				//Un-normalize by volume
-				double _ptvalue = weights_rad[i].weight
-					* weights_len[j].weight
-					* weights_rthick[m].weight
-					* weights_fthick[n].weight
-					* weights_theta[k].weight
-					* weights_phi[l].weight
-					* core_shell_bicelle_analytical_2DXY(&dp, qx, qy)
-				* pow(weights_rad[i].value+weights_rthick[m].value,2)
-				*(weights_len[j].value+2.0*weights_fthick[n].value);
-
-				if (weights_theta.size()>1) {
-				  _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0));
-				}
-				sum += _ptvalue;
-
-				//Find average volume
-				vol += weights_rad[i].weight
-					* weights_len[j].weight
-					* weights_rthick[m].weight
-					* weights_fthick[n].weight
-					* pow(weights_rad[i].value+weights_rthick[m].value,2)
-				*(weights_len[j].value+2.0*weights_fthick[n].value);
-				//Find norm for volume
-				norm_vol += weights_rad[i].weight
-					* weights_len[j].weight
-					* weights_rthick[m].weight
-					* weights_fthick[n].weight;
-
-				norm += weights_rad[i].weight
-					* weights_len[j].weight
-					* weights_rthick[m].weight
-					* weights_fthick[n].weight
-					* weights_theta[k].weight
-					* weights_phi[l].weight;
-
-			  }
-			}
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CoreShellBicelleModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CoreShellBicelleModel :: calculate_ER() {
-  CoreShellBicelleParameters dp;
-
-  dp.radius     = radius();
-  dp.rim_thick  = rim_thick();
-  dp.face_thick  = face_thick();
-  dp.length     = length();
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_rthick;
-  rim_thick.get_weights(weights_rthick);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_fthick;
-  face_thick.get_weights(weights_fthick);
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_length.size(); i++) {
-    dp.length = weights_length[i].value;
-    for(int j=0; j< (int)weights_rthick.size(); j++) {
-      dp.rim_thick = weights_rthick[j].value;
-      for(int l=0; l< (int)weights_fthick.size(); l++) {
-          dp.face_thick = weights_fthick[l].value;
-		  for(int k=0; k< (int)weights_radius.size(); k++) {
-			dp.radius = weights_radius[k].value;
-			//Note: output of "DiamCyl( )" is DIAMETER.
-			sum +=weights_length[i].weight * weights_rthick[j].weight * weights_fthick[l].weight
-				* weights_radius[k].weight*DiamCyl(dp.length+2.0*dp.face_thick,dp.radius+dp.rim_thick)/2.0;
-			norm += weights_length[i].weight* weights_rthick[j].weight * weights_fthick[l].weight* weights_radius[k].weight;
-		  }
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl()" is DIAMETER.
-    rad_out = DiamCyl(dp.length+2.0*dp.face_thick,dp.radius+dp.rim_thick)/2.0;}
-
-  return rad_out;
-}
-double CoreShellBicelleModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/coreshellcylinder.cpp
===================================================================
--- src/sans/models/src/c_models/coreshellcylinder.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,393 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "core_shell_cylinder.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double radius;
-  double thickness;
-  double length;
-  double core_sld;
-  double shell_sld;
-  double solvent_sld;
-  double background;
-  double axis_theta;
-  double axis_phi;
-} CoreShellCylinderParameters;
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the core-shell cylinder
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double core_shell_cylinder_analytical_2D_scaled(CoreShellCylinderParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y;//, cyl_z;
-  //double q_z;
-  double alpha, vol, cos_val;
-  double answer;
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->axis_theta * pi/180.0;
-  double phi = pars->axis_phi * pi/180.0;
-
-  // Cylinder orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0;
-
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("core_shell_cylinder_analytical_2D: Unexpected error: cos(alpha)=%g\n", cos_val);
-    cos_val = 1.0;
-  }
-
-  alpha = acos( cos_val );
-  if (alpha == 0.0){
-  	alpha = 1.0e-26;
-  }
-  // Call the IGOR library function to get the kernel
-  answer = CoreShellCylKernel(q, pars->radius, pars->thickness,
-      pars->core_sld,pars->shell_sld,
-      pars->solvent_sld, pars->length/2.0, alpha) / fabs(sin(alpha));
-
-  //normalize by cylinder volume
-  vol=pi*(pars->radius+pars->thickness)
-          *(pars->radius+pars->thickness)
-          *(pars->length+2.0*pars->thickness);
-  answer /= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the core-shell cylinder
- * @param q: q-value
- * @return: function value
- */
-static double core_shell_cylinder_analytical_2DXY(CoreShellCylinderParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return core_shell_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-CoreShellCylinderModel :: CoreShellCylinderModel() {
-  scale      = Parameter(1.0);
-  radius     = Parameter(20.0, true);
-  radius.set_min(0.0);
-  thickness  = Parameter(10.0, true);
-  thickness.set_min(0.0);
-  length     = Parameter(400.0, true);
-  length.set_min(0.0);
-  core_sld   = Parameter(1.e-6);
-  shell_sld  = Parameter(4.e-6);
-  solvent_sld= Parameter(1.e-6);
-  background = Parameter(0.0);
-  axis_theta = Parameter(90.0, true);
-  axis_phi   = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CoreShellCylinderModel :: operator()(double q) {
-  double dp[8];
-
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = thickness();
-  dp[3] = length();
-  dp[4] = core_sld();
-  dp[5] = shell_sld();
-  dp[6] = solvent_sld();
-  dp[7] = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_thick;
-  thickness.get_weights(weights_thick);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[1] = weights_rad[i].value;
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_len.size(); j++) {
-      dp[3] = weights_len[j].value;
-
-      // Loop over thickness weight points
-      for(size_t k=0; k<weights_thick.size(); k++) {
-        dp[2] = weights_thick[k].value;
-        //Un-normalize by volume
-        sum += weights_rad[i].weight
-            * weights_len[j].weight
-            * weights_thick[k].weight
-            * CoreShellCylinder(dp, q)
-        * pow(weights_rad[i].value+weights_thick[k].value,2)
-        *(weights_len[j].value+2.0*weights_thick[k].value);
-        //Find average volume
-        vol += weights_rad[i].weight
-            * weights_len[j].weight
-            * weights_thick[k].weight
-            * pow(weights_rad[i].value+weights_thick[k].value,2)
-        *(weights_len[j].value+2.0*weights_thick[k].value);
-        norm += weights_rad[i].weight
-            * weights_len[j].weight
-            * weights_thick[k].weight;
-      }
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CoreShellCylinderModel :: operator()(double qx, double qy) {
-  CoreShellCylinderParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.radius     = radius();
-  dp.thickness  = thickness();
-  dp.length     = length();
-  dp.core_sld   = core_sld();
-  dp.shell_sld  = shell_sld();
-  dp.solvent_sld= solvent_sld();
-  dp.background = 0.0;
-  dp.axis_theta = axis_theta();
-  dp.axis_phi   = axis_phi();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_thick;
-  thickness.get_weights(weights_thick);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.radius = weights_rad[i].value;
-
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_len.size(); j++) {
-      dp.length = weights_len[j].value;
-
-      // Loop over thickness weight points
-      for(size_t m=0; m<weights_thick.size(); m++) {
-        dp.thickness = weights_thick[m].value;
-
-        // Average over theta distribution
-        for(size_t k=0; k<weights_theta.size(); k++) {
-          dp.axis_theta = weights_theta[k].value;
-
-          // Average over phi distribution
-          for(size_t l=0; l<weights_phi.size(); l++) {
-            dp.axis_phi = weights_phi[l].value;
-            //Un-normalize by volume
-            double _ptvalue = weights_rad[i].weight
-                * weights_len[j].weight
-                * weights_thick[m].weight
-                * weights_theta[k].weight
-                * weights_phi[l].weight
-                * core_shell_cylinder_analytical_2DXY(&dp, qx, qy)
-            * pow(weights_rad[i].value+weights_thick[m].value,2)
-            *(weights_len[j].value+2.0*weights_thick[m].value);
-
-            if (weights_theta.size()>1) {
-              _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0));
-            }
-            sum += _ptvalue;
-
-            //Find average volume
-            vol += weights_rad[i].weight
-                * weights_len[j].weight
-                * weights_thick[m].weight
-                * pow(weights_rad[i].value+weights_thick[m].value,2)
-            *(weights_len[j].value+2.0*weights_thick[m].value);
-            //Find norm for volume
-            norm_vol += weights_rad[i].weight
-                * weights_len[j].weight
-                * weights_thick[m].weight;
-
-            norm += weights_rad[i].weight
-                * weights_len[j].weight
-                * weights_thick[m].weight
-                * weights_theta[k].weight
-                * weights_phi[l].weight;
-
-          }
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CoreShellCylinderModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CoreShellCylinderModel :: calculate_ER() {
-  CoreShellCylinderParameters dp;
-
-  dp.radius     = radius();
-  dp.thickness  = thickness();
-  dp.length     = length();
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_thickness;
-  thickness.get_weights(weights_thickness);
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_length.size(); i++) {
-    dp.length = weights_length[i].value;
-    for(int j=0; j< (int)weights_thickness.size(); j++) {
-      dp.thickness = weights_thickness[j].value;
-      for(int k=0; k< (int)weights_radius.size(); k++) {
-        dp.radius = weights_radius[k].value;
-        //Note: output of "DiamCyl( )" is DIAMETER.
-        sum +=weights_length[i].weight * weights_thickness[j].weight
-            * weights_radius[k].weight*DiamCyl(dp.length+2.0*dp.thickness,dp.radius+dp.thickness)/2.0;
-        norm += weights_length[i].weight* weights_thickness[j].weight* weights_radius[k].weight;
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl()" is DIAMETER.
-    rad_out = DiamCyl(dp.length+2.0*dp.thickness,dp.radius+dp.thickness)/2.0;}
-
-  return rad_out;
-}
-double CoreShellCylinderModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/coreshellsphere.cpp
===================================================================
--- src/sans/models/src/c_models/coreshellsphere.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,386 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "core_shell.h"
-
-extern "C" {
-#include "libSphere.h"
-#include "libmultifunc/libfunc.h"
-}
-
-typedef struct {
-  double scale;
-  double radius;
-  double thickness;
-  double core_sld;
-  double shell_sld;
-  double solvent_sld;
-  double background;
-  double M0_sld_shell;
-  double M_theta_shell;
-  double M_phi_shell;
-  double M0_sld_core;
-  double M_theta_core;
-  double M_phi_core;
-  double M0_sld_solv;
-  double M_theta_solv;
-  double M_phi_solv;
-  double Up_frac_i;
-  double Up_frac_f;
-  double Up_theta;
-} CoreShellParameters;
-
-CoreShellModel :: CoreShellModel() {
-  scale      = Parameter(1.0);
-  radius     = Parameter(60.0, true);
-  radius.set_min(0.0);
-  thickness  = Parameter(10.0, true);
-  thickness.set_min(0.0);
-  core_sld   = Parameter(1.e-6);
-  shell_sld  = Parameter(2.e-6);
-  solvent_sld = Parameter(3.e-6);
-  background = Parameter(0.0);
-  M0_sld_shell = Parameter(0.0e-6);
-  M_theta_shell = Parameter(0.0);
-  M_phi_shell = Parameter(0.0);
-  M0_sld_core = Parameter(0.0e-6);
-  M_theta_core = Parameter(0.0);
-  M_phi_core = Parameter(0.0);
-  M0_sld_solv = Parameter(0.0e-6);
-  M_theta_solv = Parameter(0.0);
-  M_phi_solv = Parameter(0.0);
-  Up_frac_i = Parameter(0.5);
-  Up_frac_f = Parameter(0.5);
-  Up_theta = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CoreShellModel :: operator()(double q) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = thickness();
-  dp[3] = core_sld();
-  dp[4] = shell_sld();
-  dp[5] = solvent_sld();
-  dp[6] = 0.0;
-
-  //im
-  ///dp[7] = 0.0;
-  ///dp[8] = 0.0;
-  ///dp[9] = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_thick;
-  thickness.get_weights(weights_thick);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[1] = weights_rad[i].value;
-
-    // Loop over thickness weight points
-    for(size_t j=0; j<weights_thick.size(); j++) {
-      dp[2] = weights_thick[j].value;
-      //Un-normalize SphereForm by volume
-      sum += weights_rad[i].weight
-          * weights_thick[j].weight * CoreShellForm(dp, q)* pow(weights_rad[i].value+weights_thick[j].value,3);
-
-      //Find average volume
-      vol += weights_rad[i].weight * weights_thick[j].weight
-          * pow(weights_rad[i].value+weights_thick[j].value,3);
-      norm += weights_rad[i].weight
-          * weights_thick[j].weight;
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-
-static double coreshell_analytical_2D_scaled(CoreShellParameters *pars, double q, double q_x, double q_y) {
-	double dp[7];
-	//convert angle degree to radian
-	dp[0] = pars->scale;
-	dp[1] = pars->radius;
-	dp[2] = pars->thickness;
-	dp[3] = 0.0;
-	dp[4] = 0.0;
-	dp[5] = 0.0;
-	dp[6] = 0.0;
-	//im
-	///dp[7] = 0.0;
-	///dp[8] = 0.0;
-	///dp[9] = 0.0;
-
-    double sld_core = pars->core_sld;
-    double sld_shell = pars->shell_sld;
-	double sld_solv = pars->solvent_sld;
-	double answer = 0.0;
-	double m_max = pars->M0_sld_core;
-	double m_max_shell = pars->M0_sld_shell;
-	double m_max_solv = pars->M0_sld_solv;
-
-	if (m_max < 1.0e-32 && m_max_solv < 1.0e-32 && m_max_shell < 1.0e-32){
-		dp[3] = sld_core;
-		dp[4] = sld_shell;
-		dp[5] = sld_solv;
-		answer = CoreShellForm(dp, q);
-	}
-	else{
-		double qx = q_x;
-		double qy = q_y;
-		double s_theta = pars->Up_theta;
-		double m_phi = pars->M_phi_core;
-		double m_theta = pars->M_theta_core;
-		double m_phi_shell = pars->M_phi_shell;
-		double m_theta_shell = pars->M_theta_shell;
-		double m_phi_solv = pars->M_phi_solv;
-		double m_theta_solv = pars->M_theta_solv;
-		double in_spin = pars->Up_frac_i;
-		double out_spin = pars->Up_frac_f;
-		polar_sld p_sld_core;
-		polar_sld p_sld_shell;
-		polar_sld p_sld_solv;
-		//Find (b+m) slds
-		p_sld_core = cal_msld(1, qx, qy, sld_core, m_max, m_theta, m_phi,
-								in_spin, out_spin, s_theta);
-		p_sld_shell = cal_msld(1, qx, qy, sld_shell, m_max_shell, m_theta_shell, m_phi_shell,
-								in_spin, out_spin, s_theta);
-		p_sld_solv = cal_msld(1, qx, qy, sld_solv, m_max_solv, m_theta_solv, m_phi_solv,
-						 		in_spin, out_spin, s_theta);
-		//up_up
-		if (in_spin > 0.0 && out_spin > 0.0){
-			dp[3] = p_sld_core.uu;
-			dp[4] = p_sld_shell.uu;
-			dp[5] = p_sld_solv.uu;
-			answer += CoreShellForm(dp, q);
-			}
-		//down_down
-		if (in_spin < 1.0 && out_spin < 1.0){
-			dp[3] = p_sld_core.dd;
-			dp[4] = p_sld_shell.dd;
-			dp[5] = p_sld_solv.dd;
-			answer += CoreShellForm(dp, q);
-			}
-		//up_down
-		if (in_spin > 0.0 && out_spin < 1.0){
-			dp[3] = p_sld_core.re_ud;
-			dp[4] = p_sld_shell.re_ud;
-			dp[5] = p_sld_solv.re_ud;
-			answer += CoreShellForm(dp, q);
-			dp[3] = p_sld_core.im_ud;
-			dp[4] = p_sld_shell.im_ud;
-			dp[5] = p_sld_solv.im_ud;
-			answer += CoreShellForm(dp, q);
-			}
-		//down_up
-		if (in_spin < 1.0 && out_spin > 0.0){
-			dp[3] = p_sld_core.re_du;
-			dp[4] = p_sld_shell.re_du;
-			dp[5] = p_sld_solv.re_du;
-			answer += CoreShellForm(dp, q);
-			dp[3] = p_sld_core.im_du;
-			dp[4] = p_sld_shell.im_du;
-			dp[5] = p_sld_solv.im_du;
-			answer += CoreShellForm(dp, q);
-			}
-	}
-	// Already normalized
-	// add in the background
-	answer += pars->background;
-	return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters
- * @param q: q-value
- * @return: function value
- */
-static double coreshell_analytical_2DXY(CoreShellParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return coreshell_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CoreShellModel :: operator()(double qx, double qy) {
-	CoreShellParameters dp;
-    dp.scale = scale();
-    dp.radius = radius();
-    dp.thickness = thickness();
-    dp.core_sld = core_sld();
-    dp.shell_sld = shell_sld();
-    dp.solvent_sld = solvent_sld();
-    dp.background = 0.0;
-    dp.M0_sld_shell = M0_sld_shell();
-    dp.M_theta_shell = M_theta_shell();
-    dp.M_phi_shell = M_phi_shell();
-    dp.M0_sld_core = M0_sld_core();
-    dp.M_theta_core = M_theta_core();
-    dp.M_phi_core = M_phi_core();
-    dp.M0_sld_solv = M0_sld_solv();
-    dp.M_theta_solv = M_theta_solv();
-    dp.M_phi_solv = M_phi_solv();
-    dp.Up_frac_i = Up_frac_i();
-    dp.Up_frac_f = Up_frac_f();
-    dp.Up_theta = Up_theta();
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Get the dispersion points for the thickness
-	vector<WeightPoint> weights_thick;
-	thickness.get_weights(weights_thick);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-	dp.radius = weights_rad[i].value;
-
-	// Loop over thickness weight points
-	for(size_t j=0; j<weights_thick.size(); j++) {
-	  dp.thickness = weights_thick[j].value;
-	  //Un-normalize SphereForm by volume
-	  sum += weights_rad[i].weight
-		  * weights_thick[j].weight * coreshell_analytical_2DXY(&dp, qx, qy) *
-		  	pow(weights_rad[i].value+weights_thick[j].value,3);
-
-	  //Find average volume
-	  vol += weights_rad[i].weight * weights_thick[j].weight
-		  * pow(weights_rad[i].value+weights_thick[j].value,3);
-	  norm += weights_rad[i].weight
-		  * weights_thick[j].weight;
-	}
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CoreShellModel :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CoreShellModel :: calculate_ER() {
-  CoreShellParameters dp;
-
-  dp.radius     = radius();
-  dp.thickness  = thickness();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_thickness;
-  thickness.get_weights(weights_thickness);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Loop over major shell weight points
-  for(int j=0; j< (int)weights_thickness.size(); j++) {
-    dp.thickness = weights_thickness[j].value;
-    for(int k=0; k< (int)weights_radius.size(); k++) {
-      dp.radius = weights_radius[k].value;
-      sum += weights_thickness[j].weight
-          * weights_radius[k].weight*(dp.radius+dp.thickness);
-      norm += weights_thickness[j].weight* weights_radius[k].weight;
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    rad_out = (dp.radius+dp.thickness);}
-
-  return rad_out;
-}
-double CoreShellModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/csparallelepiped.cpp
===================================================================
--- src/sans/models/src/c_models/csparallelepiped.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,561 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2010, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-#include "csparallelepiped.h"
-
-// Convenience parameter structure
-typedef struct {
-  double scale;
-  double shortA;
-  double midB;
-  double longC;
-  double rimA;
-  double rimB;
-  double rimC;
-  double sld_rimA;
-  double sld_rimB;
-  double sld_rimC;
-  double sld_pcore;
-  double sld_solv;
-  double background;
-  double parallel_theta;
-  double parallel_phi;
-  double parallel_psi;
-} CSParallelepipedParameters;
-
-static double cspkernel(double dp[],double q, double ala, double alb, double alc){
-  // mu passed in is really mu*sqrt(1-sig^2)
-  double argA,argB,argC,argtA,argtB,argtC,tmp1,tmp2,tmp3,tmpt1,tmpt2,tmpt3;     //local variables
-
-  double aa,bb,cc, ta,tb,tc;
-  double Vin,Vot,V1,V2,V3;
-  double rhoA,rhoB,rhoC, rhoP, rhosolv;
-  double dr0, drA,drB, drC;
-  double retVal;
-
-  aa = dp[1];
-  bb = dp[2];
-  cc = dp[3];
-  ta = dp[4];
-  tb = dp[5];
-  tc = dp[6];
-  rhoA=dp[7];
-  rhoB=dp[8];
-  rhoC=dp[9];
-  rhoP=dp[10];
-  rhosolv=dp[11];
-  dr0=rhoP-rhosolv;
-  drA=rhoA-rhosolv;
-  drB=rhoB-rhosolv;
-  drC=rhoC-rhosolv;
-  Vin=(aa*bb*cc);
-  Vot=(aa*bb*cc+2.0*ta*bb*cc+2.0*aa*tb*cc+2.0*aa*bb*tc);
-  V1=(2.0*ta*bb*cc);   //  incorrect V1 (aa*bb*cc+2*ta*bb*cc)
-  V2=(2.0*aa*tb*cc);  // incorrect V2(aa*bb*cc+2*aa*tb*cc)
-  V3=(2.0*aa*bb*tc);
-  //aa = aa/bb;
-  ta=(aa+2.0*ta);///bb;
-  tb=(aa+2.0*tb);///bb;
-  tc=(aa+2.0*tc);
-  //handle arg=0 separately, as sin(t)/t -> 1 as t->0
-  argA = q*aa*ala/2.0;
-  argB = q*bb*alb/2.0;
-  argC = q*cc*alc/2.0;
-  argtA = q*ta*ala/2.0;
-  argtB = q*tb*alb/2.0;
-  argtC = q*tc*alc/2.0;
-
-  if(argA==0.0) {
-    tmp1 = 1.0;
-  } else {
-    tmp1 = sin(argA)/argA;
-  }
-  if (argB==0.0) {
-    tmp2 = 1.0;
-  } else {
-    tmp2 = sin(argB)/argB;
-  }
-
-  if (argC==0.0) {
-    tmp3 = 1.0;
-  } else {
-    tmp3 = sin(argC)/argC;
-  }
-  if(argtA==0.0) {
-    tmpt1 = 1.0;
-  } else {
-    tmpt1 = sin(argtA)/argtA;
-  }
-  if (argtB==0.0) {
-    tmpt2 = 1.0;
-  } else {
-    tmpt2 = sin(argtB)/argtB;
-  }
-  if (argtC==0.0) {
-    tmpt3 = 1.0;
-  } else {
-    tmpt3 = sin(argtC)*sin(argtC)/argtC/argtC;
-  }
-  // This expression is different from NIST/IGOR package (I strongly believe the IGOR is wrong!!!). 10/15/2010.
-  retVal =( dr0*tmp1*tmp2*tmp3*Vin + drA*(tmpt1-tmp1)*tmp2*tmp3*V1+ drB*tmp1*(tmpt2-tmp2)*tmp3*V2 + drC*tmp1*tmp2*(tmpt3-tmp3)*V3)*
-      ( dr0*tmp1*tmp2*tmp3*Vin + drA*(tmpt1-tmp1)*tmp2*tmp3*V1+ drB*tmp1*(tmpt2-tmp2)*tmp3*V2 + drC*tmp1*tmp2*(tmpt3-tmp3)*V3);   //  correct FF : square of sum of phase factors
-  //retVal *= (tmp3*tmp3);
-  retVal /= Vot;
-
-  return (retVal);
-
-}//Function cspkernel()
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the CSparallelepiped
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double csparallelepiped_analytical_2D_scaled(CSParallelepipedParameters *pars, double q, double q_x, double q_y) {
-  double dp[13];
-  double cparallel_x, cparallel_y, bparallel_x, bparallel_y, parallel_x, parallel_y;
-  //double q_z;
-  double cos_val_c, cos_val_b, cos_val_a, edgeA, edgeB, edgeC;
-
-  double answer;
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->parallel_theta * pi/180.0;
-  double phi = pars->parallel_phi * pi/180.0;
-  double psi = pars->parallel_psi* pi/180.0;
-
-  // Fill paramater array
-  dp[0] = 1.0;
-  dp[1] = pars->shortA;
-  dp[2] = pars->midB;
-  dp[3] = pars->longC;
-  dp[4] = pars->rimA;
-  dp[5] = pars->rimB;
-  dp[6] = pars->rimC;
-  dp[7] = pars->sld_rimA;
-  dp[8] = pars->sld_rimB;
-  dp[9] = pars->sld_rimC;
-  dp[10] = pars->sld_pcore;
-  dp[11] = pars->sld_solv;
-  dp[12] = 0.0;
-
-
-  edgeA = pars->shortA;
-  edgeB = pars->midB;
-  edgeC = pars->longC;
-
-
-  // parallelepiped c axis orientation
-  cparallel_x = cos(theta) * cos(phi);
-  cparallel_y = sin(theta);
-  //cparallel_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0.0;
-
-  // Compute the angle btw vector q and the
-  // axis of the parallelepiped
-  cos_val_c = cparallel_x*q_x + cparallel_y*q_y;// + cparallel_z*q_z;
-  //alpha = acos(cos_val_c);
-
-  // parallelepiped a axis orientation
-  parallel_x = -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-  parallel_y = sin(psi)*cos(theta);
-
-  cos_val_a = parallel_x*q_x + parallel_y*q_y;
-
-
-
-  // parallelepiped b axis orientation
-  bparallel_x = -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-  bparallel_y = cos(theta)*cos(psi);
-  // axis of the parallelepiped
-  cos_val_b = bparallel_x*q_x + bparallel_y*q_y;
-
-  // The following test should always pass
-  if (fabs(cos_val_c)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val_c = 1.0;
-  }
-  if (fabs(cos_val_a)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val_a = 1.0;
-  }
-  if (fabs(cos_val_b)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val_b = 1.0;
-  }
-  // Call the IGOR library function to get the kernel
-  answer = cspkernel( dp, q, cos_val_a, cos_val_b, cos_val_c);
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the CSparallelepiped
- * @param q: q-value
- * @return: function value
- */
-static double csparallelepiped_analytical_2DXY(CSParallelepipedParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return csparallelepiped_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-
-
-CSParallelepipedModel :: CSParallelepipedModel() {
-  scale      = Parameter(1.0);
-  shortA     = Parameter(35.0, true);
-  shortA.set_min(1.0);
-  midB     = Parameter(75.0, true);
-  midB.set_min(1.0);
-  longC    = Parameter(400.0, true);
-  longC.set_min(1.0);
-  rimA     = Parameter(10.0, true);
-  rimB     = Parameter(10.0, true);
-  rimC     = Parameter(10.0, true);
-  sld_rimA     = Parameter(2.0e-6, true);
-  sld_rimB     = Parameter(4.0e-6, true);
-  sld_rimC    = Parameter(2.0e-6, true);
-  sld_pcore   = Parameter(1.0e-6);
-  sld_solv   = Parameter(6.0e-6);
-  background = Parameter(0.06);
-  parallel_theta  = Parameter(0.0, true);
-  parallel_phi    = Parameter(0.0, true);
-  parallel_psi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CSParallelepipedModel :: operator()(double q) {
-  double dp[13];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = shortA();
-  dp[2] = midB();
-  dp[3] = longC();
-  dp[4] = rimA();
-  dp[5] = rimB();
-  dp[6] = rimC();
-  dp[7] = sld_rimA();
-  dp[8] = sld_rimB();
-  dp[9] = sld_rimC();
-  dp[10] = sld_pcore();
-  dp[11] = sld_solv();
-  dp[12] = 0.0;
-
-  // Get the dispersion points for the short_edgeA
-  vector<WeightPoint> weights_shortA;
-  shortA.get_weights(weights_shortA);
-
-  // Get the dispersion points for the longer_edgeB
-  vector<WeightPoint> weights_midB;
-  midB.get_weights(weights_midB);
-
-  // Get the dispersion points for the longuest_edgeC
-  vector<WeightPoint> weights_longC;
-  longC.get_weights(weights_longC);
-
-
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over short_edgeA weight points
-  for(int i=0; i< (int)weights_shortA.size(); i++) {
-    dp[1] = weights_shortA[i].value;
-
-    // Loop over longer_edgeB weight points
-    for(int j=0; j< (int)weights_midB.size(); j++) {
-      dp[2] = weights_midB[j].value;
-
-      // Loop over longuest_edgeC weight points
-      for(int k=0; k< (int)weights_longC.size(); k++) {
-        dp[3] = weights_longC[k].value;
-        //Un-normalize  by volume
-        sum += weights_shortA[i].weight * weights_midB[j].weight
-            * weights_longC[k].weight * CSParallelepiped(dp, q)
-        * weights_shortA[i].value*weights_midB[j].value
-        * weights_longC[k].value;
-        //Find average volume
-        vol += weights_shortA[i].weight * weights_midB[j].weight
-            * weights_longC[k].weight
-            * weights_shortA[i].value * weights_midB[j].value
-            * weights_longC[k].value;
-
-        norm += weights_shortA[i].weight
-            * weights_midB[j].weight * weights_longC[k].weight;
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CSParallelepipedModel :: operator()(double qx, double qy) {
-  CSParallelepipedParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.shortA   = shortA();
-  dp.midB   = midB();
-  dp.longC  = longC();
-  dp.rimA   = rimA();
-  dp.rimB   = rimB();
-  dp.rimC  = rimC();
-  dp.sld_rimA   = sld_rimA();
-  dp.sld_rimB   = sld_rimB();
-  dp.sld_rimC  = sld_rimC();
-  dp.sld_pcore   = sld_pcore();
-  dp.sld_solv   = sld_solv();
-  dp.background = 0.0;
-  //dp.background = background();
-  dp.parallel_theta  = parallel_theta();
-  dp.parallel_phi    = parallel_phi();
-  dp.parallel_psi    = parallel_psi();
-
-
-
-  // Get the dispersion points for the short_edgeA
-  vector<WeightPoint> weights_shortA;
-  shortA.get_weights(weights_shortA);
-
-  // Get the dispersion points for the longer_edgeB
-  vector<WeightPoint> weights_midB;
-  midB.get_weights(weights_midB);
-
-  // Get the dispersion points for the longuest_edgeC
-  vector<WeightPoint> weights_longC;
-  longC.get_weights(weights_longC);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_parallel_theta;
-  parallel_theta.get_weights(weights_parallel_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_parallel_phi;
-  parallel_phi.get_weights(weights_parallel_phi);
-
-  // Get angular averaging for psi
-  vector<WeightPoint> weights_parallel_psi;
-  parallel_psi.get_weights(weights_parallel_psi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-
-  // Loop over radius weight points
-  for(int i=0; i< (int)weights_shortA.size(); i++) {
-    dp.shortA = weights_shortA[i].value;
-
-    // Loop over longer_edgeB weight points
-    for(int j=0; j< (int)weights_midB.size(); j++) {
-      dp.midB = weights_midB[j].value;
-
-      // Average over longuest_edgeC distribution
-      for(int k=0; k< (int)weights_longC.size(); k++) {
-        dp.longC = weights_longC[k].value;
-
-        // Average over theta distribution
-        for(int l=0; l< (int)weights_parallel_theta.size(); l++) {
-          dp.parallel_theta = weights_parallel_theta[l].value;
-
-          // Average over phi distribution
-          for(int m=0; m< (int)weights_parallel_phi.size(); m++) {
-            dp.parallel_phi = weights_parallel_phi[m].value;
-
-            // Average over phi distribution
-            for(int n=0; n< (int)weights_parallel_psi.size(); n++) {
-              dp.parallel_psi = weights_parallel_psi[n].value;
-              //Un-normalize by volume
-              double _ptvalue = weights_shortA[i].weight
-                  * weights_midB[j].weight
-                  * weights_longC[k].weight
-                  * weights_parallel_theta[l].weight
-                  * weights_parallel_phi[m].weight
-                  * weights_parallel_psi[n].weight
-                  * csparallelepiped_analytical_2DXY(&dp, qx, qy)
-              * weights_shortA[i].value*weights_midB[j].value
-              * weights_longC[k].value;
-
-              if (weights_parallel_theta.size()>1) {
-                _ptvalue *= fabs(cos(weights_parallel_theta[l].value*pi/180.0));
-              }
-              sum += _ptvalue;
-              //Find average volume
-              vol += weights_shortA[i].weight
-                  * weights_midB[j].weight
-                  * weights_longC[k].weight
-                  * weights_shortA[i].value*weights_midB[j].value
-                  * weights_longC[k].value;
-              //Find norm for volume
-              norm_vol += weights_shortA[i].weight
-                  * weights_midB[j].weight
-                  * weights_longC[k].weight;
-
-              norm += weights_shortA[i].weight
-                  * weights_midB[j].weight
-                  * weights_longC[k].weight
-                  * weights_parallel_theta[l].weight
-                  * weights_parallel_phi[m].weight
-                  * weights_parallel_psi[n].weight;
-            }
-          }
-
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_parallel_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CSParallelepipedModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CSParallelepipedModel :: calculate_ER() {
-  CSParallelepipedParameters dp;
-  dp.shortA   = shortA();
-  dp.midB   = midB();
-  dp.longC  = longC();
-  dp.rimA   = rimA();
-  dp.rimB   = rimB();
-  dp.rimC  = rimC();
-
-  double rad_out = 0.0;
-  double pi = 4.0*atan(1.0);
-  double suf_rad = sqrt((dp.shortA*dp.midB+2.0*dp.rimA*dp.midB+2.0*dp.rimA*dp.shortA)/pi);
-  double height =(dp.longC + 2.0*dp.rimC);
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the short_edgeA
-  vector<WeightPoint> weights_shortA;
-  shortA.get_weights(weights_shortA);
-
-  // Get the dispersion points for the longer_edgeB
-  vector<WeightPoint> weights_midB;
-  midB.get_weights(weights_midB);
-
-  // Get angular averaging for the longuest_edgeC
-  vector<WeightPoint> weights_longC;
-  longC.get_weights(weights_longC);
-
-  // Loop over radius weight points
-  for(int i=0; i< (int)weights_shortA.size(); i++) {
-    dp.shortA = weights_shortA[i].value;
-
-    // Loop over longer_edgeB weight points
-    for(int j=0; j< (int)weights_midB.size(); j++) {
-      dp.midB = weights_midB[j].value;
-
-      // Average over longuest_edgeC distribution
-      for(int k=0; k< (int)weights_longC.size(); k++) {
-        dp.longC = weights_longC[k].value;
-        //Calculate surface averaged radius
-        //This is rough approximation.
-        suf_rad = sqrt((dp.shortA*dp.midB+2.0*dp.rimA*dp.midB+2.0*dp.rimA*dp.shortA)/pi);
-        height =(dp.longC + 2.0*dp.rimC);
-        //Note: output of "DiamCyl(dp.length,dp.radius)" is a DIAMETER.
-        sum +=weights_shortA[i].weight* weights_midB[j].weight
-            * weights_longC[k].weight*DiamCyl(height, suf_rad)/2.0;
-        norm += weights_shortA[i].weight* weights_midB[j].weight*weights_longC[k].weight;
-      }
-    }
-  }
-
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl(length,radius)" is DIAMETER.
-    rad_out = DiamCyl(dp.longC, suf_rad)/2.0;}
-  return rad_out;
-
-}
-double CSParallelepipedModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/cylinder.cpp
===================================================================
--- src/sans/models/src/c_models/cylinder.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,420 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-
-extern "C" {
-	#include "libCylinder.h"
-	#include "libStructureFactor.h"
-	#include "libmultifunc/libfunc.h"
-}
-#include "cylinder.h"
-
-// Convenience parameter structure
-typedef struct {
-    double scale;
-    double radius;
-    double length;
-    double sldCyl;
-    double sldSolv;
-    double background;
-    double cyl_theta;
-    double cyl_phi;
-    double M0_sld_cyl;
-    double M_theta_cyl;
-    double M_phi_cyl;
-    double M0_sld_solv;
-    double M_theta_solv;
-    double M_phi_solv;
-    double Up_frac_i;
-	double Up_frac_f;
-	double Up_theta;
-} CylinderParameters;
-
-CylinderModel :: CylinderModel() {
-	scale      = Parameter(1.0);
-	radius     = Parameter(20.0, true);
-	radius.set_min(0.0);
-	length     = Parameter(400.0, true);
-	length.set_min(0.0);
-	sldCyl   = Parameter(4.e-6);
-	sldSolv   = Parameter(1.e-6);
-	background = Parameter(0.0);
-	cyl_theta  = Parameter(0.0, true);
-	cyl_phi    = Parameter(0.0, true);
-	M0_sld_cyl = Parameter(0.0e-6);
-	M_theta_cyl = Parameter(0.0);
-	M_phi_cyl = Parameter(0.0); 
-	M0_sld_solv = Parameter(0.0e-6);
-	M_theta_solv = Parameter(0.0);
-	M_phi_solv = Parameter(0.0); 
-	Up_frac_i = Parameter(0.5); 
-	Up_frac_f = Parameter(0.5);
-	Up_theta = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CylinderModel :: operator()(double q) {
-	double dp[6];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = radius();
-	dp[2] = length();
-	dp[3] = sldCyl();
-	dp[4] = sldSolv();
-	dp[5] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Get the dispersion points for the length
-	vector<WeightPoint> weights_len;
-	length.get_weights(weights_len);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[1] = weights_rad[i].value;
-
-		// Loop over length weight points
-		for(size_t j=0; j<weights_len.size(); j++) {
-			dp[2] = weights_len[j].value;
-			//Un-normalize by volume
-			sum += weights_rad[i].weight
-				* weights_len[j].weight * CylinderForm(dp, q)
-				*pow(weights_rad[i].value,2)*weights_len[j].value;
-
-			//Find average volume
-			vol += weights_rad[i].weight
-				* weights_len[j].weight *pow(weights_rad[i].value,2)*weights_len[j].value;
-			norm += weights_rad[i].weight
-				* weights_len[j].weight;
-		}
-	}
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double cylinder_analytical_2D_scaled(CylinderParameters *pars, double q, double q_x, double q_y) {
-    double cyl_x, cyl_y;//, cyl_z;
-    //double q_z;
-    double alpha, vol, cos_val;
-    double answer = 0.0;
-    double form = 0.0;
-    //convert angle degree to radian
-    double pi = 4.0*atan(1.0);
-    double theta = pars->cyl_theta * pi/180.0;
-    double phi = pars->cyl_phi * pi/180.0;
-    double sld_solv = pars->sldSolv;
-    double sld_cyl = pars->sldCyl;
-    double m_max = pars->M0_sld_cyl;
-    double m_max_solv = pars->M0_sld_solv;
-    double contrast = 0.0;
-
-    // Cylinder orientation
-	cyl_x = cos(theta) * cos(phi);
-    cyl_y = sin(theta);
-    //cyl_z = -cos(theta) * sin(phi);
-    // q vector
-    //q_z = 0.0;
-
-    // Compute the angle btw vector q and the
-    // axis of the cylinder
-    cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-    // The following test should always pass
-    if (fabs(cos_val)>1.0) {
-      printf("cyl_ana_2D: Unexpected error: |cos(alpha)=%g|>1\n", cos_val);
-      printf("cyl_ana_2D: at theta=%g and phi=%g.", theta, phi);
-      return 1.0;
-    }
-
-    // Note: cos(alpha) = 0 and 1 will get an
-    // undefined value from CylKernel
-  alpha = acos( cos_val );
-  if (alpha == 0.0){
-  	alpha = 1.0e-26;
-  	}
-  // Call the IGOR library function to get the kernel
-  //answer = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha);
-
-    // Call the IGOR library function to get the kernel
-    form = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha);
-
-	if (m_max < 1.0e-32 && m_max_solv < 1.0e-32){
-		// Multiply by contrast^2
-		contrast = (pars->sldCyl - pars->sldSolv);
-  		answer = contrast * contrast * form;
-	}
-	else{
-		double qx = q_x;
-		double qy = q_y;
-		double s_theta = pars->Up_theta;
-		double m_phi = pars->M_phi_cyl;
-		double m_theta = pars->M_theta_cyl;
-		double m_phi_solv = pars->M_phi_solv;
-		double m_theta_solv = pars->M_theta_solv;
-		double in_spin = pars->Up_frac_i;
-		double out_spin = pars->Up_frac_f;
-		polar_sld p_sld;
-		polar_sld p_sld_solv;
-		p_sld = cal_msld(1, qx, qy, sld_cyl, m_max, m_theta, m_phi, 
-			 			in_spin, out_spin, s_theta);
-		p_sld_solv = cal_msld(1, qx, qy, sld_solv, m_max_solv, m_theta_solv, m_phi_solv, 
-			 			in_spin, out_spin, s_theta);
-		//up_up	
-		if (in_spin > 0.0 && out_spin > 0.0){			 
-			answer += ((p_sld.uu- p_sld_solv.uu) * (p_sld.uu- p_sld_solv.uu) * form);
-			}
-		//down_down
-		if (in_spin < 1.0 && out_spin < 1.0){
-			answer += ((p_sld.dd - p_sld_solv.dd) * (p_sld.dd - p_sld_solv.dd) * form);
-			}
-		//up_down
-		if (in_spin > 0.0 && out_spin < 1.0){
-			answer += ((p_sld.re_ud - p_sld_solv.re_ud) * (p_sld.re_ud - p_sld_solv.re_ud) * form);
-			answer += ((p_sld.im_ud - p_sld_solv.im_ud) * (p_sld.im_ud - p_sld_solv.im_ud) * form);
-			}
-		//down_up	
-		if (in_spin < 1.0 && out_spin > 0.0){
-			answer += ((p_sld.re_du - p_sld_solv.re_du) * (p_sld.re_du - p_sld_solv.re_du) * form);
-			answer += ((p_sld.im_du - p_sld_solv.im_du) * (p_sld.im_du - p_sld_solv.im_du) * form);
-			}
-	}
-
-    //normalize by cylinder volume
-    //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-    vol = acos(-1.0) * pars->radius * pars->radius * pars->length;
-    answer *= vol;
-
-    //convert to [cm-1]
-    answer *= 1.0e8;
-
-    //Scale
-    answer *= pars->scale;
-
-    // add in the background
-    answer += pars->background;
-
-    return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @return: function value
- */
-static double cylinder_analytical_2DXY(CylinderParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CylinderModel :: operator()(double qx, double qy) {
-	CylinderParameters dp;
-	// Fill parameter array
-	dp.scale      = scale();
-	dp.radius     = radius();
-	dp.length     = length();
-	dp.sldCyl   = sldCyl();
-	dp.sldSolv   = sldSolv();
-	dp.background = 0.0;
-	dp.cyl_theta  = cyl_theta();
-	dp.cyl_phi    = cyl_phi();
-	dp.Up_theta =  Up_theta();
-	dp.M_phi_cyl =  M_phi_cyl();
-	dp.M_theta_cyl =  M_theta_cyl();
-	dp.M0_sld_cyl =  M0_sld_cyl();
-	dp.M_phi_solv =  M_phi_solv();
-	dp.M_theta_solv =  M_theta_solv();
-	dp.M0_sld_solv =  M0_sld_solv();
-	dp.Up_frac_i =  Up_frac_i();
-	dp.Up_frac_f =  Up_frac_f();
-	
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Get the dispersion points for the length
-	vector<WeightPoint> weights_len;
-	length.get_weights(weights_len);
-
-	// Get angular averaging for theta
-	vector<WeightPoint> weights_theta;
-	cyl_theta.get_weights(weights_theta);
-
-	// Get angular averaging for phi
-	vector<WeightPoint> weights_phi;
-	cyl_phi.get_weights(weights_phi);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double norm_vol = 0.0;
-	double vol = 0.0;
-	double pi = 4.0*atan(1.0);
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp.radius = weights_rad[i].value;
-
-
-		// Loop over length weight points
-		for(size_t j=0; j<weights_len.size(); j++) {
-			dp.length = weights_len[j].value;
-
-			// Average over theta distribution
-			for(size_t k=0; k<weights_theta.size(); k++) {
-				dp.cyl_theta = weights_theta[k].value;
-
-				// Average over phi distribution
-				for(size_t l=0; l<weights_phi.size(); l++) {
-					dp.cyl_phi = weights_phi[l].value;
-					//Un-normalize by volume
-					double _ptvalue = weights_rad[i].weight
-						* weights_len[j].weight
-						* weights_theta[k].weight
-						* weights_phi[l].weight
-						* cylinder_analytical_2DXY(&dp, qx, qy)
-						*pow(weights_rad[i].value,2)*weights_len[j].value;
-					if (weights_theta.size()>1) {
-						_ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0));
-					}
-					sum += _ptvalue;
-					//Find average volume
-					vol += weights_rad[i].weight
-							* weights_len[j].weight
-							* pow(weights_rad[i].value,2)*weights_len[j].value;
-					//Find norm for volume
-					norm_vol += weights_rad[i].weight
-							* weights_len[j].weight;
-
-					norm += weights_rad[i].weight
-						* weights_len[j].weight
-						* weights_theta[k].weight
-						* weights_phi[l].weight;
-
-				}
-			}
-		}
-	}
-	// Averaging in theta needs an extra normalization
-	// factor to account for the sin(theta) term in the
-	// integration (see documentation).
-	if (weights_theta.size()>1) norm = norm / asin(1.0);
-	if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm_vol);}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CylinderModel :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CylinderModel :: calculate_ER() {
-	CylinderParameters dp;
-
-	dp.radius     = radius();
-	dp.length     = length();
-	double rad_out = 0.0;
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the major shell
-	vector<WeightPoint> weights_length;
-	length.get_weights(weights_length);
-
-	// Get the dispersion points for the minor shell
-	vector<WeightPoint> weights_radius ;
-	radius.get_weights(weights_radius);
-
-	// Loop over major shell weight points
-	for(int i=0; i< (int)weights_length.size(); i++) {
-		dp.length = weights_length[i].value;
-		for(int k=0; k< (int)weights_radius.size(); k++) {
-			dp.radius = weights_radius[k].value;
-			//Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-			sum +=weights_length[i].weight
-				* weights_radius[k].weight*DiamCyl(dp.length,dp.radius)/2.0;
-			norm += weights_length[i].weight* weights_radius[k].weight;
-		}
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		//Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-		rad_out = DiamCyl(dp.length,dp.radius)/2.0;}
-
-	return rad_out;
-}
-double CylinderModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/dabmodel.cpp
===================================================================
--- src/sans/models/src/c_models/dabmodel.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,61 +1,0 @@
-
-/**
-	This software was developed by Institut Laue-Langevin as part of
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE).
-
-	Copyright 2012 Institut Laue-Langevin
-
-**/
-
-/**
-
-   Scattering model class for the DAB (Debye Anderson Brumberger) Model
-
-**/
-
-
-
-#include <math.h>
-#include "parameters.hh"
-#include "dabmodel.h"
-
-DABModel::DABModel() {
-  length = Parameter(50.0);
-  scale = Parameter(1.0);
-  background = Parameter(0.0);
-
-}
-
-double DABModel::operator()(double q) {
-  double d_length = length();
-  double d_scale = scale();
-  double d_background = background();
-
-  double numerator = d_scale*pow(d_length,3);
-  double denominator = pow(1 + pow(q*d_length,2),2);
-
-  return numerator / denominator + d_background;
-  
-
-
-}
-
-double DABModel::operator()(double qx,double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return this->operator()(q);
-}
-
-double DABModel::calculate_ER() {
-  // not implemented yet
-  return 0.0;
-}
-
-double DABModel::calculate_VR() {
-  return 1.0;
-}
-
-double DABModel::evaluate_rphi(double q,double phi) {
-  double qx = q * cos(phi);
-  double qy = q * sin(phi);
-  return this->operator()(qx,qy);
-}
Index: c/sans/models/src/c_models/disperser.c
===================================================================
--- src/sans/models/src/c_models/disperser.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,470 +1,0 @@
-/** 
- * Disperser
- * 
- * Python class that takes a model and averages its output
- * for a distribution of its parameters.
- * 
- * The parameters to be varied are specified at instantiation time.
- * The distributions are Gaussian, with std deviations specified for
- * each parameter at instantiation time.
- * 
- * @author   M.Doucet / UTK 
- */
-
-#include <Python.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-/// Error object for raised exceptions
-static PyObject * DisperserError = NULL;
-
-// Class definition
-typedef struct {
-  PyObject_HEAD
-  /// Dictionary of parameters for this class
-  PyObject * params;
-  /// Model object to disperse
-  PyObject * model;
-  /// Array of original values
-  double * centers;
-  /// Number of parameters to disperse
-  int n_pars;
-  /// Coordinate system flag
-  int cylindrical;
-} Disperser;
-
-// Function definitions
-double disperseParam(Disperser *self, int iPar, PyObject * pars);
-double Disperser_readDouble(PyObject *p);
-
-/**
- * Function to deallocate memory for the object
- */
-static void
-Disperser_dealloc(Disperser * self) {
-  free(self->centers);
-  self->ob_type->tp_free((PyObject*)self);
-}
-
-/**
- * Function to create a new Disperser object
- */
-static PyObject *
-Disperser_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-  Disperser *self;
-
-  self = (Disperser *)type->tp_alloc(type, 0);
-
-  return (PyObject *)self;
-}
-
-/**
- * Initialization of the object (__init__)
- */
-static int
-Disperser_init(Disperser *self, PyObject *args, PyObject *kwds)
-{
-  PyObject * model;
-  PyObject * paramList;
-  PyObject * sigmaList;
-
-  if (self != NULL) {
-
-    // Create parameters
-    self->params = PyDict_New();
-
-    // Get input
-    if ( !PyArg_ParseTuple(args,"OOO",&model, &paramList, &sigmaList) ) {
-      PyErr_SetString(DisperserError,
-          "Disperser: could not parse to initialize. Need Disperser(model, paramList, sigmaList)");
-      return -1;
-    }
-
-    // Check that the lists are of the right type
-    if( PyList_Check(paramList)!=1 || PyList_Check(sigmaList)!=1 ) {
-      PyErr_SetString(DisperserError,
-          "Disperser: bad input parameters; did not find lists.");
-      return -1;
-    }
-
-    // Check that the list lengths are compatible
-    if( PyList_GET_SIZE(paramList) != PyList_GET_SIZE(sigmaList) ) {
-      PyErr_SetString(DisperserError,
-          "Disperser: supplied lists are not of the same length.");
-      return -1;
-    }
-
-    // Set the data members
-    self->model = model;
-
-    // Number of parameters to disperse
-    // Let run() find out since values can change
-    self->n_pars = 0;
-
-    // Set default coordinate system as cartesian
-    self->cylindrical = 0;
-
-    // Initialize parameter dictionary
-    // Store the list of parameter names (strings)
-    PyDict_SetItemString(self->params,"paramList", paramList);
-
-    // Store the list of std deviations (floats)
-    PyDict_SetItemString(self->params,"sigmaList", sigmaList);
-
-    // Set the default number of points to average over
-    PyDict_SetItemString(self->params,"n_pts",Py_BuildValue("i",25));
-  }
-  return 0;
-}
-
-/**
- * List of member to make public
- * Only the parameters and the model are available to python users
- */
-static PyMemberDef Disperser_members[] = {
-    {"params", T_OBJECT, offsetof(Disperser, params), 0,
-        "Parameters"},
-        {"model", T_OBJECT, offsetof(Disperser, model), 0,
-            "Model to disperse"},
-            {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
- *	TODO: THIS SHOULD REALLY BE ELSEWHERE!
- *   @param p PyObject
- *   @return double
- */
-double Disperser_readDouble(PyObject *p) {
-  double value = 0.0;
-
-  if (PyFloat_Check(p)==1) {
-    value = (double)(((PyFloatObject *)(p))->ob_fval);
-    //Py_DECREF(p);
-    return value;
-  } else if (PyInt_Check(p)==1) {
-    value = (double)(((PyIntObject *)(p))->ob_ival);
-    //Py_DECREF(p);
-    return value;
-  } else if (PyLong_Check(p)==1) {
-    value = (double)PyLong_AsLong(p);
-    //Py_DECREF(p);
-    return value;
-  } else {
-    //Py_DECREF(p);
-    return 0.0;
-  }
-}
-
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [qx,qy]
- * @return: function value
- */
-static PyObject * runXY(Disperser *self, PyObject *args) {
-  PyObject* pars;
-  int n_pts;
-  int i;
-  double value;
-  PyObject * result;
-  PyObject * temp;
-
-  // Get parameters
-
-  // Check that the lists are of the right type
-  if( PyList_Check(PyDict_GetItemString(self->params, "paramList"))!=1
-      || PyList_Check(PyDict_GetItemString(self->params, "sigmaList"))!=1 ) {
-    PyErr_SetString(DisperserError,
-        "Disperser: bad input parameters; did not find lists.");
-    return NULL;
-  }
-
-  // Reader parameter dictionary
-  n_pts = PyInt_AsLong( PyDict_GetItemString(self->params, "n_pts") );
-
-  // Check that the list lengths are compatible
-  if( PyList_GET_SIZE(PyDict_GetItemString(self->params, "paramList"))
-      != PyList_GET_SIZE(PyDict_GetItemString(self->params, "sigmaList")) ) {
-    PyErr_SetString(DisperserError,
-        "Disperser: supplied lists are not of the same length.");
-    return NULL;
-  }
-
-  // Number of parameters to disperse
-  self->n_pars = PyList_GET_SIZE(PyDict_GetItemString(self->params, "paramList"));
-
-  // Allocate memory for centers
-  free(self->centers);
-  self->centers = (double *)malloc(self->n_pars * sizeof(double));
-  if(self->centers==NULL) {
-    PyErr_SetString(DisperserError,
-        "Disperser.run could not allocate memory.");
-    return NULL;
-  }
-
-  // Store initial values of those parameters
-  for( i=0; i<self->n_pars; i++ ) {
-    result = PyObject_CallMethod(self->model, "getParam", "(O)",
-        PyList_GetItem( PyDict_GetItemString(self->params, "paramList"), i ));
-
-    if( result == NULL ) {
-      PyErr_SetString(DisperserError,
-          "Disperser.run could not get current parameter values.");
-      return NULL;
-    } else {
-      self->centers[i] = Disperser_readDouble(result);
-      Py_DECREF(result);
-    };
-  }
-
-  // Get input and determine whether we have to supply a 1D or 2D return value.
-  if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-    PyErr_SetString(DisperserError,
-        "Disperser.run expects a q value.");
-    return NULL;
-  }
-
-  // Evaluate or calculate average
-  if( self->n_pars > 0 ) {
-    value = disperseParam(self, 0, pars);
-  } else {
-    if (self->cylindrical==1) {
-      result = PyObject_CallMethod(self->model, "run", "(O)",pars);
-    } else {
-      result = PyObject_CallMethod(self->model, "runXY", "(O)",pars);
-    }
-
-    if( result == NULL ) {
-      PyErr_SetString(DisperserError,
-          "Disperser.run failed.");
-      return NULL;
-    } else {
-      Py_DECREF(result);
-      return result;
-    }
-  }
-
-  // Put back the original model parameter values
-  for( i=0; i<self->n_pars; i++ ) {
-    // Maybe we need to decref the double here?
-    temp = Py_BuildValue("d", self->centers[i]);
-    result = PyObject_CallMethod(self->model, "setParam", "(OO)",
-        PyList_GetItem( PyDict_GetItemString(self->params, "paramList"), i ),
-        temp );
-    Py_DECREF(temp);
-
-    if( result == NULL ) {
-      PyErr_SetString(DisperserError,
-          "Disperser.run could not set back original parameter values.");
-      return NULL;
-    } else {
-      Py_DECREF(result);
-    };
-  }
-
-  return Py_BuildValue("d",value);
-
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(Disperser *self, PyObject *args) {
-  PyObject * output;
-  self->cylindrical = 1;
-  output = runXY(self, args);
-  self->cylindrical = 0;
-  return output;
-}
-
-
-
-
-/**
- * Gaussian weight
- * @param mean: mean value of the Gaussian
- * @param sigma: standard deviation of the Gaussian
- * @param x: value at which the Gaussian is evaluated
- * @return: value of the Gaussian
- */
-double gaussian_weight(double mean, double sigma, double x) {
-  double vary, expo_value;
-  vary = x-mean;
-  expo_value = -vary*vary/(2*sigma*sigma);
-  //return 1.0;
-  return exp(expo_value);
-}
-
-/**
- * @param iPar: ID of parameter to disperse
- * @param pars: input parameter to the evaluation function
- */
-double disperseParam(Disperser *self, int iPar, PyObject * pars) {
-  double sigma;
-  double min_value, max_value;
-  double step;
-  double prev_value;
-  double value_sum;
-  double gauss_sum;
-  double gauss_value;
-  double func_value;
-  double error_sys;
-  double value;
-  int i, n_pts;
-  PyObject *result;
-  PyObject *temp;
-
-  step = 0.0;
-  n_pts = PyInt_AsLong( PyDict_GetItemString(self->params, "n_pts") );
-
-  // If we exhausted the parameter array, simply evaluate
-  // the model
-  if( iPar < self->n_pars ) {
-
-    // Average over Gaussian distribution (2 sigmas)
-    value_sum = 0.0;
-    gauss_sum = 0.0;
-
-    // Get the standard deviation for this parameter
-    sigma = Disperser_readDouble(PyList_GetItem( PyDict_GetItemString(self->params, "sigmaList"), iPar ));
-
-    // Average over 4 sigmas wide
-    min_value = self->centers[iPar] - 2*sigma;
-    max_value = self->centers[iPar] + 2*sigma;
-
-    // Calculate step size
-    step = (max_value - min_value)/(n_pts-1);
-
-    // If we are not changing the parameter, just return the
-    // value of the function
-    if (step == 0.0) {
-      return disperseParam(self, iPar+1, pars);
-    }
-
-    // Compute average
-    prev_value = 0.0;
-    error_sys  = 0.0;
-    for( i=0; i<n_pts; i++ ) {
-      // Set the parameter value
-      value = min_value + (double)i*step;
-
-      temp = Py_BuildValue("d", value);
-      result = PyObject_CallMethod(self->model, "setParam", "(OO)",
-          PyList_GetItem( PyDict_GetItemString(self->params, "paramList"), iPar ),
-          temp);
-      Py_DECREF(temp);
-
-      if( result == NULL ) {
-        printf("Could not set param %i\n", iPar);
-        // return a value that will create an NAN
-        return 0.0/(step-step);
-      } else {
-        Py_DECREF(result);
-      }
-
-      gauss_value = gaussian_weight(self->centers[iPar], sigma, value);
-      func_value = disperseParam(self, iPar+1, pars);
-
-      value_sum += gauss_value * func_value;
-      gauss_sum += gauss_value;
-    }
-    return value_sum/gauss_sum;
-
-  } else {
-    if (self->cylindrical==1) {
-      result = PyObject_CallMethod(self->model, "run", "(O)",pars);
-    } else {
-      result = PyObject_CallMethod(self->model, "runXY", "(O)",pars);
-    }
-    if( result == NULL ) {
-      printf("Model.run() could not return\n");
-      // return a value that will create an NAN
-      return 0.0/(step-step);
-    } else {
-      value = Disperser_readDouble(result);
-      Py_DECREF(result);
-      return value;
-    }
-  }
-
-}
-
-static PyMethodDef Disperser_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-        "Evaluate the model at a given input value"},
-        {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-            "Evaluate the model at a given input value"},
-            {NULL}
-};
-
-static PyTypeObject DisperserType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "Disperser",             /*tp_name*/
-    sizeof(Disperser),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)Disperser_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "Disperser objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    Disperser_methods,             /* tp_methods */
-    Disperser_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)Disperser_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    Disperser_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL}
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addDisperser(PyObject *module) {
-  PyObject *d;
-
-  if (PyType_Ready(&DisperserType) < 0)
-    return;
-
-  Py_INCREF(&DisperserType);
-  PyModule_AddObject(module, "Disperser", (PyObject *)&DisperserType);
-
-  d = PyModule_GetDict(module);
-  DisperserError = PyErr_NewException("Disperser.error", NULL, NULL);
-  PyDict_SetItemString(d, "DisperserError", DisperserError);
-}
-
Index: c/sans/models/src/c_models/dispersion_visitor.cpp
===================================================================
--- src/sans/models/src/c_models/dispersion_visitor.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,132 +1,0 @@
-#include "dispersion_visitor.hh"
-#include "parameters.hh"
-
-#ifndef __MODELS_STANDALONE__
-extern "C" {
-	#include <Python.h>
-}
-#endif
-
-void DispersionVisitor:: dispersion_to_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	DispersionModel * disp = (DispersionModel*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	PyDict_SetItemString(dict, "type",  Py_BuildValue("s", "flat"));
-    PyDict_SetItemString(dict, "npts",  Py_BuildValue("i", disp->npts));
-    PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width));
-#endif
-}
-
-void DispersionVisitor:: gaussian_to_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	GaussianDispersion * disp = (GaussianDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	PyDict_SetItemString(dict, "type",  Py_BuildValue("s", "gaussian"));
-    PyDict_SetItemString(dict, "npts",  Py_BuildValue("i", disp->npts));
-    PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width));
-    PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("d", disp->nsigmas));
-#endif
-}
-
-void DispersionVisitor:: rectangle_to_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	RectangleDispersion * disp = (RectangleDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	PyDict_SetItemString(dict, "type",  Py_BuildValue("s", "rectangle"));
-    PyDict_SetItemString(dict, "npts",  Py_BuildValue("i", disp->npts));
-    PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width));
-    PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("d", disp->nsigmas));
-#endif
-}
-
-void DispersionVisitor:: lognormal_to_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	LogNormalDispersion * disp = (LogNormalDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	PyDict_SetItemString(dict, "type",  Py_BuildValue("s", "lognormal"));
-    PyDict_SetItemString(dict, "npts",  Py_BuildValue("i", disp->npts));
-    PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width));
-    PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("d", disp->nsigmas));
-#endif
-}
-
-
-void DispersionVisitor:: schulz_to_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	SchulzDispersion * disp = (SchulzDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	PyDict_SetItemString(dict, "type",  Py_BuildValue("s", "schulz"));
-    PyDict_SetItemString(dict, "npts",  Py_BuildValue("i", disp->npts));
-    PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width));
-    PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("d", disp->nsigmas));
-#endif
-}
-
-void DispersionVisitor:: array_to_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	ArrayDispersion * disp = (ArrayDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-    PyDict_SetItemString(dict, "type",  Py_BuildValue("s", "array"));
-#endif
-}
-
-void DispersionVisitor:: dispersion_from_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	DispersionModel * disp = (DispersionModel*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	disp->npts  = PyInt_AsLong( PyDict_GetItemString(dict, "npts") );
-	disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") );
-#endif
-}
-
-void DispersionVisitor:: gaussian_from_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	GaussianDispersion * disp = (GaussianDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	disp->npts    = PyInt_AsLong( PyDict_GetItemString(dict, "npts") );
-	disp->width   = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") );
-	disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") );
-#endif
-}
-
-void DispersionVisitor:: rectangle_from_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	RectangleDispersion * disp = (RectangleDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	disp->npts    = PyInt_AsLong( PyDict_GetItemString(dict, "npts") );
-	disp->width   = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") );
-	disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") );
-#endif
-}
-
-void DispersionVisitor:: lognormal_from_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	LogNormalDispersion * disp = (LogNormalDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	disp->npts    = PyInt_AsLong( PyDict_GetItemString(dict, "npts") );
-	disp->width   = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") );
-	disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") );
-#endif
-}
-void DispersionVisitor:: schulz_from_dict(void* dispersion, void* dictionary) {
-#ifndef __MODELS_STANDALONE__
-	SchulzDispersion * disp = (SchulzDispersion*)dispersion;
-	PyObject * dict = (PyObject*)dictionary;
-
-	disp->npts    = PyInt_AsLong( PyDict_GetItemString(dict, "npts") );
-	disp->width   = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") );
-	disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") );
-#endif
-}
-
-void DispersionVisitor:: array_from_dict(void* dispersion, void* dictionary) {}
Index: c/sans/models/src/c_models/dispersion_visitor.hh
===================================================================
--- src/sans/models/src/c_models/dispersion_visitor.hh	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,36 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-#ifndef DISP_VISIT_H
-#define DISP_VISIT_H
-
-class DispersionVisitor {
-public:
-	void dispersion_to_dict(void *, void *);
-	void gaussian_to_dict(void *, void *);
-	void rectangle_to_dict(void *, void *);
-	void lognormal_to_dict(void *, void *);
-	void schulz_to_dict(void*, void *);
-	void array_to_dict(void *, void *);
-
-	void dispersion_from_dict(void*, void *);
-	void gaussian_from_dict(void*, void *);
-	void rectangle_from_dict(void*, void *);
-	void lognormal_from_dict(void*, void *);
-	void schulz_from_dict(void*, void *);
-	void array_from_dict(void*, void *);
-
-};
-
-
-#endif
Index: c/sans/models/src/c_models/ellipsoid.cpp
===================================================================
--- src/sans/models/src/c_models/ellipsoid.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,344 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "ellipsoid.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double radius_a;
-  double radius_b;
-  double sldEll;
-  double sldSolv;
-  double background;
-  double axis_theta;
-  double axis_phi;
-} EllipsoidParameters;
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the ellipsoid
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double ellipsoid_analytical_2D_scaled(EllipsoidParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y;//, cyl_z;
-  //double q_z;
-  double alpha, vol, cos_val;
-  double answer;
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->axis_theta * pi/180.0;
-  double phi = pars->axis_phi * pi/180.0;
-
-  // Ellipsoid orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0.0;
-
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("ellipsoid_ana_2D: Unexpected error: cos(alpha)>1\n");
-    return 0;
-  }
-
-  // Angle between rotation axis and q vector
-  alpha = acos( cos_val );
-
-  // Call the IGOR library function to get the kernel
-  answer = EllipsoidKernel(q, pars->radius_b, pars->radius_a, cos_val);
-
-  // Multiply by contrast^2
-  answer *= (pars->sldEll - pars->sldSolv) * (pars->sldEll - pars->sldSolv);
-
-  //normalize by cylinder volume
-  vol = 4.0/3.0 * acos(-1.0) * pars->radius_b * pars->radius_b * pars->radius_a;
-  answer *= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the ellipsoid
- * @param q: q-value
- * @return: function value
- */
-static double ellipsoid_analytical_2DXY(EllipsoidParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return ellipsoid_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-EllipsoidModel :: EllipsoidModel() {
-  scale      = Parameter(1.0);
-  radius_a   = Parameter(20.0, true);
-  radius_a.set_min(0.0);
-  radius_b   = Parameter(400.0, true);
-  radius_b.set_min(0.0);
-  sldEll   = Parameter(4.e-6);
-  sldSolv   = Parameter(1.e-6);
-  background = Parameter(0.0);
-  axis_theta  = Parameter(57.325, true);
-  axis_phi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double EllipsoidModel :: operator()(double q) {
-  double dp[6];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius_a();
-  dp[2] = radius_b();
-  dp[3] = sldEll();
-  dp[4] = sldSolv();
-  dp[5] = 0.0;
-
-  // Get the dispersion points for the radius_a
-  vector<WeightPoint> weights_rad_a;
-  radius_a.get_weights(weights_rad_a);
-
-  // Get the dispersion points for the radius_b
-  vector<WeightPoint> weights_rad_b;
-  radius_b.get_weights(weights_rad_b);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius_a weight points
-  for(size_t i=0; i<weights_rad_a.size(); i++) {
-    dp[1] = weights_rad_a[i].value;
-
-    // Loop over radius_b weight points
-    for(size_t j=0; j<weights_rad_b.size(); j++) {
-      dp[2] = weights_rad_b[j].value;
-      //Un-normalize  by volume
-      sum += weights_rad_a[i].weight
-          * weights_rad_b[j].weight * EllipsoidForm(dp, q)
-      * pow(weights_rad_b[j].value,2) * weights_rad_a[i].value;
-
-      //Find average volume
-      vol += weights_rad_a[i].weight
-          * weights_rad_b[j].weight
-          * pow(weights_rad_b[j].value,2)
-      * weights_rad_a[i].value;
-      norm += weights_rad_a[i].weight
-          * weights_rad_b[j].weight;
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double EllipsoidModel :: operator()(double qx, double qy) {
-  EllipsoidParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.radius_a   = radius_a();
-  dp.radius_b   = radius_b();
-  dp.sldEll   = sldEll();
-  dp.sldSolv   = sldSolv();
-  dp.background = 0.0;
-  dp.axis_theta = axis_theta();
-  dp.axis_phi   = axis_phi();
-
-  // Get the dispersion points for the radius_a
-  vector<WeightPoint> weights_rad_a;
-  radius_a.get_weights(weights_rad_a);
-
-  // Get the dispersion points for the radius_b
-  vector<WeightPoint> weights_rad_b;
-  radius_b.get_weights(weights_rad_b);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad_a.size(); i++) {
-    dp.radius_a = weights_rad_a[i].value;
-
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_rad_b.size(); j++) {
-      dp.radius_b = weights_rad_b[j].value;
-
-      // Average over theta distribution
-      for(size_t k=0; k<weights_theta.size(); k++) {
-        dp.axis_theta = weights_theta[k].value;
-
-        // Average over phi distribution
-        for(size_t l=0; l<weights_phi.size(); l++) {
-          dp.axis_phi = weights_phi[l].value;
-          //Un-normalize by volume
-          double _ptvalue = weights_rad_a[i].weight
-              * weights_rad_b[j].weight
-              * weights_theta[k].weight
-              * weights_phi[l].weight
-              * ellipsoid_analytical_2DXY(&dp, qx, qy)
-          * pow(weights_rad_b[j].value,2) * weights_rad_a[i].value;
-          if (weights_theta.size()>1) {
-            _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0));
-          }
-          sum += _ptvalue;
-          //Find average volume
-          vol += weights_rad_a[i].weight
-              * weights_rad_b[j].weight
-              * pow(weights_rad_b[j].value,2) * weights_rad_a[i].value;
-          //Find norm for volume
-          norm_vol += weights_rad_a[i].weight
-              * weights_rad_b[j].weight;
-
-          norm += weights_rad_a[i].weight
-              * weights_rad_b[j].weight
-              * weights_theta[k].weight
-              * weights_phi[l].weight;
-
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double EllipsoidModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double EllipsoidModel :: calculate_ER() {
-  EllipsoidParameters dp;
-
-  dp.radius_a = radius_a();
-  dp.radius_b = radius_b();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_radius_a;
-  radius_a.get_weights(weights_radius_a);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_radius_b;
-  radius_b.get_weights(weights_radius_b);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_radius_b.size(); i++) {
-    dp.radius_b = weights_radius_b[i].value;
-    for(int k=0; k< (int)weights_radius_a.size(); k++) {
-      dp.radius_a = weights_radius_a[k].value;
-      sum +=weights_radius_b[i].weight
-          * weights_radius_a[k].weight*DiamEllip(dp.radius_a,dp.radius_b)/2.0;
-      norm += weights_radius_b[i].weight* weights_radius_a[k].weight;
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    rad_out = DiamEllip(dp.radius_a,dp.radius_b)/2.0;}
-
-  return rad_out;
-}
-double EllipsoidModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/ellipticalcylinder.cpp
===================================================================
--- src/sans/models/src/c_models/ellipticalcylinder.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,466 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "elliptical_cylinder.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double r_minor;
-  double r_ratio;
-  double length;
-  double sldCyl;
-  double sldSolv;
-  double background;
-  double cyl_theta;
-  double cyl_phi;
-  double cyl_psi;
-} EllipticalCylinderParameters;
-
-
-static double elliptical_cylinder_kernel(EllipticalCylinderParameters *pars, double q, double cos_val, double cos_nu, double cos_mu) {
-  double qr;
-  double qL;
-  double Be,Si;
-  double r_major;
-  double kernel;
-
-  r_major = pars->r_ratio * pars->r_minor;
-
-  qr = q*sqrt( r_major*r_major*cos_nu*cos_nu + pars->r_minor*pars->r_minor*cos_mu*cos_mu );
-  qL = q*pars->length*cos_val/2.0;
-
-  if (qr==0){
-    Be = 0.5;
-  }else{
-    Be = NR_BessJ1(qr)/qr;
-  }
-  if (qL==0){
-    Si = 1.0;
-  }else{
-    Si = sin(qL)/qL;
-  }
-
-
-  kernel = 2.0*Be * Si;
-  return kernel*kernel;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double elliptical_cylinder_analytical_2D_scaled(EllipticalCylinderParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y;//, cyl_z;
-  double ella_x, ella_y, ellb_x, ellb_y;
-  //double q_z;
-  double vol, cos_val;
-  double cos_mu, cos_nu;
-  double answer;
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->cyl_theta * pi/180.0;
-  double phi = pars->cyl_phi * pi/180.0;
-  double psi = pars->cyl_psi * pi/180.0;
-
-  //Cylinder orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0;
-
-  // Note: cos(alpha) = 0 and 1 will get an
-  // undefined value from CylKernel
-  //alpha = acos( cos_val );
-
-  //ellipse orientation:
-  // the elliptical corss section was transformed and projected
-  // into the detector plane already through sin(alpha)and furthermore psi remains as same
-  // on the detector plane.
-  // So, all we need is to calculate the angle (nu) of the minor axis of the ellipse wrt
-  // the wave vector q.
-
-  //x- y- component on the detector plane.
-  ella_x =  -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-  ella_y =  sin(psi)*cos(theta);
-  ellb_x =  -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-  ellb_y =  cos(theta)*cos(psi);
-  
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // calculate the axis of the ellipse wrt q-coord.
-  cos_nu = ella_x*q_x + ella_y*q_y;
-  cos_mu = ellb_x*q_x + ellb_y*q_y;
-  
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    //printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val = 1.0;
-  }
-  if (fabs(cos_nu)>1.0) {
-    //printf("cyl_ana_2D: Unexpected error: cos(nu)>1\n");
-    cos_nu = 1.0;
-  }
-  if (fabs(cos_mu)>1.0) {
-    //printf("cyl_ana_2D: Unexpected error: cos(nu)>1\n");
-    cos_mu = 1.0;
-  }
-  answer = elliptical_cylinder_kernel(pars, q, cos_val, cos_nu, cos_mu);
-
-  // Multiply by contrast^2
-  answer *= (pars->sldCyl - pars->sldSolv) * (pars->sldCyl - pars->sldSolv);
-
-  //normalize by cylinder volume
-  //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-  vol = acos(-1.0) * pars->r_minor * pars->r_minor * pars->r_ratio * pars->length;
-  answer *= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @return: function value
- */
-static double elliptical_cylinder_analytical_2DXY(EllipticalCylinderParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return elliptical_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-EllipticalCylinderModel :: EllipticalCylinderModel() {
-  scale      = Parameter(1.0);
-  r_minor    = Parameter(20.0, true);
-  r_minor.set_min(0.0);
-  r_ratio    = Parameter(1.5, true);
-  r_ratio.set_min(0.0);
-  length     = Parameter(400.0, true);
-  length.set_min(0.0);
-  sldCyl   = Parameter(4.e-6);
-  sldSolv   = Parameter(1.e-6);
-  background = Parameter(0.0);
-  cyl_theta  = Parameter(57.325, true);
-  cyl_phi    = Parameter(0.0, true);
-  cyl_psi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double EllipticalCylinderModel :: operator()(double q) {
-  double dp[7];
-
-  dp[0] = scale();
-  dp[1] = r_minor();
-  dp[2] = r_ratio();
-  dp[3] = length();
-  dp[4] = sldCyl();
-  dp[5] = sldSolv();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the r_minor
-  vector<WeightPoint> weights_rad;
-  r_minor.get_weights(weights_rad);
-
-  // Get the dispersion points for the r_ratio
-  vector<WeightPoint> weights_rat;
-  r_ratio.get_weights(weights_rat);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over r_minor weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[1] = weights_rad[i].value;
-
-    // Loop over r_ratio weight points
-    for(size_t j=0; j<weights_rat.size(); j++) {
-      dp[2] = weights_rat[j].value;
-
-      // Loop over length weight points
-      for(size_t k=0; k<weights_len.size(); k++) {
-        dp[3] = weights_len[k].value;
-        //Un-normalize  by volume
-        sum += weights_rad[i].weight
-            * weights_len[k].weight
-            * weights_rat[j].weight
-            * EllipCyl20(dp, q)
-        * pow(weights_rad[i].value,2) * weights_rat[j].value
-        * weights_len[k].value;
-        //Find average volume
-        vol += weights_rad[i].weight
-            * weights_len[k].weight
-            * weights_rat[j].weight
-            * pow(weights_rad[i].value,2) * weights_rat[j].value
-            * weights_len[k].value;
-        norm += weights_rad[i].weight
-            * weights_len[k].weight
-            * weights_rat[j].weight;
-      }
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double EllipticalCylinderModel :: operator()(double qx, double qy) {
-  EllipticalCylinderParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.r_minor    = r_minor();
-  dp.r_ratio    = r_ratio();
-  dp.length     = length();
-  dp.sldCyl   = sldCyl();
-  dp.sldSolv   = sldSolv();
-  dp.background = 0.0;
-  dp.cyl_theta  = cyl_theta();
-  dp.cyl_phi    = cyl_phi();
-  dp.cyl_psi    = cyl_psi();
-
-  // Get the dispersion points for the r_minor
-  vector<WeightPoint> weights_rad;
-  r_minor.get_weights(weights_rad);
-
-  // Get the dispersion points for the r_ratio
-  vector<WeightPoint> weights_rat;
-  r_ratio.get_weights(weights_rat);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  cyl_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  cyl_phi.get_weights(weights_phi);
-
-  // Get angular averaging for psi
-  vector<WeightPoint> weights_psi;
-  cyl_psi.get_weights(weights_psi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over minor radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.r_minor = weights_rad[i].value;
-
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_len.size(); j++) {
-      dp.length = weights_len[j].value;
-
-      // Loop over r_ration weight points
-      for(size_t m=0; m<weights_rat.size(); m++) {
-        dp.r_ratio = weights_rat[m].value;
-
-        // Average over theta distribution
-        for(size_t k=0; k<weights_theta.size(); k++) {
-          dp.cyl_theta = weights_theta[k].value;
-
-          // Average over phi distribution
-          for(size_t l=0; l<weights_phi.size(); l++) {
-            dp.cyl_phi = weights_phi[l].value;
-
-            // Average over phi distribution
-            for(size_t o=0; o<weights_psi.size(); o++) {
-              dp.cyl_psi = weights_psi[o].value;
-              //Un-normalize by volume
-              double _ptvalue = weights_rad[i].weight
-                  * weights_len[j].weight
-                  * weights_rat[m].weight
-                  * weights_theta[k].weight
-                  * weights_phi[l].weight
-                  * weights_psi[o].weight
-                  * elliptical_cylinder_analytical_2DXY(&dp, qx, qy)
-              * pow(weights_rad[i].value,2)
-              * weights_len[j].value
-              * weights_rat[m].value;
-              if (weights_theta.size()>1) {
-                _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0));
-              }
-              sum += _ptvalue;
-              //Find average volume
-              vol += weights_rad[i].weight
-                  * weights_len[j].weight
-                  * weights_rat[m].weight
-                  * pow(weights_rad[i].value,2)
-              * weights_len[j].value
-              * weights_rat[m].value;
-              //Find norm for volume
-              norm_vol += weights_rad[i].weight
-                  * weights_len[j].weight
-                  * weights_rat[m].weight;
-
-              norm += weights_rad[i].weight
-                  * weights_len[j].weight
-                  * weights_rat[m].weight
-                  * weights_theta[k].weight
-                  * weights_phi[l].weight
-                  * weights_psi[o].weight;
-
-            }
-          }
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double EllipticalCylinderModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double EllipticalCylinderModel :: calculate_ER() {
-  EllipticalCylinderParameters dp;
-  dp.r_minor    = r_minor();
-  dp.r_ratio    = r_ratio();
-  dp.length     = length();
-  double rad_out = 0.0;
-  double suf_rad = sqrt(dp.r_minor*dp.r_minor*dp.r_ratio);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the r_minor
-  vector<WeightPoint> weights_rad;
-  r_minor.get_weights(weights_rad);
-
-  // Get the dispersion points for the r_ratio
-  vector<WeightPoint> weights_rat;
-  r_ratio.get_weights(weights_rat);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Loop over minor radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.r_minor = weights_rad[i].value;
-
-    // Loop over length weight points
-    for(size_t j=0; j<weights_len.size(); j++) {
-      dp.length = weights_len[j].value;
-
-      // Loop over r_ration weight points
-      for(size_t m=0; m<weights_rat.size(); m++) {
-        dp.r_ratio = weights_rat[m].value;
-        //Calculate surface averaged radius
-        suf_rad = sqrt(dp.r_minor * dp.r_minor * dp.r_ratio);
-
-        //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-        sum +=weights_rad[i].weight *weights_len[j].weight
-            * weights_rat[m].weight*DiamCyl(dp.length, suf_rad)/2.0;
-        norm += weights_rad[i].weight *weights_len[j].weight* weights_rat[m].weight;
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-    rad_out = DiamCyl(dp.length, suf_rad)/2.0;}
-
-  return rad_out;
-}
-double EllipticalCylinderModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/fcc.cpp
===================================================================
--- src/sans/models/src/c_models/fcc.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,338 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "fcc.h"
-
-extern "C" {
-#include "libSphere.h"
-}
-
-// Convenience parameter structure
-typedef struct {
-  double scale;
-  double dnn;
-  double d_factor;
-  double radius;
-  double sldSph;
-  double sldSolv;
-  double background;
-  double theta;
-  double phi;
-  double psi;
-} FCParameters;
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the FCCCrystalModel
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double fc_analytical_2D_scaled(FCParameters *pars, double q, double q_x, double q_y) {
-  double b3_x, b3_y, b1_x, b1_y, b2_x, b2_y; //, b3_z
-  double q_z;
-  double cos_val_b3, cos_val_b2, cos_val_b1;
-  double a1_dot_q, a2_dot_q,a3_dot_q;
-  double answer;
-  double Pi = 4.0*atan(1.0);
-  double aa, Da, qDa_2, latticeScale, Zq, Fkq, Fkq_2;
-
-  double dp[5];
-  //convert angle degree to radian
-  double theta = pars->theta * Pi/180.0;
-  double phi = pars->phi * Pi/180.0;
-  double psi = pars->psi * Pi/180.0;
-  dp[0] = 1.0;
-  dp[1] = pars->radius;
-  dp[2] = pars->sldSph;
-  dp[3] = pars->sldSolv;
-  dp[4] = 0.0;
-
-  aa = pars->dnn;
-  Da = pars->d_factor*aa;
-  qDa_2 = pow(q*Da,2.0);
-  //contrast = pars->sldSph - pars->sldSolv;
-
-  latticeScale = 4.0*(4.0/3.0)*Pi*(dp[1]*dp[1]*dp[1])/pow(aa*sqrt(2.0),3.0);
-  // q vector
-  q_z = 0.0; // for SANS; assuming qz is negligible
-  /// Angles here are respect to detector coordinate
-  ///  instead of against q coordinate in PRB 36(46), 3(6), 1754(3854)
-  // b3 axis orientation
-  b3_x = cos(theta) * cos(phi);
-  b3_y = sin(theta);
-  //b3_z = -cos(theta) * sin(phi);
-  cos_val_b3 =  b3_x*q_x + b3_y*q_y;// + b3_z*q_z;
-  
-  // b1 axis orientation
-  b1_x = -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-  b1_y = sin(psi)*cos(theta);
-  cos_val_b1 = b1_x*q_x + b1_y*q_y;
-  
-  // b2 axis orientation
-  b2_x = -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-  b2_y = cos(theta)*cos(psi);
-  cos_val_b2 =  b2_x*q_x + b2_y*q_y;
-  
-  // The following test should always pass
-  if (fabs(cos_val_b3)>1.0) {
-    //printf("bcc_ana_2D: Unexpected error: cos()>1\n");
-    cos_val_b3 = 1.0;
-  }
-  if (fabs(cos_val_b2)>1.0) {
-    //printf("bcc_ana_2D: Unexpected error: cos()>1\n");
-    cos_val_b2 = 1.0;
-  }
-  if (fabs(cos_val_b1)>1.0) {
-    //printf("bcc_ana_2D: Unexpected error: cos()>1\n");
-    cos_val_b1 = 1.0;
-  }
-  // Compute the angle btw vector q and the a3 axis
-  a3_dot_q = 0.5*aa*q*(cos_val_b2+cos_val_b1);
-
-  // a1 axis
-  a1_dot_q = 0.5*aa*q*(cos_val_b2+cos_val_b3);
-
-  // a2 axis
-  a2_dot_q = 0.5*aa*q*(cos_val_b3+cos_val_b1);
-
-
-  // Get Fkq and Fkq_2
-  Fkq = exp(-0.5*pow(Da/aa,2.0)*(a1_dot_q*a1_dot_q+a2_dot_q*a2_dot_q+a3_dot_q*a3_dot_q));
-  Fkq_2 = Fkq*Fkq;
-  // Call Zq=Z1*Z2*Z3
-  Zq = (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a1_dot_q)+Fkq_2);
-  Zq = Zq * (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a2_dot_q)+Fkq_2);
-  Zq = Zq * (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a3_dot_q)+Fkq_2);
-
-  // Use SphereForm directly from libigor
-  answer = SphereForm(dp,q)*Zq;
-
-  //consider scales
-  answer *= latticeScale * pars->scale;
-
-  // This FIXES a singualrity the kernel in libigor.
-  if ( answer == INFINITY || answer == NAN){
-    answer = 0.0;
-  }
-
-  // add background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the FCC_ParaCrystal
- * @param q: q-value
- * @return: function value
- */
-static double fc_analytical_2DXY(FCParameters *pars, double qx, double qy){
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return fc_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-FCCrystalModel :: FCCrystalModel() {
-  scale      = Parameter(1.0);
-  dnn		= Parameter(220.0);
-  d_factor = Parameter(0.06);
-  radius     = Parameter(40.0, true);
-  radius.set_min(0.0);
-  sldSph   = Parameter(3.0e-6);
-  sldSolv   = Parameter(6.3e-6);
-  background = Parameter(0.0);
-  theta  = Parameter(0.0, true);
-  phi    = Parameter(0.0, true);
-  psi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double FCCrystalModel :: operator()(double q) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = dnn();
-  dp[2] = d_factor();
-  dp[3] = radius();
-  dp[4] = sldSph();
-  dp[5] = sldSolv();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-  double result;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[3] = weights_rad[i].value;
-
-    //Un-normalize SphereForm by volume
-    result = FCC_ParaCrystal(dp, q) * pow(weights_rad[i].value,3);
-    // This FIXES a singualrity the kernel in libigor.
-    if ( result == INFINITY || result == NAN){
-      result = 0.0;
-    }
-    sum += weights_rad[i].weight
-        * result;
-    //Find average volume
-    vol += weights_rad[i].weight
-        * pow(weights_rad[i].value,3);
-
-    norm += weights_rad[i].weight;
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double FCCrystalModel :: operator()(double qx, double qy) {
-  FCParameters dp;
-  dp.scale      = scale();
-  dp.dnn   = dnn();
-  dp.d_factor   = d_factor();
-  dp.radius  = radius();
-  dp.sldSph   = sldSph();
-  dp.sldSolv   = sldSolv();
-  dp.background = 0.0;
-  dp.theta  = theta();
-  dp.phi    = phi();
-  dp.psi    = psi();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  phi.get_weights(weights_phi);
-
-  // Get angular averaging for psi
-  vector<WeightPoint> weights_psi;
-  psi.get_weights(weights_psi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.radius = weights_rad[i].value;
-    // Average over theta distribution
-    for(size_t j=0; j< weights_theta.size(); j++) {
-      dp.theta = weights_theta[j].value;
-      // Average over phi distribution
-      for(size_t k=0; k< weights_phi.size(); k++) {
-        dp.phi = weights_phi[k].value;
-        // Average over phi distribution
-        for(size_t l=0; l< weights_psi.size(); l++) {
-          dp.psi = weights_psi[l].value;
-          //Un-normalize SphereForm by volume
-          double _ptvalue = weights_rad[i].weight
-              * weights_theta[j].weight
-              * weights_phi[k].weight
-              * weights_psi[l].weight
-              * fc_analytical_2DXY(&dp, qx, qy);
-          //* pow(weights_rad[i].value,3.0);
-          // Consider when there is infinte or nan.
-          if ( _ptvalue == INFINITY || _ptvalue == NAN){
-            _ptvalue = 0.0;
-          }
-          if (weights_theta.size()>1) {
-            _ptvalue *= fabs(cos(weights_theta[j].value*pi/180.0));
-          }
-          sum += _ptvalue;
-          // This model dose not need the volume of spheres correction!!!
-          norm += weights_rad[i].weight
-              * weights_theta[j].weight
-              * weights_phi[k].weight
-              * weights_psi[l].weight;
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the FCCCrystal
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double FCCrystalModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double FCCrystalModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double FCCrystalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/flexcyl_ellipX.cpp
===================================================================
--- src/sans/models/src/c_models/flexcyl_ellipX.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,216 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "flexcyl_ellipX.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double length;
-  double kuhn_length;
-  double radius;
-  double axis_ratio;
-  double sldCyl;
-  double sldSolv;
-  double background;
-} FlexCylEXParameters;
-
-FlexCylEllipXModel :: FlexCylEllipXModel() {
-  scale      = Parameter(1.0);
-  length     = Parameter(1000.0, true);
-  length.set_min(0.0);
-  kuhn_length = Parameter(100.0, true);
-  kuhn_length.set_min(0.0);
-  radius  = Parameter(20.0, true);
-  radius.set_min(0.0);
-  axis_ratio = Parameter(1.5);
-  axis_ratio.set_min(0.0);
-  sldCyl   = Parameter(1.0e-6);
-  sldSolv   = Parameter(6.3e-6);
-  background = Parameter(0.0001);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double FlexCylEllipXModel :: operator()(double q) {
-  double dp[8];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = length();
-  dp[2] = kuhn_length();
-  dp[3] = radius();
-  dp[4] = axis_ratio();
-  dp[5] = sldCyl();
-  dp[6] = sldSolv();
-  dp[7] = 0.0;
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_len;
-  length.get_weights(weights_len);
-
-  // Get the dispersion points for the kuhn_length
-  vector<WeightPoint> weights_kuhn;
-  kuhn_length.get_weights(weights_kuhn);
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get the dispersion points for the axis_ratio
-  vector<WeightPoint> weights_ratio;
-  axis_ratio.get_weights(weights_ratio);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over length weight points
-  for(int i=0; i< (int)weights_len.size(); i++) {
-    dp[1] = weights_len[i].value;
-
-    // Loop over kuhn_length weight points
-    for(int j=0; j< (int)weights_kuhn.size(); j++) {
-      dp[2] = weights_kuhn[j].value;
-
-      // Loop over radius weight points
-      for(int k=0; k< (int)weights_rad.size(); k++) {
-        dp[3] = weights_rad[k].value;
-        // Loop over axis_ratio weight points
-        for(int l=0; l< (int)weights_ratio.size(); l++) {
-          dp[4] = weights_ratio[l].value;
-
-          //Un-normalize by volume
-          sum += weights_len[i].weight * weights_kuhn[j].weight*weights_rad[k].weight
-              * weights_ratio[l].weight * FlexCyl_Ellip(dp, q)
-          * (pow(weights_rad[k].value,2.0) * weights_ratio[l].value * weights_len[i].value);
-          //Find weighted volume
-          vol += weights_rad[k].weight * weights_kuhn[j].weight
-              * weights_len[i].weight * weights_ratio[l].weight
-              *pow(weights_rad[k].value,2.0)* weights_ratio[l].weight*weights_len[i].value;
-          norm += weights_len[i].weight * weights_kuhn[j].weight
-              *weights_rad[k].weight* weights_ratio[l].weight;
-        }
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double FlexCylEllipXModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the triaxial ellipsoid
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double FlexCylEllipXModel :: evaluate_rphi(double q, double phi) {
-  //double qx = q*cos(phi);
-  //double qy = q*sin(phi);
-  return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double FlexCylEllipXModel :: calculate_ER() {
-  FlexCylEXParameters dp;
-
-  dp.radius  = radius();
-  dp.length     = length();
-  dp.axis_ratio  = axis_ratio();
-
-  double rad_out = 0.0;
-  double suf_rad = sqrt(dp.radius*dp.radius*dp.axis_ratio );
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the total length
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Get the dispersion points for minor radius
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for axis ratio = major_radius/minor_radius
-  vector<WeightPoint> weights_ratio ;
-  axis_ratio.get_weights(weights_ratio);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_length.size(); i++) {
-    dp.length = weights_length[i].value;
-    for(int k=0; k< (int)weights_radius.size(); k++) {
-      dp.radius = weights_radius[k].value;
-      // Loop over axis_ratio weight points
-      for(int l=0; l< (int)weights_ratio.size(); l++) {
-        dp.axis_ratio = weights_ratio[l].value;
-        suf_rad = sqrt(dp.radius  * dp.radius  * dp.axis_ratio);
-        //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-        sum +=weights_length[i].weight * weights_radius[k].weight
-            * weights_ratio[l].weight *DiamCyl(dp.length,suf_rad)/2.0;
-        norm += weights_length[i].weight* weights_radius[k].weight* weights_ratio[l].weight;
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-    rad_out = DiamCyl(dp.length,suf_rad)/2.0;}
-
-  return rad_out;
-}
-double FlexCylEllipXModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/flexiblecylinder.cpp
===================================================================
--- src/sans/models/src/c_models/flexiblecylinder.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,195 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: add 2d
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "flexible_cylinder.h"
-
-extern "C" {
-	#include "libCylinder.h"
-	#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double length;
-  double kuhn_length;
-  double radius;
-  double sldCyl;
-  double sldSolv;
-  double background;
-} FlexibleCylinderParameters;
-
-FlexibleCylinderModel :: FlexibleCylinderModel() {
-	scale      = Parameter(1.0);
-	length     = Parameter(1000.0, true);
-	length.set_min(0.0);
-	kuhn_length = Parameter(100.0, true);
-	kuhn_length.set_min(0.0);
-	radius  = Parameter(20.0, true);
-	radius.set_min(0.0);
-	sldCyl   = Parameter(1.0e-6);
-	sldSolv   = Parameter(6.3e-6);
-	background = Parameter(0.0001);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double FlexibleCylinderModel :: operator()(double q) {
-	double dp[7];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = length();
-	dp[2] = kuhn_length();
-	dp[3] = radius();
-	dp[4] = sldCyl();
-	dp[5] = sldSolv();
-	dp[6] = 0.0;
-
-	// Get the dispersion points for the length
-	vector<WeightPoint> weights_len;
-	length.get_weights(weights_len);
-
-	// Get the dispersion points for the kuhn_length
-	vector<WeightPoint> weights_kuhn;
-	kuhn_length.get_weights(weights_kuhn);
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over semi axis A weight points
-	for(int i=0; i< (int)weights_len.size(); i++) {
-		dp[1] = weights_len[i].value;
-
-		// Loop over semi axis B weight points
-		for(int j=0; j< (int)weights_kuhn.size(); j++) {
-			dp[2] = weights_kuhn[j].value;
-
-			// Loop over semi axis C weight points
-			for(int k=0; k< (int)weights_rad.size(); k++) {
-				dp[3] = weights_rad[k].value;
-				//Un-normalize by volume
-				sum += weights_len[i].weight
-					* weights_kuhn[j].weight*weights_rad[k].weight * FlexExclVolCyl(dp, q)
-					* pow(weights_rad[k].value,2.0)*weights_len[i].value;
-				//Find average volume
-				vol += weights_rad[k].weight
-					* weights_len[i].weight
-					* weights_kuhn[j].weight
-					*pow(weights_rad[k].value,2.0)*weights_len[i].value;
-				norm += weights_len[i].weight
-					* weights_kuhn[j].weight*weights_rad[k].weight;
-			}
-		}
-	}
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double FlexibleCylinderModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the triaxial ellipsoid
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double FlexibleCylinderModel :: evaluate_rphi(double q, double phi) {
-	//double qx = q*cos(phi);
-	//double qy = q*sin(phi);
-	return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double FlexibleCylinderModel :: calculate_ER() {
-	FlexibleCylinderParameters dp;
-
-	dp.radius  = radius();
-	dp.length     = length();
-
-	double rad_out = 0.0;
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the major shell
-	vector<WeightPoint> weights_length;
-	length.get_weights(weights_length);
-
-	// Get the dispersion points for the minor shell
-	vector<WeightPoint> weights_radius ;
-	radius.get_weights(weights_radius);
-
-	// Loop over major shell weight points
-	for(int i=0; i< (int)weights_length.size(); i++) {
-		dp.length = weights_length[i].value;
-		for(int k=0; k< (int)weights_radius.size(); k++) {
-			dp.radius = weights_radius[k].value;
-			//Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-			sum +=weights_length[i].weight
-				* weights_radius[k].weight*DiamCyl(dp.length,dp.radius)/2.0;
-			norm += weights_length[i].weight* weights_radius[k].weight;
-		}
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		//Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-		rad_out = DiamCyl(dp.length,dp.radius)/2.0;}
-
-	return rad_out;
-}
-double FlexibleCylinderModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/fractal.cpp
===================================================================
--- src/sans/models/src/c_models/fractal.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "fractal.h"
-
-extern "C" {
-#include "libTwoPhase.h"
-}
-
-FractalModel :: FractalModel() {
-  scale      = Parameter(1.0);
-  radius = Parameter(5.0, true);
-  radius.set_min(0.0);
-  fractal_dim = Parameter(2.0);
-  cor_length = Parameter(100.0);
-  sldBlock = Parameter(2.0e-6);
-  sldSolv= Parameter(6.35e-6);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double FractalModel :: operator()(double q) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = fractal_dim();
-  dp[3] = cor_length();
-  dp[4] = sldBlock();
-  dp[5] = sldSolv();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[1] = weights_rad[i].value;
-
-    //Un-normalize Fractal by volume
-    sum += weights_rad[i].weight
-        * Fractal(dp, fabs(q)) * pow(weights_rad[i].value,3);
-    //Find average volume
-    vol += weights_rad[i].weight
-        * pow(weights_rad[i].value,3);
-
-    norm += weights_rad[i].weight;
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double FractalModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the FractalModel
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double FractalModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double FractalModel :: calculate_ER() {
-  //NOT implemented yet!!! 'cause None shape Model
-  return 0.0;
-}
-double FractalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/fuzzysphere.cpp
===================================================================
--- src/sans/models/src/c_models/fuzzysphere.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,184 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "fuzzysphere.h"
-
-extern "C" {
-#include "libSphere.h"
-}
-
-// scattering from a uniform sphere w/ fuzzy surface
-// Modified from FuzzySpheres in libigor/libSphere.c without polydispersion: JHC
-static double fuzzysphere_kernel(double dp[], double q){
-  double pi,x,xr;
-  double radius,sldSph,sldSolv,scale,bkg,delrho,fuzziness,f2,bes,vol,f;   //my local names
-
-  pi = 4.0*atan(1.0);
-  x= q;
-  scale = dp[0];
-  radius = dp[1];
-  fuzziness = dp[2];
-  sldSph = dp[3];
-  sldSolv = dp[4];
-  bkg = dp[5];
-  delrho=sldSph-sldSolv;
-
-  xr = x*radius;
-  //handle xr==0 separately
-  if(xr == 0.0){
-    bes = 1.0;
-  }else{
-    bes = 3.0*(sin(xr)-xr*cos(xr))/(xr*xr*xr);
-  }
-  vol = 4.0*pi/3.0*radius*radius*radius;
-  f = vol*bes*delrho;   // [=] A
-  f *= exp(-0.5*fuzziness*fuzziness*x*x);
-  // normalize to single particle volume, convert to 1/cm
-  f2 = f * f / vol * 1.0e8;   // [=] 1/cm
-
-  f2 *= scale;
-  f2 += bkg;
-
-    return(f2); //scale, and add in the background
-}
-
-FuzzySphereModel :: FuzzySphereModel() {
-	scale      = Parameter(0.01);
-	radius     = Parameter(60.0, true);
-	radius.set_min(0.0);
-	fuzziness  = Parameter(10.0);
-	fuzziness.set_min(0.0);
-	sldSph   = Parameter(1.0e-6);
-	sldSolv   = Parameter(3.0e-6);
-	background = Parameter(0.001);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double FuzzySphereModel :: operator()(double q) {
-	double dp[6];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = radius();
-	dp[2] = fuzziness();
-	dp[3] = sldSph();
-	dp[4] = sldSolv();
-	dp[5] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_radius;
-	radius.get_weights(weights_radius);
-
-	// Get the dispersion points for the fuzziness
-	vector<WeightPoint> weights_fuzziness;
-	fuzziness.get_weights(weights_fuzziness);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double norm_vol = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_radius.size(); i++) {
-		dp[1] = weights_radius[i].value;
-		// Loop over fuzziness weight points
-		for(size_t j=0; j<weights_fuzziness.size(); j++) {
-			dp[2] = weights_fuzziness[j].value;
-
-			//Un-normalize SphereForm by volume
-			sum += weights_radius[i].weight * weights_fuzziness[j].weight
-				* fuzzysphere_kernel(dp, q) * pow(weights_radius[i].value,3);
-			//Find average volume : Note the fuzziness has no contribution to the volume
-			vol += weights_radius[i].weight
-				* pow(weights_radius[i].value,3);
-
-			norm += weights_radius[i].weight * weights_fuzziness[j].weight;
-			norm_vol += weights_radius[i].weight;
-		}
-	}
-
-	if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm_vol);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double FuzzySphereModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double FuzzySphereModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double FuzzySphereModel :: calculate_ER() {
-	double rad_out = 0.0;
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the radius
-	// No need to consider the fuzziness.
-	vector<WeightPoint> weights_radius;
-	radius.get_weights(weights_radius);
-	// Loop over radius weight points to average the radius value
-	for(size_t i=0; i<weights_radius.size(); i++) {
-		sum += weights_radius[i].weight
-			* weights_radius[i].value;
-		norm += weights_radius[i].weight;
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		rad_out = radius();}
-
-	return rad_out;
-}
-double FuzzySphereModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/gamma_win.c
===================================================================
--- src/sans/models/src/c_models/gamma_win.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,141 +1,0 @@
-// Visit http://www.johndcook.com/stand_alone_code.html for the source of this code and more like it.
-// Modified for the DANSE project.
-
-#include <math.h>
-
-#include "gamma_win.h"
-
-// Note that the functions Gamma and LogGamma are mutually dependent.
-
-double gamma(double x)
-{
-  // Split the function domain into three intervals:
-  // (0, 0.001), [0.001, 12), and (12, infinity)
-
-  ///////////////////////////////////////////////////////////////////////////
-  // First interval: (0, 0.001)
-  //
-  // For small x, 1/Gamma(x) has power series x + gamma x^2  - ...
-  // So in this range, 1/Gamma(x) = x + gamma x^2 with error on the order of x^3.
-  // The relative error over this interval is less than 6e-7.
-
-  const double gamma = 0.577215664901532860606512090; // Euler's gamma constant
-  double y;
-  int arg_was_less_than_one = 0;
-  int n = 0;
-  // numerator coefficients for approximation over the interval (1,2)
-  static const double p[] =
-  {
-      -1.71618513886549492533811E+0,
-       2.47656508055759199108314E+1,
-      -3.79804256470945635097577E+2,
-       6.29331155312818442661052E+2,
-       8.66966202790413211295064E+2,
-      -3.14512729688483675254357E+4,
-      -3.61444134186911729807069E+4,
-       6.64561438202405440627855E+4
-  };
-  // denominator coefficients for approximation over the interval (1,2)
-  static const double q[] =
-  {
-      -3.08402300119738975254353E+1,
-       3.15350626979604161529144E+2,
-      -1.01515636749021914166146E+3,
-      -3.10777167157231109440444E+3,
-       2.25381184209801510330112E+4,
-       4.75584627752788110767815E+3,
-      -1.34659959864969306392456E+5,
-      -1.15132259675553483497211E+5
-  };
-  double num = 0.0;
-  double den = 1.0;
-  int i;
-  double z;
-  double result;
-
-  if (x < 0.001)
-      return 1.0/(x*(1.0 + gamma*x));
-
-  ///////////////////////////////////////////////////////////////////////////
-  // Second interval: [0.001, 12)
-
-  if (x < 12.0)
-    {
-      // The algorithm directly approximates gamma over (1,2) and uses
-      // reduction identities to reduce other arguments to this interval.
-
-      y = x;
-
-      if (y < 1.0) arg_was_less_than_one = 1;
-
-      // Add or subtract integers as necessary to bring y into (1,2)
-      // Will correct for this below
-      if (arg_was_less_than_one==1) {
-          y += 1.0;
-      } else {
-          n = (int) (floor(y)) - 1;  // will use n later
-          y -= n;
-      }
-
-      z = y - 1;
-      for (i = 0; i < 8; i++) {
-          num = (num + p[i])*z;
-          den = den*z + q[i];
-      }
-      result = num/den + 1.0;
-
-      // Apply correction if argument was not initially in (1,2)
-      if (arg_was_less_than_one==1) {
-          // Use identity gamma(z) = gamma(z+1)/z
-          // The variable "result" now holds gamma of the original y + 1
-          // Thus we use y-1 to get back the orginal y.
-          result /= (y-1.0);
-      } else {
-          // Use the identity gamma(z+n) = z*(z+1)* ... *(z+n-1)*gamma(z)
-          for (i = 0; i < n; i++)
-              result *= y++;
-      }
-
-      return result;
-    }
-
-    return exp(lgamma(x));
-}
-
-double lgamma (double x)
-{
-  static const double c[8] =
-  {
-   1.0/12.0,
-  -1.0/360.0,
-  1.0/1260.0,
-  -1.0/1680.0,
-  1.0/1188.0,
-  -691.0/360360.0,
-  1.0/156.0,
-  -3617.0/122400.0
-  };
-  double z = 1.0/(x*x);
-  double sum = c[7];
-  static const double halfLogTwoPi = 0.91893853320467274178032973640562;
-  double series;
-  double logGamma;
-  int i;
-
-  if (x < 12.0) {
-     return log(fabs(gamma(x)));
-  }
-
-  // Abramowitz and Stegun 6.1.41
-  // Asymptotic series should be good to at least 11 or 12 figures
-  // For error analysis, see Whittiker and Watson
-  // A Course in Modern Analysis (1927), page 252
-
-  for (i=6; i >= 0; i--) {
-      sum *= z;
-      sum += c[i];
-  }
-  series = sum/x;
-  logGamma = (x - 0.5)*log(x) - x + halfLogTwoPi + series;
-  return logGamma;
-}
Index: c/sans/models/src/c_models/gamma_win.h
===================================================================
--- src/sans/models/src/c_models/gamma_win.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,19 +1,0 @@
-// Visit http://www.johndcook.com/stand_alone_code.html for the source of this code and more like it.
-
-#ifndef GAMMA_H
-#define GAMMA_H
-
-// Note that the functions Gamma and LogGamma are mutually dependent.
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-double lgamma(double);
-double gamma(double);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
Index: c/sans/models/src/c_models/gaussian.cpp
===================================================================
--- src/sans/models/src/c_models/gaussian.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,82 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "gaussian.h"
-
-Gaussian :: Gaussian() {
-  scale  = Parameter(1.0, true);
-  sigma  = Parameter(1.0, true);
-  center = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D Gaussian function.
- * The function is normalized to the 'scale' parameter.
- *
- * f(x)=scale * 1/(sigma^2*2pi)e^(-(x-mu)^2/2sigma^2)
- *
- * @param q: q-value
- * @return: function value
- */
-double Gaussian :: operator()(double q) {
-  double sigma2 = pow(sigma(), 2);
-  return scale() / sigma2 * exp( -pow((q-center()), 2) / (2*sigma2));
-}
-
-/**
- * Function to evaluate 2D Gaussian  function
- * The function is normalized to the 'scale' parameter.
- *
- * f(x,y) = Gaussian(x) * Gaussian(y)
- *
- * where both Gaussians share the same parameters.
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double Gaussian :: operator()(double qx, double qy) {
-  return (*this).operator()(qx) * (*this).operator()(qy);
-}
-
-/**
- * Function to evaluate 2D Gaussian  function
- * The function is normalized to the 'scale' parameter.
- *
- * f(x,y) = Gaussian(x) * Gaussian(y)
- *
- * where both Gaussians share the same parameters.
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double Gaussian :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double Gaussian :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double Gaussian :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/hollowcylinder.cpp
===================================================================
--- src/sans/models/src/c_models/hollowcylinder.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,423 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "hollow_cylinder.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double core_radius;
-  double radius;
-  double length;
-  double sldCyl;
-  double sldSolv;
-  double background;
-  double axis_theta;
-  double axis_phi;
-} HollowCylinderParameters;
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the hollow cylinder
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double hollow_cylinder_analytical_2D_scaled(HollowCylinderParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y; //, cyl_z
-  //double q_z;
-  double  alpha,vol, cos_val;
-  double answer;
-  //convert angle degree to radian
-  double pi = 4.0*atan(1.0);
-  double theta = pars->axis_theta * pi/180.0;
-  double phi = pars->axis_phi * pi/180.0;
-
-  // Cylinder orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0;
-
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("core_shell_cylinder_analytical_2D: Unexpected error: cos(alpha)=%g\n", cos_val);
-    return 0;
-  }
-
-  alpha = acos( cos_val );
-
-  // Call the IGOR library function to get the kernel
-  answer = HolCylKernel(q, pars->core_radius, pars->radius, pars->length, cos_val);
-
-  // Multiply by contrast^2
-  answer *= (pars->sldCyl - pars->sldSolv)*(pars->sldCyl - pars->sldSolv);
-
-  //normalize by cylinder volume
-  vol=pi*((pars->radius*pars->radius)-(pars->core_radius *pars->core_radius))
-          *(pars->length);
-  answer *= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the Hollow cylinder
- * @param q: q-value
- * @return: function value
- */
-static double hollow_cylinder_analytical_2DXY(HollowCylinderParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return hollow_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-HollowCylinderModel :: HollowCylinderModel() {
-  scale      = Parameter(1.0);
-  core_radius = Parameter(20.0, true);
-  core_radius.set_min(0.0);
-  radius  = Parameter(30.0, true);
-  radius.set_min(0.0);
-  length     = Parameter(400.0, true);
-  length.set_min(0.0);
-  sldCyl  = Parameter(6.3e-6);
-  sldSolv  = Parameter(1.0e-6);
-  background = Parameter(0.0);
-  axis_theta = Parameter(0.0, true);
-  axis_phi   = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double HollowCylinderModel :: operator()(double q) {
-  double dp[7];
-
-  dp[0] = scale();
-  dp[1] = core_radius();
-  dp[2] = radius();
-  dp[3] = length();
-  dp[4] = sldCyl();
-  dp[5] = sldSolv();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the core radius
-  vector<WeightPoint> weights_core_radius;
-  core_radius.get_weights(weights_core_radius);
-
-  // Get the dispersion points for the shell radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over core radius weight points
-  for(int i=0; i< (int)weights_core_radius.size(); i++) {
-    dp[1] = weights_core_radius[i].value;
-
-    // Loop over length weight points
-    for(int j=0; j< (int)weights_length.size(); j++) {
-      dp[3] = weights_length[j].value;
-
-      // Loop over shell radius weight points
-      for(int k=0; k< (int)weights_radius.size(); k++) {
-        dp[2] = weights_radius[k].value;
-        //Un-normalize  by volume
-        sum += weights_core_radius[i].weight
-            * weights_length[j].weight
-            * weights_radius[k].weight
-            * HollowCylinder(dp, q)
-        * (pow(weights_radius[k].value,2)-pow(weights_core_radius[i].value,2))
-        * weights_length[j].value;
-        //Find average volume
-        vol += weights_core_radius[i].weight
-            * weights_length[j].weight
-            * weights_radius[k].weight
-            * (pow(weights_radius[k].value,2)-pow(weights_core_radius[i].value,2))
-            * weights_length[j].value;
-
-        norm += weights_core_radius[i].weight
-            * weights_length[j].weight
-            * weights_radius[k].weight;
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double HollowCylinderModel :: operator()(double qx, double qy) {
-  HollowCylinderParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.core_radius     = core_radius();
-  dp.radius  = radius();
-  dp.length     = length();
-  dp.sldCyl   = sldCyl();
-  dp.sldSolv  = sldSolv();
-  dp.background = 0.0;
-  dp.axis_theta = axis_theta();
-  dp.axis_phi   = axis_phi();
-
-  // Get the dispersion points for the core radius
-  vector<WeightPoint> weights_core_radius;
-  core_radius.get_weights(weights_core_radius);
-
-  // Get the dispersion points for the shell radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over core radius weight points
-  for(int i=0; i<(int)weights_core_radius.size(); i++) {
-    dp.core_radius = weights_core_radius[i].value;
-
-
-    // Loop over length weight points
-    for(int j=0; j<(int)weights_length.size(); j++) {
-      dp.length = weights_length[j].value;
-
-      // Loop over shell radius weight points
-      for(int m=0; m< (int)weights_radius.size(); m++) {
-        dp.radius = weights_radius[m].value;
-
-        // Average over theta distribution
-        for(int k=0; k< (int)weights_theta.size(); k++) {
-          dp.axis_theta = weights_theta[k].value;
-
-          // Average over phi distribution
-          for(int l=0; l< (int)weights_phi.size(); l++) {
-            dp.axis_phi = weights_phi[l].value;
-            //Un-normalize by volume
-            double _ptvalue = weights_core_radius[i].weight
-                * weights_length[j].weight
-                * weights_radius[m].weight
-                * weights_theta[k].weight
-                * weights_phi[l].weight
-                * hollow_cylinder_analytical_2DXY(&dp, qx, qy)
-            / ((pow(weights_radius[m].value,2)-pow(weights_core_radius[i].value,2))
-                * weights_length[j].value);
-            if (weights_theta.size()>1) {
-              _ptvalue *= fabs(cos(weights_theta[k].value * pi/180.0));
-            }
-            sum += _ptvalue;
-            //Find average volume
-            vol += weights_core_radius[i].weight
-                * weights_length[j].weight
-                * weights_radius[m].weight
-                * (pow(weights_radius[m].value,2)-pow(weights_core_radius[i].value,2))
-                * weights_length[j].value;
-            //Find norm for volume
-            norm_vol += weights_core_radius[i].weight
-                * weights_length[j].weight
-                * weights_radius[m].weight;
-
-            norm += weights_core_radius[i].weight
-                * weights_length[j].weight
-                * weights_radius[m].weight
-                * weights_theta[k].weight
-                * weights_phi[l].weight;
-
-          }
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm/asin(1.0);
-  if (vol != 0.0 || norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum*(vol/norm_vol);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the  cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double HollowCylinderModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double HollowCylinderModel :: calculate_ER() {
-  HollowCylinderParameters dp;
-
-  dp.radius  = radius();
-  dp.length     = length();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_length.size(); i++) {
-    dp.length = weights_length[i].value;
-    for(int k=0; k< (int)weights_radius.size(); k++) {
-      dp.radius = weights_radius[k].value;
-      //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-      sum +=weights_length[i].weight
-          * weights_radius[k].weight*DiamCyl(dp.length,dp.radius)/2.0;
-      norm += weights_length[i].weight* weights_radius[k].weight;
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-    rad_out = DiamCyl(dp.length,dp.radius)/2.0;}
-
-  return rad_out;
-}
-/**
- * Function to calculate volf_ratio for shell
- * @return: volf_ratio value
- */
-double HollowCylinderModel :: calculate_VR() {
-  HollowCylinderParameters dp;
-  dp.core_radius = core_radius();
-  dp.radius  = radius();
-  dp.length  = length();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum_tot = 0.0;
-  double sum_shell = 0.0;
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_length;
-  length.get_weights(weights_length);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for the core radius
-  vector<WeightPoint> weights_core_radius;
-  core_radius.get_weights(weights_core_radius);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_length.size(); i++) {
-    dp.length = weights_length[i].value;
-    for(int k=0; k< (int)weights_radius.size(); k++) {
-      dp.radius = weights_radius[k].value;
-      for(int j=0; j<(int)weights_core_radius.size(); j++) {
-    	  dp.core_radius = weights_core_radius[j].value;
-		  sum_tot +=weights_length[i].weight* weights_core_radius[j].weight
-			  * weights_radius[k].weight*pow(dp.radius, 2);
-		  sum_shell += weights_length[i].weight* weights_core_radius[j].weight
-			  * weights_radius[k].weight*(pow(dp.radius, 2)-pow(dp.core_radius, 2));
-      }
-    }
-  }
-    if (sum_tot == 0.0){
-      //return the default value
-      rad_out =  1.0;}
-    else{
-      //return ratio value
-      return sum_shell/sum_tot;
-    }
-}
Index: c/sans/models/src/c_models/lamellar.cpp
===================================================================
--- src/sans/models/src/c_models/lamellar.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,134 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "lamellar.h"
-
-/*  LamellarFFX  :  calculates the form factor of a lamellar structure - no S(q) effects included
-            -NO polydispersion included
-*/
-static double lamellar_kernel(double dp[], double q){
-  double scale,del,sld_bi,sld_sol,contr,bkg;    //local variables of coefficient wave
-  double inten, qval,Pq;
-  double Pi;
-
-
-  Pi = 4.0*atan(1.0);
-  scale = dp[0];
-  del = dp[1];
-  sld_bi = dp[2];
-  sld_sol = dp[3];
-  bkg = dp[4];
-  qval = q;
-  contr = sld_bi -sld_sol;
-
-  Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del));
-
-  inten = 2.0*Pi*scale*Pq/(qval*qval);    //this is now dimensionless...
-
-  inten /= del;     //normalize by the thickness (in A)
-
-  inten *= 1.0e8;   // 1/A to 1/cm
-
-  return(inten+bkg);
-}
-
-LamellarModel :: LamellarModel() {
-	scale      = Parameter(1.0);
-	bi_thick     = Parameter(50.0, true);
-	bi_thick.set_min(0.0);
-	sld_bi    = Parameter(1.0e-6);
-	sld_sol    = Parameter(6.3e-6);
-	background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double LamellarModel :: operator()(double q) {
-	double dp[5];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = bi_thick();
-	dp[2] = sld_bi();
-	dp[3] = sld_sol();
-	dp[4] = 0.0;
-
-	// Get the dispersion points for the bi_thick
-	vector<WeightPoint> weights_bi_thick;
-	bi_thick.get_weights(weights_bi_thick);
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over short_edgeA weight points
-	for(int i=0; i< (int)weights_bi_thick.size(); i++) {
-		dp[1] = weights_bi_thick[i].value;
-
-		sum += weights_bi_thick[i].weight * lamellar_kernel(dp, q);
-		norm += weights_bi_thick[i].weight;
-
-	}
-
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-
-double LamellarModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the lamellar
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LamellarModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double LamellarModel :: calculate_ER() {
-//NOT implemented yet!!!
-	return 0.0;
-}
-double LamellarModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/lamellarFF_HG.cpp
===================================================================
--- src/sans/models/src/c_models/lamellarFF_HG.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "lamellarFF_HG.h"
-
-extern "C" {
-#include "libCylinder.h"
-}
-
-LamellarFFHGModel :: LamellarFFHGModel() {
-  scale      = Parameter(1.0);
-  t_length     = Parameter(15.0, true);
-  t_length.set_min(0.0);
-  h_thickness    = Parameter(10.0, true);
-  h_thickness.set_min(0.0);
-  sld_tail   = Parameter(4e-7);
-  sld_head  = Parameter(3e-6);
-  sld_solvent    = Parameter(6e-6);
-  background = Parameter(0.0);
-
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double LamellarFFHGModel :: operator()(double q) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = t_length();
-  dp[2] = h_thickness();
-  dp[3] = sld_tail();
-  dp[4] = sld_head();
-  dp[5] = sld_solvent();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the tail length
-  vector<WeightPoint> weights_t_length;
-  t_length.get_weights(weights_t_length);
-
-  // Get the dispersion points for the head thickness
-  vector<WeightPoint> weights_h_thickness;
-  h_thickness.get_weights(weights_h_thickness);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over semi axis A weight points
-  for(int i=0; i< (int)weights_t_length.size(); i++) {
-    dp[1] = weights_t_length[i].value;
-
-    for (int j=0; j< (int)weights_h_thickness.size(); j++){
-      dp[2] = weights_h_thickness[j].value;
-
-      sum += weights_t_length[i].weight* weights_h_thickness[j].weight*LamellarFF_HG(dp, q);
-      norm += weights_t_length[i].weight* weights_h_thickness[j].weight;
-    }
-
-  }
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-
-double LamellarFFHGModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the lamellar
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LamellarFFHGModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double LamellarFFHGModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double LamellarFFHGModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/lamellarPC.cpp
===================================================================
--- src/sans/models/src/c_models/lamellarPC.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "lamellarPC.h"
-
-extern "C" {
-#include "libCylinder.h"
-}
-
-LamellarPCrystalModel :: LamellarPCrystalModel() {
-  scale      = Parameter(1.0);
-  thickness     = Parameter(33.0, true);
-  thickness.set_min(0.0);
-  Nlayers    = Parameter(20.0, true);
-  Nlayers.set_min(0.0);
-  spacing   = Parameter(250);
-  pd_spacing   = Parameter(0.0);
-  sld_layer  = Parameter(1.0e-6);
-  sld_solvent    = Parameter(6.34e-6);
-  background = Parameter(0.0);
-
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double LamellarPCrystalModel :: operator()(double q) {
-  double dp[8];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = thickness();
-  dp[2] = Nlayers();
-  dp[3] = spacing();
-  dp[4] = pd_spacing();
-  dp[5] = sld_layer();
-  dp[6] = sld_solvent();
-  dp[7] = 0.0; // Do not apply background here.
-
-  // Get the dispersion points for the head thickness
-  vector<WeightPoint> weights_thickness;
-  thickness.get_weights(weights_thickness);
-
-  // Let's provide from the func which is more accurate especially for small q region.
-  // Get the dispersion points for the tail length
-  //vector<WeightPoint> weights_spacing;
-  //spacing.get_weights(weights_spacing);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over thickness and spacing weight points
-  for(int i=0; i< (int)weights_thickness.size(); i++) {
-    dp[1] = weights_thickness[i].value;
-    //for (int j=0; j< (int)weights_spacing.size(); j++){
-    //dp[3] = weights_spacing[j].value;
-    sum += weights_thickness[i].weight*Lamellar_ParaCrystal(dp, q);
-    norm += weights_thickness[i].weight;
-    //}
-  }
-  //apply norm and background
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-
-double LamellarPCrystalModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the lamellar
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LamellarPCrystalModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double LamellarPCrystalModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double LamellarPCrystalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/lamellarPS.cpp
===================================================================
--- src/sans/models/src/c_models/lamellarPS.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,186 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: refactor so that we pull in the old sansmodels.c_extensions
- *	TODO: add 2D function
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "lamellarPS.h"
-
-extern "C" {
-#include "libCylinder.h"
-}
-
-/*LamellarPS_kernel() was moved from libigor to get rid of polydipersity in del(thickness) that we provide from control panel.
-  LamellarPSX  :  calculates the form factor of a lamellar structure - with S(q) effects included
--------
-------- resolution effects ARE NOT included, but only a CONSTANT default value, not the real q-dependent resolution!!
-
- */
-static double LamellarPS_kernel(double dp[], double q)
-{
-  double scale,dd,del,sld_bi,sld_sol,contr,NN,Cp,bkg;   //local variables of coefficient wave
-  double inten, qval,Pq,Sq,alpha,temp,t1,t2,t3,dQ;
-  double Pi,Euler,dQDefault,fii;
-  int ii,NNint;
-  Euler = 0.5772156649;   // Euler's constant
-  dQDefault = 0.0;    //[=] 1/A, q-resolution, default value
-  dQ = dQDefault;
-
-  Pi = 4.0*atan(1.0);
-  qval = q;
-
-  scale = dp[0];
-  dd = dp[1];
-  del = dp[2];
-  sld_bi = dp[3];
-  sld_sol = dp[4];
-  NN = trunc(dp[5]);    //be sure that NN is an integer
-  Cp = dp[6];
-  bkg = dp[7];
-
-  contr = sld_bi - sld_sol;
-
-  Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del));
-
-  NNint = (int)NN;    //cast to an integer for the loop
-  ii=0;
-  Sq = 0.0;
-  for(ii=1;ii<(NNint-1);ii+=1) {
-
-    fii = (double)ii;   //do I really need to do this?
-
-    temp = 0.0;
-    alpha = Cp/4.0/Pi/Pi*(log(Pi*ii) + Euler);
-    t1 = 2.0*dQ*dQ*dd*dd*alpha;
-    t2 = 2.0*qval*qval*dd*dd*alpha;
-    t3 = dQ*dQ*dd*dd*ii*ii;
-
-    temp = 1.0-ii/NN;
-    temp *= cos(dd*qval*ii/(1.0+t1));
-    temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
-    temp /= sqrt(1.0+t1);
-
-    Sq += temp;
-  }
-
-  Sq *= 2.0;
-  Sq += 1.0;
-
-  inten = 2.0*Pi*scale*Pq*Sq/(dd*qval*qval);
-
-  inten *= 1.0e8;   // 1/A to 1/cm
-
-  return(inten+bkg);
-}
-
-LamellarPSModel :: LamellarPSModel() {
-  scale      = Parameter(1.0);
-  spacing    = Parameter(400.0, true);
-  spacing.set_min(0.0);
-  delta     = Parameter(30.0);
-  delta.set_min(0.0);
-  sld_bi   = Parameter(6.3e-6);
-  sld_sol   = Parameter(1.0e-6);
-  n_plates     = Parameter(20.0);
-  caille = Parameter(0.1);
-  background = Parameter(0.0);
-
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double LamellarPSModel :: operator()(double q) {
-  double dp[8];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = spacing();
-  dp[2] = delta();
-  dp[3] = sld_bi();
-  dp[4] = sld_sol();
-  dp[5] = n_plates();
-  dp[6] = caille();
-  dp[7] = 0.0;
-
-
-  // Get the dispersion points for spacing and delta (thickness)
-  vector<WeightPoint> weights_spacing;
-  spacing.get_weights(weights_spacing);
-  vector<WeightPoint> weights_delta;
-  delta.get_weights(weights_delta);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Loop over short_edgeA weight points
-  for(int i=0; i< (int)weights_spacing.size(); i++) {
-    dp[1] = weights_spacing[i].value;
-    for(int j=0; j< (int)weights_spacing.size(); j++) {
-      dp[2] = weights_delta[i].value;
-
-      sum += weights_spacing[i].weight * weights_delta[j].weight * LamellarPS_kernel(dp, q);
-      norm += weights_spacing[i].weight * weights_delta[j].weight;
-    }
-  }
-  return sum/norm + background();
-}
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double LamellarPSModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LamellarPSModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double LamellarPSModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double LamellarPSModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/lamellarPS_HG.cpp
===================================================================
--- src/sans/models/src/c_models/lamellarPS_HG.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,139 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: add 2D function
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "lamellarPS_HG.h"
-
-extern "C" {
-	#include "libCylinder.h"
-}
-
-LamellarPSHGModel :: LamellarPSHGModel() {
-	scale      = Parameter(1.0);
-	spacing    = Parameter(40.0, true);
-	spacing.set_min(0.0);
-	deltaT     = Parameter(10.0, true);
-	deltaT.set_min(0.0);
-	deltaH     = Parameter(2.0, true);
-	deltaH.set_min(0.0);
-	sld_tail    = Parameter(4e-7);
-	sld_head    = Parameter(2e-6);
-	sld_solvent   = Parameter(6e-6);
-	n_plates     = Parameter(30);
-	caille = Parameter(0.001);
-	background = Parameter(0.001);
-
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double LamellarPSHGModel :: operator()(double q) {
-	double dp[10];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = spacing();
-	dp[2] = deltaT();
-	dp[3] = deltaH();
-	dp[4] = sld_tail();
-	dp[5] = sld_head();
-	dp[6] = sld_solvent();
-	dp[7] = n_plates();
-	dp[8] = caille();
-	dp[9] = 0.0;
-
-
-	// Get the dispersion points for (deltaT) thickness of the tail
-	vector<WeightPoint> weights_deltaT;
-	deltaT.get_weights(weights_deltaT);
-
-	// Get the dispersion points for (deltaH) thickness of the head
-	vector<WeightPoint> weights_deltaH;
-	deltaH.get_weights(weights_deltaH);
-
-	// Get the dispersion points for spacing
-	vector<WeightPoint> weights_spacing;
-	spacing.get_weights(weights_spacing);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Loop over deltaT  weight points
-	for(int i=0; i< (int)weights_deltaT.size(); i++) {
-		dp[2] = weights_deltaT[i].value;
-
-		// Loop over deltaH weight points
-		for(int j=0; j< (int)weights_deltaH.size(); j++) {
-			dp[3] = weights_deltaH[j].value;
-			// Loop over spacing weight points
-			for(int k=0; k< (int)weights_spacing.size(); k++) {
-				dp[1] = weights_spacing[k].value;
-
-				sum += weights_deltaT[i].weight * weights_deltaH[j].weight *weights_spacing[k].weight
-								*LamellarPS_HG(dp, q);
-				norm += weights_deltaT[i].weight * weights_deltaH[j].weight * weights_spacing[k].weight;
-			}
-		}
-	}
-	return sum/norm + background();
-}
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double LamellarPSHGModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the lamellarPS_HG
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LamellarPSHGModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double LamellarPSHGModel :: calculate_ER() {
-//NOT implemented yet!!!
-	return 0.0;
-}
-double LamellarPSHGModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/libfunc.c
===================================================================
--- src/sans/models/src/c_models/libfunc.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,332 +1,0 @@
-// by jcho
-
-#include <math.h>
-
-#include "libmultifunc/libfunc.h"
-
-#include <stdio.h>
-
-
-
-//used in Si func
-
-int factorial(int i) {
-
-	int k, j;
-	if (i<2){
-		return 1;
-	}
-
-	k=1;
-
-	for(j=1;j<i;j++) {
-		k=k*(j+1);
-	}
-
-	return k;
-
-}
-
-
-
-// Used in pearl nec model
-
-// Sine integral function: approximated within 1%!!!
-
-// integral of sin(x)/x up to namx term nmax=6 looks the best.
-
-double Si(double x)
-
-{
-	int i;
-	int nmax=6;
-	double out;
-	long double power;
-	double pi = 4.0*atan(1.0);
-
-	if (x >= pi*6.2/4.0){
-		double out_sin = 0.0;
-		double out_cos = 0.0;
-		out = pi/2.0;
-
-		for (i=0; i<nmax-2; i+=1) {
-			out_cos += pow(-1.0, i) * (double)factorial(2*i) / pow(x, 2*i+1);
-			out_sin += pow(-1.0, i) * (double)factorial(2*i+1) / pow(x, 2*i+2);
-		}
-
-		out -= cos(x) * out_cos;
-		out -= sin(x) * out_sin;
-		return out;
-	}
-
-	out = 0.0;
-
-	for (i=0; i<nmax; i+=1)	{
-		if (i==0) {
-			out += x;
-			continue;
-		}
-
-		power = pow(x,(2 * i + 1));
-		out += (double)pow(-1, i) * power / ((2.0 * (double)i + 1.0) * (double)factorial(2 * i + 1));
-
-		//printf ("Si=%g %g %d\n", x, out, i);
-	}
-
-	return out;
-}
-
-
-
-double sinc(double x)
-{
-  if (x==0.0){
-    return 1.0;
-  }
-  return sin(x)/x;
-}
-
-
-double gamln(double xx) {
-
-    double x,y,tmp,ser;
-    static double cof[6]={76.18009172947146,-86.50532032941677,
-    24.01409824083091,-1.231739572450155,
-    0.1208650973866179e-2,-0.5395239384953e-5};
-    int j;
-
-    y=x=xx;
-    tmp=x+5.5;
-    tmp -= (x+0.5)*log(tmp);
-    ser=1.000000000190015;
-    for (j=0;j<=5;j++) ser += cof[j]/++y;
-    return -tmp+log(2.5066282746310005*ser/x);
-}
-
-// calculate magnetic sld and return total sld
-// bn : contrast (not just sld of the layer)
-// m0: max mag of M; mtheta: angle from x-z plane;
-// mphi: angle (anti-clock-wise)of x-z projection(M) from x axis
-// spinfraci: the fraction of UP among UP+Down (before sample)
-// spinfracf: the fraction of UP among UP+Down (after sample and before detector)
-// spintheta: angle (anti-clock-wise) between neutron spin(up) and x axis
-// Note: all angles are in degrees.
-polar_sld cal_msld(int isangle, double qx, double qy, double bn,
-				double m01, double mtheta1, double mphi1,
-				double spinfraci, double spinfracf, double spintheta)
-{
-	//locals
-	double q_x = qx;
-	double q_y = qy;
-	double sld = bn;
-	int is_angle = isangle;
-	double pi = 4.0*atan(1.0);
-	double s_theta = spintheta * pi/180.0;
-	double m_max = m01;
-	double m_phi = mphi1;
-	double m_theta = mtheta1;
-	double in_spin = spinfraci;
-	double out_spin = spinfracf;
-
-	double m_perp = 0.0;
-	double m_perp_z = 0.0;
-	double m_perp_y = 0.0;
-	double m_perp_x = 0.0;
-	double m_sigma_x = 0.0;
-	double m_sigma_z = 0.0;
-	double m_sigma_y = 0.0;
-	//double b_m = 0.0;
-	double q_angle = 0.0;
-	double mx = 0.0;
-	double my = 0.0;
-	double mz = 0.0;
-	polar_sld p_sld;
-	p_sld.uu = sld;
-	p_sld.dd = sld;
-	p_sld.re_ud = 0.0;
-	p_sld.im_ud = 0.0;
-	p_sld.re_du = 0.0;
-	p_sld.im_du = 0.0;
-
-	//No mag means no further calculation
-	if (isangle>0){
-		if (m_max < 1.0e-32){
-			p_sld.uu = sqrt(sqrt(in_spin * out_spin)) * p_sld.uu;
-			p_sld.dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * p_sld.dd;
-			return p_sld;
-		}
-	}
-	else{
-		if (fabs(m_max)< 1.0e-32 && fabs(m_phi)< 1.0e-32 && fabs(m_theta)< 1.0e-32){
-			p_sld.uu = sqrt(sqrt(in_spin * out_spin)) * p_sld.uu;
-			p_sld.dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * p_sld.dd;
-			return p_sld;
-		}
-	}
-
-	//These are needed because of the precision of inputs
-	if (in_spin < 0.0) in_spin = 0.0;
-	if (in_spin > 1.0) in_spin = 1.0;
-	if (out_spin < 0.0) out_spin = 0.0;
-	if (out_spin > 1.0) out_spin = 1.0;
-
-	if (q_x == 0.0) q_angle = pi / 2.0;
-	else q_angle = atan(q_y/q_x);
-	if (q_y < 0.0 && q_x < 0.0) q_angle -= pi;
-	else if (q_y > 0.0 && q_x < 0.0) q_angle += pi;
-
-	q_angle = pi/2.0 - q_angle;
-	if (q_angle > pi) q_angle -= 2.0 * pi;
-	else if (q_angle < -pi) q_angle += 2.0 * pi;
-
-	if (fabs(q_x) < 1.0e-16 && fabs(q_y) < 1.0e-16){
-		m_perp = 0.0;
-		}
-	else {
-		m_perp = m_max;
-		}
-	if (is_angle > 0){
-		m_phi *= pi/180.0;
-		m_theta *= pi/180.0;
-		mx = m_perp * cos(m_theta) * cos(m_phi);
-		my = m_perp * sin(m_theta);
-		mz = -(m_perp * cos(m_theta) * sin(m_phi));
-	}
-	else{
-		mx = m_perp;
-		my = m_phi;
-		mz = m_theta;
-	}
-	//ToDo: simplify these steps
-	// m_perp1 -m_perp2
-	m_perp_x = (mx) *  cos(q_angle);
-	m_perp_x -= (my) * sin(q_angle);
-	m_perp_y = m_perp_x;
-	m_perp_x *= cos(-q_angle);
-	m_perp_y *= sin(-q_angle);
-	m_perp_z = mz;
-
-	m_sigma_x = (m_perp_x * cos(-s_theta) - m_perp_y * sin(-s_theta));
-	m_sigma_y = (m_perp_x * sin(-s_theta) + m_perp_y * cos(-s_theta));
-	m_sigma_z = (m_perp_z);
-
-	//Find b
-	p_sld.uu -= m_sigma_x;
-	p_sld.dd += m_sigma_x;
-	p_sld.re_ud = m_sigma_y;
-	p_sld.re_du = m_sigma_y;
-	p_sld.im_ud = m_sigma_z;
-	p_sld.im_du = -m_sigma_z;
-
-	p_sld.uu = sqrt(sqrt(in_spin * out_spin)) * p_sld.uu;
-	p_sld.dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * p_sld.dd;
-
-	p_sld.re_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * p_sld.re_ud;
-	p_sld.im_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * p_sld.im_ud;
-	p_sld.re_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * p_sld.re_du;
-	p_sld.im_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * p_sld.im_du;
-
-	return p_sld;
-}
-
-
-/** Modifications below by kieranrcampbell@gmail.com
-    Institut Laue-Langevin, July 2012
-**/
-
-/**
-   Implements eq 6.2.5 (small gamma) of Numerical Recipes in C, essentially
-   the incomplete gamma function multiplied by the gamma function.
-   Required for implementation of fast error function (erf)
-**/
-
-
-#define ITMAX 100
-#define EPS 3.0e-7
-#define FPMIN 1.0e-30
-
-void gser(float *gamser, float a, float x, float *gln) {
-  int n;
-  float sum,del,ap;
-
-  *gln = gamln(a);
-  if(x <= 0.0) {
-    if (x < 0.0) printf("Error: x less than 0 in routine gser");
-    *gamser = 0.0;
-    return;
-  } else {
-    ap = a;
-    del = sum = 1.0/a;
-
-    for(n=1;n<=ITMAX;n++) {
-      ++ap;
-      del *= x/ap;
-      sum += del;
-      if(fabs(del) < fabs(sum)*EPS) {
-	*gamser = sum * exp(-x + a * log(x) - (*gln));
-	return;
-      }
-    }
-    printf("a too large, ITMAX too small in routine gser");
-    return;
-
-  }
-
-
-}
-
-/**
-   Implements the incomplete gamma function Q(a,x) evaluated by its continued fraction
-   representation
-**/
-
-void gcf(float *gammcf, float a, float x, float *gln) {
-  int i;
-  float an,b,c,d,del,h;
-
-  *gln = gamln(a);
-  b = x+1.0-a;
-  c = 1.0/FPMIN;
-  d = 1.0/b;
-  h=d;
-  for (i=1;i <= ITMAX; i++) {
-    an = -i*(i-a);
-    b += 2.0;
-    d = an*d + b;
-    if (fabs(d) < FPMIN) d = FPMIN;
-    c = b+an/c;
-    if (fabs(c) < FPMIN) c = FPMIN;
-    d = 1.0/d;
-    del = d*c;
-    h += del;
-    if (fabs(del-1.0) < EPS) break;
-  }
-  if (i > ITMAX) printf("a too large, ITMAX too small in gcf");
-  *gammcf = exp(-x+a*log(x)-(*gln))*h;
-  return;
-}
-
-
-/**
-   Represents incomplete error function, P(a,x)
-**/
-float gammp(float a, float x) {
-  float gamser,gammcf,gln;
-  if(x < 0.0 || a <= 0.0) printf("Invalid arguments in routine gammp");
-  if (x < (a+1.0)) {
-    gser(&gamser,a,x,&gln);
-    return gamser;
-  } else {
-    gcf(&gammcf,a,x,&gln);
-    return 1.0 - gammcf;
-  }
-}
-
-/**
-    Implementation of the error function, erf(x)
-**/
-
-float erff(float x) {
-  return x < 0.0 ? -gammp(0.5,x*x) : gammp(0.5,x*x);
-}
-
Index: c/sans/models/src/c_models/librefl.c
===================================================================
--- src/sans/models/src/c_models/librefl.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,331 +1,0 @@
-// The original code, of which work was not DANSE funded,
-// was provided by J. Cho.
-// And modified to fit sansmodels/sansview: JC
-
-#include <math.h>
-#include "libmultifunc/librefl.h"
-#include <stdio.h>
-#include <stdlib.h>
-#if defined(_MSC_VER)
-#include "winFuncs.h"
-#endif
-
-complex cassign(real, imag)
-	double real, imag;
-{
-	complex x;
-	x.re = real;
-	x.im = imag;
-	return x;
-}
-
-
-complex cplx_add(x,y)
-	complex x,y;
-{
-	complex z;
-	z.re = x.re + y.re;
-	z.im = x.im + y.im;
-	return z;
-}
-
-complex rcmult(x,y)
-	double x;
-    complex y;
-{
-	complex z;
-	z.re = x*y.re;
-	z.im = x*y.im;
-	return z;
-}
-
-complex cplx_sub(x,y)
-	complex x,y;
-{
-	complex z;
-	z.re = x.re - y.re;
-	z.im = x.im - y.im;
-	return z;
-}
-
-
-complex cplx_mult(x,y)
-	complex x,y;
-{
-	complex z;
-	z.re = x.re*y.re - x.im*y.im;
-	z.im = x.re*y.im + x.im*y.re;
-	return z;
-}
-
-complex cplx_div(x,y)
-	complex x,y;
-{
-	complex z;
-	z.re = (x.re*y.re + x.im*y.im)/(y.re*y.re + y.im*y.im);
-	z.im = (x.im*y.re - x.re*y.im)/(y.re*y.re + y.im*y.im);
-	return z;
-}
-
-complex cplx_exp(b)
-	complex b;
-{
-	complex z;
-	double br,bi;
-	br=b.re;
-	bi=b.im;
-	z.re = exp(br)*cos(bi);
-	z.im = exp(br)*sin(bi);
-	return z;
-}
-
-
-complex cplx_sqrt(z)    //see Schaum`s Math Handbook p. 22, 6.6 and 6.10
-	complex z;
-{
-	complex c;
-	double zr,zi,x,y,r,w;
-
-	zr=z.re;
-	zi=z.im;
-
-	if (zr==0.0 && zi==0.0)
-	{
-    c.re=0.0;
-	c.im=0.0;
-    return c;
-	}
-	else
-	{
-		x=fabs(zr);
-		y=fabs(zi);
-		if (x>y)
-		{
-			r=y/x;
-			w=sqrt(x)*sqrt(0.5*(1.0+sqrt(1.0+r*r)));
-		}
-		else
-		{
-			r=x/y;
-			w=sqrt(y)*sqrt(0.5*(r+sqrt(1.0+r*r)));
-		}
-		if (zr >=0.0)
-		{
-			c.re=w;
-			c.im=zi/(2.0*w);
-		}
-		else
-		{
-			c.im=(zi >= 0) ? w : -w;
-			c.re=zi/(2.0*c.im);
-		}
-		return c;
-	}
-}
-
-complex cplx_cos(b)
-	complex b;
-{
-	complex zero,two,z,i,bi,negbi;
-	zero = cassign(0.0,0.0);
-	two = cassign(2.0,0.0);
-	i = cassign(0.0,1.0);
-	bi = cplx_mult(b,i);
-	negbi = cplx_sub(zero,bi);
-	z = cplx_div(cplx_add(cplx_exp(bi),cplx_exp(negbi)),two);
-	return z;
-}
-
-// normalized and modified erf
-//   |
-// 1 +                __  - - - -
-//   |             _
-//	 |            _
-//   |        __
-// 0 + - - -
-//   |-------------+------------+--
-//   0           center       n_sub    --->
-//                                     ind
-//
-// n_sub = total no. of bins(or sublayers)
-// ind = x position: 0 to max
-// nu = max x to integration
-double err_mod_func(double n_sub, double ind, double nu)
-{
-  double center, func;
-  if (nu == 0.0)
-		nu = 1e-14;
-	if (n_sub == 0.0)
-		n_sub = 1.0;
-
-
-	//ind = (n_sub-1.0)/2.0-1.0 +ind;
-	center = n_sub/2.0;
-	// transform it so that min(ind) = 0
-	ind -= center;
-	// normalize by max limit
-	ind /= center;
-	// divide by sqrt(2) to get Gaussian func
-	nu /= sqrt(2.0);
-	ind *= nu;
-	// re-scale and normalize it so that max(erf)=1, min(erf)=0
-	func = erf(ind)/erf(nu)/2.0;
-	// shift it by +0.5 in y-direction so that min(erf) = 0
-	func += 0.5;
-
-	return func;
-}
-double linearfunc(double n_sub, double ind, double nu)
-{
-  double bin_size, func;
-	if (n_sub == 0.0)
-		n_sub = 1.0;
-
-	bin_size = 1.0/n_sub;  //size of each sub-layer
-	// rescale
-	ind *= bin_size;
-	func = ind;
-
-	return func;
-}
-// use the right hand side from the center of power func
-double power_r(double n_sub, double ind, double nu)
-{
-  double bin_size,func;
-	if (nu == 0.0)
-		nu = 1e-14;
-	if (n_sub == 0.0)
-		n_sub = 1.0;
-
-	bin_size = 1.0/n_sub;  //size of each sub-layer
-	// rescale
-	ind *= bin_size;
-	func = pow(ind, nu);
-
-	return func;
-}
-// use the left hand side from the center of power func
-double power_l(double n_sub, double ind, double nu)
-{
-  double bin_size, func;
-	if (nu == 0.0)
-		nu = 1e-14;
-	if (n_sub == 0.0)
-		n_sub = 1.0;
-
-	bin_size = 1.0/n_sub;  //size of each sub-layer
-	// rescale
-	ind *= bin_size;
-	func = 1.0-pow((1.0-ind),nu);
-
-	return func;
-}
-// use 1-exp func from x=0 to x=1
-double exp_r(double n_sub, double ind, double nu)
-{
-  double bin_size, func;
-	if (nu == 0.0)
-		nu = 1e-14;
-	if (n_sub == 0.0)
-		n_sub = 1.0;
-
-	bin_size = 1.0/n_sub;  //size of each sub-layer
-	// rescale
-	ind *= bin_size;
-	// modify func so that func(0) =0 and func(max)=1
-	func = 1.0-exp(-nu*ind);
-	// normalize by its max
-	func /= (1.0-exp(-nu));
-
-	return func;
-}
-
-// use the left hand side mirror image of exp func
-double exp_l(double n_sub, double ind, double nu)
-{
-  double bin_size, func;
-	if (nu == 0.0)
-		nu = 1e-14;
-	if (n_sub == 0.0)
-		n_sub = 1.0;
-
-	bin_size = 1.0/n_sub;  //size of each sub-layer
-	// rescale
-	ind *= bin_size;
-	// modify func
-	func = exp(-nu*(1.0-ind))-exp(-nu);
-	// normalize by its max
-	func /= (1.0-exp(-nu));
-
-	return func;
-}
-
-// To select function called
-// At nu = 0 (singular point), call line function
-double intersldfunc(int fun_type, double n_sub, double i, double nu, double sld_l, double sld_r)
-{
-	double sld_i, func;
-	// this condition protects an error from the singular point
-	if (nu == 0.0){
-		nu = 1e-13;
-	}
-	// select func
-	switch(fun_type){
-		case 1 :
-			func = power_r(n_sub, i, nu);
-			break;
-		case 2 :
-			func = power_l(n_sub, i, nu);
-			break;
-		case 3 :
-			func = exp_r(n_sub, i, nu);
-			break;
-		case 4 :
-			func = exp_l(n_sub, i, nu);
-			break;
-		case 5 :
-			func = linearfunc(n_sub, i, nu);
-			break;
-		default:
-			func = err_mod_func(n_sub, i, nu);
-			break;
-	}
-	// compute sld
-	if (sld_r>sld_l){
-		sld_i = (sld_r-sld_l)*func+sld_l; //sld_cal(sld[i],sld[i+1],n_sub,dz,thick);
-	}
-	else if (sld_r<sld_l){
-		func = 1.0-func;
-		sld_i = (sld_l-sld_r)*func+sld_r; //sld_cal(sld[i],sld[i+1],n_sub,dz,thick);
-	}
-	else{
-		sld_i = sld_r;
-	}
-	return sld_i;
-}
-
-
-// used by refl.c
-double interfunc(int fun_type, double n_sub, double i, double sld_l, double sld_r)
-{
-	double sld_i, func;
-	switch(fun_type){
-		case 0 :
-			func = err_mod_func(n_sub, i, 2.5);
-			break;
-		default:
-			func = linearfunc(n_sub, i, 1.0);
-			break;
-	}
-	if (sld_r>sld_l){
-		sld_i = (sld_r-sld_l)*func+sld_l; //sld_cal(sld[i],sld[i+1],n_sub,dz,thick);
-	}
-	else if (sld_r<sld_l){
-		func = 1.0-func;
-		sld_i = (sld_l-sld_r)*func+sld_r; //sld_cal(sld[i],sld[i+1],n_sub,dz,thick);
-	}
-	else{
-		sld_i = sld_r;
-	}
-	return sld_i;
-}
Index: c/sans/models/src/c_models/linearpearls.cpp
===================================================================
--- src/sans/models/src/c_models/linearpearls.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,219 +1,0 @@
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "linearpearls.h"
-
-extern "C" {
-#include "libmultifunc/libfunc.h"
-}
-
-static double linear_pearls_kernel(double dp[], double q) {
-  //fit parameters
-  double scale = dp[0];
-  double radius = dp[1];
-  double edge_separation = dp[2];
-  double num_pearls = dp[3];
-  double sld_pearl = dp[4];
-  double sld_solv = dp[5];
-  double background = dp[6];
-  //others
-  double psi = 0.0;
-  double n_contrib = 0.0;
-  double form_factor = 0.0;
-  //Pi
-  double pi = 4.0 * atan(1.0);
-  //relative sld
-  double contrast_pearl = sld_pearl - sld_solv;
-  //each volume
-  double pearl_vol = 4.0 /3.0 * pi * pow(radius, 3.0);
-  //total volume
-  double tot_vol = num_pearls * pearl_vol;
-  //mass
-  double m_s = contrast_pearl * pearl_vol;
-  //center to center distance between the neighboring pearls
-  double separation = edge_separation + 2.0 * radius;
-  //integer
-  int num = 0;
-  int n_max = 0;
-  // constraints
-  if (scale<=0 || radius<=0 || edge_separation<0 || num_pearls<=0){
-	  return 0.0;
-  }
-  //sine functions of a pearl
-  psi = sin(q * radius);
-  psi -= q * radius * cos(q * radius);
-  psi /= pow((q * radius), 3.0);
-
-  // N pearls contribution
-  n_max = num_pearls - 1;
-  for(num=0; num<=n_max; num++) {
-
-	  if (num == 0){
-		  n_contrib = num_pearls;
-		  continue;
-	  }
-	  n_contrib += (2.0*(num_pearls-double(num))*sinc(q*separation*double(num)));
-  }
-  // form factor for num_pearls
-  form_factor = n_contrib;
-  form_factor *= pow((m_s*psi*3.0), 2.0);
-  form_factor /= (tot_vol * 1.0e-8); // norm by volume and A^-1 to cm^-1
-
-  // scale and background
-  form_factor *= scale;
-  form_factor += background;
-  return (form_factor);
-}
-
-LinearPearlsModel :: LinearPearlsModel() {
-  scale = Parameter(1.0);
-  radius = Parameter(80.0, true);
-  radius.set_min(0.0);
-  edge_separation = Parameter(350.0, true);
-  edge_separation.set_min(0.0);
-  num_pearls = Parameter(3);
-  num_pearls.set_min(0.0);
-  sld_pearl = Parameter(1.0e-06);
-  sld_solv = Parameter(6.3e-06);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D LinearPearlsModel function
- * @param q: q-value
- * @return: function value
- */
-double LinearPearlsModel :: operator()(double q) {
-  double dp[7];
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = edge_separation();
-  dp[3] = num_pearls();
-  dp[4] = sld_pearl();
-  dp[5] = sld_solv();
-  dp[6] = 0.0;
-  double pi = 4.0*atan(1.0);
-  // No polydispersion supported in this model.
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-  vector<WeightPoint> weights_edge_separation;
-  edge_separation.get_weights(weights_edge_separation);
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-  double pearl_vol = 0.0;
-  double tot_vol = 0.0;
-  // Loop over core weight points
-  for(size_t i=0; i<weights_radius.size(); i++) {
-    dp[1] = weights_radius[i].value;
-    // Loop over thick_inter0 weight points
-    for(size_t j=0; j<weights_edge_separation.size(); j++) {
-      dp[2] = weights_edge_separation[j].value;
-      pearl_vol = 4.0 /3.0 * pi * pow(dp[1], 3);
-      tot_vol += dp[3] * pearl_vol;
-      //Un-normalize Sphere by volume
-      sum += weights_radius[i].weight * weights_edge_separation[j].weight
-          * linear_pearls_kernel(dp,q) * tot_vol;
-      //Find average volume
-      vol += weights_radius[i].weight * weights_edge_separation[j].weight
-          * tot_vol;
-      norm += weights_radius[i].weight * weights_edge_separation[j].weight;
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D LinearPearlsModel function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double LinearPearlsModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate LinearPearlsModel function
- * @param pars: parameters of the StringOfPearlsModel
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LinearPearlsModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate TOTAL radius
- * Todo: decide whether or not we keep this calculation
- * @return: effective radius value
- */
-// No polydispersion supported in this model.
-// Calculate max radius assumming max_radius = effective radius
-// Note that this max radius is not affected by sld of layer, sld of interface, or
-// sld of solvent.
-double LinearPearlsModel :: calculate_ER() {
-	LinearPearlsParameters dp;
-
-  dp.scale = scale();
-  dp.radius = radius();
-  dp.edge_separation = edge_separation();
-  dp.num_pearls = num_pearls();
-
-  double rad_out = 0.0;
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-  vector<WeightPoint> weights_edge_separation;
-  edge_separation.get_weights(weights_edge_separation);
-  // Perform the computation, with all weight points
-  double pearl_vol = 0.0;
-  double tot_vol = 0.0;
-  // Loop over core weight points
-  for(size_t i=0; i<weights_radius.size(); i++) {
-    dp.radius = weights_radius[i].value;
-    // Loop over thick_inter0 weight points
-    for(size_t j=0; j<weights_edge_separation.size(); j++) {
-      dp.edge_separation = weights_edge_separation[j].value;
-      pearl_vol = 4.0 /3.0 * pi * pow(dp.radius , 3);
-      tot_vol = dp.num_pearls * pearl_vol;
-      //Find  volume
-      // This may be a too much approximation
-      //Todo: decided whether or not we keep this calculation
-      sum += weights_radius[i].weight * weights_edge_separation[j].weight
-          * pow(3.0*tot_vol/4.0/pi,0.333333);
-      norm += weights_radius[i].weight * weights_edge_separation[j].weight;
-    }
-  }
-
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    pearl_vol = 4.0 /3.0 * pi * pow(dp.radius , 3);
-    tot_vol = dp.num_pearls * pearl_vol;
-
-    rad_out =  pow((3.0*tot_vol/4.0/pi), 0.33333);
-  }
-
-  return rad_out;
-
-}
-double LinearPearlsModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/logNormal.cpp
===================================================================
--- src/sans/models/src/c_models/logNormal.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,82 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "logNormal.h"
-
-LogNormal :: LogNormal() {
-  scale  = Parameter(1.0, true);
-  sigma  = Parameter(1.0, true);
-  center = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D Log normal function.
- * The function is normalized to the 'scale' parameter.
- *
- * f(x)=scale * 1/(sigma*math.sqrt(2pi))e^(-1/2*((math.log(x)-mu)/sigma)^2)
- *
- * @param q: q-value
- * @return: function value
- */
-double LogNormal :: operator()(double q) {
-  double sigma2 = pow(sigma(), 2);
-  return scale() / (q*sigma2) * exp( -pow((log(q) - center()), 2) / (2*sigma2));
-}
-
-/**
- * Function to evaluate 2D LogNormal  function
- * The function is normalized to the 'scale' parameter.
- *
- * f(x,y) = LogNormal(x) * LogNormal(y)
- *
- * where both LogNormals share the same parameters.
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double LogNormal :: operator()(double qx, double qy) {
-  return (*this).operator()(qx) * (*this).operator()(qy);
-}
-
-/**
- * Function to evaluate 2D LogNormal  function
- * The function is normalized to the 'scale' parameter.
- *
- * f(x,y) = LogNormal(x) * LogNormal(y)
- *
- * where both LogNormals share the same parameters.
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double LogNormal :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double LogNormal :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double LogNormal :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/lorentzian.cpp
===================================================================
--- src/sans/models/src/c_models/lorentzian.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "lorentzian.h"
-
-Lorentzian :: Lorentzian() {
-  scale  = Parameter(1.0, true);
-  gamma  = Parameter(1.0, true);
-  center = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double Lorentzian :: operator()(double q) {
-  double delta2 = pow( (q-center()), 2);
-  return scale() / acos(-1.0) * 0.5*gamma() /
-      (delta2 + 0.25*gamma()*gamma());
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double Lorentzian :: operator()(double qx, double qy) {
-  return (*this).operator()(qx) * (*this).operator()(qy);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double Lorentzian :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double Lorentzian :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double Lorentzian :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/massfractal.cpp
===================================================================
--- src/sans/models/src/c_models/massfractal.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "massfractal.h"
-extern "C" {
-#include "libmultifunc/libfunc.h"
-}
-
-static double mass_fractal_kernel(double dp[], double q) {
-  //fit parameters
-  double scale = dp[0];
-  double radius = dp[1];
-  double mass_dim = dp[2];
-  double co_length = dp[3];
-  double background = dp[4];
-  //others
-  double pq = 0.0;
-  double sq = 0.0;
-  double mmo = 0.0;
-  //result
-  double result = 0.0;
-  if( (q*radius) == 0.0){
-		pq = 1.0;
-  }
-  else{
-	//calculate P(q) for the spherical subunits; not normalized
-	pq = pow((3.0*(sin(q*radius) - q*radius*cos(q*radius))/pow((q*radius),3)),2);
-  }
-  mmo = mass_dim-1.0;
-  //calculate S(q)
-  sq = exp(gamln(mmo))*sin((mmo)*atan(q*co_length));
-  sq *= pow(co_length, mmo);
-  sq /= pow((1.0 + (q*co_length)*(q*co_length)),(mmo/2.0));
-
-
-  sq /= q;
-  //combine and return
-  result = pq * sq;
-  result *= scale;
-  result += background;
-
-  return(result);
-}
-
-MassFractalModel :: MassFractalModel() {
-  scale      = Parameter(1.0);
-  radius = Parameter(10.0);
-  mass_dim = Parameter(1.9);
-  co_length = Parameter(100.0);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double MassFractalModel :: operator()(double q) {
-  double dp[5];
-
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = mass_dim();
-  dp[3] = co_length();
-  dp[4] = 0.0;
-
-  // Perform the computation
-  double sum = 0.0;
-
-  sum = mass_fractal_kernel(dp, fabs(q));
-  return sum + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double MassFractalModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the FractalModel
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double MassFractalModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double MassFractalModel :: calculate_ER() {
-  //NOT implemented yet!!! 'cause None shape Model
-  return 0.0;
-}
-double MassFractalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/masssurfacefractal.cpp
===================================================================
--- src/sans/models/src/c_models/masssurfacefractal.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,160 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "masssurfacefractal.h"
-
-
-
-static double mass_surface_fractal_kernel(double dp[], double q) {
-  //fit parameters
-  double scale = dp[0];
-  double mass_dim = dp[1];
-  double surface_dim = dp[2];
-  double cluster_rg = dp[3];
-  double primary_rg = dp[4];
-  double background = dp[5];
-
-  //others
-  double tot_dim = 0.0;
-  double rc_norm = 0.0;
-  double rp_norm = 0.0;
-  double x_val1 = 0.0;
-  double x_val2 = 0.0;
-  double form_factor = 0.0;
-  double inv_form = 0.0;
-
-  // This model is valid only for 0<dm<=6 and 0<ds<=6
-  // Not valid values => reject as 0.0
-  if (mass_dim < 1e-16){
-	  return background;
-  }
-  if (mass_dim > 6.0){
-	  return background;
-  }
-  if (surface_dim < 1e-16){
-	  return background;
-  }
-  if (surface_dim > 6.0){
-	  return background;
-  }
-  tot_dim = 6.0 - surface_dim - mass_dim;
-  //singulars
-  if (tot_dim < 0.0){
-	  return background;
-  }
-
-  //computation
-  mass_dim /= 2.0;
-  tot_dim /= 2.0;
-  rc_norm = cluster_rg * cluster_rg / (3.0 * mass_dim);
-  if (tot_dim < 1.0e-16){
-	  tot_dim = 1.0e-16;
-  }
-  rp_norm = primary_rg * primary_rg / (3.0 * tot_dim);
-
-  //x for P
-  x_val1 = 1.0 +  q * q * rc_norm;
-  x_val2 = 1.0 +  q * q * rp_norm;
-
-  inv_form = pow(x_val1, mass_dim) * pow(x_val2, tot_dim);
-
-  //another singular
-  if (inv_form == 0.0) return background;
-
-  form_factor = 1.0;
-  form_factor /= inv_form;
-
-  //scale and background
-  form_factor *= scale;
-  form_factor += background;
-  return (form_factor);
-}
-
-MassSurfaceFractal :: MassSurfaceFractal() {
-  scale      = Parameter(1.0);
-  mass_dim = Parameter(1.8);
-  surface_dim = Parameter(2.3);
-  cluster_rg = Parameter(86.7);
-  primary_rg = Parameter(4000.0);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double MassSurfaceFractal :: operator()(double q) {
-  double dp[6];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = mass_dim();
-  dp[2] = surface_dim();
-  dp[3] = cluster_rg();
-  dp[4] = primary_rg();
-  dp[5] = 0.0;
-
-  //computation: no polydispersion
-  double sum = 0.0;
-  sum = mass_surface_fractal_kernel(dp, q);
-
-  return sum + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double MassSurfaceFractal :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the FractalModel
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double MassSurfaceFractal :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double MassSurfaceFractal :: calculate_ER() {
-  //NOT implemented yet!!! 'cause None shape Model
-  return 0.0;
-}
-double MassSurfaceFractal :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/multishell.cpp
===================================================================
--- src/sans/models/src/c_models/multishell.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,199 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "multishell.h"
-
-extern "C" {
-#include "libSphere.h"
-}
-
-typedef struct {
-  double scale;
-  double core_radius;
-  double s_thickness;
-  double w_thickness;
-  double core_sld;
-  double shell_sld;
-  double n_pairs;
-  double background;
-
-} MultiShellParameters;
-
-MultiShellModel :: MultiShellModel() {
-  scale      = Parameter(1.0);
-  core_radius     = Parameter(60.0, true);
-  core_radius.set_min(0.0);
-  s_thickness  = Parameter(10.0, true);
-  s_thickness.set_min(0.0);
-  w_thickness   = Parameter(10.0, true);
-  w_thickness.set_min(0.0);
-  core_sld   = Parameter(6.4e-6);
-  shell_sld   = Parameter(4.0e-7);
-  n_pairs   = Parameter(2);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double MultiShellModel :: operator()(double q) {
-  double dp[8];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = core_radius();
-  dp[2] = s_thickness();
-  dp[3] = w_thickness();
-  dp[4] = core_sld();
-  dp[5] = shell_sld();
-  dp[6] = n_pairs();
-  dp[7] = 0.0;
-
-  // Get the dispersion points for the core radius
-  vector<WeightPoint> weights_core_radius;
-  core_radius.get_weights(weights_core_radius);
-
-  // Get the dispersion points for the s_thickness
-  vector<WeightPoint> weights_s_thickness;
-  s_thickness.get_weights(weights_s_thickness);
-
-  // Get the dispersion points for the w_thickness
-  vector<WeightPoint> weights_w_thickness;
-  w_thickness.get_weights(weights_w_thickness);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(int i=0; i< (int)weights_core_radius.size(); i++) {
-    dp[1] = weights_core_radius[i].value;
-    for(int j=0; j< (int)weights_s_thickness.size(); j++){
-      dp[2] = weights_s_thickness[j].value;
-      for(int k=0; k< (int)weights_w_thickness.size(); k++){
-        dp[3] = weights_w_thickness[k].value;
-        //Un-normalize SphereForm by volume
-        sum += weights_core_radius[i].weight*weights_s_thickness[j].weight
-            *weights_w_thickness[k].weight* MultiShell(dp, q)
-        *pow(weights_core_radius[i].value+dp[6]*weights_s_thickness[j].value+(dp[6]-1)*weights_w_thickness[k].value,3);
-        //Find average volume
-        vol += weights_core_radius[i].weight*weights_s_thickness[j].weight
-            *weights_w_thickness[k].weight
-            *pow(weights_core_radius[i].value+dp[6]*weights_s_thickness[j].value+(dp[6]-1)*weights_w_thickness[k].value,3);
-        norm += weights_core_radius[i].weight*weights_s_thickness[j].weight
-            *weights_w_thickness[k].weight;
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double MultiShellModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the multishell
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double MultiShellModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double MultiShellModel :: calculate_ER() {
-  MultiShellParameters dp;
-
-  dp.core_radius     = core_radius();
-  dp.s_thickness  = s_thickness();
-  dp.w_thickness  = w_thickness();
-  dp.n_pairs = n_pairs();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  if (dp.n_pairs <= 0.0 ){
-    dp.n_pairs = 0.0;
-  }
-
-  // Get the dispersion points for the core radius
-  vector<WeightPoint> weights_core_radius;
-  core_radius.get_weights(weights_core_radius);
-
-  // Get the dispersion points for the s_thickness
-  vector<WeightPoint> weights_s_thickness;
-  s_thickness.get_weights(weights_s_thickness);
-
-  // Get the dispersion points for the w_thickness
-  vector<WeightPoint> weights_w_thickness;
-  w_thickness.get_weights(weights_w_thickness);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_s_thickness.size(); i++) {
-    dp.s_thickness = weights_s_thickness[i].value;
-    for(int j=0; j< (int)weights_w_thickness.size(); j++) {
-      dp.w_thickness = weights_w_thickness[j].value;
-      for(int k=0; k< (int)weights_core_radius.size(); k++) {
-        dp.core_radius = weights_core_radius[k].value;
-        sum += weights_s_thickness[i].weight*weights_w_thickness[j].weight
-            * weights_core_radius[k].weight*(dp.core_radius+dp.n_pairs*dp.s_thickness+(dp.n_pairs-1.0)*dp.w_thickness);
-        norm += weights_s_thickness[i].weight*weights_w_thickness[j].weight* weights_core_radius[k].weight;
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    rad_out = (dp.core_radius+dp.n_pairs*dp.s_thickness+(dp.n_pairs-1.0)*dp.w_thickness);}
-
-  return rad_out;
-}
-double MultiShellModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/onion.cpp
===================================================================
--- src/sans/models/src/c_models/onion.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,679 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "onion.h"
-
-// Convenience parameter structure
-typedef struct {
-  int n_shells;
-  double scale;
-  double rad_core0;
-  double sld_core0;
-  double sld_solv;
-  double background;
-  double sld_out_shell1;
-  double sld_out_shell2;
-  double sld_out_shell3;
-  double sld_out_shell4;
-  double sld_out_shell5;
-  double sld_out_shell6;
-  double sld_out_shell7;
-  double sld_out_shell8;
-  double sld_out_shell9;
-  double sld_out_shell10;
-  double sld_in_shell1;
-  double sld_in_shell2;
-  double sld_in_shell3;
-  double sld_in_shell4;
-  double sld_in_shell5;
-  double sld_in_shell6;
-  double sld_in_shell7;
-  double sld_in_shell8;
-  double sld_in_shell9;
-  double sld_in_shell10;
-
-  double A_shell1;
-  double A_shell2;
-  double A_shell3;
-  double A_shell4;
-  double A_shell5;
-  double A_shell6;
-  double A_shell7;
-  double A_shell8;
-  double A_shell9;
-  double A_shell10;
-
-  double thick_shell1;
-  double thick_shell2;
-  double thick_shell3;
-  double thick_shell4;
-  double thick_shell5;
-  double thick_shell6;
-  double thick_shell7;
-  double thick_shell8;
-  double thick_shell9;
-  double thick_shell10;
-
-  int func_shell1;
-  int func_shell2;
-  int func_shell3;
-  int func_shell4;
-  int func_shell5;
-  int func_shell6;
-  int func_shell7;
-  int func_shell8;
-  int func_shell9;
-  int func_shell10;
-} OnionParameters;
-
-// some details can be found in sld_cal.c
-static double so_kernel(double dp[], double q) {
-  int n = dp[0];
-  double scale = dp[1];
-  double rad_core0 = dp[2];
-  double sld_core0 = dp[3];
-  double sld_solv = dp[4];
-  double background = dp[5];
-  int i,j;
-  double bes,fun,alpha,f,vol,vol_pre,vol_sub,qr,r,contr,f2;
-  double sign;
-  double pi;
-  double r0 = 0.0;
-
-  double *sld_out;
-  double *slope;
-  double *sld_in;
-  double *thick;
-  double *A;
-  int *fun_type;
-
-  sld_out = (double*)malloc((n+2)*sizeof(double));
-  slope = (double*)malloc((n+2)*sizeof(double));
-  sld_in = (double*)malloc((n+2)*sizeof(double));
-  thick = (double*)malloc((n+2)*sizeof(double));
-  A = (double*)malloc((n+2)*sizeof(double));
-  fun_type = (int*)malloc((n+2)*sizeof(int));
-
-  for (i =1; i<=n; i++){
-    sld_out[i] = dp[i+5];
-    sld_in[i] = dp[i+15];
-    A[i] = dp[i+25];
-    thick[i] = dp[i+35];
-    fun_type[i] = dp[i+45];
-  }
-  sld_out[0] = sld_core0;
-  sld_out[n+1] = sld_solv;
-  sld_in[0] = sld_core0;
-  sld_in[n+1] = sld_solv;
-  thick[0] = rad_core0;
-  thick[n+1] = 1e+10;
-  A[0] = 0.0;
-  A[n+1] = 0.0;
-  fun_type[0] = 0;
-  fun_type[n+1] = 0;
-
-
-  pi = 4.0*atan(1.0);
-  f = 0.0;
-  r = 0.0;
-  vol = 0.0;
-  vol_pre = 0.0;
-  vol_sub = 0.0;
-
-  for (i =0; i<= n+1; i++){
-    if (thick[i] == 0.0){
-      continue;
-    }
-    if (fun_type[i]== 0 ){
-      slope[i] = 0.0;
-      A[i] = 0.0;
-    }
-    vol_pre = vol;
-    switch(fun_type[i]){
-    case 2 :
-      r0 = r;
-      if (A[i] == 0.0){
-        slope[i] = 0.0;
-      }
-      else{
-        slope[i] = (sld_out[i]-sld_in[i])/(exp(A[i])-1.0);
-      }
-      for (j=0; j<2; j++){
-        if ( i == 0 && j == 0){
-          continue;
-        }
-        if (i == n+1 && j == 1){
-          continue;
-        }
-        if ( j == 1){
-          sign = 1.0;
-          r += thick[i];
-        }
-        else{
-          sign = -1.0;
-        }
-        qr = q * r;
-        alpha = A[i] * r/thick[i];
-        fun = 0.0;
-        if(qr == 0.0){
-          fun = sign * 1.0;
-          bes = sign * 1.0;
-        }
-        else{
-          if (fabs(A[i]) > 0.0 ){
-            fun = 3.0 * ((alpha*alpha - qr * qr) * sin(qr) - 2.0 * alpha * qr * cos(qr))/ ((alpha * alpha + qr * qr) * (alpha * alpha + qr * qr) * qr);
-            fun = fun - 3.0 * (alpha * sin(qr) - qr * cos(qr)) / ((alpha * alpha + qr * qr) * qr);
-            fun = - sign *fun;
-            bes = sign * 3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr);
-          }
-          else {
-            fun = sign * 3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr);
-            bes = sign * 3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr);
-          }
-        }
-        contr = slope[i]*exp(A[i]*(r-r0)/thick[i]);
-
-        vol = 4.0 * pi / 3.0 * r * r * r;
-        //if (j == 1 && fabs(sld_in[i]-sld_solv) < 1e-04*fabs(sld_solv) && A[i]==0.0){
-        //  vol_sub += (vol_pre - vol);
-        //}
-        f += vol * (contr * (fun) + (sld_in[i]-slope[i]) * bes);
-      }
-      break;
-    default :
-      if (fun_type[i]==0){
-        slope[i] = 0.0;
-      }
-      else{
-        slope[i]= (sld_out[i] -sld_in[i])/thick[i];
-      }
-      contr = sld_in[i]-slope[i]*r;
-      for (j=0; j<2; j++){
-        if ( i == 0 && j == 0){
-          continue;
-        }
-        if (i == n+1 && j == 1){
-          continue;
-        }
-        if ( j == 1){
-          sign = 1.0;
-          r += thick[i];
-        }
-        else{
-          sign = -1.0;
-        }
-
-        qr = q * r;
-        fun = 0.0;
-        if(qr == 0.0){
-          bes = sign * 1.0;
-        }
-        else{
-          bes = sign *  3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr);
-          if (fabs(slope[i]) > 0.0 ){
-            fun = sign * 3.0 * r * (2.0*qr*sin(qr)-((qr*qr)-2.0)*cos(qr))/(qr * qr * qr * qr);
-          }
-        }
-        vol = 4.0 * pi / 3.0 * r * r * r;
-        //if (j == 1 && fabs(sld_in[i]-sld_solv) < 1e-04*fabs(sld_solv) && fun_type[i]==0){
-        //  vol_sub += (vol_pre - vol);
-        //}
-        f += vol * (bes * contr + fun * slope[i]);
-      }
-      break;
-    }
-
-  }
-  //vol += vol_sub;
-  f2 = f * f / vol * 1.0e8;
-  f2 *= scale;
-  f2 += background;
-
-  free(sld_out);
-  free(slope);
-  free(sld_in);
-  free(thick);
-  free(A);
-  free(fun_type);
-
-  return (f2);
-}
-
-
-OnionModel :: OnionModel() {
-  n_shells = Parameter(1.0);
-  scale = Parameter(1.0);
-  rad_core0 = Parameter(200.0);
-  rad_core0.set_min(0.0);
-  sld_core0 = Parameter(1e-06);
-  sld_solv = Parameter(6.4e-06);
-  background = Parameter(0.0);
-
-  sld_out_shell1 = Parameter(1.0e-06);
-  sld_out_shell2 = Parameter(1.0e-06);
-  sld_out_shell3 = Parameter(1.0e-06);
-  sld_out_shell4 = Parameter(1.0e-06);
-  sld_out_shell5 = Parameter(1.0e-06);
-  sld_out_shell6 = Parameter(1.0e-06);
-  sld_out_shell7 = Parameter(1.0e-06);
-  sld_out_shell8 = Parameter(1.0e-06);
-  sld_out_shell9 = Parameter(1.0e-06);
-  sld_out_shell10 = Parameter(1.0e-06);
-
-  sld_in_shell1 = Parameter(2.3e-06);
-  sld_in_shell2 = Parameter(2.6e-06);
-  sld_in_shell3 = Parameter(2.9e-06);
-  sld_in_shell4 = Parameter(3.2e-06);
-  sld_in_shell5 = Parameter(3.5e-06);
-  sld_in_shell6 = Parameter(3.8e-06);
-  sld_in_shell7 = Parameter(4.1e-06);
-  sld_in_shell8 = Parameter(4.4e-06);
-  sld_in_shell9 = Parameter(4.7e-06);
-  sld_in_shell10 = Parameter(5.0e-06);
-
-  A_shell1 = Parameter(1.0);
-  A_shell2 = Parameter(1.0);
-  A_shell3 = Parameter(1.0);
-  A_shell4 = Parameter(1.0);
-  A_shell5 = Parameter(1.0);
-  A_shell6 = Parameter(1.0);
-  A_shell7 = Parameter(1.0);
-  A_shell8 = Parameter(1.0);
-  A_shell9 = Parameter(1.0);
-  A_shell10 = Parameter(1.0);
-
-  thick_shell1 = Parameter(50.0);
-  thick_shell1.set_min(0.0);
-  thick_shell2 = Parameter(50.0);
-  thick_shell2.set_min(0.0);
-  thick_shell3 = Parameter(50.0);
-  thick_shell3.set_min(0.0);
-  thick_shell4 = Parameter(50.0);
-  thick_shell4.set_min(0.0);
-  thick_shell5 = Parameter(50.0);
-  thick_shell5.set_min(0.0);
-  thick_shell6 = Parameter(50.0);
-  thick_shell6.set_min(0.0);
-  thick_shell7 = Parameter(50.0);
-  thick_shell7.set_min(0.0);
-  thick_shell8 = Parameter(50.0);
-  thick_shell8.set_min(0.0);
-  thick_shell9 = Parameter(50.0);
-  thick_shell9.set_min(0.0);
-  thick_shell10 = Parameter(50.0);
-  thick_shell10.set_min(0.0);
-
-  func_shell1 = Parameter(2);
-  func_shell2 = Parameter(2);
-  func_shell3 = Parameter(2);
-  func_shell4 = Parameter(2);
-  func_shell5 = Parameter(2);
-  func_shell6 = Parameter(2);
-  func_shell7 = Parameter(2);
-  func_shell8 = Parameter(2);
-  func_shell9 = Parameter(2);
-  func_shell10 = Parameter(2);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double OnionModel :: operator()(double q) {
-  double dp[56];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = n_shells();
-  dp[1] = scale();
-  dp[2] = rad_core0();
-  dp[3] = sld_core0();
-  dp[4] = sld_solv();
-  dp[5] = 0.0;
-
-  dp[6] = sld_out_shell1();
-  dp[7] = sld_out_shell2();
-  dp[8] = sld_out_shell3();
-  dp[9] = sld_out_shell4();
-  dp[10] = sld_out_shell5();
-  dp[11] = sld_out_shell6();
-  dp[12] = sld_out_shell7();
-  dp[13] = sld_out_shell8();
-  dp[14] = sld_out_shell9();
-  dp[15] = sld_out_shell10();
-
-  dp[16] = sld_in_shell1();
-  dp[17] = sld_in_shell2();
-  dp[18] = sld_in_shell3();
-  dp[19] = sld_in_shell4();
-  dp[20] = sld_in_shell5();
-  dp[21] = sld_in_shell6();
-  dp[22] = sld_in_shell7();
-  dp[23] = sld_in_shell8();
-  dp[24] = sld_in_shell9();
-  dp[25] = sld_in_shell10();
-
-  dp[26] = A_shell1();
-  dp[27] = A_shell2();
-  dp[28] = A_shell3();
-  dp[29] = A_shell4();
-  dp[30] = A_shell5();
-  dp[31] = A_shell6();
-  dp[32] = A_shell7();
-  dp[33] = A_shell8();
-  dp[34] = A_shell9();
-  dp[35] = A_shell10();
-
-  dp[36] = thick_shell1();
-  dp[37] = thick_shell2();
-  dp[38] = thick_shell3();
-  dp[39] = thick_shell4();
-  dp[40] = thick_shell5();
-  dp[41] = thick_shell6();
-  dp[42] = thick_shell7();
-  dp[43] = thick_shell8();
-  dp[44] = thick_shell9();
-  dp[45] = thick_shell10();
-
-  dp[46] = func_shell1();
-  dp[47] = func_shell2();
-  dp[48] = func_shell3();
-  dp[49] = func_shell4();
-  dp[50] = func_shell5();
-  dp[51] = func_shell6();
-  dp[52] = func_shell7();
-  dp[53] = func_shell8();
-  dp[54] = func_shell9();
-  dp[55] = func_shell10();
-
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  rad_core0.get_weights(weights_rad);
-
-  // Get the dispersion points for the thick 1
-  vector<WeightPoint> weights_s1;
-  thick_shell1.get_weights(weights_s1);
-
-  // Get the dispersion points for the thick 2
-  vector<WeightPoint> weights_s2;
-  thick_shell2.get_weights(weights_s2);
-
-  // Get the dispersion points for the thick 3
-  vector<WeightPoint> weights_s3;
-  thick_shell3.get_weights(weights_s3);
-
-  // Get the dispersion points for the thick 4
-  vector<WeightPoint> weights_s4;
-  thick_shell4.get_weights(weights_s4);
-
-  // Get the dispersion points for the thick 5
-  vector<WeightPoint> weights_s5;
-  thick_shell5.get_weights(weights_s5);
-
-  // Get the dispersion points for the thick 6
-  vector<WeightPoint> weights_s6;
-  thick_shell6.get_weights(weights_s6);
-
-  // Get the dispersion points for the thick 7
-  vector<WeightPoint> weights_s7;
-  thick_shell7.get_weights(weights_s7);
-
-  // Get the dispersion points for the thick 8
-  vector<WeightPoint> weights_s8;
-  thick_shell8.get_weights(weights_s8);
-  // Get the dispersion points for the thick 9
-  vector<WeightPoint> weights_s9;
-  thick_shell9.get_weights(weights_s9);
-
-  // Get the dispersion points for the thick 10
-  vector<WeightPoint> weights_s10;
-  thick_shell10.get_weights(weights_s10);
-
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[2] = weights_rad[i].value;
-    // Loop over radius weight points
-    for(size_t j=0; j<weights_s1.size(); j++) {
-      dp[36] = weights_s1[j].value;
-      // Loop over radius weight points
-      for(size_t k=0; k<weights_s2.size(); k++) {
-        dp[37] = weights_s2[k].value;
-        // Loop over radius weight points
-        for(size_t l=0; l<weights_s3.size(); l++) {
-          dp[38] = weights_s3[l].value;
-          // Loop over radius weight points
-          for(size_t m=0; m<weights_s4.size(); m++) {
-            dp[39] = weights_s4[m].value;
-            for(size_t n=0; n<weights_s5.size(); n++) {
-              dp[40] = weights_s5[n].value;
-              for(size_t o=0; o<weights_s6.size(); o++) {
-                dp[41] = weights_s6[o].value;
-                for(size_t p=0; p<weights_s7.size(); p++) {
-                  dp[42] = weights_s7[p].value;
-                  for(size_t t=0; t<weights_s8.size(); t++) {
-                    dp[43] = weights_s8[t].value;
-                    for(size_t r=0; r<weights_s9.size(); r++) {
-                      dp[44] = weights_s9[r].value;
-                      for(size_t s=0; s<weights_s10.size(); s++) {
-                        dp[45] = weights_s10[s].value;
-                        //Un-normalize Shells by volume
-                        sum += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-                            *weights_s5[n].weight*weights_s6[o].weight*weights_s7[p].weight*weights_s8[t].weight
-                            *weights_s9[r].weight*weights_s10[s].weight
-                            * so_kernel(dp,q) * pow((weights_rad[i].value+weights_s1[j].value+weights_s2[k].value+weights_s3[l].value+weights_s4[m].value
-                                +weights_s5[n].value+weights_s6[o].value+weights_s7[p].value+weights_s8[t].value
-                                +weights_s9[r].value+weights_s10[s].value),3.0);
-                        //Find average volume
-                        vol += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-                            *weights_s5[n].weight*weights_s6[o].weight*weights_s7[p].weight*weights_s8[t].weight
-                            *weights_s9[r].weight*weights_s10[s].weight
-                            * pow((weights_rad[i].value+weights_s1[j].value+weights_s2[k].value+weights_s3[l].value+weights_s4[m].value
-                                +weights_s5[n].value+weights_s6[o].value+weights_s7[p].value+weights_s8[t].value
-                                +weights_s9[r].value+weights_s10[s].value),3.0);
-                        norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-                            *weights_s5[n].weight*weights_s6[o].weight*weights_s7[p].weight*weights_s8[t].weight
-                            *weights_s9[r].weight*weights_s10[s].weight;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double OnionModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double OnionModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double OnionModel :: calculate_ER() {
-  OnionParameters dp;
-  dp.rad_core0 = rad_core0();
-  dp.thick_shell1 = thick_shell1();
-  dp.thick_shell2 = thick_shell2();
-  dp.thick_shell3 = thick_shell3();
-  dp.thick_shell4 = thick_shell4();
-  dp.thick_shell5 = thick_shell5();
-  dp.thick_shell6 = thick_shell6();
-  dp.thick_shell7 = thick_shell7();
-  dp.thick_shell8 = thick_shell8();
-  dp.thick_shell9 = thick_shell9();
-  dp.thick_shell10 = thick_shell10();
-
-  double rad_out = 0.0;
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  rad_core0.get_weights(weights_rad);
-
-  // Get the dispersion points for the thick 1
-  vector<WeightPoint> weights_s1;
-  thick_shell1.get_weights(weights_s1);
-
-  // Get the dispersion points for the thick 2
-  vector<WeightPoint> weights_s2;
-  thick_shell2.get_weights(weights_s2);
-
-  // Get the dispersion points for the thick 3
-  vector<WeightPoint> weights_s3;
-  thick_shell3.get_weights(weights_s3);
-
-  // Get the dispersion points for the thick 4
-  vector<WeightPoint> weights_s4;
-  thick_shell4.get_weights(weights_s4);
-  // Get the dispersion points for the thick 5
-  vector<WeightPoint> weights_s5;
-  thick_shell5.get_weights(weights_s5);
-
-  // Get the dispersion points for the thick 6
-  vector<WeightPoint> weights_s6;
-  thick_shell6.get_weights(weights_s6);
-
-  // Get the dispersion points for the thick 7
-  vector<WeightPoint> weights_s7;
-  thick_shell7.get_weights(weights_s7);
-
-  // Get the dispersion points for the thick 8
-  vector<WeightPoint> weights_s8;
-  thick_shell8.get_weights(weights_s8);
-  // Get the dispersion points for the thick 9
-  vector<WeightPoint> weights_s9;
-  thick_shell9.get_weights(weights_s9);
-
-  // Get the dispersion points for the thick 10
-  vector<WeightPoint> weights_s10;
-  thick_shell10.get_weights(weights_s10);
-
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.rad_core0 = weights_rad[i].value;
-    // Loop over radius weight points
-    for(size_t j=0; j<weights_s1.size(); j++) {
-      dp.thick_shell1 = weights_s1[j].value;
-      // Loop over radius weight points
-      for(size_t k=0; k<weights_s2.size(); k++) {
-        dp.thick_shell2 = weights_s2[k].value;
-        // Loop over radius weight points
-        for(size_t l=0; l<weights_s3.size(); l++) {
-          dp.thick_shell3 = weights_s3[l].value;
-          // Loop over radius weight points
-          for(size_t m=0; m<weights_s4.size(); m++) {
-            dp.thick_shell4 = weights_s4[m].value;
-            // Loop over radius weight points
-            for(size_t n=0; j<weights_s5.size(); n++) {
-              dp.thick_shell5 = weights_s5[n].value;
-              // Loop over radius weight points
-              for(size_t o=0; k<weights_s6.size(); o++) {
-                dp.thick_shell6 = weights_s6[o].value;
-                // Loop over radius weight points
-                for(size_t p=0; l<weights_s7.size(); p++) {
-                  dp.thick_shell7 = weights_s7[p].value;
-                  // Loop over radius weight points
-                  for(size_t t=0; m<weights_s8.size(); t++) {
-                    dp.thick_shell8 = weights_s8[t].value;
-                    // Loop over radius weight points
-                    for(size_t r=0; l<weights_s9.size(); r++) {
-                      dp.thick_shell8 = weights_s9[r].value;
-                      // Loop over radius weight points
-                      for(size_t s=0; m<weights_s10.size(); s++) {
-                        dp.thick_shell10 = weights_s10[s].value;
-                        //Un-normalize FourShell by volume
-                        sum += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-                            *weights_s5[n].weight*weights_s6[o].weight*weights_s7[p].weight*weights_s8[t].weight
-                            *weights_s9[r].weight*weights_s10[s].weight
-                            * (dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4+dp.thick_shell5
-                                +dp.thick_shell6+dp.thick_shell7+dp.thick_shell8+dp.thick_shell9+dp.thick_shell10);
-                        norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight
-                            *weights_s4[m].weight*weights_s5[n].weight*weights_s6[o].weight*weights_s7[p].weight
-                            *weights_s8[t].weight*weights_s9[r].weight*weights_s10[s].weight;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    rad_out = dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4
-        +dp.thick_shell5+dp.thick_shell6+dp.thick_shell7+dp.thick_shell8+dp.thick_shell9+dp.thick_shell10;}
-  return rad_out;
-}
-double OnionModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/parallelepiped.cpp
===================================================================
--- src/sans/models/src/c_models/parallelepiped.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,543 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: add 2D function
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-
-extern "C" {
-	#include "libCylinder.h"
-	#include "libStructureFactor.h"
-	#include "libmultifunc/libfunc.h"
-}
-#include "parallelepiped.h"
-
-// Convenience parameter structure
-typedef struct {
-    double scale;
-    double short_a;
-    double short_b;
-    double long_c;
-    double sldPipe;
-    double sldSolv;
-    double background;
-    double parallel_theta;
-    double parallel_phi;
-    double parallel_psi;
-    double M0_sld_pipe;
-    double M_theta_pipe;
-    double M_phi_pipe;
-    double M0_sld_solv;
-    double M_theta_solv;
-    double M_phi_solv;
-    double Up_frac_i;
-	double Up_frac_f;
-	double Up_theta;
-} ParallelepipedParameters;
-
-
-static double pkernel(double a, double b,double c, double ala, double alb, double alc){
-    // mu passed in is really mu*sqrt(1-sig^2)
-    double argA,argB,argC,tmp1,tmp2,tmp3;     //local variables
-
-    //handle arg=0 separately, as sin(t)/t -> 1 as t->0
-    argA = a*ala/2.0;
-    argB = b*alb/2.0;
-    argC = c*alc/2.0;
-    if(argA==0.0) {
-    tmp1 = 1.0;
-  } else {
-    tmp1 = sin(argA)*sin(argA)/argA/argA;
-    }
-    if (argB==0.0) {
-    tmp2 = 1.0;
-  } else {
-    tmp2 = sin(argB)*sin(argB)/argB/argB;
-    }
-
-    if (argC==0.0) {
-    tmp3 = 1.0;
-  } else {
-    tmp3 = sin(argC)*sin(argC)/argC/argC;
-    }
-
-    return (tmp1*tmp2*tmp3);
-
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the parallelepiped
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double parallelepiped_analytical_2D_scaled(ParallelepipedParameters *pars, double q, double q_x, double q_y) {
-  double cparallel_x, cparallel_y, bparallel_x, bparallel_y, parallel_x, parallel_y;
-  //double q_z;
-  double vol, cos_val_c, cos_val_b, cos_val_a, edgeA, edgeB, edgeC;
-
-  double answer = 0.0;
-  double form = 0.0;
-  double pi = 4.0*atan(1.0);
-  
-  //convert angle degree to radian
-  double theta = pars->parallel_theta * pi/180.0;
-  double phi = pars->parallel_phi * pi/180.0;
-  double psi = pars->parallel_psi * pi/180.0;
-  double sld_solv = pars->sldSolv;
-  double sld_pipe = pars->sldPipe;
-  double m_max = pars->M0_sld_pipe;
-  double m_max_solv = pars->M0_sld_solv;
-  double contrast = 0.0;
-    
-  edgeA = pars->short_a;
-  edgeB = pars->short_b;
-  edgeC = pars->long_c;
-
-
-    // parallelepiped c axis orientation
-    cparallel_x = cos(theta) * cos(phi);
-    cparallel_y = sin(theta);
-    //cparallel_z = -cos(theta) * sin(phi);
-
-    // q vector
-    //q_z = 0.0;
-
-    // Compute the angle btw vector q and the
-    // axis of the parallelepiped
-    cos_val_c = cparallel_x*q_x + cparallel_y*q_y;// + cparallel_z*q_z;
-    //alpha = acos(cos_val_c);
-
-    // parallelepiped a axis orientation
-    parallel_x = -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-    parallel_y = sin(psi)*cos(theta);
-	//parallel_z = sin(theta)*sin(phi)*sin(psi)+cos(phi)*cos(psi);
-	
-    cos_val_a = parallel_x*q_x + parallel_y*q_y;
-
-    // parallelepiped b axis orientation
-    bparallel_x = -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-    bparallel_y = cos(theta)*cos(psi);
-    //bparallel_z = sin(theta)*sin(phi)*cos(psi)-sin(psi)*cos(phi);
-    
-    // axis of the parallelepiped
-    cos_val_b = bparallel_x*q_x + bparallel_y*q_y;
-
-    // The following test should always pass
-    if (fabs(cos_val_c)>1.0) {
-      //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-      cos_val_c = 1.0;
-    }
-    if (fabs(cos_val_a)>1.0) {
-      //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-      cos_val_a = 1.0;
-    }
-    if (fabs(cos_val_b)>1.0) {
-      //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-      cos_val_b = 1.0;
-    }
-  // Call the IGOR library function to get the kernel
-  form = pkernel( q*edgeA, q*edgeB, q*edgeC, cos_val_a, cos_val_b, cos_val_c);
-  
-  if (m_max < 1.0e-32 && m_max_solv < 1.0e-32){
-      // Multiply by contrast^2
-      contrast = (pars->sldPipe - pars->sldSolv);
- 	  answer = contrast * contrast * form;
-  }
-  else{
-	  double qx = q_x;
-	  double qy = q_y;
-	  double s_theta = pars->Up_theta;
-	  double m_phi = pars->M_phi_pipe;
-	  double m_theta = pars->M_theta_pipe;
-	  double m_phi_solv = pars->M_phi_solv;
-	  double m_theta_solv = pars->M_theta_solv;
-	  double in_spin = pars->Up_frac_i;
-	  double out_spin = pars->Up_frac_f;
-	  polar_sld p_sld;
-	  polar_sld p_sld_solv;
-	  p_sld = cal_msld(1, qx, qy, sld_pipe, m_max, m_theta, m_phi, 
-	  	 			in_spin, out_spin, s_theta);
-	  p_sld_solv = cal_msld(1, qx, qy, sld_solv, m_max_solv, m_theta_solv, m_phi_solv, 
-			 			in_spin, out_spin, s_theta);
-	  //up_up	
-	  if (in_spin > 0.0 && out_spin > 0.0){			 
-		  answer += ((p_sld.uu- p_sld_solv.uu) * (p_sld.uu- p_sld_solv.uu) * form);
-		  }
-	  //down_down
-	  if (in_spin < 1.0 && out_spin < 1.0){
-		  answer += ((p_sld.dd - p_sld_solv.dd) * (p_sld.dd - p_sld_solv.dd) * form);
-		  }
-	  //up_down
-	  if (in_spin > 0.0 && out_spin < 1.0){
-		  answer += ((p_sld.re_ud - p_sld_solv.re_ud) * (p_sld.re_ud - p_sld_solv.re_ud) * form);
-		  answer += ((p_sld.im_ud - p_sld_solv.im_ud) * (p_sld.im_ud - p_sld_solv.im_ud) * form);
-		  }
-	  //down_up	
-	  if (in_spin < 1.0 && out_spin > 0.0){
-		  answer += ((p_sld.re_du - p_sld_solv.re_du) * (p_sld.re_du - p_sld_solv.re_du) * form);
-		  answer += ((p_sld.im_du - p_sld_solv.im_du) * (p_sld.im_du - p_sld_solv.im_du) * form);
-		  }
-  }
-  
-
-  //normalize by cylinder volume
-  //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vparallel
-  vol = edgeA* edgeB * edgeC;
-  answer *= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the parallelepiped
- * @param q: q-value
- * @return: function value
- */
-static double parallelepiped_analytical_2DXY(ParallelepipedParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-    return parallelepiped_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-ParallelepipedModel :: ParallelepipedModel() {
-	scale      = Parameter(1.0);
-	short_a     = Parameter(35.0, true);
-	short_a.set_min(1.0);
-	short_b     = Parameter(75.0, true);
-	short_b.set_min(1.0);
-	long_c     = Parameter(400.0, true);
-	long_c.set_min(1.0);
-	sldPipe   = Parameter(6.3e-6);
-	sldSolv   = Parameter(1.0e-6);
-	background = Parameter(0.0);
-	parallel_theta  = Parameter(0.0, true);
-	parallel_phi    = Parameter(0.0, true);
-	parallel_psi    = Parameter(0.0, true);
-	M0_sld_pipe = Parameter(0.0e-6);
-	M_theta_pipe = Parameter(0.0);
-	M_phi_pipe = Parameter(0.0); 
-	M0_sld_solv = Parameter(0.0e-6);
-	M_theta_solv = Parameter(0.0);
-	M_phi_solv = Parameter(0.0); 
-	Up_frac_i = Parameter(0.5); 
-	Up_frac_f = Parameter(0.5);
-	Up_theta = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double ParallelepipedModel :: operator()(double q) {
-	double dp[7];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = short_a();
-	dp[2] = short_b();
-	dp[3] = long_c();
-	dp[4] = sldPipe();
-	dp[5] = sldSolv();
-	dp[6] = 0.0;
-
-	// Get the dispersion points for the short_edgeA
-	vector<WeightPoint> weights_short_a;
-	short_a.get_weights(weights_short_a);
-
-	// Get the dispersion points for the longer_edgeB
-	vector<WeightPoint> weights_short_b;
-	short_b.get_weights(weights_short_b);
-
-	// Get the dispersion points for the longuest_edgeC
-	vector<WeightPoint> weights_long_c;
-	long_c.get_weights(weights_long_c);
-
-
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over short_edgeA weight points
-	for(int i=0; i< (int)weights_short_a.size(); i++) {
-		dp[1] = weights_short_a[i].value;
-
-		// Loop over longer_edgeB weight points
-		for(int j=0; j< (int)weights_short_b.size(); j++) {
-			dp[2] = weights_short_b[j].value;
-
-			// Loop over longuest_edgeC weight points
-			for(int k=0; k< (int)weights_long_c.size(); k++) {
-				dp[3] = weights_long_c[k].value;
-				//Un-normalize  by volume
-				sum += weights_short_a[i].weight * weights_short_b[j].weight
-					* weights_long_c[k].weight * Parallelepiped(dp, q)
-					* weights_short_a[i].value*weights_short_b[j].value
-					* weights_long_c[k].value;
-				//Find average volume
-				vol += weights_short_a[i].weight * weights_short_b[j].weight
-					* weights_long_c[k].weight
-					* weights_short_a[i].value * weights_short_b[j].value
-					* weights_long_c[k].value;
-
-				norm += weights_short_a[i].weight
-					 * weights_short_b[j].weight * weights_long_c[k].weight;
-			}
-		}
-	}
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-
-	return sum/norm + background();
-}
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double ParallelepipedModel :: operator()(double qx, double qy) {
-	ParallelepipedParameters dp;
-	// Fill parameter array
-	dp.scale      = scale();
-	dp.short_a   = short_a();
-	dp.short_b   = short_b();
-	dp.long_c  = long_c();
-	dp.sldPipe   = sldPipe();
-	dp.sldSolv   = sldSolv();
-	dp.background = 0.0;
-	//dp.background = background();
-	dp.parallel_theta  = parallel_theta();
-	dp.parallel_phi    = parallel_phi();
-	dp.parallel_psi    = parallel_psi();
-	dp.Up_theta =  Up_theta();
-	dp.M_phi_pipe =  M_phi_pipe();
-	dp.M_theta_pipe =  M_theta_pipe();
-	dp.M0_sld_pipe =  M0_sld_pipe();
-	dp.M_phi_solv =  M_phi_solv();
-	dp.M_theta_solv =  M_theta_solv();
-	dp.M0_sld_solv =  M0_sld_solv();
-	dp.Up_frac_i =  Up_frac_i();
-	dp.Up_frac_f =  Up_frac_f();
-
-
-	// Get the dispersion points for the short_edgeA
-	vector<WeightPoint> weights_short_a;
-	short_a.get_weights(weights_short_a);
-
-	// Get the dispersion points for the longer_edgeB
-	vector<WeightPoint> weights_short_b;
-	short_b.get_weights(weights_short_b);
-
-	// Get angular averaging for the longuest_edgeC
-	vector<WeightPoint> weights_long_c;
-	long_c.get_weights(weights_long_c);
-
-	// Get angular averaging for theta
-	vector<WeightPoint> weights_parallel_theta;
-	parallel_theta.get_weights(weights_parallel_theta);
-
-	// Get angular averaging for phi
-	vector<WeightPoint> weights_parallel_phi;
-	parallel_phi.get_weights(weights_parallel_phi);
-
-	// Get angular averaging for psi
-	vector<WeightPoint> weights_parallel_psi;
-	parallel_psi.get_weights(weights_parallel_psi);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double norm_vol = 0.0;
-	double vol = 0.0;
-	double pi = 4.0*atan(1.0);
-	// Loop over radius weight points
-	for(int i=0; i< (int)weights_short_a.size(); i++) {
-		dp.short_a = weights_short_a[i].value;
-
-		// Loop over longer_edgeB weight points
-		for(int j=0; j< (int)weights_short_b.size(); j++) {
-			dp.short_b = weights_short_b[j].value;
-
-			// Average over longuest_edgeC distribution
-			for(int k=0; k< (int)weights_long_c.size(); k++) {
-				dp.long_c = weights_long_c[k].value;
-
-				// Average over theta distribution
-				for(int l=0; l< (int)weights_parallel_theta.size(); l++) {
-				dp.parallel_theta = weights_parallel_theta[l].value;
-
-					// Average over phi distribution
-					for(int m=0; m< (int)weights_parallel_phi.size(); m++) {
-						dp.parallel_phi = weights_parallel_phi[m].value;
-
-						// Average over phi distribution
-						for(int n=0; n< (int)weights_parallel_psi.size(); n++) {
-							dp.parallel_psi = weights_parallel_psi[n].value;
-							//Un-normalize by volume
-							double _ptvalue = weights_short_a[i].weight
-								* weights_short_b[j].weight
-								* weights_long_c[k].weight
-								* weights_parallel_theta[l].weight
-								* weights_parallel_phi[m].weight
-								* weights_parallel_psi[n].weight
-								* parallelepiped_analytical_2DXY(&dp, qx, qy)
-								* weights_short_a[i].value*weights_short_b[j].value
-								* weights_long_c[k].value;
-
-							if (weights_parallel_theta.size()>1) {
-								_ptvalue *= fabs(cos(weights_parallel_theta[l].value*pi/180.0));
-							}
-							sum += _ptvalue;
-							//Find average volume
-							vol += weights_short_a[i].weight
-								* weights_short_b[j].weight
-								* weights_long_c[k].weight
-								* weights_short_a[i].value*weights_short_b[j].value
-								* weights_long_c[k].value;
-							//Find norm for volume
-							norm_vol += weights_short_a[i].weight
-								* weights_short_b[j].weight
-								* weights_long_c[k].weight;
-
-							norm += weights_short_a[i].weight
-								* weights_short_b[j].weight
-								* weights_long_c[k].weight
-								* weights_parallel_theta[l].weight
-								* weights_parallel_phi[m].weight
-								* weights_parallel_psi[n].weight;
-						}
-					}
-
-				}
-			}
-		}
-	}
-	// Averaging in theta needs an extra normalization
-	// factor to account for the sin(theta) term in the
-	// integration (see documentation).
-	if (weights_parallel_theta.size()>1) norm = norm / asin(1.0);
-
-	if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm_vol);}
-
-	return sum/norm + background();
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double ParallelepipedModel :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double ParallelepipedModel :: calculate_ER() {
-	ParallelepipedParameters dp;
-	dp.short_a   = short_a();
-	dp.short_b   = short_b();
-	dp.long_c  = long_c();
-	double rad_out = 0.0;
-	double pi = 4.0*atan(1.0);
-	double suf_rad = sqrt(dp.short_a*dp.short_b/pi);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the short_edgeA
-	vector<WeightPoint> weights_short_a;
-	short_a.get_weights(weights_short_a);
-
-	// Get the dispersion points for the longer_edgeB
-	vector<WeightPoint> weights_short_b;
-	short_b.get_weights(weights_short_b);
-
-	// Get angular averaging for the longuest_edgeC
-	vector<WeightPoint> weights_long_c;
-	long_c.get_weights(weights_long_c);
-
-	// Loop over radius weight points
-	for(int i=0; i< (int)weights_short_a.size(); i++) {
-		dp.short_a = weights_short_a[i].value;
-
-		// Loop over longer_edgeB weight points
-		for(int j=0; j< (int)weights_short_b.size(); j++) {
-			dp.short_b = weights_short_b[j].value;
-
-			// Average over longuest_edgeC distribution
-			for(int k=0; k< (int)weights_long_c.size(); k++) {
-				dp.long_c = weights_long_c[k].value;
-				//Calculate surface averaged radius
-				//This is rough approximation.
-				suf_rad = sqrt(dp.short_a*dp.short_b/pi);
-
-				//Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-				sum +=weights_short_a[i].weight* weights_short_b[j].weight
-					* weights_long_c[k].weight*DiamCyl(dp.long_c, suf_rad)/2.0;
-				norm += weights_short_a[i].weight* weights_short_b[j].weight*weights_long_c[k].weight;
-			}
-		}
-	}
-
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		//Note: output of "DiamCyl(length,radius)" is DIAMETER.
-		rad_out = DiamCyl(dp.long_c, suf_rad)/2.0;}
-	return rad_out;
-
-}
-double ParallelepipedModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/parameters.cpp
===================================================================
--- src/sans/models/src/c_models/parameters.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,467 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-#include "parameters.hh"
-#include <stdio.h>
-#include <math.h>
-using namespace std;
-
-#if defined(_MSC_VER)
-#include "gamma_win.h"
-#endif
-
-/**
- * TODO: normalize all dispersion weight lists
- */
-
-
-/**
- * Weight points
- */
-WeightPoint :: WeightPoint() {
-	value = 0.0;
-	weight = 0.0;
-}
-
-WeightPoint :: WeightPoint(double v, double w) {
-	value = v;
-	weight = w;
-}
-
-/**
- * Dispersion models
- */
-DispersionModel :: DispersionModel() {
-	npts  = 1;
-	width = 0.0;
-};
-
-void DispersionModel :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->dispersion_to_dict(from, to);
-}
-void DispersionModel :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->dispersion_from_dict(from, to);
-}
-void DispersionModel :: operator() (void *param, vector<WeightPoint> &weights){
-	// Check against zero width
-	if (width<=0) {
-		width = 0.0;
-		npts  = 1;
-	}
-
-	Parameter* par = (Parameter*)param;
-	double value = (*par)();
-	double sig;
-	if (npts<2) {
-		weights.insert(weights.end(), WeightPoint(value, 1.0));
-	} else {
-		for(int i=0; i<npts; i++) {
-
-			if ((*par).has_min==false){
-				// width = sigma for angles
-				sig = width;
-			}
-			else{
-				//width = polydispersity (=sigma/value) for length
-				sig = width * value;
-			}
-			double val = value + sig * (1.0*double(i)/double(npts-1) - 0.5);
-			if ( ((*par).has_min==false || val>(*par).min)
-			  && ((*par).has_max==false || val<(*par).max)  )
-				weights.insert(weights.end(), WeightPoint(val, 1.0));
-		}
-	}
-}
-
-/**
- * Method to set the weights
- * Not implemented for this class
- */
-void DispersionModel :: set_weights(int npoints, double* values, double* weights){}
-
-/**
- * Gaussian dispersion
- */
-
-GaussianDispersion :: GaussianDispersion() {
-	npts  = 35;
-	width = 0.0;
-	nsigmas = 3;
-};
-
-void GaussianDispersion :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->gaussian_to_dict(from, to);
-}
-void GaussianDispersion :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->gaussian_from_dict(from, to);
-}
-
-double gaussian_weight(double mean, double sigma, double x) {
-	double vary, expo_value;
-    vary = x-mean;
-    expo_value = -vary*vary/(2.0*sigma*sigma);
-    //return 1.0;
-    return exp(expo_value);
-}
-
-/**
- * Gaussian dispersion
- * @param mean: mean value of the Gaussian
- * @param sigma: standard deviation of the Gaussian
- * @param x: value at which the Gaussian is evaluated
- * @return: value of the Gaussian
- */
-void GaussianDispersion :: operator() (void *param, vector<WeightPoint> &weights){
-	// Check against zero width
-	if (width<=0) {
-		width = 0.0;
-		npts  = 1;
-		nsigmas = 3;
-	}
-
-	Parameter* par = (Parameter*)param;
-	double value = (*par)();
-	double sig;
-	if (npts<2) {
-		weights.insert(weights.end(), WeightPoint(value, 1.0));
-	} else {
-		for(int i=0; i<npts; i++) {
-			if ((*par).has_min==false){
-				// width = sigma for angles
-				sig = width;
-			}
-			else{
-				//width = polydispersity (=sigma/value) for length
-				sig = width * value;
-			}
-			// We cover n(nsigmas) times sigmas on each side of the mean
-			double val = value + sig * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas);
-			if ( ((*par).has_min==false || val>(*par).min)
-			  && ((*par).has_max==false || val<(*par).max)  ) {
-				double _w = gaussian_weight(value, sig, val);
-				weights.insert(weights.end(), WeightPoint(val, _w));
-			}
-		}
-	}
-}
-
-
-/**
- * Flat dispersion
- */
-
-RectangleDispersion :: RectangleDispersion() {
-	npts  = 35;
-	width = 0.0;
-	nsigmas = 1.73205;
-};
-
-void RectangleDispersion :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->rectangle_to_dict(from, to);
-}
-void RectangleDispersion :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->rectangle_from_dict(from, to);
-}
-
-double rectangle_weight(double mean, double sigma, double x) {
-    double wid = fabs(sigma) * sqrt(3.0);
-    if (x>= (mean-wid) && x<=(mean+wid)){
-    	return 1.0;
-    }
-    else{
-    	return 0.0;
-    }
-}
-
-/**
- * Flat dispersion
- * @param mean: mean value
- * @param sigma: half width of top hat function
- * @param x: value at which the Flat is evaluated
- * @return: value of the Flat
- */
-void RectangleDispersion :: operator() (void *param, vector<WeightPoint> &weights){
-	// Check against zero width
-	if (width<=0) {
-		width = 0.0;
-		npts  = 1;
-		nsigmas = 1.73205;
-	}
-
-	Parameter* par = (Parameter*)param;
-	double value = (*par)();
-	double sig;
-	if (npts<2) {
-		weights.insert(weights.end(), WeightPoint(value, 1.0));
-	} else {
-		for(int i=0; i<npts; i++) {
-			if ((*par).has_min==false){
-				// width = sigma for angles
-				sig = width;
-			}
-			else{
-				//width = polydispersity (=sigma/value) for length
-				sig = width * value;
-			}
-			// We cover n(nsigmas) times sigmas on each side of the mean
-			double val = value + sig * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas);
-			if ( ((*par).has_min==false || val>(*par).min)
-			  && ((*par).has_max==false || val<(*par).max)  ) {
-				double _w = rectangle_weight(value, sig, val);
-				weights.insert(weights.end(), WeightPoint(val, _w));
-			}
-		}
-	}
-}
-
-
-/**
- * LogNormal dispersion
- */
-
-LogNormalDispersion :: LogNormalDispersion() {
-	npts  = 80;
-	width = 0.0;
-	nsigmas = 8.0;
-};
-
-void LogNormalDispersion :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->lognormal_to_dict(from, to);
-}
-void LogNormalDispersion :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->lognormal_from_dict(from, to);
-}
-
-double lognormal_weight(double mean, double sigma, double x) {
-
-	double sigma2 = pow(sigma, 2.0);
-	return 1.0/(x*sigma) * exp( -pow((log(x) - mean), 2.0) / (2.0*sigma2));
-
-}
-
-/**
- * Lognormal dispersion
- * @param mean: mean value of the LogNormal
- * @param sigma: standard deviation of the LogNormal
- * @param x: value at which the LogNormal is evaluated
- * @return: value of the LogNormal
- */
-void LogNormalDispersion :: operator() (void *param, vector<WeightPoint> &weights){
-	// Check against zero width
-	if (width<=0) {
-		width = 0.0;
-		npts  = 1;
-		nsigmas = 8.0;
-	}
-
-	Parameter* par = (Parameter*)param;
-	double value = (*par)();
-	double sig;
-	if (npts<2) {
-		weights.insert(weights.end(), WeightPoint(value, 1.0));
-	} else {
-		for(int i=0; i<npts; i++) {
-			// Note that the definition of sigma is different from Gaussian
-			if ((*par).has_min==false){
-				// sig  for angles
-				sig = width;
-			}
-			else{
-				// by lognormal definition, PD is same as sigma
-				sig = width * value;
-			}
-			
-			// We cover n(nsigmas) times sigmas on each side of the mean
-			//constant bin in real space
-			double val = value + sig * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas);
-			// sigma in the lognormal function is in ln(R) space, thus needs converting
-			sig = fabs(sig/value); 
-			if ( ((*par).has_min==false || val>(*par).min)
-			  && ((*par).has_max==false || val<(*par).max)  ) {
-				double _w = lognormal_weight(log(value), sig, val);
-				weights.insert(weights.end(), WeightPoint(val, _w));
-				//printf("%g \t %g\n",val,_w);
-
-			}
-		}
-	}
-}
-
-
-
-/**
- * Schulz dispersion
- */
-
-SchulzDispersion :: SchulzDispersion() {
-	npts  = 80;
-	width = 0.0;
-	nsigmas = 8.0;
-};
-
-void SchulzDispersion :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->schulz_to_dict(from, to);
-}
-void SchulzDispersion :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->schulz_from_dict(from, to);
-}
-
-double schulz_weight(double mean, double sigma, double x) {
-    double z = pow(mean/ sigma, 2.0)-1.0;
-	double R= x/mean;
-	double zz= z+1.0;
-	double expo;
-	expo = zz*log(zz)+z*log(R)-R*zz-log(mean)-lgamma(zz);
-	return  exp(expo);
-}
-
-/**
- * Schulz dispersion
- * @param mean: mean value of the Schulz
- * @param sigma: standard deviation of the Schulz
- * @param x: value at which the Schulz is evaluated
- * @return: value of the Schulz
- */
-void SchulzDispersion :: operator() (void *param, vector<WeightPoint> &weights){
-	// Check against zero width
-	if (width<=0) {
-		width = 0.0;
-		npts  = 1;
-		nsigmas = 8.0;
-	}
-
-	Parameter* par = (Parameter*)param;
-	double value = (*par)();
-	double sig;
-	if (npts<2) {
-		weights.insert(weights.end(), WeightPoint(value, 1.0));
-	} else {
-		for(int i=0; i<npts; i++) {
-			if ((*par).has_min==false){
-				// width = sigma for angles
-				sig = width;
-			}
-			else{
-				//width = polydispersity (=sigma/value) for length
-				sig = width * value;
-			}
-			// We cover n(nsigmas) times sigmas on each side of the mean
-			double val = value + sig * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas);
-
-			if ( ((*par).has_min==false || val>(*par).min)
-			  && ((*par).has_max==false || val<(*par).max)  ) {
-				double _w = schulz_weight(value, sig, val);
-				weights.insert(weights.end(), WeightPoint(val, _w));
-			}
-		}
-	}
-}
-
-
-
-
-/**
- * Array dispersion based on input arrays
- */
-
-void ArrayDispersion :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->array_to_dict(from, to);
-}
-void ArrayDispersion :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) {
-	visitor->array_from_dict(from, to);
-}
-
-/**
- * Method to get the weights
- */
-void ArrayDispersion :: operator() (void *param, vector<WeightPoint> &weights) {
-	Parameter* par = (Parameter*)param;
-	double value = (*par)();
-
-	if (npts<2) {
-		weights.insert(weights.end(), WeightPoint(value, 1.0));
-	} else {
-		for(int i=0; i<npts; i++) {
-			double val = _values[i]; //+ value;  //ToDo: Talk to Paul and put back the 'value'.
-
-			if ( ((*par).has_min==false || val>(*par).min)
-			  && ((*par).has_max==false || val<(*par).max)  )
-				weights.insert(weights.end(), WeightPoint(val, _weights[i]));
-		}
-	}
-}
-/**
- * Method to set the weights
- */
-void ArrayDispersion :: set_weights(int npoints, double* values, double* weights){
-	npts = npoints;
-	_values = values;
-	_weights = weights;
-}
-
-
-/**
- * Parameters
- */
-Parameter :: Parameter() {
-	value = 0;
-	min   = 0.0;
-	max   = 0.0;
-	has_min = false;
-	has_max = false;
-	has_dispersion = false;
-	dispersion = new GaussianDispersion();
-}
-
-Parameter :: Parameter(double _value) {
-	value = _value;
-	min   = 0.0;
-	max   = 0.0;
-	has_min = false;
-	has_max = false;
-	has_dispersion = false;
-	dispersion = new GaussianDispersion();
-}
-
-Parameter :: Parameter(double _value, bool disp) {
-	value = _value;
-	min   = 0.0;
-	max   = 0.0;
-	has_min = false;
-	has_max = false;
-	has_dispersion = disp;
-	dispersion = new GaussianDispersion();
-}
-
-void Parameter :: get_weights(vector<WeightPoint> &weights) {
-	(*dispersion)((void*)this, weights);
-}
-
-void Parameter :: set_min(double value) {
-	has_min = true;
-	min = value;
-}
-
-void Parameter :: set_max(double value) {
-	has_max = true;
-	max = value;
-}
-
-double Parameter :: operator()() {
-	return value;
-}
-
-double Parameter :: operator=(double _value){
-	value = _value;
-	return value;
-}
Index: c/sans/models/src/c_models/parameters.hh
===================================================================
--- src/sans/models/src/c_models/parameters.hh	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,176 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-#ifndef PARAM_CLASS_H
-#define PARAM_CLASS_H
-/**
- * TODO: will need to write a bridge class
- * to convert the dispersion model parameters
- * into dictionary parameters for python.
- */
-#include <vector>
-#include "dispersion_visitor.hh"
-
-using namespace std;
-
-/**
- * Weight point class to hold averaging points
- */
-class WeightPoint {
-public:
-	/// Value of the weight point
-	double value;
-	/// Weight of the weight point
-	double weight;
-
-	WeightPoint();
-	WeightPoint(double, double);
-};
-
-/**
- * Basic averaging model. The class instance will
- * generate a flat distribution of weight points
- * according to the number of points specified
- * and the width of the distribution. The center
- * of the distribution is specified by the
- * Parameter object taken in as a parameter.
- */
-class DispersionModel {
-public:
-	/// Number of points to average over
-	int npts;
-	/// Width of the distribution (step function)
-	double width;
-
-	DispersionModel();
-	/// Method that generates the weight points
-	virtual void operator()(void *, vector<WeightPoint>&);
-	virtual void set_weights(int, double*, double*);
-	virtual void accept_as_source(DispersionVisitor*, void*, void*);
-	virtual void accept_as_destination(DispersionVisitor*, void*, void*);
-};
-
-
-/**
- * Gaussian dispersion model
- */
-class GaussianDispersion: public DispersionModel {
-public:
-	/// Number of sigmas on each side of the mean
-	double nsigmas;
-
-	GaussianDispersion();
-	void operator()(void *, vector<WeightPoint>&);
-	void accept_as_source(DispersionVisitor*, void*, void*);
-	void accept_as_destination(DispersionVisitor*, void*, void*);
-};
-
-/**
- * Flat dispersion model
- */
-class RectangleDispersion: public DispersionModel {
-public:
-	/// Number of sigmas on each side of the mean
-	double nsigmas;
-
-	RectangleDispersion();
-	void operator()(void *, vector<WeightPoint>&);
-	void accept_as_source(DispersionVisitor*, void*, void*);
-	void accept_as_destination(DispersionVisitor*, void*, void*);
-};
-
-/**
- * Schulz dispersion model
- */
-class SchulzDispersion: public DispersionModel {
-public:
-	/// Number of sigmas on each side of the mean
-	double nsigmas;
-
-	SchulzDispersion();
-	void operator()(void *, vector<WeightPoint>&);
-	void accept_as_source(DispersionVisitor*, void*, void*);
-	void accept_as_destination(DispersionVisitor*, void*, void*);
-};
-
-/**
- * LogNormal dispersion model
- */
-class LogNormalDispersion: public DispersionModel {
-public:
-	/// Number of sigmas on each side of the mean
-	double nsigmas;
-
-	LogNormalDispersion();
-	void operator()(void *, vector<WeightPoint>&);
-	void accept_as_source(DispersionVisitor*, void*, void*);
-	void accept_as_destination(DispersionVisitor*, void*, void*);
-};
-
-
-/**
- * Dispersion model based on arrays provided by the user
- */
-class ArrayDispersion: public DispersionModel {
-private:
-	/// Array of values
-	double* _values;
-	/// Array of weights
-	double* _weights;
-
-	/// Method to set the weight points from arrays
-	void set_weights(int, double*, double*);
-	void operator()(void *, vector<WeightPoint>&);
-	void accept_as_source(DispersionVisitor*, void*, void*);
-	void accept_as_destination(DispersionVisitor*, void*, void*);
-public:
-
-};
-
-/**
- * Parameter class to hold information about a
- * parameter.
- */
-class Parameter {
-public:
-	/// Current value of the parameter
-	double value;
-	/// True if the parameter has a minimum bound
-	bool has_min;
-	/// True if the parameter has a maximum bound
-	bool has_max;
-	/// Minimum bound
-	double min;
-	/// Maximum bound
-	double max;
-	/// True if the parameter can be dispersed or averaged
-	bool has_dispersion;
-	/// Pointer to the dispersion model object for this parameter
-	DispersionModel* dispersion;
-
-	Parameter();
-	Parameter(double);
-	Parameter(double, bool);
-
-	/// Method to set a minimum value
-	void set_min(double);
-	/// Method to set a maximum value
-	void set_max(double);
-	/// Method to get weight points for this parameter
-	void get_weights(vector<WeightPoint>&);
-	/// Returns the value of the parameter
-	double operator()();
-	/// Sets the value of the parameter
-	double operator=(double);
-};
-#endif
Index: c/sans/models/src/c_models/pearlnecklace.cpp
===================================================================
--- src/sans/models/src/c_models/pearlnecklace.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,286 +1,0 @@
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "pearlnecklace.h"
-
-extern "C" {
-#include "libmultifunc/libfunc.h"
-}
-
-static double pearl_necklace_kernel(double dp[], double q) {
-  // fit parameters
-  double scale = dp[0];
-  double radius = dp[1];
-  double edge_separation = dp[2];
-  double thick_string = dp[3];
-  double num_pearls = dp[4];
-  double sld_pearl = dp[5];
-  double sld_string = dp[6];
-  double sld_solv = dp[7];
-  double background = dp[8];
-
-  //relative slds
-  double contrast_pearl = sld_pearl - sld_solv;
-  double contrast_string = sld_string - sld_solv;
-
-  // number of string segments
-  double num_strings = num_pearls - 1.0;
-
-  //Pi
-  double pi = 4.0*atan(1.0);
-
-  // each volumes
-  double string_vol = edge_separation * pi * pow((thick_string / 2.0), 2);
-  double pearl_vol = 4.0 /3.0 * pi * pow(radius, 3);
-
-  //total volume
-  double tot_vol;
-  //each masses
-  double m_r= contrast_string * string_vol;
-  double m_s= contrast_pearl * pearl_vol;
-  double psi;
-  double gamma;
-  double beta;
-  //form factors
-  double sss; //pearls
-  double srr; //strings
-  double srs; //cross
-  double A_s;
-  double srr_1;
-  double srr_2;
-  double srr_3;
-  double form_factor;
-
-  tot_vol = num_strings * string_vol;
-  tot_vol += num_pearls * pearl_vol;
-
-  //sine functions of a pearl
-  psi = sin(q*radius);
-  psi -= q * radius * cos(q * radius);
-  psi /= pow((q * radius), 3);
-  psi *= 3.0;
-
-  // Note take only 20 terms in Si series: 10 terms may be enough though.
-  gamma = Si(q* edge_separation);
-  gamma /= (q* edge_separation);
-  beta = Si(q * (edge_separation + radius));
-  beta -= Si(q * radius);
-  beta /= (q* edge_separation);
-
-  // center to center distance between the neighboring pearls
-  A_s = edge_separation + 2.0 * radius;
-
-  // form factor for num_pearls
-  sss = 1.0 - pow(sinc(q*A_s), num_pearls );
-  sss /= pow((1.0-sinc(q*A_s)), 2);
-  sss *= -sinc(q*A_s);
-  sss -= num_pearls/2.0;
-  sss += num_pearls/(1.0-sinc(q*A_s));
-  sss *= 2.0 * pow((m_s*psi), 2);
-
-  // form factor for num_strings (like thin rods)
-  srr_1 = -pow(sinc(q*edge_separation/2.0), 2);
-
-  srr_1 += 2.0 * gamma;
-  srr_1 *= num_strings;
-  srr_2 = 2.0/(1.0-sinc(q*A_s));
-  srr_2 *= num_strings;
-  srr_2 *= pow(beta, 2);
-  srr_3 = 1.0 - pow(sinc(q*A_s), num_strings);
-  srr_3 /= pow((1.0-sinc(q*A_s)), 2);
-  srr_3 *= pow(beta, 2);
-  srr_3 *= -2.0;
-
-  // total srr
-  srr = srr_1 + srr_2 + srr_3;
-  srr *= pow(m_r, 2);
-
-  // form factor for correlations
-  srs = 1.0;
-  srs -= pow(sinc(q*A_s), num_strings);
-  srs /= pow((1.0-sinc(q*A_s)), 2);
-  srs *= -sinc(q*A_s);
-  srs += (num_strings/(1.0-sinc(q*A_s)));
-  srs *= 4.0;
-  srs *= (m_r * m_s * beta * psi);
-
-  form_factor = sss + srr + srs;
-  form_factor /= (tot_vol * 1.0e-8); // norm by volume and A^-1 to cm^-1
-
-  // scale and background
-  form_factor *= scale;
-  form_factor += background;
-  return (form_factor);
-}
-
-PearlNecklaceModel :: PearlNecklaceModel() {
-  scale = Parameter(1.0);
-  radius = Parameter(80.0, true);
-  radius.set_min(0.0);
-  edge_separation = Parameter(350.0, true);
-  edge_separation.set_min(0.0);
-  thick_string = Parameter(2.5, true);
-  thick_string.set_min(0.0);
-  num_pearls = Parameter(3);
-  num_pearls.set_min(0.0);
-  sld_pearl = Parameter(1.0e-06);
-  sld_string = Parameter(1.0e-06);
-  sld_solv = Parameter(6.3e-06);
-  background = Parameter(0.0);
-
-}
-
-/**
- * Function to evaluate 1D PearlNecklaceModel function
- * @param q: q-value
- * @return: function value
- */
-double PearlNecklaceModel :: operator()(double q) {
-  double dp[9];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = edge_separation();
-  dp[3] = thick_string();
-  dp[4] = num_pearls();
-  dp[5] = sld_pearl();
-  dp[6] = sld_string();
-  dp[7] = sld_solv();
-  dp[8] = 0.0;
-  double pi = 4.0*atan(1.0);
-  // No polydispersion supported in this model.
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-  vector<WeightPoint> weights_edge_separation;
-  edge_separation.get_weights(weights_edge_separation);
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-  double string_vol = 0.0;
-  double pearl_vol = 0.0;
-  double tot_vol = 0.0;
-  // Loop over core weight points
-  for(size_t i=0; i<weights_radius.size(); i++) {
-    dp[1] = weights_radius[i].value;
-    // Loop over thick_inter0 weight points
-    for(size_t j=0; j<weights_edge_separation.size(); j++) {
-      dp[2] = weights_edge_separation[j].value;
-      pearl_vol = 4.0 /3.0 * pi * pow(dp[1], 3);
-      string_vol =dp[2] * pi * pow((dp[3] / 2.0), 2);
-      tot_vol = (dp[4] - 1.0) * string_vol;
-      tot_vol += dp[4] * pearl_vol;
-      //Un-normalize Sphere by volume
-      sum += weights_radius[i].weight * weights_edge_separation[j].weight
-          * pearl_necklace_kernel(dp,q) * tot_vol;
-      //Find average volume
-      vol += weights_radius[i].weight * weights_edge_separation[j].weight
-          * tot_vol;
-      norm += weights_radius[i].weight * weights_edge_separation[j].weight;
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D PearlNecklaceModel function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double PearlNecklaceModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate PearlNecklaceModel function
- * @param pars: parameters of the PearlNecklaceModel
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double PearlNecklaceModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate TOTAL radius
- * Todo: decide whether or not we keep this calculation
- * @return: effective radius value
- */
-// No polydispersion supported in this model.
-// Calculate max radius assumming max_radius = effective radius
-// Note that this max radius is not affected by sld of layer, sld of interface, or
-// sld of solvent.
-double PearlNecklaceModel :: calculate_ER() {
-  PeralNecklaceParameters dp;
-
-  dp.scale = scale();
-  dp.radius = radius();
-  dp.edge_separation = edge_separation();
-  dp.thick_string = thick_string();
-  dp.num_pearls = num_pearls();
-
-  double rad_out = 0.0;
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double pi = 4.0*atan(1.0);
-  // No polydispersion supported in this model.
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-  vector<WeightPoint> weights_edge_separation;
-  edge_separation.get_weights(weights_edge_separation);
-  // Perform the computation, with all weight points
-  double string_vol = 0.0;
-  double pearl_vol = 0.0;
-  double tot_vol = 0.0;
-  // Loop over core weight points
-  for(size_t i=0; i<weights_radius.size(); i++) {
-    dp.radius = weights_radius[i].value;
-    // Loop over thick_inter0 weight points
-    for(size_t j=0; j<weights_edge_separation.size(); j++) {
-      dp.edge_separation = weights_edge_separation[j].value;
-      pearl_vol = 4.0 /3.0 * pi * pow(dp.radius , 3);
-      string_vol =dp.edge_separation * pi * pow((dp.thick_string / 2.0), 2);
-      tot_vol = (dp.num_pearls - 1.0) * string_vol;
-      tot_vol += dp.num_pearls * pearl_vol;
-      //Find  volume
-      // This may be a too much approximation
-      //Todo: decided whether or not we keep this calculation
-      sum += weights_radius[i].weight * weights_edge_separation[j].weight
-          * pow(3.0*tot_vol/4.0/pi,0.333333);
-      norm += weights_radius[i].weight * weights_edge_separation[j].weight;
-    }
-  }
-
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    pearl_vol = 4.0 /3.0 * pi * pow(dp.radius , 3);
-    string_vol =dp.edge_separation * pi * pow((dp.thick_string / 2.0), 2);
-    tot_vol = (dp.num_pearls - 1.0) * string_vol;
-    tot_vol += dp.num_pearls * pearl_vol;
-
-    rad_out =  pow((3.0*tot_vol/4.0/pi), 0.33333);
-  }
-
-  return rad_out;
-
-}
-double PearlNecklaceModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/polygausscoil.cpp
===================================================================
--- src/sans/models/src/c_models/polygausscoil.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,144 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "polygausscoil.h"
-
-extern "C" {
-	#include "libTwoPhase.h"
-}
-
-Poly_GaussCoil :: Poly_GaussCoil() {
-	scale      = Parameter(1.0);
-	rg     = Parameter(60.0, true);
-	rg.set_min(0.0);
-	poly_m   = Parameter(2.0);
-	background = Parameter(0.001);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double Poly_GaussCoil :: operator()(double q) {
-	double dp[4];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = rg();
-	dp[2] = poly_m();
-	dp[3] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	rg.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-
-
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[1] = weights_rad[i].value;
-
-		//Un-normalize SphereForm by volume
-		sum += weights_rad[i].weight
-			* PolyGaussCoil(dp, q) * pow(weights_rad[i].value,3);
-		//Find average volume
-		vol += weights_rad[i].weight
-			* pow(weights_rad[i].value,3);
-
-		norm += weights_rad[i].weight;
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-
-
-	sum = PolyGaussCoil(dp, q);
-	return sum + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double Poly_GaussCoil :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double Poly_GaussCoil :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double Poly_GaussCoil :: calculate_ER() {
-	double rad_out = 0.0;
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	rg.get_weights(weights_rad);
-	// Loop over radius weight points to average the radius value
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		sum += weights_rad[i].weight
-			* weights_rad[i].value;
-		norm += weights_rad[i].weight;
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		rad_out = rg();}
-
-	return rad_out;
-}
-double Poly_GaussCoil :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/pringles.cpp
===================================================================
--- src/sans/models/src/c_models/pringles.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,351 +1,0 @@
-/**
- * PringlesModel
- *
- * (c) 2013 / Andrew J Jackson / andrew.jackson@esss.se
- *
- * Model for "pringles" particle from K. Edler @ Bath University
- *
- */
-#include <math.h>
-#include "parameters.hh"
-#include "pringles.h"
-#include "cephes.h"
-using namespace std;
-
-extern "C"
-{
-#include "GaussWeights.h"
-#include "libStructureFactor.h"
-}
-
-// Convenience parameter structure
-typedef struct {
-    double scale;
-    double radius;
-    double thickness;
-    double alpha;
-    double beta;
-    double sldCyl;
-    double sldSolv;
-    double background;
-    double cyl_theta;
-    double cyl_phi;
-} PringleParameters;
-
-
-PringlesModel::PringlesModel() {
-	scale = Parameter(1.0);
-	radius = Parameter(60.0,true);
-	radius.set_min(0.0);
-	thickness = Parameter(10.0,true);
-	thickness.set_min(0.0);
-	alpha = Parameter(0.001,true);
-	beta = Parameter(0.02,true);
-	sld_pringle = Parameter(1.0e-6);
-	sld_solvent = Parameter(6.35e-6);
-	background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double PringlesModel::operator()(double q) {
-	double dp[8];
-	// Fill parameter array
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = radius();
-	dp[2] = thickness();
-	dp[3] = alpha();
-	dp[4] = beta();
-	dp[5] = sld_pringle();
-	dp[6] = sld_solvent();
-	dp[7] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Get the dispersion points for the thickness
-	vector<WeightPoint> weights_thick;
-	thickness.get_weights(weights_thick);
-
-	// Get the dispersion points for alpha
-	vector<WeightPoint> weights_alpha;
-	alpha.get_weights(weights_alpha);
-
-	// Get the dispersion points for beta
-	vector<WeightPoint> weights_beta;
-	beta.get_weights(weights_beta);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double volnorm = 0.0;
-	double vol = 0.0;
-	double Pi;
-
-	Pi = 4.0 * atan(1.0);
-
-	// Loop over alpha weight points
-	for (size_t i = 0; i < weights_alpha.size(); i++) {
-		dp[3] = weights_alpha[i].value;
-
-		//Loop over beta weight points
-		for (size_t j = 0; j < weights_beta.size(); j++) {
-			dp[4] = weights_beta[j].value;
-
-			// Loop over thickness weight points
-			for (size_t k = 0; k < weights_thick.size(); k++) {
-				dp[2] = weights_thick[k].value;
-
-				// Loop over radius weight points
-				for (size_t l = 0; l < weights_rad.size(); l++) {
-					dp[1] = weights_rad[l].value;
-					sum += weights_rad[l].weight * weights_thick[k].weight
-							* weights_alpha[i].weight * weights_beta[j].weight
-							* pringle_form(dp, q);
-					//Find average volume
-					vol += weights_rad[l].weight * weights_thick[k].weight * Pi * pow(weights_rad[l].value, 2) * weights_thick[k].value;
-					volnorm += weights_rad[l].weight * weights_thick[k].weight;
-					norm +=  weights_rad[l].weight * weights_thick[k].weight * weights_alpha[i].weight * weights_beta[j].weight;
-
-				}
-			}
-		}
-	}
-
-	if (vol > 0.0 && norm > 0.0) {
-		//normalize by avg volume
-		sum = sum * (vol/volnorm);
-		return sum/norm + background();
-	} else {
-		return 0.0;
-	}
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double PringlesModel::operator()(double qx, double qy) {
-	double q = sqrt(qx * qx + qy * qy);
-	return (*this).operator()(q);
-}
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the model
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double PringlesModel::evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double PringlesModel::calculate_ER() {
-	PringleParameters dp;
-
-	dp.radius     = radius();
-	dp.thickness  = thickness();
-	double rad_out = 0.0;
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the major shell
-	vector<WeightPoint> weights_thick;
-	thickness.get_weights(weights_thick);
-
-	// Get the dispersion points for the minor shell
-	vector<WeightPoint> weights_radius ;
-	radius.get_weights(weights_radius);
-
-	// Loop over major shell weight points
-	for(int i=0; i< (int)weights_thick.size(); i++) {
-		dp.thickness = weights_thick[i].value;
-		for(int k=0; k< (int)weights_radius.size(); k++) {
-			dp.radius = weights_radius[k].value;
-			//Note: output of "DiamCyl(dp.thick,dp.radius)" is DIAMETER.
-			sum +=weights_thick[i].weight
-				* weights_radius[k].weight*DiamCyl(dp.thickness,dp.radius)/2.0;
-			norm += weights_thick[i].weight* weights_radius[k].weight;
-		}
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		//Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-		rad_out = DiamCyl(dp.thickness,dp.radius)/2.0;}
-
-	return rad_out;
-}
-/**
- * Function to calculate particle volume/total volume for shape models:
- *    Most case returns 1 but for example for the vesicle model it is
- *    (total volume - core volume)/total volume
- *    (< 1 depending on the thickness).
- * @return: effective radius value
- */
-double PringlesModel::calculate_VR() {
-	return 1.0;
-}
-
-/*
- * Useful work functions start here!
- *
- */
-
-static double pringle_form(double dp[], double q) {
-
-	double Pi;
-	int nord = 76, i=0;			//order of integration
-	double uplim, lolim;		//upper and lower integration limits
-	double summ, phi, yyy, answer, vcyl;			//running tally of integration
-	double delrho;
-
-	Pi = 4.0 * atan(1.0);
-	lolim = 0.0;
-	uplim = Pi / 2.0;
-
-	summ = 0.0;			//initialize integral
-
-	delrho = dp[5] - dp[6] ; //make contrast term
-
-	for (i = 0; i < nord; i++) {
-		phi = (Gauss76Z[i] * (uplim - lolim) + uplim + lolim) / 2.0;
-		yyy = Gauss76Wt[i] * pringle_kernel(dp, q, phi);
-		summ += yyy;
-	}
-
-	answer = (uplim - lolim) / 2.0 * summ;
-
-	answer *= delrho*delrho;
-
-    //normalize by cylinder volume
-	//vcyl=Pi*dp[1]*dp[1]*dp[2];
-	//answer *= vcyl;
-
-    //convert to [cm-1]
-	answer *= 1.0e8;
-
-    //Scale by volume fraction
-	answer *= dp[0];
-
-	return answer;
-}
-
-static double pringle_kernel(double dp[], double q, double phi) {
-
-	double sumterm, sincarg, sincterm, nn, retval;
-
-	sincarg = q * dp[2] * cos(phi) / 2.0; //dp[2] = thickness
-	sincterm = pow(sin(sincarg) / sincarg, 2.0);
-
-	//calculate sum term from n = -3 to 3
-	sumterm = 0;
-	for (nn = -3; nn <= 3; nn = nn + 1) {
-		sumterm = sumterm
-				+ (pow(pringleC(dp, q, phi, nn), 2.0)
-						+ pow(pringleS(dp, q, phi, nn), 2.0));
-	}
-
-	retval = 4.0 * sin(phi) * sumterm * sincterm;
-
-	return retval;
-
-}
-
-static double pringleC(double dp[], double q, double phi, double n) {
-
-	double nord, va, vb, summ;
-	double bessargs, cosarg, bessargcb;
-	double r, retval, yyy;
-	int ii;
-	// set up the integration
-	// end points and weights
-	nord = 76;
-	va = 0;
-	vb = dp[1]; //radius
-
-	// evaluate at Gauss points
-	// remember to index from 0,size-1
-
-	summ = 0.0;		// initialize integral
-	ii = 0;
-	do {
-		// Using 76 Gauss points
-		r = (Gauss76Z[ii] * (vb - va) + vb + va) / 2.0;
-
-		bessargs = q * r * sin(phi);
-		cosarg = q * r * r * dp[3] * cos(phi);
-		bessargcb = q * r * r * dp[4] * cos(phi);
-
-		yyy = Gauss76Wt[ii] * r * cos(cosarg) * jn(n, bessargcb)
-				* jn(2 * n, bessargs);
-		summ += yyy;
-
-		ii += 1;
-	} while (ii < nord);			// end of loop over quadrature points
-	//
-	// calculate value of integral to return
-
-	retval = (vb - va) / 2.0 * summ;
-
-	retval = retval / pow(r, 2.0);
-
-	return retval;
-}
-
-static double pringleS(double dp[], double q, double phi, double n) {
-
-	double nord, va, vb, summ;
-	double bessargs, sinarg, bessargcb;
-	double r, retval, yyy;
-	int ii;
-	// set up the integration
-	// end points and weights
-	nord = 76;
-	va = 0;
-	vb = dp[1]; //radius
-
-	// evaluate at Gauss points
-	// remember to index from 0,size-1
-
-	summ = 0.0;		// initialize integral
-	ii = 0;
-	do {
-		// Using 76 Gauss points
-		r = (Gauss76Z[ii] * (vb - va) + vb + va) / 2.0;
-
-		bessargs = q * r * sin(phi);
-		sinarg = q * r * r * dp[3] * cos(phi);
-		bessargcb = q * r * r * dp[4] * cos(phi);
-
-		yyy = Gauss76Wt[ii] * r * sin(sinarg) * jn(n, bessargcb)
-				* jn(2 * n, bessargs);
-
-		summ += yyy;
-
-		ii += 1;
-	} while (ii < nord);			// end of loop over quadrature points
-	//
-	// calculate value of integral to return
-
-	retval = (vb - va) / 2.0 * summ;
-
-	retval = retval / pow(r, 2.0);
-
-	return retval;
-}
Index: c/sans/models/src/c_models/raspberry.cpp
===================================================================
--- src/sans/models/src/c_models/raspberry.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,245 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "raspberry.h"
-
-// scattering
-// Modified from igor model: JHC - May 04, 2012
-//
-// you should write your function to calculate the intensity
-// for a single q-value (that's the input parameter x)
-// based on the wave (array) of parameters that you send it (w)
-// Ref: J. coll. inter. sci. (2010) vol. 343 (1) pp. 36-41.
-//  model calculation
-//
-static double raspberry_func(double dp[], double q){
-	// variables are:							
-	//[0] volume fraction large spheres
-	//[1] radius large sphere (A)
-	//[2] sld large sphere (A-2)
-	//[3] volume fraction small spheres
-	//[4] radius small sphere (A)
-	//[5] fraction of small spheres at surface
-	//[6] sld small sphere
-	//[7] small sphere penetration (A) 
-	//[8] sld solvent
-	//[9] background (cm-1)
-	double vfL, rL, sldL, vfS, rS, sldS, deltaS, delrhoL, delrhoS, bkg, sldSolv, aSs;
-	vfL = dp[0];
-	rL = dp[1];
-	sldL = dp[2];
-	vfS = dp[3];
-	rS = dp[4];
-	aSs = dp[5];
-	sldS = dp[6];
-	deltaS = dp[7];
-	sldSolv = dp[8];
-	bkg = dp[9];
-	
-	delrhoL = fabs(sldL - sldSolv);
-	delrhoS = fabs(sldS - sldSolv);	
-	
-	double VL, VS, Np, f2, fSs;
-	double pi = 4.0*atan(1.0);
-	  
-	VL = 4*pi/3*pow(rL,3.0);
-	VS = 4*pi/3*pow(rS,3.0);
-	Np = aSs*4.0*pow(((rL+deltaS)/rS), 2.0);
-	fSs = Np*vfL*VS/vfS/VL;
-	
-	double rasp_temp[8];
-	rasp_temp[0] = dp[0];
-	rasp_temp[1] = dp[1];
-	rasp_temp[2] = delrhoL;
-	rasp_temp[3] = dp[3];
-	rasp_temp[4] = dp[4];
-	rasp_temp[5] = dp[5];
-	rasp_temp[6] = delrhoS;
-	rasp_temp[7] = dp[7];
-
-	f2 = raspberry_kernel(rasp_temp,q);
-	f2+= vfS*(1.0-fSs)*pow(delrhoS, 2)*VS*rasp_bes(q,rS)*rasp_bes(q,rS);
-	
-	// normalize to single particle volume and convert to 1/cm
-	f2 *= 1.0e8;		// [=] 1/cm
-	
-	return (f2+bkg);	// Scale, then add in the background
-}
-
-double raspberry_kernel(double dp[], double q){
-	// variables are:							
-	//[0] volume fraction large spheres
-	//[1] radius large sphere (A)
-	//[2] sld large sphere (A-2)
-	//[3] volume fraction small spheres
-	//[4] radius small sphere (A)
-	//[5] fraction of small spheres at surface
-	//[6] sld small sphere
-	//[7] small sphere penetration (A) 
-
-	double vfL, rL, vfS, rS, deltaS;
-	double delrhoL, delrhoS, qval, aSs;
-	vfL = dp[0];
-	rL = dp[1];
-	delrhoL = dp[2];
-	vfS = dp[3];
-	rS = dp[4];
-	aSs = dp[5];
-	delrhoS = dp[6];
-	deltaS = dp[7];
-			
-	qval = q;		//rename the input q-value, purely for readability
-	double pi = 4.0*atan(1.0);
-		
-	double psiL,psiS,f2;
-	double sfLS,sfSS;
-	double VL,VS,slT,Np,fSs;
-
-	VL = 4.0*pi/3.0*pow(rL,3.0);
-	VS = 4.0*pi/3.0*pow(rS,3.0);
-
-	Np = aSs*4.0*(rS/(rL+deltaS))*VL/VS; 
-
-	fSs = Np*vfL*VS/vfS/VL;
-
-	slT = delrhoL*VL + Np*delrhoS*VS;
-
-	psiL = rasp_bes(qval,rL);
-	psiS = rasp_bes(qval,rS);
-
-	sfLS = psiL*psiS*(sin(qval*(rL+deltaS*rS))/qval/(rL+deltaS*rS));
-	sfSS = psiS*psiS*pow((sin(qval*(rL+deltaS*rS))/qval/(rL+deltaS*rS)),2);
-		
-	f2 = delrhoL*delrhoL*VL*VL*psiL*psiL; 
-	f2 += Np*delrhoS*delrhoS*VS*VS*psiS*psiS; 
-	f2 += Np*(Np-1)*delrhoS*delrhoS*VS*VS*sfSS; 
-	f2 += 2*Np*delrhoL*delrhoS*VL*VS*sfLS;
-	if (f2 != 0.0){
-		f2 = f2/slT/slT;
-	}
-
-	f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs*Np*delrhoS*delrhoS*VS);
-
-	return f2;
-}
-
-double rasp_bes(double qval, double rad){
-	double retval;
-	retval = 3.0*(sin(qval*rad)-qval*rad*cos(qval*rad))/(qval*qval*qval)/(rad*rad*rad);
-	return retval;
-}
-
-RaspBerryModel :: RaspBerryModel() {
-	volf_Lsph = Parameter(0.05);
-	radius_Lsph = Parameter(5000.0, true);
-	radius_Lsph.set_min(0.0);
-	sld_Lsph = Parameter(-4.0e-7);
-	volf_Ssph = Parameter(0.005);
-	radius_Ssph = Parameter(100.0, true);
-	radius_Ssph.set_min(0.0);
-	surfrac_Ssph = Parameter(0.4);
-	sld_Ssph = Parameter(3.5e-6);
-	delta_Ssph = Parameter(0.0);
-	sld_solv   = Parameter(6.3e-6);
-	background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double RaspBerryModel :: operator()(double q) {
-	double dp[10];
-	// Add the background after averaging
-	dp[0] = volf_Lsph();
-	dp[1] = radius_Lsph();
-	dp[2] = sld_Lsph();
-	dp[3] = volf_Ssph();
-	dp[4] = radius_Ssph();
-	dp[5] = surfrac_Ssph();
-	dp[6] = sld_Ssph();
-	dp[7] = delta_Ssph();
-	dp[8] = sld_solv();
-	dp[9] = 0.0;
-
-	// Get the dispersion points for the radius_Lsph
-	vector<WeightPoint> weights_radius_Lsph;
-	radius_Lsph.get_weights(weights_radius_Lsph);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	//double norm_vol = 0.0;
-	//double vol = 0.0;
-
-	// Loop over radius_Lsph weight points
-	for(size_t i=0; i<weights_radius_Lsph.size(); i++) {
-		dp[1] = weights_radius_Lsph[i].value;
-			//Un-normalize by volume
-			sum += weights_radius_Lsph[i].weight
-				* raspberry_func(dp, q);// * pow(weights_radius_Lsph[i].value,3.0);
-			//Find average volume 
-			//vol += weights_radius_Lsph[i].weight
-			//	* pow(weights_radius_Lsph[i].value,3.0);
-			norm += weights_radius_Lsph[i].weight;
-			//norm_vol += weights_radius_Lsph[i].weight;
-		}
-	
-	//if (vol != 0.0 && norm_vol != 0.0) {
-		//Re-normalize by avg volume
-		//sum = sum/(vol/norm_vol);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double RaspBerryModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-	return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters 
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double RaspBerryModel :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double RaspBerryModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double RaspBerryModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/refl.cpp
===================================================================
--- src/sans/models/src/c_models/refl.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,303 +1,0 @@
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-#include "refl.h"
-using namespace std;
-
-extern "C" {
-#include "libmultifunc/librefl.h"
-}
-
-#define lamda 4.62
-
-static double re_kernel(double dp[], double q) {
-  int n = dp[0];
-  int i,j;
-
-  double scale = dp[1];
-  double thick_inter_sub = dp[2];
-  double sld_sub = dp[4];
-  double sld_super = dp[5];
-  double background = dp[6];
-
-  double total_thick=0.0;
-  double nsl=21.0; //nsl = Num_sub_layer:
-  int n_s;
-  double sld_i,dz,phi,R,ko2;
-  double fun;
-  double pi;
-
-  double* sld;
-  double* thick_inter;
-  double* thick;
-  int*fun_type;
-  complex  phi1,alpha,alpha2,kn,fnm,fnp,rn,Xn,nn,nn2,an,nnp1,one,two,n_sub,n_sup,knp1,Xnp1;
-
-  sld = (double*)malloc((n+2)*sizeof(double));
-  thick_inter = (double*)malloc((n+2)*sizeof(double));
-  thick = (double*)malloc((n+2)*sizeof(double));
-  fun_type = (int*)malloc((n+2)*sizeof(int));
-
-  fun_type[0] = dp[3];
-  for (i =1; i<=n; i++){
-    sld[i] = dp[i+6];
-    thick_inter[i]= dp[i+16];
-    thick[i] = dp[i+26];
-    fun_type[i] = dp[i+36];
-    total_thick += thick[i] + thick_inter[i];
-  }
-  sld[0] = sld_sub;
-  sld[n+1] = sld_super;
-
-  thick[0] = total_thick/5.0;
-  thick[n+1] = total_thick/5.0;
-  thick_inter[0] = thick_inter_sub;
-  thick_inter[n+1] = 0.0;
-
-  pi = 4.0*atan(1.0);
-  Xn = cassign(0.0,0.0);
-  one = cassign(1.0,0.0);
-  two = cassign(0.0,-2.0);
-
-  //Checking if floor is available.
-  //no imaginary sld inputs in this function yet
-  n_sub=cassign(1.0-sld_sub*pow(lamda,2.0)/(2.0*pi),0.0);
-  n_sup=cassign(1.0-sld_super*pow(lamda,2.0)/(2.0*pi),0.0);
-  ko2 = pow(2.0*pi/lamda,2.0);
-
-  phi = asin(lamda*q/(4.0*pi));
-  phi1 = cplx_div(rcmult(phi,one),n_sup);
-  alpha = cplx_mult(n_sup,cplx_cos(phi1));
-  alpha2 = cplx_mult(alpha,alpha);
-
-  nnp1=n_sub;
-  knp1=cplx_sqrt(rcmult(ko2,cplx_sub(cplx_mult(nnp1,nnp1),alpha2)));  //nnp1*ko*sin(phinp1)
-  Xnp1=cassign(0.0,0.0);
-  dz = 0.0;
-  // iteration for # of layers +sub from the top
-  for (i=1;i<=n+1; i++){
-    if (fun_type[i-1]==1)
-      fun = 5;
-    else
-      fun = 0;
-    //iteration for 9 sub-layers
-    for (j=0;j<2;j++){
-      for (n_s=0;n_s<nsl; n_s++){
-        if (j==1){
-          if (i==n+1)
-            break;
-          dz = thick[i];
-          sld_i = sld[i];
-        }
-        else{
-          dz = thick_inter[i-1]/nsl;//nsl;
-          if (sld[i-1] == sld[i]){
-            sld_i = sld[i];
-          }
-          else{
-            sld_i = intersldfunc(fun,nsl, n_s+0.5, 2.5, sld[i-1], sld[i]);
-          }
-        }
-        nn = cassign(1.0-sld_i*pow(lamda,2.0)/(2.0*pi),0.0);
-        nn2=cplx_mult(nn,nn);
-
-        kn=cplx_sqrt(rcmult(ko2,cplx_sub(nn2,alpha2)));        //nn*ko*sin(phin)
-        an=cplx_exp(rcmult(dz,cplx_mult(two,kn)));
-
-        fnm=cplx_sub(kn,knp1);
-        fnp=cplx_add(kn,knp1);
-        rn=cplx_div(fnm,fnp);
-        Xn=cplx_mult(an,cplx_div(cplx_add(rn,Xnp1),cplx_add(one,cplx_mult(rn,Xnp1))));    //Xn=an*((rn+Xnp1*anp1)/(1+rn*Xnp1*anp1))
-
-        Xnp1=Xn;
-        knp1=kn;
-
-        if (j==1)
-          break;
-      }
-    }
-  }
-  R=pow(Xn.re,2.0)+pow(Xn.im,2.0);
-  // This temperarily fixes the total reflection for Rfunction and linear.
-  // ToDo: Show why it happens that Xn.re=0 and Xn.im >1!
-  if (Xn.im == 0.0){
-    R=1.0;
-  }
-  R *= scale;
-  R += background;
-
-  free(sld);
-  free(thick_inter);
-  free(thick);
-  free(fun_type);
-
-  return R;
-
-}
-ReflModel :: ReflModel() {
-  n_layers = Parameter(1.0);
-  scale = Parameter(1.0);
-  thick_inter0 = Parameter(1.0);
-  func_inter0 = Parameter(0);
-  sld_bottom0 = Parameter(2.07e-06);
-  sld_medium = Parameter(1.0e-06);
-  background = Parameter(0.0);
-
-
-  sld_flat1 = Parameter(3.0e-06);
-  sld_flat2 = Parameter(3.5e-06);
-  sld_flat3 = Parameter(4.0e-06);
-  sld_flat4 = Parameter(3.5e-06);
-  sld_flat5 = Parameter(4.0e-06);
-  sld_flat6 = Parameter(3.5e-06);
-  sld_flat7 = Parameter(4.0e-06);
-  sld_flat8 = Parameter(3.5e-06);
-  sld_flat9 = Parameter(4.0e-06);
-  sld_flat10 = Parameter(3.5e-06);
-
-
-  thick_inter1 = Parameter(1);
-  thick_inter2 = Parameter(1);
-  thick_inter3 = Parameter(1);
-  thick_inter4 = Parameter(1);
-  thick_inter5 = Parameter(1);
-  thick_inter6 = Parameter(1);
-  thick_inter7 = Parameter(1);
-  thick_inter8 = Parameter(1);
-  thick_inter9 = Parameter(1);
-  thick_inter10 = Parameter(1);
-
-
-  thick_flat1 = Parameter(15);
-  thick_flat2 = Parameter(100);
-  thick_flat3 = Parameter(100);
-  thick_flat4 = Parameter(100);
-  thick_flat5 = Parameter(100);
-  thick_flat6 = Parameter(100);
-  thick_flat7 = Parameter(100);
-  thick_flat8 = Parameter(100);
-  thick_flat9 = Parameter(100);
-  thick_flat10 = Parameter(100);
-
-
-  func_inter1 = Parameter(0);
-  func_inter2 = Parameter(0);
-  func_inter3 = Parameter(0);
-  func_inter4 = Parameter(0);
-  func_inter5 = Parameter(0);
-  func_inter6 = Parameter(0);
-  func_inter7 = Parameter(0);
-  func_inter8 = Parameter(0);
-  func_inter9 = Parameter(0);
-  func_inter10 = Parameter(0);
-
-}
-
-/**
- * Function to evaluate 1D NR function
- * @param q: q-value
- * @return: function value
- */
-double ReflModel :: operator()(double q) {
-  double dp[47];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = n_layers();
-  dp[1] = scale();
-  dp[2] = thick_inter0();
-  dp[3] = func_inter0();
-  dp[4] = sld_bottom0();
-  dp[5] = sld_medium();
-  dp[6] = background();
-
-  dp[7] = sld_flat1();
-  dp[8] = sld_flat2();
-  dp[9] = sld_flat3();
-  dp[10] = sld_flat4();
-  dp[11] = sld_flat5();
-  dp[12] = sld_flat6();
-  dp[13] = sld_flat7();
-  dp[14] = sld_flat8();
-  dp[15] = sld_flat9();
-  dp[16] = sld_flat10();
-
-  dp[17] = thick_inter1();
-  dp[18] = thick_inter2();
-  dp[19] = thick_inter3();
-  dp[20] = thick_inter4();
-  dp[21] = thick_inter5();
-  dp[22] = thick_inter6();
-  dp[23] = thick_inter7();
-  dp[24] = thick_inter8();
-  dp[25] = thick_inter9();
-  dp[26] = thick_inter10();
-
-  dp[27] = thick_flat1();
-  dp[28] = thick_flat2();
-  dp[29] = thick_flat3();
-  dp[30] = thick_flat4();
-  dp[31] = thick_flat5();
-  dp[32] = thick_flat6();
-  dp[33] = thick_flat7();
-  dp[34] = thick_flat8();
-  dp[35] = thick_flat9();
-  dp[36] = thick_flat10();
-
-  dp[37] = func_inter1();
-  dp[38] = func_inter2();
-  dp[39] = func_inter3();
-  dp[40] = func_inter4();
-  dp[41] = func_inter5();
-  dp[42] = func_inter6();
-  dp[43] = func_inter7();
-  dp[44] = func_inter8();
-  dp[45] = func_inter9();
-  dp[46] = func_inter10();
-
-  // Get the dispersion points for the radius
-  //vector<WeightPoint> weights_thick;
-  //thick_inter0.get_weights(weights_thick_inter0);
-
-
-  return re_kernel(dp,q);
-}
-
-/**
- * Function to evaluate 2D NR function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double ReflModel :: operator()(double qx, double qy) {
-  // For 2D set qy as q, ignoring qx.
-  double q = qy;//sqrt(qx*qx + qy*qy);
-  if (q < 0.0){
-    return 0.0;
-  }
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D NR function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double ReflModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double ReflModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double ReflModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/refl_adv.cpp
===================================================================
--- src/sans/models/src/c_models/refl_adv.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,381 +1,0 @@
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-#include "refl_adv.h"
-
-extern "C" {
-#include "libmultifunc/librefl.h"
-}
-
-using namespace std;
-
-#define lamda 4.62
-
-
-double re_adv_kernel(double dp[], double q) {
-  int n = dp[0];
-  int i,j;
-  double nsl;
-
-  double scale = dp[1];
-  double thick_inter_sub = dp[2];
-  double sld_sub = dp[4];
-  double sld_super = dp[5];
-  double background = dp[6];
-  double npts = dp[69]; //number of sub_layers in each interface
-
-  double total_thick=0.0;
-
-  int n_s;
-  double sld_i,sldim_i,dz,phi,R,ko2;
-  double pi;
-
-  int* fun_type;
-  double* sld;
-  double* sld_im;
-  double* thick_inter;
-  double* thick;
-  double* fun_coef;
-  complex  phi1,alpha,alpha2,kn,fnm,fnp,rn,Xn,nn,nn2,an,nnp1,one,two,n_sub,n_sup,knp1,Xnp1;
-
-  fun_type = (int*)malloc((n+2)*sizeof(int));
-  sld = (double*)malloc((n+2)*sizeof(double));
-  sld_im = (double*)malloc((n+2)*sizeof(double));
-  thick_inter = (double*)malloc((n+2)*sizeof(double));
-  thick = (double*)malloc((n+2)*sizeof(double));
-  fun_coef = (double*)malloc((n+2)*sizeof(double));
-
-  fun_type[0] = dp[3];
-  fun_coef[0] = fabs(dp[70]);
-  for (i =1; i<=n; i++){
-    sld[i] = dp[i+6];
-    thick_inter[i]= dp[i+16];
-    thick[i] = dp[i+26];
-    fun_type[i] = dp[i+36];
-    sld_im[i] = dp[i+46];
-    fun_coef[i] = fabs(dp[i+56]);
-    //printf("type_func2 =%g\n",fun_coef[i]);
-
-    total_thick += thick[i] + thick_inter[i];
-  }
-  sld[0] = sld_sub;
-  sld[n+1] = sld_super;
-  sld_im[0] = fabs(dp[1+66]);
-  sld_im[n+1] = fabs(dp[2+66]);
-  thick[0] = total_thick/5.0;
-  thick[n+1] = total_thick/5.0;
-  thick_inter[0] = thick_inter_sub;
-  thick_inter[n+1] = 0.0;
-  fun_coef[n+1] = 0.0;
-
-  nsl=npts;//21.0; //nsl = Num_sub_layer:  MUST ODD number in double //no other number works now
-
-  pi = 4.0*atan(1.0);
-  one = cassign(1.0,0.0);
-  Xn = cassign(0.0,0.0);
-  two = cassign(0.0,-2.0);
-
-  //Checking if floor is available.
-  //no imaginary sld inputs in this function yet
-  n_sub=cassign(1.0-sld_sub*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sld_im[0]);
-  n_sup=cassign(1.0-sld_super*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sld_im[n+1]);
-  ko2 = pow(2.0*pi/lamda,2.0);
-
-  phi = asin(lamda*q/(4.0*pi));
-  phi1 = cplx_div(rcmult(phi,one),n_sup);
-  alpha = cplx_mult(n_sup,cplx_cos(phi1));
-  alpha2 = cplx_mult(alpha,alpha);
-
-  nnp1=n_sub;
-  knp1=cplx_sqrt(rcmult(ko2,cplx_sub(cplx_mult(nnp1,nnp1),alpha2)));  //nnp1*ko*sin(phinp1)
-  Xnp1=cassign(0.0,0.0);
-  dz = 0.0;
-  // iteration for # of layers +sub from the top
-  for (i=1;i<=n+1; i++){
-    //if (fun_coef[i]==0.0)
-    //  // this condition protects an error in numerical multiplication
-    //  fun_coef[i] = 1e-14;
-    //iteration for 9 sub-layers
-    for (j=0;j<2;j++){
-      for (n_s=0;n_s<nsl; n_s++){
-        // for flat layer
-        if (j==1){
-          if (i==n+1)
-            break;
-          dz = thick[i];
-          sld_i = sld[i];
-          sldim_i = sld_im[i];
-        }
-        // for interface
-        else{
-          dz = thick_inter[i-1]/nsl;
-          if (sld[i-1] == sld[i]){
-            sld_i = sld[i];
-          }
-          else{
-            sld_i = intersldfunc(fun_type[i-1],nsl, n_s+0.5, fun_coef[i-1], sld[i-1], sld[i]);
-          }
-          if (sld_im[i-1] == sld_im[i]){
-            sldim_i = sld_im[i];
-          }
-          else{
-            sldim_i = intersldfunc(fun_type[i-1],nsl, n_s+0.5, fun_coef[i-1], sld_im[i-1], sld_im[i]);
-          }
-        }
-        nn = cassign(1.0-sld_i*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sldim_i);
-        nn2=cplx_mult(nn,nn);
-
-        kn=cplx_sqrt(rcmult(ko2,cplx_sub(nn2,alpha2)));        //nn*ko*sin(phin)
-        an=cplx_exp(rcmult(dz,cplx_mult(two,kn)));
-
-        fnm=cplx_sub(kn,knp1);
-        fnp=cplx_add(kn,knp1);
-        rn=cplx_div(fnm,fnp);
-        Xn=cplx_mult(an,cplx_div(cplx_add(rn,Xnp1),cplx_add(one,cplx_mult(rn,Xnp1))));    //Xn=an*((rn+Xnp1*anp1)/(1+rn*Xnp1*anp1))
-
-        Xnp1=Xn;
-        knp1=kn;
-        // no for-loop for flat layer
-        if (j==1)
-          break;
-      }
-    }
-  }
-  R=pow(Xn.re,2.0)+pow(Xn.im,2.0);
-  // This temperarily fixes the total reflection for Rfunction and linear.
-  // ToDo: Show why it happens that Xn.re=0 and Xn.im >1!
-  if (Xn.im == 0.0 || R > 1){
-    R=1.0;
-  }
-  R *= scale;
-  R += background;
-
-  free(fun_type);
-  free(sld);
-  free(sld_im);
-  free(thick_inter);
-  free(thick);
-  free(fun_coef);
-
-  return R;
-
-}
-ReflAdvModel :: ReflAdvModel() {
-  n_layers = Parameter(1.0);
-  scale = Parameter(1.0);
-  thick_inter0 = Parameter(1.0);
-  func_inter0 = Parameter(0);
-  sld_bottom0 = Parameter(2.07e-06);
-  sld_medium = Parameter(1.0e-06);
-  background = Parameter(0.0);
-
-
-  sld_flat1 = Parameter(2.7e-06);
-  sld_flat2 = Parameter(3.5e-06);
-  sld_flat3 = Parameter(4.0e-06);
-  sld_flat4 = Parameter(3.5e-06);
-  sld_flat5 = Parameter(4.0e-06);
-  sld_flat6 = Parameter(3.5e-06);
-  sld_flat7 = Parameter(4.0e-06);
-  sld_flat8 = Parameter(3.5e-06);
-  sld_flat9 = Parameter(4.0e-06);
-  sld_flat10 = Parameter(3.5e-06);
-
-
-  thick_inter1 = Parameter(1.0);
-  thick_inter2 = Parameter(1.0);
-  thick_inter3 = Parameter(1.0);
-  thick_inter4 = Parameter(1.0);
-  thick_inter5 = Parameter(1.0);
-  thick_inter6 = Parameter(1.0);
-  thick_inter7 = Parameter(1.0);
-  thick_inter8 = Parameter(1.0);
-  thick_inter9 = Parameter(1.0);
-  thick_inter10 = Parameter(1.0);
-
-
-  thick_flat1 = Parameter(15.0);
-  thick_flat2 = Parameter(100.0);
-  thick_flat3 = Parameter(100.0);
-  thick_flat4 = Parameter(100.0);
-  thick_flat5 = Parameter(100.0);
-  thick_flat6 = Parameter(100.0);
-  thick_flat7 = Parameter(100.0);
-  thick_flat8 = Parameter(100.0);
-  thick_flat9 = Parameter(100.0);
-  thick_flat10 = Parameter(100.0);
-
-
-  func_inter1 = Parameter(0);
-  func_inter2 = Parameter(0);
-  func_inter3 = Parameter(0);
-  func_inter4 = Parameter(0);
-  func_inter5 = Parameter(0);
-  func_inter6 = Parameter(0);
-  func_inter7 = Parameter(0);
-  func_inter8 = Parameter(0);
-  func_inter9 = Parameter(0);
-  func_inter10 = Parameter(0);
-
-  sldIM_flat1 = Parameter(0);
-  sldIM_flat2 = Parameter(0);
-  sldIM_flat3 = Parameter(0);
-  sldIM_flat4 = Parameter(0);
-  sldIM_flat5 = Parameter(0);
-  sldIM_flat6 = Parameter(0);
-  sldIM_flat7 = Parameter(0);
-  sldIM_flat8 = Parameter(0);
-  sldIM_flat9 = Parameter(0);
-  sldIM_flat10 = Parameter(0);
-
-  nu_inter1 = Parameter(2.5);
-  nu_inter2 = Parameter(2.5);
-  nu_inter3 = Parameter(2.5);
-  nu_inter4 = Parameter(2.5);
-  nu_inter5 = Parameter(2.5);
-  nu_inter6 = Parameter(2.5);
-  nu_inter7 = Parameter(2.5);
-  nu_inter8 = Parameter(2.5);
-  nu_inter9 = Parameter(2.5);
-  nu_inter10 = Parameter(2.5);
-
-  sldIM_sub0 = Parameter(0.0);
-  sldIM_medium = Parameter(0.0);
-  npts_inter = Parameter(21.0);
-  nu_inter0 = Parameter(2.5);
-}
-
-/**
- * Function to evaluate 1D NR function
- * @param q: q-value
- * @return: function value
- */
-double ReflAdvModel :: operator()(double q) {
-  double dp[71];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = n_layers();
-  dp[1] = scale();
-  dp[2] = thick_inter0();
-  dp[3] = func_inter0();
-  dp[4] = sld_bottom0();
-  dp[5] = sld_medium();
-  dp[6] = background();
-
-  dp[7] = sld_flat1();
-  dp[8] = sld_flat2();
-  dp[9] = sld_flat3();
-  dp[10] = sld_flat4();
-  dp[11] = sld_flat5();
-  dp[12] = sld_flat6();
-  dp[13] = sld_flat7();
-  dp[14] = sld_flat8();
-  dp[15] = sld_flat9();
-  dp[16] = sld_flat10();
-
-  dp[17] = thick_inter1();
-  dp[18] = thick_inter2();
-  dp[19] = thick_inter3();
-  dp[20] = thick_inter4();
-  dp[21] = thick_inter5();
-  dp[22] = thick_inter6();
-  dp[23] = thick_inter7();
-  dp[24] = thick_inter8();
-  dp[25] = thick_inter9();
-  dp[26] = thick_inter10();
-
-  dp[27] = thick_flat1();
-  dp[28] = thick_flat2();
-  dp[29] = thick_flat3();
-  dp[30] = thick_flat4();
-  dp[31] = thick_flat5();
-  dp[32] = thick_flat6();
-  dp[33] = thick_flat7();
-  dp[34] = thick_flat8();
-  dp[35] = thick_flat9();
-  dp[36] = thick_flat10();
-
-  dp[37] = func_inter1();
-  dp[38] = func_inter2();
-  dp[39] = func_inter3();
-  dp[40] = func_inter4();
-  dp[41] = func_inter5();
-  dp[42] = func_inter6();
-  dp[43] = func_inter7();
-  dp[44] = func_inter8();
-  dp[45] = func_inter9();
-  dp[46] = func_inter10();
-
-  dp[47] = sldIM_flat1();
-  dp[48] = sldIM_flat2();
-  dp[49] = sldIM_flat3();
-  dp[50] = sldIM_flat4();
-  dp[51] = sldIM_flat5();
-  dp[52] = sldIM_flat6();
-  dp[53] = sldIM_flat7();
-  dp[54] = sldIM_flat8();
-  dp[55] = sldIM_flat9();
-  dp[56] = sldIM_flat10();
-
-  dp[57] = nu_inter1();
-  dp[58] = nu_inter2();
-  dp[59] = nu_inter3();
-  dp[60] = nu_inter4();
-  dp[61] = nu_inter5();
-  dp[62] = nu_inter6();
-  dp[63] = nu_inter7();
-  dp[64] = nu_inter8();
-  dp[65] = nu_inter9();
-  dp[66] = nu_inter10();
-
-  dp[67] = sldIM_sub0();
-  dp[68] = sldIM_medium();
-  dp[69] = npts_inter();
-  dp[70] = nu_inter0();
-  // Get the dispersion points for the radius
-  //vector<WeightPoint> weights_thick;
-  //thick_inter0.get_weights(weights_thick_inter0);
-
-
-  return re_adv_kernel(dp,q);
-}
-
-/**
- * Function to evaluate 2D NR function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double ReflAdvModel :: operator()(double qx, double qy) {
-  // For 2D set qy as q, ignoring qx.
-  double q = qy;//sqrt(qx*qx + qy*qy);
-  if (q < 0.0){
-    return 0.0;
-  }
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D NR function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double ReflAdvModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double ReflAdvModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double ReflAdvModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/rpa.cpp
===================================================================
--- src/sans/models/src/c_models/rpa.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,542 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include "rpa.h"
-
-using namespace std;
-
-static double rpa_kernel(double dp[], double q) {
-  int lCASE = dp[0];
-
-  double Na,Nb,Nc,Nd,Nab,Nac,Nad,Nbc,Nbd,Ncd;
-  double Phia,Phib,Phic,Phid,Phiab,Phiac,Phiad;
-  double Phibc,Phibd,Phicd;
-  double va,vb,vc,vd,vab,vac,vad,vbc,vbd,vcd;
-  double m;
-  double ba,bb,bc,bd;
-  double Xa,Xb,Xc,Xd;
-  double Paa,S0aa,Pab,S0ab,Pac,S0ac,Pad,S0ad;
-  double S0ba,Pbb,S0bb,Pbc,S0bc,Pbd,S0bd;
-  double S0ca,S0cb,Pcc,S0cc,Pcd,S0cd;
-  double S0da,S0db,S0dc,Pdd,S0dd;
-  double Kaa,Kab,Kac,Kad,Kba,Kbb,Kbc,Kbd;
-  double Kca,Kcb,Kcc,Kcd,Kda,Kdb,Kdc,Kdd;
-  double Zaa,Zab,Zac,Zba,Zbb,Zbc,Zca,Zcb,Zcc;
-  double DenT,T11,T12,T13,T21,T22,T23,T31,T32,T33;
-  double Y1,Y2,Y3,X11,X12,X13,X21,X22,X23,X31,X32,X33;
-  double ZZ,DenQ1,DenQ2,DenQ3,DenQ,Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33;
-  double N11,N12,N13,N21,N22,N23,N31,N32,N33;
-  double M11,M12,M13,M21,M22,M23,M31,M32,M33;
-  double S11,S12,S13,S14,S21,S22,S23,S24;
-  double S31,S32,S33,S34,S41,S42,S43,S44;
-  double La,Lb,Lc,Ld,Lad,Lbd,Lcd,Nav,Intg;
-  double scale, background;
-
-  int ii=13;  //dp[ii<13] = fittable, else fixed
-
-  Na=1000.0;
-  Nb=1000.0;
-  Nc=1000.0;
-  Nd=1000.0;  //DEGREE OF POLYMERIZATION
-  Phia=0.25;
-  Phib=0.25;
-  Phic=0.25;
-  Phid=0.25 ; //VOL FRACTION
-  Kab=-0.0004;
-  Kac=-0.0004;
-  Kad=-0.0004;  //CHI PARAM
-  Kbc=-0.0004;
-  Kbd=-0.0004;
-  Kcd=-0.0004;
-  La=1.0e-12;
-  Lb=1.0e-12;
-  Lc=1.0e-12;
-  Ld=0.0e-12;   //SCATT. LENGTH
-  va=100.0;
-  vb=100.0;
-  vc=100.0;
-  vd=100.0  ; //SPECIFIC VOLUME
-  ba=5.0;
-  bb=5.0;
-  bc=5.0;
-  bd=5.0;   //SEGMENT LENGTH
-
-  //lCASE was shifted to N-1 from the original code
-  if (lCASE <= 1){
-    Phia=0.0000001;
-    Phib=0.0000001;
-    Phic=0.5;
-    Phid=0.5;
-    Nc=dp[ii+8];
-    Phic=dp[ii+9];
-    vc=dp[ii+10];
-    Lc=dp[ii+11];
-    bc=dp[3];
-    Nd=dp[ii+12];
-    Phid=dp[ii+13];
-    vd=dp[ii+14];
-    Ld=dp[ii+15];
-    bd=dp[4];
-    Kcd=dp[10];
-    scale=dp[11];
-    background=dp[12];
-  }
-  else if ((lCASE > 1) && (lCASE <= 4)){
-    Phia=0.0000001;
-    Phib=0.333333;
-    Phic=0.333333;
-    Phid=0.333333;
-    Nb=dp[ii+4];
-    Phib=dp[ii+5];
-    vb=dp[ii+6];
-    Lb=dp[ii+7];
-    bb=dp[2];
-    Nc=dp[ii+8];
-    Phic=dp[ii+9];
-    vc=dp[ii+10];
-    Lc=dp[ii+11];
-    bc=dp[3];
-    Nd=dp[ii+12];
-    Phid=dp[ii+13];
-    vd=dp[ii+14];
-    Ld=dp[ii+15];
-    bd=dp[4];
-    Kbc=dp[8];
-    Kbd=dp[9];
-    Kcd=dp[10];
-    scale=dp[11];
-    background=dp[12];
-  }
-  else {
-    Phia=0.25;
-    Phib=0.25;
-    Phic=0.25;
-    Phid=0.25;
-    Na=dp[ii+0];
-    Phia=dp[ii+1];
-    va=dp[ii+2];
-    La=dp[ii+3];
-    ba=dp[1];
-    Nb=dp[ii+4];
-    Phib=dp[ii+5];
-    vb=dp[ii+6];
-    Lb=dp[ii+7];
-    bb=dp[2];
-    Nc=dp[ii+8];
-    Phic=dp[ii+9];
-    vc=dp[ii+10];
-    Lc=dp[ii+11];
-    bc=dp[3];
-    Nd=dp[ii+12];
-    Phid=dp[ii+13];
-    vd=dp[ii+14];
-    Ld=dp[ii+15];
-    bd=dp[4];
-    Kab=dp[5];
-    Kac=dp[6];
-    Kad=dp[7];
-    Kbc=dp[8];
-    Kbd=dp[9];
-    Kcd=dp[10];
-    scale=dp[11];
-    background=dp[12];
-  }
-
-  Nab=pow((Na*Nb),(0.5));
-  Nac=pow((Na*Nc),(0.5));
-  Nad=pow((Na*Nd),(0.5));
-  Nbc=pow((Nb*Nc),(0.5));
-  Nbd=pow((Nb*Nd),(0.5));
-  Ncd=pow((Nc*Nd),(0.5));
-
-  vab=pow((va*vb),(0.5));
-  vac=pow((va*vc),(0.5));
-  vad=pow((va*vd),(0.5));
-  vbc=pow((vb*vc),(0.5));
-  vbd=pow((vb*vd),(0.5));
-  vcd=pow((vc*vd),(0.5));
-
-  Phiab=pow((Phia*Phib),(0.5));
-  Phiac=pow((Phia*Phic),(0.5));
-  Phiad=pow((Phia*Phid),(0.5));
-  Phibc=pow((Phib*Phic),(0.5));
-  Phibd=pow((Phib*Phid),(0.5));
-  Phicd=pow((Phic*Phid),(0.5));
-
-  Xa=q*q*ba*ba*Na/6.0;
-  Xb=q*q*bb*bb*Nb/6.0;
-  Xc=q*q*bc*bb*Nc/6.0;
-  Xd=q*q*bd*bb*Nd/6.0;
-
-  Paa=2.0*(exp(-Xa)-1.0+Xa)/pow(Xa,2.0);
-  S0aa=Na*Phia*va*Paa;
-  Pab=((1.0-exp(-Xa))/Xa)*((1.0-exp(-Xb))/Xb);
-  S0ab=(Phiab*vab*Nab)*Pab;
-  Pac=((1.0-exp(-Xa))/Xa)*exp(-Xb)*((1.0-exp(-Xc))/Xc);
-  S0ac=(Phiac*vac*Nac)*Pac;
-  Pad=((1.0-exp(-Xa))/Xa)*exp(-Xb-Xc)*((1.0-exp(-Xd))/Xd);
-  S0ad=(Phiad*vad*Nad)*Pad;
-
-  S0ba=S0ab;
-  Pbb=2.0*(exp(-Xb)-1.0+Xb)/pow(Xb,2.0);
-  S0bb=Nb*Phib*vb*Pbb;
-  Pbc=((1.0-exp(-Xb))/Xb)*((1.0-exp(-Xc))/Xc);
-  S0bc=(Phibc*vbc*Nbc)*Pbc;
-  Pbd=((1.0-exp(-Xb))/Xb)*exp(-Xc)*((1.0-exp(-Xd))/Xd);
-  S0bd=(Phibd*vbd*Nbd)*Pbd;
-
-  S0ca=S0ac;
-  S0cb=S0bc;
-  Pcc=2.0*(exp(-Xc)-1.0+Xc)/pow(Xc,2.0);
-  S0cc=Nc*Phic*vc*Pcc;
-  Pcd=((1.0-exp(-Xc))/Xc)*((1.0-exp(-Xd))/Xd);
-  S0cd=(Phicd*vcd*Ncd)*Pcd;
-
-  S0da=S0ad;
-  S0db=S0bd;
-  S0dc=S0cd;
-  Pdd=2.0*(exp(-Xd)-1.0+Xd)/pow(Xd,2.0);
-  S0dd=Nd*Phid*vd*Pdd;
-  //lCASE was shifted to N-1 from the original code
-  switch(lCASE){
-  case 0:
-    S0aa=0.000001;
-    S0ab=0.000002;
-    S0ac=0.000003;
-    S0ad=0.000004;
-    S0bb=0.000005;
-    S0bc=0.000006;
-    S0bd=0.000007;
-    S0cd=0.000008;
-    break;
-  case 1:
-    S0aa=0.000001;
-    S0ab=0.000002;
-    S0ac=0.000003;
-    S0ad=0.000004;
-    S0bb=0.000005;
-    S0bc=0.000006;
-    S0bd=0.000007;
-    break;
-  case 2:
-    S0aa=0.000001;
-    S0ab=0.000002;
-    S0ac=0.000003;
-    S0ad=0.000004;
-    S0bc=0.000005;
-    S0bd=0.000006;
-    S0cd=0.000007;
-    break;
-  case 3:
-    S0aa=0.000001;
-    S0ab=0.000002;
-    S0ac=0.000003;
-    S0ad=0.000004;
-    S0bc=0.000005;
-    S0bd=0.000006;
-    break;
-  case 4:
-    S0aa=0.000001;
-    S0ab=0.000002;
-    S0ac=0.000003;
-    S0ad=0.000004;
-    break;
-  case 5:
-    S0ab=0.000001;
-    S0ac=0.000002;
-    S0ad=0.000003;
-    S0bc=0.000004;
-    S0bd=0.000005;
-    S0cd=0.000006;
-    break;
-  case 6:
-    S0ab=0.000001;
-    S0ac=0.000002;
-    S0ad=0.000003;
-    S0bc=0.000004;
-    S0bd=0.000005;
-    break;
-  case 7:
-    S0ab=0.000001;
-    S0ac=0.000002;
-    S0ad=0.000003;
-    break;
-  case 8:
-    S0ac=0.000001;
-    S0ad=0.000002;
-    S0bc=0.000003;
-    S0bd=0.000004;
-    break;
-  default : //case 9:
-    break;
-  }
-  S0ba=S0ab;
-  S0ca=S0ac;
-  S0cb=S0bc;
-  S0da=S0ad;
-  S0db=S0bd;
-  S0dc=S0cd;
-
-  Kaa=0.0;
-  Kbb=0.0;
-  Kcc=0.0;
-  Kdd=0.0;
-
-  Kba=Kab;
-  Kca=Kac;
-  Kcb=Kbc;
-  Kda=Kad;
-  Kdb=Kbd;
-  Kdc=Kcd;
-
-  Zaa=Kaa-Kad-Kad;
-  Zab=Kab-Kad-Kbd;
-  Zac=Kac-Kad-Kcd;
-  Zba=Kba-Kbd-Kad;
-  Zbb=Kbb-Kbd-Kbd;
-  Zbc=Kbc-Kbd-Kcd;
-  Zca=Kca-Kcd-Kad;
-  Zcb=Kcb-Kcd-Kbd;
-  Zcc=Kcc-Kcd-Kcd;
-
-  DenT=(-(S0ac*S0bb*S0ca) + S0ab*S0bc*S0ca + S0ac*S0ba*S0cb - S0aa*S0bc*S0cb - S0ab*S0ba*S0cc + S0aa*S0bb*S0cc);
-
-  T11= (-(S0bc*S0cb) + S0bb*S0cc)/DenT;
-  T12= (S0ac*S0cb - S0ab*S0cc)/DenT;
-  T13= (-(S0ac*S0bb) + S0ab*S0bc)/DenT;
-  T21= (S0bc*S0ca - S0ba*S0cc)/DenT;
-  T22= (-(S0ac*S0ca) + S0aa*S0cc)/DenT;
-  T23= (S0ac*S0ba - S0aa*S0bc)/DenT;
-  T31= (-(S0bb*S0ca) + S0ba*S0cb)/DenT;
-  T32= (S0ab*S0ca - S0aa*S0cb)/DenT;
-  T33= (-(S0ab*S0ba) + S0aa*S0bb)/DenT;
-
-  Y1=T11*S0ad+T12*S0bd+T13*S0cd+1.0;
-  Y2=T21*S0ad+T22*S0bd+T23*S0cd+1.0;
-  Y3=T31*S0ad+T32*S0bd+T33*S0cd+1.0;
-
-  X11=Y1*Y1;
-  X12=Y1*Y2;
-  X13=Y1*Y3;
-  X21=Y2*Y1;
-  X22=Y2*Y2;
-  X23=Y2*Y3;
-  X31=Y3*Y1;
-  X32=Y3*Y2;
-  X33=Y3*Y3;
-
-  ZZ=S0ad*(T11*S0ad+T12*S0bd+T13*S0cd)+S0bd*(T21*S0ad+T22*S0bd+T23*S0cd)+S0cd*(T31*S0ad+T32*S0bd+T33*S0cd);
-
-  m=1.0/(S0dd-ZZ);
-
-  N11=m*X11+Zaa;
-  N12=m*X12+Zab;
-  N13=m*X13+Zac;
-  N21=m*X21+Zba;
-  N22=m*X22+Zbb;
-  N23=m*X23+Zbc;
-  N31=m*X31+Zca;
-  N32=m*X32+Zcb;
-  N33=m*X33+Zcc;
-
-  M11= N11*S0aa + N12*S0ab + N13*S0ac;
-  M12= N11*S0ab + N12*S0bb + N13*S0bc;
-  M13= N11*S0ac + N12*S0bc + N13*S0cc;
-  M21= N21*S0aa + N22*S0ab + N23*S0ac;
-  M22= N21*S0ab + N22*S0bb + N23*S0bc;
-  M23= N21*S0ac + N22*S0bc + N23*S0cc;
-  M31= N31*S0aa + N32*S0ab + N33*S0ac;
-  M32= N31*S0ab + N32*S0bb + N33*S0bc;
-  M33= N31*S0ac + N32*S0bc + N33*S0cc;
-
-  DenQ1=1.0+M11-M12*M21+M22+M11*M22-M13*M31-M13*M22*M31;
-  DenQ2=  M12*M23*M31+M13*M21*M32-M23*M32-M11*M23*M32+M33+M11*M33;
-  DenQ3=  -M12*M21*M33+M22*M33+M11*M22*M33;
-  DenQ=DenQ1+DenQ2+DenQ3;
-
-  Q11= (1.0 + M22-M23*M32 + M33 + M22*M33)/DenQ;
-  Q12= (-M12 + M13*M32 - M12*M33)/DenQ;
-  Q13= (-M13 - M13*M22 + M12*M23)/DenQ;
-  Q21= (-M21 + M23*M31 - M21*M33)/DenQ;
-  Q22= (1.0 + M11 - M13*M31 + M33 + M11*M33)/DenQ;
-  Q23= (M13*M21 - M23 - M11*M23)/DenQ;
-  Q31= (-M31 - M22*M31 + M21*M32)/DenQ;
-  Q32= (M12*M31 - M32 - M11*M32)/DenQ;
-  Q33= (1.0 + M11 - M12*M21 + M22 + M11*M22)/DenQ;
-
-  S11= Q11*S0aa + Q21*S0ab + Q31*S0ac;
-  S12= Q12*S0aa + Q22*S0ab + Q32*S0ac;
-  S13= Q13*S0aa + Q23*S0ab + Q33*S0ac;
-  S14=-S11-S12-S13;
-  S21= Q11*S0ba + Q21*S0bb + Q31*S0bc;
-  S22= Q12*S0ba + Q22*S0bb + Q32*S0bc;
-  S23= Q13*S0ba + Q23*S0bb + Q33*S0bc;
-  S24=-S21-S22-S23;
-  S31= Q11*S0ca + Q21*S0cb + Q31*S0cc;
-  S32= Q12*S0ca + Q22*S0cb + Q32*S0cc;
-  S33= Q13*S0ca + Q23*S0cb + Q33*S0cc;
-  S34=-S31-S32-S33;
-  S41=S14;
-  S42=S24;
-  S43=S34;
-  S44=S11+S22+S33+2.0*S12+2.0*S13+2.0*S23;
-
-  Nav=6.022045e+23;
-  Lad=(La/va-Ld/vd)*sqrt(Nav);
-  Lbd=(Lb/vb-Ld/vd)*sqrt(Nav);
-  Lcd=(Lc/vc-Ld/vd)*sqrt(Nav);
-
-  Intg=pow(Lad,2.0)*S11+pow(Lbd,2.0)*S22+pow(Lcd,2.0)*S33+2.0*Lad*Lbd*S12+2.0*Lbd*Lcd*S23+2.0*Lad*Lcd*S13;
-
-  Intg *= scale;
-  Intg += background;
-
-  return Intg;
-
-}
-
-RPAModel :: RPAModel() {
-  lcase_n = Parameter(0.0);
-  ba = Parameter(5.0);
-  bb = Parameter(5.0);
-  bc = Parameter(5.0);
-  bd = Parameter(5.0);
-
-  Kab = Parameter(-0.0004);
-  Kac = Parameter(-0.0004);
-  Kad = Parameter(-0.0004);
-  Kbc = Parameter(-0.0004);
-  Kbd = Parameter(-0.0004);
-  Kcd = Parameter(-0.0004);
-
-  scale = Parameter(1.0);
-  background = Parameter(0.0);
-
-  Na = Parameter(1000.0);
-  Phia = Parameter(0.25);
-  va = Parameter(100.0);
-  La = Parameter(1.0e-012);
-
-  Nb = Parameter(1000.0);
-  Phib = Parameter(0.25);
-  vb = Parameter(100.0);
-  Lb = Parameter(1.0e-012);
-
-  Nc = Parameter(1000.0);
-  Phic = Parameter(0.25);
-  vc = Parameter(100.0);
-  Lc = Parameter(1.0e-012);
-
-  Nd = Parameter(1000.0);
-  Phid = Parameter(0.25);
-  vd = Parameter(100.0);
-  Ld = Parameter(0.0e-012);
-
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double RPAModel :: operator()(double q) {
-  double dp[29];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  //Fittable parameters
-  dp[0] = lcase_n();
-
-  dp[1] = ba();
-  dp[2] = bb();
-  dp[3] = bc();
-  dp[4] = bd();
-
-  dp[5] = Kab();
-  dp[6] = Kac();
-  dp[7] = Kad();
-  dp[8] = Kbc();
-  dp[9] = Kbd();
-  dp[10] = Kcd();
-
-  dp[11] = scale();
-  dp[12] = background();
-
-  //Fixed parameters
-  dp[13] = Na();
-  dp[14] = Phia();
-  dp[15] = va();
-  dp[16] = La();
-
-  dp[17] = Nb();
-  dp[18] = Phib();
-  dp[19] = vb();
-  dp[20] = Lb();
-
-  dp[21] = Nc();
-  dp[22] = Phic();
-  dp[23] = vc();
-  dp[24] = Lc();
-
-  dp[25] = Nd();
-  dp[26] = Phid();
-  dp[27] = vd();
-  dp[28] = Ld();
-
-  return rpa_kernel(dp,q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double RPAModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double RPAModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double RPAModel :: calculate_ER() {
-  //NOT implemented!!!
-  return 0.0;
-}
-double RPAModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/sc.cpp
===================================================================
--- src/sans/models/src/c_models/sc.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,338 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "sc.h"
-
-extern "C" {
-#include "libSphere.h"
-}
-
-// Convenience structure
-typedef struct {
-  double scale;
-  double dnn;
-  double d_factor;
-  double radius;
-  double sldSph;
-  double sldSolv;
-  double background;
-  double theta;
-  double phi;
-  double psi;
-} SCParameters;
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the SCCrystalModel
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double sc_analytical_2D_scaled(SCParameters *pars, double q, double q_x, double q_y) {
-  double a3_x, a3_y, a2_x, a2_y, a1_x, a1_y; //, a3_z
-  double q_z;
-  double cos_val_a3, cos_val_a2, cos_val_a1;
-  double a1_dot_q, a2_dot_q,a3_dot_q;
-  double answer;
-  double Pi = 4.0*atan(1.0);
-  double aa, Da, qDa_2, latticeScale, Zq;
-
-  double dp[5];
-  //convert angle degree to radian
-  double theta = pars->theta * Pi/180.0;
-  double phi = pars->phi * Pi/180.0;
-  double psi = pars->psi * Pi/180.0;
-  dp[0] = 1.0;
-  dp[1] = pars->radius;
-  dp[2] = pars->sldSph;
-  dp[3] = pars->sldSolv;
-  dp[4] = 0.0;
-
-
-  aa = pars->dnn;
-  Da = pars->d_factor*aa;
-  qDa_2 = pow(q*Da,2.0);
-
-  latticeScale = (4.0/3.0)*Pi*(dp[1]*dp[1]*dp[1])/pow(aa,3.0);
-  /// Angles here are respect to detector coordinate instead of against q coordinate(PRB 36, 3, 1754)
-  // a3 axis orientation
-  a3_x = cos(theta) * cos(phi);
-  a3_y = sin(theta);
-  //a3_z = -cos(theta) * sin(phi);
-  // q vector
-  q_z = 0.0;
-
-  // Compute the angle btw vector q and the a3 axis
-  cos_val_a3 = a3_x*q_x + a3_y*q_y;// + a3_z*q_z;
-
-  // a1 axis orientation
-  a1_x = -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-  a1_y = sin(psi)*cos(theta);
-
-  cos_val_a1 = a1_x*q_x + a1_y*q_y;
-
-  // a2 axis orientation
-  a2_x = -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-  a2_y = cos(theta)*cos(psi);
-  // a2 axis
-  cos_val_a2 =  a2_x*q_x + a2_y*q_y;
-
-  // The following test should always pass
-  if (fabs(cos_val_a3)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val_a3 = 1.0;
-  }
-   if (fabs(cos_val_a1)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val_a1 = 1.0;
-  }
-   if (fabs(cos_val_a2)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val_a3 = 1.0;
-  }
-  a3_dot_q = aa*q*cos_val_a3;
-  a1_dot_q = aa*q*cos_val_a1;//*sin(alpha);
-  a2_dot_q = aa*q*cos_val_a2;
-  
-  // Call Zq=Z1*Z2*Z3
-  Zq = (1.0-exp(-qDa_2))/(1.0-2.0*exp(-0.5*qDa_2)*cos(a1_dot_q)+exp(-qDa_2));
-  Zq *= (1.0-exp(-qDa_2))/(1.0-2.0*exp(-0.5*qDa_2)*cos(a2_dot_q)+exp(-qDa_2));
-  Zq *= (1.0-exp(-qDa_2))/(1.0-2.0*exp(-0.5*qDa_2)*cos(a3_dot_q)+exp(-qDa_2));
-
-  // Use SphereForm directly from libigor
-  answer = SphereForm(dp,q)*Zq;
-
-  //consider scales
-  answer *= latticeScale * pars->scale;
-
-  // This FIXES a singualrity the kernel in libigor.
-  if ( answer == INFINITY || answer == NAN){
-    answer = 0.0;
-  }
-
-  // add background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the SC_ParaCrystal
- * @param q: q-value
- * @return: function value
- */
-static double sc_analytical_2DXY(SCParameters *pars, double qx, double qy){
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return sc_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-SCCrystalModel :: SCCrystalModel() {
-  scale      = Parameter(1.0);
-  dnn		= Parameter(220.0);
-  d_factor = Parameter(0.06);
-  radius     = Parameter(40.0, true);
-  radius.set_min(0.0);
-  sldSph   = Parameter(3.0e-6);
-  sldSolv   = Parameter(6.3e-6);
-  background = Parameter(0.0);
-  theta  = Parameter(0.0, true);
-  phi    = Parameter(0.0, true);
-  psi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double SCCrystalModel :: operator()(double q) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = dnn();
-  dp[2] = d_factor();
-  dp[3] = radius();
-  dp[4] = sldSph();
-  dp[5] = sldSolv();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-  double result;
-
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp[3] = weights_rad[i].value;
-
-    //Un-normalize SphereForm by volume
-    result = SC_ParaCrystal(dp, q) * pow(weights_rad[i].value,3);
-    // This FIXES a singualrity the kernel in libigor.
-    if ( result == INFINITY || result == NAN){
-      result = 0.0;
-    }
-    sum += weights_rad[i].weight
-        * result;
-    //Find average volume
-    vol += weights_rad[i].weight
-        * pow(weights_rad[i].value,3);
-
-    norm += weights_rad[i].weight;
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double SCCrystalModel :: operator()(double qx, double qy) {
-  SCParameters dp;
-  dp.scale      = scale();
-  dp.dnn   = dnn();
-  dp.d_factor   = d_factor();
-  dp.radius  = radius();
-  dp.sldSph   = sldSph();
-  dp.sldSolv   = sldSolv();
-  dp.background = 0.0;
-  dp.theta  = theta();
-  dp.phi    = phi();
-  dp.psi    = psi();
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad;
-  radius.get_weights(weights_rad);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  phi.get_weights(weights_phi);
-
-  // Get angular averaging for psi
-  vector<WeightPoint> weights_psi;
-  psi.get_weights(weights_psi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad.size(); i++) {
-    dp.radius = weights_rad[i].value;
-    // Average over theta distribution
-    for(size_t j=0; j< weights_theta.size(); j++) {
-      dp.theta = weights_theta[j].value;
-      // Average over phi distribution
-      for(size_t k=0; k< weights_phi.size(); k++) {
-        dp.phi = weights_phi[k].value;
-        // Average over phi distribution
-        for(size_t l=0; l< weights_psi.size(); l++) {
-          dp.psi = weights_psi[l].value;
-          //Un-normalize SphereForm by volume
-          double _ptvalue = weights_rad[i].weight
-              * weights_theta[j].weight
-              * weights_phi[k].weight
-              * weights_psi[l].weight
-              * sc_analytical_2DXY(&dp, qx, qy);
-          //* pow(weights_rad[i].value,3.0);
-          // Consider when there is infinte or nan.
-          if ( _ptvalue == INFINITY || _ptvalue == NAN){
-            _ptvalue = 0.0;
-          }
-          if (weights_theta.size()>1) {
-            _ptvalue *= fabs(cos(weights_theta[j].value*pi/180.0));
-          }
-          sum += _ptvalue;
-          // This model dose not need the volume of spheres correction!!!
-          //Find average volume
-          //vol += weights_rad[i].weight
-          //	* pow(weights_rad[i].value,3);
-          //Find norm for volume
-          //norm_vol += weights_rad[i].weight;
-
-          norm += weights_rad[i].weight
-              * weights_theta[j].weight
-              * weights_phi[k].weight
-              * weights_psi[l].weight;
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the SCCrystal
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double SCCrystalModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double SCCrystalModel :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double SCCrystalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/schulz.cpp
===================================================================
--- src/sans/models/src/c_models/schulz.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "schulz.h"
-
-#if defined(_MSC_VER)
-#include "gamma_win.h"
-#endif
-
-Schulz :: Schulz() {
-  scale  = Parameter(1.0, true);
-  sigma  = Parameter(1.0, true);
-  center = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
-/**
- * Function to evaluate 1D Schulz function.
- * The function is normalized to the 'scale' parameter.
- *
- * f(x)=scale * math.pow(z+1, z+1)*math.pow((R), z)*
- *          math.exp(-R*(z+1))/(center*gamma(z+1)
- *    z= math.pow[(1/(sigma/center),2]-1
- *    R= x/center
- *
- * @param q: q-value
- * @return: function value
- */
-double Schulz :: operator()(double q) {
-  double z = pow(center()/ sigma(), 2)-1;
-  double R= q/center();
-  double zz= z+1;
-  double expo;
-  expo = log(scale())+zz*log(zz)+z*log(R)-R*zz-log(center())-lgamma(zz);
-
-  return exp(expo);//scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((center) * tgamma(zz)) ;
-}
-
-/**
- * Function to evaluate 2D schulz function
- * The function is normalized to the 'scale' parameter.
- *
- * f(x,y) = Schulz(x) * Schulz(y)
- *
- * where both Shulzs share the same parameters.
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double Schulz :: operator()(double qx, double qy) {
-  return (*this).operator()(qx) * (*this).operator()(qy);
-}
-
-/**
- * Function to evaluate 2D schulz function
- * The function is normalized to the 'scale' parameter.
- *
- * f(x,y) = Schulz(x) * Schulz(y)
- *
- * where both Shulzs share the same parameters.
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double Schulz :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double Schulz :: calculate_ER() {
-  //NOT implemented yet!!!
-  return 0.0;
-}
-double Schulz :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/sld_cal.cpp
===================================================================
--- src/sans/models/src/c_models/sld_cal.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,109 +1,0 @@
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/c_extensions/libmultifunc/librefl.h
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "sld_cal.h"
-
-extern "C" {
-#include "libmultifunc/librefl.h"
-}
-
-// Convenience structure
-typedef struct {
-    double fun_type;
-    double npts_inter;
-    double shell_num;
-    double nu_inter;
-    double sld_left;
-    double sld_right;
-} SLDCalParameters;
-
-/**
- * Function to calculate sld
- * @param pars: parameters
- * @param x: independent param-value
- * @return: sld value
- */
-static double sld_cal_analytical_1D(SLDCalParameters *pars, double x) {
-  double fun, nsl, n_s, fun_coef, sld_l, sld_r, sld_out;
-  int fun_type;
-
-  fun = pars->fun_type;
-  nsl = pars->npts_inter;
-  n_s = pars->shell_num;
-  fun_coef = pars->nu_inter;
-  sld_l = pars-> sld_left;
-  sld_r = pars-> sld_right;
-
-  fun_type = floor(fun);
-
-  sld_out = intersldfunc(fun_type, nsl, n_s, fun_coef, sld_l, sld_r);
-
-  return sld_out;
-}
-
-SLDCalFunc :: SLDCalFunc() {
-	fun_type     = Parameter(0);
-	npts_inter   = Parameter(21);
-	shell_num	 = Parameter(1);
-	nu_inter	 = Parameter(2.5);
-	sld_left 	 = Parameter(1.0e-06);
-	sld_right	 = Parameter(2.0e-06);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double SLDCalFunc :: operator()(double q) {
-	SLDCalParameters dp;
-
-	dp.fun_type = fun_type();
-	dp.npts_inter = npts_inter();
-	dp.shell_num = shell_num();
-	dp.nu_inter = nu_inter();
-	dp.sld_left = sld_left();
-	dp.sld_right = sld_right();
-
-	return sld_cal_analytical_1D(&dp, q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double SLDCalFunc :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-		return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double SLDCalFunc :: evaluate_rphi(double q, double phi) {
-	return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double SLDCalFunc :: calculate_ER() {
-//NOT implemented yet!!!
-	return 0.0;
-}
-double SLDCalFunc :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/sphere.cpp
===================================================================
--- src/sans/models/src/c_models/sphere.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,308 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "sphere.h"
-
-extern "C" {
-	#include "libSphere.h"
-	#include "libmultifunc/libfunc.h"
-}
-// Convenience parameter structure
-typedef struct {
-    double scale;
-    double radius;
-    double sldSph;
-    double sldSolv;
-    double background;
-    double M0_sld_sph;
-    double M_theta_sph;
-    double M_phi_sph;
-    double M0_sld_solv;
-    double M_theta_solv;
-    double M_phi_solv;
-    double Up_frac_i;
-	double Up_frac_f;
-	double Up_theta;
-} SphereParameters;
-
-SphereModel :: SphereModel() {
-	scale      = Parameter(1.0);
-	radius     = Parameter(20.0, true);
-	radius.set_min(0.0);
-	sldSph   = Parameter(4.0e-6);
-	sldSolv   = Parameter(1.0e-6);
-	background = Parameter(0.0);
-	M0_sld_sph = Parameter(0.0e-6);
-	M_theta_sph = Parameter(0.0);
-	M_phi_sph = Parameter(0.0); 
-	M0_sld_solv = Parameter(0.0e-6);
-	M_theta_solv = Parameter(0.0);
-	M_phi_solv = Parameter(0.0); 
-	Up_frac_i = Parameter(0.5); 
-	Up_frac_f = Parameter(0.5);
-	Up_theta = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double SphereModel :: operator()(double q) {
-	double dp[5];
-
-	// Fill parameter array for IGOR library
-	// Add the background after averaging
-	dp[0] = scale();
-	dp[1] = radius();
-	dp[2] = sldSph();
-	dp[3] = sldSolv();
-	dp[4] = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp[1] = weights_rad[i].value;
-
-		//Un-normalize SphereForm by volume
-		sum += weights_rad[i].weight
-			* SphereForm(dp, q) * pow(weights_rad[i].value,3);
-		//Find average volume
-		vol += weights_rad[i].weight
-			* pow(weights_rad[i].value,3);
-
-		norm += weights_rad[i].weight;
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-
-static double sphere_analytical_2D_scaled(SphereParameters *pars, double q, double q_x, double q_y) {
-	double dp[5];
-	//convert angle degree to radian
-	dp[0] = 1.0;
-	dp[1] = pars->radius;
-	dp[2] = 0.0;
-	dp[3] = 0.0;
-	dp[4] = 0.0;
-
-    double sldSph = pars->sldSph;
-    double sldSolv = pars->sldSolv;
-	double answer = 0.0;
-	double m_max = pars->M0_sld_sph;
-	double m_max_solv = pars->M0_sld_solv;
-
-	if (m_max < 1.0e-32 && m_max_solv < 1.0e-32){
-		dp[2] = sldSph;
-		dp[3] = sldSolv;
-		answer = SphereForm(dp, q);
-	}
-	else{
-		//double contrast = sldSph - sldSolv;
-		double qx = q_x;
-		double qy = q_y;
-		double s_theta = pars->Up_theta;
-		double m_phi = pars->M_phi_sph;
-		double m_theta = pars->M_theta_sph;
-		double m_phi_solv = pars->M_phi_solv;
-		double m_theta_solv = pars->M_theta_solv;
-		double in_spin = pars->Up_frac_i;
-		double out_spin = pars->Up_frac_f;
-		polar_sld p_sld;
-		polar_sld p_sld_solv;
-		p_sld = cal_msld(1, qx, qy, sldSph, m_max, m_theta, m_phi, 
-			 				in_spin, out_spin, s_theta);
-		p_sld_solv = cal_msld(1, qx, qy, sldSolv, m_max_solv, m_theta_solv, m_phi_solv, 
-								in_spin, out_spin, s_theta);
-		//up_up	
-		if (in_spin > 0.0 && out_spin > 0.0){			 
-			dp[2] = p_sld.uu;
-			dp[3] = p_sld_solv.uu;
-			answer += SphereForm(dp, q);
-			}
-		//down_down
-		if (in_spin < 1.0 && out_spin < 1.0){
-			dp[2] = p_sld.dd;
-			dp[3] = p_sld_solv.dd;
-			answer += SphereForm(dp, q);
-			}
-		//up_down
-		if (in_spin > 0.0 && out_spin < 1.0){
-			dp[2] = p_sld.re_ud;
-			dp[3] = p_sld_solv.re_ud;
-			answer += SphereForm(dp, q);	
-			dp[2] = p_sld.im_ud;
-			dp[3] = p_sld_solv.im_ud;
-			answer += SphereForm(dp, q);
-			}
-		//down_up	
-		if (in_spin < 1.0 && out_spin > 0.0){
-			dp[2] = p_sld.re_du;
-			dp[3] = p_sld_solv.re_du;
-			answer += SphereForm(dp, q);	
-			dp[2] = p_sld.im_du;
-			dp[3] = p_sld_solv.im_du;
-			answer += SphereForm(dp, q);
-			}
-	}
-	
-	// add in the background
-	answer *= pars->scale;
-	answer += pars->background;
-	return answer;
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters
- * @param q: q-value
- * @return: function value
- */
-static double sphere_analytical_2DXY(SphereParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return sphere_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double SphereModel :: operator()(double qx, double qy) {
-	SphereParameters dp;
-	dp.scale = scale();
-	dp.radius = radius();
-	dp.sldSph = sldSph();
-	dp.sldSolv = sldSolv();
-	dp.background = 0.0;
-	dp.Up_theta =  Up_theta();
-	dp.M_phi_sph =  M_phi_sph();
-	dp.M_theta_sph =  M_theta_sph();
-	dp.M0_sld_sph =  M0_sld_sph();
-	dp.M_phi_solv =  M_phi_solv();
-	dp.M_theta_solv =  M_theta_solv();
-	dp.M0_sld_solv =  M0_sld_solv();
-	dp.Up_frac_i =  Up_frac_i();
-	dp.Up_frac_f =  Up_frac_f();
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-	double vol = 0.0;
-
-	// Loop over radius weight points
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		dp.radius = weights_rad[i].value;
-
-		//Un-normalize SphereForm by volume
-		sum += weights_rad[i].weight
-			* sphere_analytical_2DXY(&dp, qx, qy) * pow(weights_rad[i].value,3);
-		//Find average volume
-		vol += weights_rad[i].weight
-			* pow(weights_rad[i].value,3);
-
-		norm += weights_rad[i].weight;
-	}
-
-	if (vol != 0.0 && norm != 0.0) {
-		//Re-normalize by avg volume
-		sum = sum/(vol/norm);}
-	return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the sphere
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double SphereModel :: evaluate_rphi(double q, double phi) {
-	double qx = q*cos(phi);
-	double qy = q*sin(phi);
-	return (*this).operator()(qx, qy);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double SphereModel :: calculate_ER() {
-	double rad_out = 0.0;
-
-	// Perform the computation, with all weight points
-	double sum = 0.0;
-	double norm = 0.0;
-
-	// Get the dispersion points for the radius
-	vector<WeightPoint> weights_rad;
-	radius.get_weights(weights_rad);
-	// Loop over radius weight points to average the radius value
-	for(size_t i=0; i<weights_rad.size(); i++) {
-		sum += weights_rad[i].weight
-			* weights_rad[i].value;
-		norm += weights_rad[i].weight;
-	}
-	if (norm != 0){
-		//return the averaged value
-		rad_out =  sum/norm;}
-	else{
-		//return normal value
-		rad_out = radius();}
-
-	return rad_out;
-}
-double SphereModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/spheresld.cpp
===================================================================
--- src/sans/models/src/c_models/spheresld.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,634 +1,0 @@
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-
-extern "C" {
-#include "libmultifunc/librefl.h"
-}
-
-#include "spheresld.h"
-
-using namespace std;
-
-// Convenience structure
-typedef struct {
-  /// number of shells
-  //  [DEFAULT]=n_shells=1
-  int n_shells;
-  /// Scale factor
-  //  [DEFAULT]=scale= 1.0
-  double scale;
-  /// thick_inter0 [A]
-  //  [DEFAULT]=thick_inter0=50.0 [A]
-  double thick_inter0;
-  /// func_inter0
-  //  [DEFAULT]=func_inter0= 0
-  double func_inter0;
-  /// sld_core0 [1/A^(2)]
-  //  [DEFAULT]=sld_core0= 2.07e-6 [1/A^(2)]
-  double sld_core0;
-  /// sld_solv [1/A^(2)]
-  //  [DEFAULT]=sld_solv= 1.0e-6 [1/A^(2)]
-  double sld_solv;
-  /// Background
-  //  [DEFAULT]=background=0
-  double background;
-
-  //  [DEFAULT]=sld_flat1=4.0e-06 [1/A^(2)]
-  double sld_flat1;
-  //  [DEFAULT]=sld_flat2=3.5e-06 [1/A^(2)]
-  double sld_flat2;
-  //  [DEFAULT]=sld_flat3=4.0e-06 [1/A^(2)]
-  double sld_flat3;
-  //  [DEFAULT]=sld_flat4=3.5e-06 [1/A^(2)]
-  double sld_flat4;
-  //  [DEFAULT]=sld_flat5=4.0e-06 [1/A^(2)]
-  double sld_flat5;
-  //  [DEFAULT]=sld_flat6=3.5e-06 [1/A^(2)]
-  double sld_flat6;
-  //  [DEFAULT]=sld_flat7=4.0e-06 [1/A^(2)]
-  double sld_flat7;
-  //  [DEFAULT]=sld_flat8=3.5e-06 [1/A^(2)]
-  double sld_flat8;
-  //  [DEFAULT]=sld_flat9=4.0e-06 [1/A^(2)]
-  double sld_flat9;
-  //  [DEFAULT]=sld_flat10=3.5e-06 [1/A^(2)]
-  double sld_flat10;
-
-  //  [DEFAULT]=thick_inter1=50.0 [A]
-  double thick_inter1;
-  //  [DEFAULT]=thick_inter2=50.0 [A]
-  double thick_inter2;
-  //  [DEFAULT]=thick_inter3=50.0 [A]
-  double thick_inter3;
-  //  [DEFAULT]=thick_inter4=50.0 [A]
-  double thick_inter4;
-  //  [DEFAULT]=thick_inter5=50.0 [A]
-  double thick_inter5;
-  //  [DEFAULT]=thick_inter6=50.0 [A]
-  double thick_inter6;
-  //  [DEFAULT]=thick_inter7=50.0 [A]
-  double thick_inter7;
-  //  [DEFAULT]=thick_inter8=50.0 [A]
-  double thick_inter8;
-  //  [DEFAULT]=thick_inter9=50.0 [A]
-  double thick_inter9;
-  //  [DEFAULT]=thick_inter10=50.0 [A]
-  double thick_inter10;
-
-  //  [DEFAULT]=thick_flat1=100 [A]
-  double thick_flat1;
-  //  [DEFAULT]=thick_flat2=100 [A]
-  double thick_flat2;
-  //  [DEFAULT]=thick_flat3=100 [A]
-  double thick_flat3;
-  //  [DEFAULT]=thick_flat4=100 [A]
-  double thick_flat4;
-  //  [DEFAULT]=thick_flat5=100 [A]
-  double thick_flat5;
-  //  [DEFAULT]=thick_flat6=100 [A]
-  double thick_flat6;
-  //  [DEFAULT]=thick_flat7=100 [A]
-  double thick_flat7;
-  //  [DEFAULT]=thick_flat8=100 [A]
-  double thick_flat8;
-  //  [DEFAULT]=thick_flat9=100 [A]
-  double thick_flat9;
-  //  [DEFAULT]=thick_flat10=100 [A]
-  double thick_flat10;
-
-  //  [DEFAULT]=func_inter1=0
-  double func_inter1;
-  //  [DEFAULT]=func_inter2=0
-  double func_inter2;
-  //  [DEFAULT]=func_inter3=0
-  double func_inter3;
-  //  [DEFAULT]=func_inter4=0
-  double func_inter4;
-  //  [DEFAULT]=func_inter5=0
-  double func_inter5;
-  //  [DEFAULT]=func_inter6=0
-  double func_inter6;
-  //  [DEFAULT]=func_inter7=0
-  double func_inter7;
-  //  [DEFAULT]=func_inter8=0
-  double func_inter8;
-  //  [DEFAULT]=func_inter9=0
-  double func_inter9;
-  //  [DEFAULT]=func_inter10=0
-  double func_inter10;
-
-  //  [DEFAULT]=nu_inter1=2.5
-  double nu_inter1;
-  //  [DEFAULT]=nu_inter2=2.5
-  double nu_inter2;
-  //  [DEFAULT]=nu_inter3=2.5
-  double nu_inter3;
-  //  [DEFAULT]=nu_inter4=2.5
-  double nu_inter4;
-  //  [DEFAULT]=nu_inter5=2.5
-  double nu_inter5;
-  //  [DEFAULT]=nu_inter6=2.5
-  double nu_inter6;
-  //  [DEFAULT]=nu_inter7=2.5
-  double nu_inter7;
-  //  [DEFAULT]=nu_inter8=2.5
-  double nu_inter8;
-  //  [DEFAULT]=nu_inter9=2.5
-  double nu_inter9;
-  //  [DEFAULT]=nu_inter10=2.5
-  double nu_inter10;
-
-  //  [DEFAULT]=npts_inter=35.0
-  double npts_inter;
-  //  [DEFAULT]=nu_inter0=2.5
-  double nu_inter0;
-  //  [DEFAULT]=rad_core0=50.0 [A]
-  double rad_core0;
-} SphereSLDParameters;
-
-
-static double sphere_sld_kernel(double dp[], double q) {
-  int n = dp[0];
-  int i,j,k;
-
-  double scale = dp[1];
-  double thick_inter_core = dp[2];
-  double sld_core = dp[4];
-  double sld_solv = dp[5];
-  double background = dp[6];
-  double npts = dp[57]; //number of sub_layers in each interface
-  double nsl=npts;//21.0; //nsl = Num_sub_layer:  MUST ODD number in double //no other number works now
-  int n_s;
-
-  double sld_i,sld_f,dz,bes,fun,f,vol,vol_pre,vol_sub,qr,r,contr,f2;
-  double sign,slope=0.0;
-  double pi;
-
-  int* fun_type;
-  double* sld;
-  double* thick_inter;
-  double* thick;
-  double* fun_coef;
-
-  double total_thick=0.0;
-
-  fun_type = (int*)malloc((n+2)*sizeof(int));
-  sld = (double*)malloc((n+2)*sizeof(double));
-  thick_inter = (double*)malloc((n+2)*sizeof(double));
-  thick = (double*)malloc((n+2)*sizeof(double));
-  fun_coef = (double*)malloc((n+2)*sizeof(double));
-
-  fun_type[0] = dp[3];
-  fun_coef[0] = fabs(dp[58]);
-  for (i =1; i<=n; i++){
-    sld[i] = dp[i+6];
-    thick_inter[i]= dp[i+16];
-    thick[i] = dp[i+26];
-    fun_type[i] = dp[i+36];
-    fun_coef[i] = fabs(dp[i+46]);
-    total_thick += thick[i] + thick_inter[i];
-  }
-  sld[0] = sld_core;
-  sld[n+1] = sld_solv;
-  thick[0] = dp[59];
-  thick[n+1] = total_thick/5.0;
-  thick_inter[0] = thick_inter_core;
-  thick_inter[n+1] = 0.0;
-  fun_coef[n+1] = 0.0;
-
-  pi = 4.0*atan(1.0);
-  f = 0.0;
-  r = 0.0;
-  vol = 0.0;
-  vol_pre = 0.0;
-  vol_sub = 0.0;
-  sld_f = sld_core;
-
-  //floor_nsl = floor(nsl/2.0);
-
-  dz = 0.0;
-  // iteration for # of shells + core + solvent
-  for (i=0;i<=n+1; i++){
-    //iteration for N sub-layers
-    //if (fabs(thick[i]) <= 1e-24){
-    //   continue;
-    //}
-    // iteration for flat and interface
-    for (j=0;j<2;j++){
-      // iteration for sub_shells in the interface
-      // starts from #1 sub-layer
-      for (n_s=1;n_s<=nsl; n_s++){
-        // for solvent, it doesn't have an interface
-        if (i==n+1 && j==1)
-          break;
-        // for flat layers
-        if (j==0){
-          dz = thick[i];
-          sld_i = sld[i];
-          slope = 0.0;
-        }
-        // for interfacial sub_shells
-        else{
-          dz = thick_inter[i]/nsl;
-          // find sld_i at the outer boundary of sub-layer #n_s
-          sld_i = intersldfunc(fun_type[i],nsl, n_s, fun_coef[i], sld[i], sld[i+1]);
-          // calculate slope
-          slope= (sld_i -sld_f)/dz;
-        }
-        contr = sld_f-slope*r;
-        // iteration for the left and right boundary of the shells(or sub_shells)
-        for (k=0; k<2; k++){
-          // At r=0, the contribution to I is zero, so skip it.
-          if ( i == 0 && j == 0 && k == 0){
-            continue;
-          }
-          // On the top of slovent there is no interface; skip it.
-          if (i == n+1 && k == 1){
-            continue;
-          }
-          // At the right side (outer) boundary
-          if ( k == 1){
-            sign = 1.0;
-            r += dz;
-          }
-          // At the left side (inner) boundary
-          else{
-            sign = -1.0;
-          }
-          qr = q * r;
-          fun = 0.0;
-          if(qr == 0.0){
-            // sigular point
-            bes = sign * 1.0;
-          }
-          else{
-            // for flat sub-layer
-            bes = sign *  3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr);
-            // with linear slope
-            if (fabs(slope) > 0.0 ){
-              fun = sign * 3.0 * r * (2.0*qr*sin(qr)-((qr*qr)-2.0)*cos(qr))/(qr * qr * qr * qr);
-            }
-          }
-          // update total volume
-          vol = 4.0 * pi / 3.0 * r * r * r;
-          // we won't do the following volume correction for now.
-          // substrate empty area of volume
-          //if (k == 1 && fabs(sld_in[i]-sld_solv) < 1e-04*fabs(sld_solv) && fun_type[i]==0){
-          //  vol_sub += (vol_pre - vol);
-          //}
-          f += vol * (bes * contr + fun * slope);
-        }
-        // remember this sld as sld_f
-        sld_f =sld_i;
-        // no sub-layer iteration (n_s loop) for the flat layer
-        if (j==0)
-          break;
-      }
-    }
-  }
-  //vol += vol_sub;
-  f2 = f * f / vol * 1.0e8;
-  f2 *= scale;
-  f2 += background;
-
-  free(fun_type);
-  free(sld);
-  free(thick_inter);
-  free(thick);
-  free(fun_coef);
-
-  return (f2);
-}
-
-
-SphereSLDModel :: SphereSLDModel() {
-  n_shells = Parameter(1.0);
-  scale = Parameter(1.0);
-  thick_inter0 = Parameter(1.0, true);
-  thick_inter0.set_min(0.0);
-  func_inter0 = Parameter(0);
-  sld_core0 = Parameter(2.07e-06);
-  sld_solv = Parameter(1.0e-06);
-  background = Parameter(0.0);
-
-
-  sld_flat1 = Parameter(2.7e-06);
-  sld_flat2 = Parameter(3.5e-06);
-  sld_flat3 = Parameter(4.0e-06);
-  sld_flat4 = Parameter(3.5e-06);
-  sld_flat5 = Parameter(4.0e-06);
-  sld_flat6 = Parameter(3.5e-06);
-  sld_flat7 = Parameter(4.0e-06);
-  sld_flat8 = Parameter(3.5e-06);
-  sld_flat9 = Parameter(4.0e-06);
-  sld_flat10 = Parameter(3.5e-06);
-
-
-  thick_inter1 = Parameter(1.0);
-  thick_inter2 = Parameter(1.0);
-  thick_inter3 = Parameter(1.0);
-  thick_inter4 = Parameter(1.0);
-  thick_inter5 = Parameter(1.0);
-  thick_inter6 = Parameter(1.0);
-  thick_inter7 = Parameter(1.0);
-  thick_inter8 = Parameter(1.0);
-  thick_inter9 = Parameter(1.0);
-  thick_inter10 = Parameter(1.0);
-
-
-  thick_flat1 = Parameter(100.0);
-  thick_flat2 = Parameter(100.0);
-  thick_flat3 = Parameter(100.0);
-  thick_flat4 = Parameter(100.0);
-  thick_flat5 = Parameter(100.0);
-  thick_flat6 = Parameter(100.0);
-  thick_flat7 = Parameter(100.0);
-  thick_flat8 = Parameter(100.0);
-  thick_flat9 = Parameter(100.0);
-  thick_flat10 = Parameter(100.0);
-
-
-  func_inter1 = Parameter(0);
-  func_inter2 = Parameter(0);
-  func_inter3 = Parameter(0);
-  func_inter4 = Parameter(0);
-  func_inter5 = Parameter(0);
-  func_inter6 = Parameter(0);
-  func_inter7 = Parameter(0);
-  func_inter8 = Parameter(0);
-  func_inter9 = Parameter(0);
-  func_inter10 = Parameter(0);
-
-  nu_inter1 = Parameter(2.5);
-  nu_inter2 = Parameter(2.5);
-  nu_inter3 = Parameter(2.5);
-  nu_inter4 = Parameter(2.5);
-  nu_inter5 = Parameter(2.5);
-  nu_inter6 = Parameter(2.5);
-  nu_inter7 = Parameter(2.5);
-  nu_inter8 = Parameter(2.5);
-  nu_inter9 = Parameter(2.5);
-  nu_inter10 = Parameter(2.5);
-
-  npts_inter = Parameter(35.0);
-  nu_inter0 = Parameter(2.5);
-  rad_core0 = Parameter(60.0, true);
-  rad_core0.set_min(0.0);
-}
-
-/**
- * Function to evaluate 1D SphereSLD function
- * @param q: q-value
- * @return: function value
- */
-double SphereSLDModel :: operator()(double q) {
-  double dp[60];
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = n_shells();
-  dp[1] = scale();
-  dp[2] = thick_inter0();
-  dp[3] = func_inter0();
-  dp[4] = sld_core0();
-  dp[5] = sld_solv();
-  dp[6] = 0.0;
-
-  dp[7] = sld_flat1();
-  dp[8] = sld_flat2();
-  dp[9] = sld_flat3();
-  dp[10] = sld_flat4();
-  dp[11] = sld_flat5();
-  dp[12] = sld_flat6();
-  dp[13] = sld_flat7();
-  dp[14] = sld_flat8();
-  dp[15] = sld_flat9();
-  dp[16] = sld_flat10();
-
-  dp[17] = thick_inter1();
-  dp[18] = thick_inter2();
-  dp[19] = thick_inter3();
-  dp[20] = thick_inter4();
-  dp[21] = thick_inter5();
-  dp[22] = thick_inter6();
-  dp[23] = thick_inter7();
-  dp[24] = thick_inter8();
-  dp[25] = thick_inter9();
-  dp[26] = thick_inter10();
-
-  dp[27] = thick_flat1();
-  dp[28] = thick_flat2();
-  dp[29] = thick_flat3();
-  dp[30] = thick_flat4();
-  dp[31] = thick_flat5();
-  dp[32] = thick_flat6();
-  dp[33] = thick_flat7();
-  dp[34] = thick_flat8();
-  dp[35] = thick_flat9();
-  dp[36] = thick_flat10();
-
-  dp[37] = func_inter1();
-  dp[38] = func_inter2();
-  dp[39] = func_inter3();
-  dp[40] = func_inter4();
-  dp[41] = func_inter5();
-  dp[42] = func_inter6();
-  dp[43] = func_inter7();
-  dp[44] = func_inter8();
-  dp[45] = func_inter9();
-  dp[46] = func_inter10();
-
-  dp[47] = nu_inter1();
-  dp[48] = nu_inter2();
-  dp[49] = nu_inter3();
-  dp[50] = nu_inter4();
-  dp[51] = nu_inter5();
-  dp[52] = nu_inter6();
-  dp[53] = nu_inter7();
-  dp[54] = nu_inter8();
-  dp[55] = nu_inter9();
-  dp[56] = nu_inter10();
-
-
-  dp[57] = npts_inter();
-  dp[58] = nu_inter0();
-  dp[59] = rad_core0();
-
-  // No polydispersion supported in this model.
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad_core0;
-  rad_core0.get_weights(weights_rad_core0);
-  vector<WeightPoint> weights_thick_inter0;
-  thick_inter0.get_weights(weights_thick_inter0);
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over core weight points
-  for(size_t i=0; i<weights_rad_core0.size(); i++) {
-    dp[59] = weights_rad_core0[i].value;
-    // Loop over thick_inter0 weight points
-    for(size_t j=0; j<weights_thick_inter0.size(); j++) {
-      dp[2] = weights_thick_inter0[j].value;
-
-      //Un-normalize Sphere by volume
-      sum += weights_rad_core0[i].weight * weights_thick_inter0[j].weight
-          * sphere_sld_kernel(dp,q) * pow((weights_rad_core0[i].value +
-              weights_thick_inter0[j].value),3.0);
-      //Find average volume
-      vol += weights_rad_core0[i].weight * weights_thick_inter0[j].weight
-          * pow((weights_rad_core0[i].value+weights_thick_inter0[j].value),3.0);
-
-      norm += weights_rad_core0[i].weight * weights_thick_inter0[j].weight;
-    }
-  }
-
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D SphereSLD function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double SphereSLDModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate SphereSLD function
- * @param pars: parameters of the SphereSLD
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double SphereSLDModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate TOTAL radius
- * ToDo: Find What is the effective radius for this model.
- * @return: effective radius value
- */
-// No polydispersion supported in this model.
-// Calculate max radius assumming max_radius = effective radius
-// Note that this max radius is not affected by sld of layer, sld of interface, or
-// sld of solvent.
-double SphereSLDModel :: calculate_ER() {
-  SphereSLDParameters dp;
-
-  dp.n_shells = n_shells();
-
-  dp.rad_core0 = rad_core0();
-  dp.thick_flat1 = thick_flat1();
-  dp.thick_flat2 = thick_flat2();
-  dp.thick_flat3 = thick_flat3();
-  dp.thick_flat4 = thick_flat4();
-  dp.thick_flat5 = thick_flat5();
-  dp.thick_flat6 = thick_flat6();
-  dp.thick_flat7 = thick_flat7();
-  dp.thick_flat8 = thick_flat8();
-  dp.thick_flat9 = thick_flat9();
-  dp.thick_flat10 = thick_flat10();
-
-  dp.thick_inter0 = thick_inter0();
-  dp.thick_inter1 = thick_inter1();
-  dp.thick_inter2 = thick_inter2();
-  dp.thick_inter3 = thick_inter3();
-  dp.thick_inter4 = thick_inter4();
-  dp.thick_inter5 = thick_inter5();
-  dp.thick_inter6 = thick_inter6();
-  dp.thick_inter7 = thick_inter7();
-  dp.thick_inter8 = thick_inter8();
-  dp.thick_inter9 = thick_inter9();
-  dp.thick_inter10 = thick_inter10();
-
-  double rad_out = 0.0;
-  double out = 0.0;
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_rad_core0;
-  rad_core0.get_weights(weights_rad_core0);
-
-  // Get the dispersion points for the thick 1
-  vector<WeightPoint> weights_thick_inter0;
-  thick_inter0.get_weights(weights_thick_inter0);
-  // Loop over radius weight points
-  for(size_t i=0; i<weights_rad_core0.size(); i++) {
-    dp.rad_core0 = weights_rad_core0[i].value;
-    // Loop over radius weight points
-    for(size_t j=0; j<weights_thick_inter0.size(); j++) {
-      dp.thick_inter0 = weights_thick_inter0[j].value;
-      rad_out = dp.rad_core0 + dp.thick_inter0;
-      if (dp.n_shells > 0)
-        rad_out += dp.thick_flat1 + dp.thick_inter1;
-      if (dp.n_shells > 1)
-        rad_out += dp.thick_flat2 + dp.thick_inter2;
-      if (dp.n_shells > 2)
-        rad_out += dp.thick_flat3 + dp.thick_inter3;
-      if (dp.n_shells > 3)
-        rad_out += dp.thick_flat4 + dp.thick_inter4;
-      if (dp.n_shells > 4)
-        rad_out += dp.thick_flat5 + dp.thick_inter5;
-      if (dp.n_shells > 5)
-        rad_out += dp.thick_flat6 + dp.thick_inter6;
-      if (dp.n_shells > 6)
-        rad_out += dp.thick_flat7 + dp.thick_inter7;
-      if (dp.n_shells > 7)
-        rad_out += dp.thick_flat8 + dp.thick_inter8;
-      if (dp.n_shells > 8)
-        rad_out += dp.thick_flat9 + dp.thick_inter9;
-      if (dp.n_shells > 9)
-        rad_out += dp.thick_flat10 + dp.thick_inter10;
-      sum += weights_rad_core0[i].weight*weights_thick_inter0[j].weight
-          * (rad_out);
-      norm += weights_rad_core0[i].weight*weights_thick_inter0[j].weight;
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    out =  sum/norm;}
-  else{
-    //return normal value
-    out = dp.rad_core0 + dp.thick_inter0;
-    if (dp.n_shells > 0)
-      out += dp.thick_flat1 + dp.thick_inter1;
-    if (dp.n_shells > 1)
-      out += dp.thick_flat2 + dp.thick_inter2;
-    if (dp.n_shells > 2)
-      out += dp.thick_flat3 + dp.thick_inter3;
-    if (dp.n_shells > 3)
-      out += dp.thick_flat4 + dp.thick_inter4;
-    if (dp.n_shells > 4)
-      out += dp.thick_flat5 + dp.thick_inter5;
-    if (dp.n_shells > 5)
-      out += dp.thick_flat6 + dp.thick_inter6;
-    if (dp.n_shells > 6)
-      out += dp.thick_flat7 + dp.thick_inter7;
-    if (dp.n_shells > 7)
-      out += dp.thick_flat8 + dp.thick_inter8;
-    if (dp.n_shells > 8)
-      out += dp.thick_flat9 + dp.thick_inter9;
-    if (dp.n_shells > 9)
-      out += dp.thick_flat10 + dp.thick_inter10;
-  }
-
-  return out;
-
-}
-double SphereSLDModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/spheroid.cpp
===================================================================
--- src/sans/models/src/c_models/spheroid.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,417 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "spheroid.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double equat_core;
-  double polar_core;
-  double equat_shell;
-  double polar_shell;
-  double sld_core;
-  double sld_shell;
-  double sld_solvent;
-  double background;
-  double axis_theta;
-  double axis_phi;
-
-} SpheroidParameters;
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the prolate
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double spheroid_analytical_2D_scaled(SpheroidParameters *pars, double q, double q_x, double q_y) {
-
-  double cyl_x, cyl_y;//, cyl_z;
-  //double q_z;
-  double alpha, vol, cos_val;
-  double answer;
-  double Pi = 4.0*atan(1.0);
-  double sldcs,sldss;
-
-  //convert angle degree to radian
-  double theta = pars->axis_theta * Pi/180.0;
-  double phi = pars->axis_phi * Pi/180.0;
-
-
-  // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis.
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-  //del sld
-  sldcs = pars->sld_core - pars->sld_shell;
-  sldss = pars->sld_shell- pars->sld_solvent;
-
-  // q vector
-  //q_z = 0;
-
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
-    return 0;
-  }
-
-  // Note: cos(alpha) = 0 and 1 will get an
-  // undefined value from CylKernel
-  alpha = acos( cos_val );
-
-  // Call the IGOR library function to get the kernel: MUST use gfn4 not gf2 because of the def of params.
-  answer = gfn4(cos_val,pars->equat_core,pars->polar_core,pars->equat_shell,pars->polar_shell,sldcs,sldss,q);
-  //It seems that it should be normalized somehow. How???
-
-  //normalize by cylinder volume
-  //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-  vol = 4.0*Pi/3.0*pars->equat_shell*pars->equat_shell*pars->polar_shell;
-  answer /= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-CoreShellEllipsoidModel :: CoreShellEllipsoidModel() {
-  scale      = Parameter(1.0);
-  equat_core     = Parameter(200.0, true);
-  equat_core.set_min(0.0);
-  polar_core     = Parameter(20.0, true);
-  polar_core.set_min(0.0);
-  equat_shell   = Parameter(250.0, true);
-  equat_shell.set_min(0.0);
-  polar_shell    = Parameter(30.0, true);
-  polar_shell.set_min(0.0);
-  sld_core   = Parameter(2e-6);
-  sld_shell  = Parameter(1e-6);
-  sld_solvent = Parameter(6.3e-6);
-  background = Parameter(0.0);
-  axis_theta  = Parameter(0.0, true);
-  axis_phi    = Parameter(0.0, true);
-
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the prolate
- * @param q: q-value
- * @return: function value
- */
-static double spheroid_analytical_2DXY(SpheroidParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return spheroid_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double CoreShellEllipsoidModel :: operator()(double q) {
-  double dp[9];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = equat_core();
-  dp[2] = polar_core();
-  dp[3] = equat_shell();
-  dp[4] = polar_shell();
-  dp[5] = sld_core();
-  dp[6] = sld_shell();
-  dp[7] = sld_solvent();
-  dp[8] = 0.0;
-
-  // Get the dispersion points for the major core
-  vector<WeightPoint> weights_equat_core;
-  equat_core.get_weights(weights_equat_core);
-
-  // Get the dispersion points for the minor core
-  vector<WeightPoint> weights_polar_core;
-  polar_core.get_weights(weights_polar_core);
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_equat_shell;
-  equat_shell.get_weights(weights_equat_shell);
-
-  // Get the dispersion points for the minor_shell
-  vector<WeightPoint> weights_polar_shell;
-  polar_shell.get_weights(weights_polar_shell);
-
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over major core weight points
-  for(int i=0; i<(int)weights_equat_core.size(); i++) {
-    dp[1] = weights_equat_core[i].value;
-
-    // Loop over minor core weight points
-    for(int j=0; j<(int)weights_polar_core.size(); j++) {
-      dp[2] = weights_polar_core[j].value;
-
-      // Loop over major shell weight points
-      for(int k=0; k<(int)weights_equat_shell.size(); k++) {
-        dp[3] = weights_equat_shell[k].value;
-
-        // Loop over minor shell weight points
-        for(int l=0; l<(int)weights_polar_shell.size(); l++) {
-          dp[4] = weights_polar_shell[l].value;
-          //Un-normalize  by volume
-          sum += weights_equat_core[i].weight* weights_polar_core[j].weight * weights_equat_shell[k].weight
-              * weights_polar_shell[l].weight * OblateForm(dp, q)
-          * pow(weights_equat_shell[k].value,2)*weights_polar_shell[l].value;
-          //Find average volume
-          vol += weights_equat_core[i].weight* weights_polar_core[j].weight
-              * weights_equat_shell[k].weight
-              * weights_polar_shell[l].weight
-              * pow(weights_equat_shell[k].value,2)*weights_polar_shell[l].value;
-          norm += weights_equat_core[i].weight* weights_polar_core[j].weight * weights_equat_shell[k].weight
-              * weights_polar_shell[l].weight;
-        }
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-/*
-double OblateModel :: operator()(double qx, double qy) {
-	double q = sqrt(qx*qx + qy*qy);
-
-	return (*this).operator()(q);
-}
- */
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the oblate
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double CoreShellEllipsoidModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double CoreShellEllipsoidModel :: operator()(double qx, double qy) {
-  SpheroidParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.equat_core = equat_core();
-  dp.polar_core = polar_core();
-  dp.equat_shell = equat_shell();
-  dp.polar_shell = polar_shell();
-  dp.sld_core = sld_core();
-  dp.sld_shell = sld_shell();
-  dp.sld_solvent = sld_solvent();
-  dp.background = 0.0;
-  dp.axis_theta = axis_theta();
-  dp.axis_phi = axis_phi();
-
-  // Get the dispersion points for the major core
-  vector<WeightPoint> weights_equat_core;
-  equat_core.get_weights(weights_equat_core);
-
-  // Get the dispersion points for the minor core
-  vector<WeightPoint> weights_polar_core;
-  polar_core.get_weights(weights_polar_core);
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_equat_shell;
-  equat_shell.get_weights(weights_equat_shell);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_polar_shell;
-  polar_shell.get_weights(weights_polar_shell);
-
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over major core weight points
-  for(int i=0; i< (int)weights_equat_core.size(); i++) {
-    dp.equat_core = weights_equat_core[i].value;
-
-    // Loop over minor core weight points
-    for(int j=0; j< (int)weights_polar_core.size(); j++) {
-      dp.polar_core = weights_polar_core[j].value;
-
-      // Loop over major shell weight points
-      for(int k=0; k< (int)weights_equat_shell.size(); k++) {
-        dp.equat_shell = weights_equat_shell[i].value;
-
-        // Loop over minor shell weight points
-        for(int l=0; l< (int)weights_polar_shell.size(); l++) {
-          dp.polar_shell = weights_polar_shell[l].value;
-
-          // Average over theta distribution
-          for(int m=0; m< (int)weights_theta.size(); m++) {
-            dp.axis_theta = weights_theta[m].value;
-
-            // Average over phi distribution
-            for(int n=0; n< (int)weights_phi.size(); n++) {
-              dp.axis_phi = weights_phi[n].value;
-              //Un-normalize by volume
-              double _ptvalue = weights_equat_core[i].weight *weights_polar_core[j].weight
-                  * weights_equat_shell[k].weight * weights_polar_shell[l].weight
-                  * weights_theta[m].weight
-                  * weights_phi[n].weight
-                  * spheroid_analytical_2DXY(&dp, qx, qy)
-              * pow(weights_equat_shell[k].value,2)*weights_polar_shell[l].value;
-              if (weights_theta.size()>1) {
-                _ptvalue *= fabs(cos(weights_theta[m].value*pi/180.0));
-              }
-              sum += _ptvalue;
-              //Find average volume
-              vol += weights_equat_shell[k].weight
-                  * weights_polar_shell[l].weight
-                  * pow(weights_equat_shell[k].value,2)*weights_polar_shell[l].value;
-              //Find norm for volume
-              norm_vol += weights_equat_shell[k].weight
-                  * weights_polar_shell[l].weight;
-
-              norm += weights_equat_core[i].weight *weights_polar_core[j].weight
-                  * weights_equat_shell[k].weight * weights_polar_shell[l].weight
-                  * weights_theta[m].weight * weights_phi[n].weight;
-            }
-          }
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double CoreShellEllipsoidModel :: calculate_ER() {
-  SpheroidParameters dp;
-
-  dp.equat_shell = equat_shell();
-  dp.polar_shell = polar_shell();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_equat_shell;
-  equat_shell.get_weights(weights_equat_shell);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_polar_shell;
-  polar_shell.get_weights(weights_polar_shell);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_equat_shell.size(); i++) {
-    dp.equat_shell = weights_equat_shell[i].value;
-    for(int k=0; k< (int)weights_polar_shell.size(); k++) {
-      dp.polar_shell = weights_polar_shell[k].value;
-      //Note: output of "DiamEllip(dp.polar_shell,dp.equat_shell)" is DIAMETER.
-      sum +=weights_equat_shell[i].weight
-          * weights_polar_shell[k].weight*DiamEllip(dp.polar_shell,dp.equat_shell)/2.0;
-      norm += weights_equat_shell[i].weight* weights_polar_shell[k].weight;
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamEllip(dp.polar_shell,dp.equat_shell)" is DIAMETER.
-    rad_out = DiamEllip(dp.polar_shell,dp.equat_shell)/2.0;}
-
-  return rad_out;
-}
-double CoreShellEllipsoidModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/stackeddisks.cpp
===================================================================
--- src/sans/models/src/c_models/stackeddisks.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,396 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- *	TODO: refactor so that we pull in the old sansmodels.c_extensions
- *	TODO: add 2d
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "stacked_disks.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double radius;
-  double core_thick;
-  double layer_thick;
-  double core_sld;
-  double layer_sld;
-  double solvent_sld;
-  double n_stacking;
-  double sigma_d;
-  double background;
-  double axis_theta;
-  double axis_phi;
-} StackedDisksParameters;
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the staked disks
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double stacked_disks_analytical_2D_scaled(StackedDisksParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y;//, cyl_z;
-  //double q_z;
-  double alpha, vol, cos_val;
-  double d, dum, halfheight;
-  double answer;
-  double pi = 4.0*atan(1.0);
-  double theta = pars->axis_theta * pi/180.0;
-  double phi = pars->axis_phi * pi/180.0;
-
-
-  // parallelepiped orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-
-  // q vector
-  //q_z = 0;
-
-  // Compute the angle btw vector q and the
-  // axis of the parallelepiped
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    return 0;
-  }
-
-  // Note: cos(alpha) = 0 and 1 will get an
-  // undefined value from Stackdisc_kern
-  alpha = acos( cos_val );
-
-  // Call the IGOR library function to get the kernel
-  d = 2 * pars->layer_thick + pars->core_thick;
-  halfheight = pars->core_thick/2.0;
-  dum =alpha ;
-  answer = Stackdisc_kern(q, pars->radius, pars->core_sld,pars->layer_sld,
-      pars->solvent_sld, halfheight, pars->layer_thick, dum, pars->sigma_d, d, pars->n_stacking)/sin(alpha);
-
-  // Multiply by contrast^2
-  //answer *= pars->contrast*pars->contrast;
-
-  //normalize by staked disks volume
-  vol = acos(-1.0) * pars->radius * pars->radius * d * pars->n_stacking;
-  answer /= vol;
-
-  //convert to [cm-1]
-  answer *= 1.0e8;
-
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the staked disks
- * @param q: q-value
- * @return: function value
- */
-static double stacked_disks_analytical_2DXY(StackedDisksParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return stacked_disks_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-StackedDisksModel :: StackedDisksModel() {
-  scale      = Parameter(1.0);
-  radius     = Parameter(3000.0, true);
-  radius.set_min(0.0);
-  core_thick  = Parameter(10.0, true);
-  core_thick.set_min(0.0);
-  layer_thick     = Parameter(15.0);
-  layer_thick.set_min(0.0);
-  core_sld = Parameter(4.0e-6);
-  layer_sld  = Parameter(-4.0e-7);
-  solvent_sld  = Parameter(5.0e-6);
-  n_stacking   = Parameter(1);
-  sigma_d   = Parameter(0);
-  background = Parameter(0.001);
-  axis_theta  = Parameter(0.0, true);
-  axis_phi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double StackedDisksModel :: operator()(double q) {
-  double dp[10];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = core_thick();
-  dp[3] = layer_thick();
-  dp[4] = core_sld();
-  dp[5] = layer_sld();
-  dp[6] = solvent_sld();
-  dp[7] = n_stacking();
-  dp[8] = sigma_d();
-  dp[9] = 0.0;
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for the core_thick
-  vector<WeightPoint> weights_core_thick;
-  core_thick.get_weights(weights_core_thick);
-
-  // Get the dispersion points for the layer_thick
-  vector<WeightPoint> weights_layer_thick;
-  layer_thick.get_weights(weights_layer_thick);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over length weight points
-  for(int i=0; i< (int)weights_radius.size(); i++) {
-    dp[1] = weights_radius[i].value;
-
-    // Loop over radius weight points
-    for(int j=0; j< (int)weights_core_thick.size(); j++) {
-      dp[2] = weights_core_thick[j].value;
-
-      // Loop over thickness weight points
-      for(int k=0; k< (int)weights_layer_thick.size(); k++) {
-        dp[3] = weights_layer_thick[k].value;
-        //Un-normalize by volume
-        sum += weights_radius[i].weight
-            * weights_core_thick[j].weight * weights_layer_thick[k].weight* StackedDiscs(dp, q)
-        *pow(weights_radius[i].value,2)*(weights_core_thick[j].value+2*weights_layer_thick[k].value);
-        //Find average volume
-        vol += weights_radius[i].weight
-            * weights_core_thick[j].weight * weights_layer_thick[k].weight
-            *pow(weights_radius[i].value,2)*(weights_core_thick[j].value+2*weights_layer_thick[k].value);
-        norm += weights_radius[i].weight
-            * weights_core_thick[j].weight* weights_layer_thick[k].weight;
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double StackedDisksModel :: operator()(double qx, double qy) {
-  StackedDisksParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.core_thick    = core_thick();
-  dp.radius	  = radius();
-  dp.layer_thick  = layer_thick();
-  dp.core_sld   = core_sld();
-  dp.layer_sld  = layer_sld();
-  dp.solvent_sld= solvent_sld();
-  dp.n_stacking	  = n_stacking();
-  dp.sigma_d   = sigma_d();
-  dp.background = 0.0;
-  dp.axis_theta = axis_theta();
-  dp.axis_phi   = axis_phi();
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_core_thick;
-  core_thick.get_weights(weights_core_thick);
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_layer_thick;
-  layer_thick.get_weights(weights_layer_thick);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  
-  // Loop over length weight points
-  for(int i=0; i< (int)weights_core_thick.size(); i++) {
-    dp.core_thick = weights_core_thick[i].value;
-
-    // Loop over radius weight points
-    for(int j=0; j< (int)weights_radius.size(); j++) {
-      dp.radius = weights_radius[j].value;
-
-      // Loop over thickness weight points
-      for(int k=0; k< (int)weights_layer_thick.size(); k++) {
-        dp.layer_thick = weights_layer_thick[k].value;
-
-        for(int l=0; l< (int)weights_theta.size(); l++) {
-          dp.axis_theta = weights_theta[l].value;
-
-          // Average over phi distribution
-          for(int m=0; m <(int)weights_phi.size(); m++) {
-            dp.axis_phi = weights_phi[m].value;
-
-            //Un-normalize by volume
-            double _ptvalue = weights_core_thick[i].weight
-                * weights_radius[j].weight
-                * weights_layer_thick[k].weight
-                * weights_theta[l].weight
-                * weights_phi[m].weight
-                * stacked_disks_analytical_2DXY(&dp, qx, qy)
-            *pow(weights_radius[j].value,2)*(weights_core_thick[i].value+2*weights_layer_thick[k].value);
-            if (weights_theta.size()>1) {
-              _ptvalue *= fabs(cos(weights_theta[l].value*pi/180.0));
-            }
-            sum += _ptvalue;
-            //Find average volume
-            vol += weights_radius[j].weight
-                * weights_core_thick[i].weight * weights_layer_thick[k].weight
-                *pow(weights_radius[j].value,2)*(weights_core_thick[i].value+2*weights_layer_thick[k].value);
-            //Find norm for volume
-            norm_vol += weights_radius[j].weight
-                * weights_core_thick[i].weight * weights_layer_thick[k].weight;
-
-            norm += weights_core_thick[i].weight
-                * weights_radius[j].weight
-                * weights_layer_thick[k].weight
-                * weights_theta[l].weight
-                * weights_phi[m].weight;
-          }
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the triaxial ellipsoid
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double StackedDisksModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double StackedDisksModel :: calculate_ER() {
-  StackedDisksParameters dp;
-
-  dp.core_thick    = core_thick();
-  dp.radius	  = radius();
-  dp.layer_thick  = layer_thick();
-  dp.n_stacking	  = n_stacking();
-
-  double rad_out = 0.0;
-  if (dp.n_stacking <= 0.0){
-    return rad_out;
-  }
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the length
-  vector<WeightPoint> weights_core_thick;
-  core_thick.get_weights(weights_core_thick);
-
-  // Get the dispersion points for the radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_layer_thick;
-  layer_thick.get_weights(weights_layer_thick);
-
-  // Loop over major shell weight points
-  for(int i=0; i< (int)weights_core_thick.size(); i++) {
-    dp.core_thick = weights_core_thick[i].value;
-    for(int j=0; j< (int)weights_layer_thick.size(); j++) {
-      dp.layer_thick = weights_layer_thick[j].value;
-      for(int k=0; k< (int)weights_radius.size(); k++) {
-        dp.radius = weights_radius[k].value;
-        //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-        sum +=weights_core_thick[i].weight*weights_layer_thick[j].weight
-            * weights_radius[k].weight*DiamCyl(dp.n_stacking*(dp.layer_thick*2.0+dp.core_thick),dp.radius)/2.0;
-        norm += weights_core_thick[i].weight*weights_layer_thick[j].weight* weights_radius[k].weight;
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER.
-    rad_out = DiamCyl(dp.n_stacking*(dp.layer_thick*2.0+dp.core_thick),dp.radius)/2.0;}
-
-  return rad_out;
-}
-double StackedDisksModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/starpolymer.cpp
===================================================================
--- src/sans/models/src/c_models/starpolymer.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/**
-	This software was developed by Institut Laue-Langevin as part of
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE).
-
-	Copyright 2012 Institut Laue-Langevin
-
-**/
-
-#include <math.h>
-#include "parameters.hh"
-#include "starpolymer.h"
-
-StarPolymer::StarPolymer() {
- 
-  arms = Parameter(3.0);
-  R2 = Parameter(100.0);
-  scale = Parameter(1.0);
-  background = Parameter(0.0);
-
-}
-
-double StarPolymer::operator()(double q) {
-
-  double d_arms = arms();
-  double d_R2 = R2();
-  double d_scale = scale();
-  double d_background = background();
-
-  double u_2 = d_R2 * pow(q,2);
-  double v = u_2 * d_arms / (3.0 * d_arms - 2.0);
-
-  double term1 = v - 1.0 + exp(-v);
-  double term2 = ((d_arms - 1.0)/2.0)* pow((1.0 - exp(-v)),2.0);
-
-  return 2.0 * d_scale / (d_arms * pow(v,2.0)) * (term1 + term2) + d_background;
-
-}
-
-double StarPolymer::operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return this->operator()(q);
-}
-
-double StarPolymer::calculate_ER() {
-  // not implemented yet
-  return 0.0;
-}
-
-double StarPolymer::calculate_VR() {
-  return 1.0;
-}
-
-double StarPolymer::evaluate_rphi(double q, double phi) {
-  double qx = q * cos(phi);
-  double qy = q * sin(phi);
-  return this->operator()(qx, qy);
-}
-
-
Index: c/sans/models/src/c_models/surfacefractal.cpp
===================================================================
--- src/sans/models/src/c_models/surfacefractal.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,128 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "surfacefractal.h"
-extern "C" {
-#include "libmultifunc/libfunc.h"
-}
-
-static double surface_fractal_kernel(double dp[], double q) {
-  //fit parameters
-  double scale = dp[0];
-  double radius = dp[1];
-  double surface_dim = dp[2];
-  double co_length = dp[3];
-  double background = dp[4];
-  //others
-  double pq = 0.0;
-  double sq = 0.0;
-  double mmo = 0.0;
-  //result
-  double result = 0.0;
-  if( (q*radius) == 0.0){
-		pq = 1.0;
-  }
-  else{
-	//calculate P(q) for the spherical subunits; not normalized
-	pq = pow((3.0*(sin(q*radius) - q*radius*cos(q*radius))/pow((q*radius),3)),2);
-  }
-  mmo = 5.0 - surface_dim;
-
-  //calculate S(q)
-  sq = exp(gamln(mmo))*sin(-(mmo)*atan(q*co_length));
-  sq *= pow(co_length, mmo);
-  sq /= pow((1.0 + (q*co_length)*(q*co_length)),(mmo/2.0));
-  sq /= q;
-  //combine and return
-  result = pq * sq;
-  result *= scale;
-  result += background;
-
-  return(result);
-}
-
-SurfaceFractalModel :: SurfaceFractalModel() {
-  scale      = Parameter(1.0);
-  radius = Parameter(10.0);
-  surface_dim = Parameter(2.0);
-  co_length = Parameter(500.0);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * @param q: q-value
- * @return: function value
- */
-double SurfaceFractalModel :: operator()(double q) {
-  double dp[5];
-
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = surface_dim();
-  dp[3] = co_length();
-  dp[4] = 0.0;
-
-  // Perform the computation
-  double sum = 0.0;
-
-  sum = surface_fractal_kernel(dp, fabs(q));
-  return sum + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double SurfaceFractalModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the SurfaceFractalModel
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double SurfaceFractalModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double SurfaceFractalModel :: calculate_ER() {
-  //NOT implemented yet!!! 'cause None shape Model
-  return 0.0;
-}
-double SurfaceFractalModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/teubner_strey.cpp
===================================================================
--- src/sans/models/src/c_models/teubner_strey.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/**
-	This software was developed by Institut Laue-Langevin as part of
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE).
-
-	Copyright 2012 Institut Laue-Langevin
-
-**/
-
-#include <math.h>
-#include "parameters.hh"
-#include "teubner_strey.h"
-
-TeubnerStreyModel::TeubnerStreyModel() {
-  scale = Parameter(0.1);
-  c1 = Parameter(-30.0);
-  c2 = Parameter(5000.0);
-  background = Parameter(0.0);
-}
-
-double TeubnerStreyModel::operator()(double q) { 
-  double d_scale = scale();
-  double d_c1 = c1();
-  double d_c2 = c2();
-  double d_background = background();
-
-  double term1 = d_c1 * pow(q,2);
-  double term2 = d_c2 * pow(q,4);
-
-  return 1/(d_scale + term1 + term2) + d_background;
-
-}
-
-
-double TeubnerStreyModel::operator()(double qx,double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return this->operator()(q);
-}
-
-double TeubnerStreyModel::calculate_ER() {
-  // not implemented yet
-  return 0.0;
-}
-
-double TeubnerStreyModel::calculate_VR() {
-  return 1.0;
-}
-
-double TeubnerStreyModel::evaluate_rphi(double q,double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return this->operator()(qx, qy);
-}
-
-
-
-/***
-    Notes
-
-    This file was ported from python to C++ at ILL Grenoble in
-    July 2012. In the original python file were two functions,
-    teubnerStreyLengths and teubnerStreyDistance that did not appear
-    to be used anywhere in the code. The source for them is below:
-
-    def teubnerStreyLengths(self):
-        """
-            Calculate the correlation length (L) 
-            @return L: the correlation distance 
-        """
-        return  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\
-                            +(self.params['c1']/(4*self.params['c2'])),-1/2 )
-    def teubnerStreyDistance(self):
-        """
-            Calculate the quasi-periodic repeat distance (D/(2*pi)) 
-            @return D: quasi-periodic repeat distance
-        """
-        return  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\
-                            -(self.params['c1']/(4*self.params['c2'])),-1/2 )
-
-
-***/
Index: c/sans/models/src/c_models/triaxialellipsoid.cpp
===================================================================
--- src/sans/models/src/c_models/triaxialellipsoid.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,462 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-#include <stdlib.h>
-using namespace std;
-#include "triaxial_ellipsoid.h"
-
-extern "C" {
-#include "libCylinder.h"
-#include "libStructureFactor.h"
-}
-
-typedef struct {
-  double scale;
-  double semi_axisA;
-  double semi_axisB;
-  double semi_axisC;
-  double sldEll;
-  double sldSolv;
-  double background;
-  double axis_theta;
-  double axis_phi;
-  double axis_psi;
-
-} TriaxialEllipsoidParameters;
-
-static double triaxial_ellipsoid_kernel(TriaxialEllipsoidParameters *pars, double q, double cos_val, double cos_nu, double cos_mu) {
-  double t,a,b,c;
-  double kernel;
-
-  a = pars->semi_axisA ;
-  b = pars->semi_axisB ;
-  c = pars->semi_axisC ;
-
-  t = q * sqrt(a*a*cos_nu*cos_nu+b*b*cos_mu*cos_mu+c*c*cos_val*cos_val);
-  if (t==0.0){
-    kernel  = 1.0;
-  }else{
-    kernel  = 3.0*(sin(t)-t*cos(t))/(t*t*t);
-  }
-  return kernel*kernel;
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the triaxial ellipsoid
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-static double triaxial_ellipsoid_analytical_2D_scaled(TriaxialEllipsoidParameters *pars, double q, double q_x, double q_y) {
-  double cyl_x, cyl_y, ella_x, ella_y, ellb_x, ellb_y;
-  //double q_z;
-  double cos_nu, cos_mu;
-  double vol, cos_val;
-  double answer;
-  double pi = 4.0*atan(1.0);
-
-  //convert angle degree to radian
-  double theta = pars->axis_theta * pi/180.0;
-  double phi = pars->axis_phi * pi/180.0;
-  double psi = pars->axis_psi * pi/180.0;
-
-  // Cylinder orientation
-  cyl_x = cos(theta) * cos(phi);
-  cyl_y = sin(theta);
-  //cyl_z = -cos(theta) * sin(phi);
-
-  // q vector
-  //q_z = 0.0;
-
-  //dx = 1.0;
-  //dy = 1.0;
-  // Compute the angle btw vector q and the
-  // axis of the cylinder
-  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
-
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
-    return 0;
-  }
-
-  // Note: cos(alpha) = 0 and 1 will get an
-  // undefined value from CylKernel
-  //alpha = acos( cos_val );
-
-  //ellipse orientation:
-  // the elliptical corss section was transformed and projected
-  // into the detector plane already through sin(alpha)and furthermore psi remains as same
-  // on the detector plane.
-  // So, all we need is to calculate the angle (nu) of the minor axis of the ellipse wrt
-  // the wave vector q.
-
-  //x- y- component of a-axis on the detector plane.
-  ella_x =  -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi);
-  ella_y =  sin(psi)*cos(theta);
-  
-  //x- y- component of b-axis on the detector plane.
-  ellb_x =  -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi);
-  ellb_y =  cos(theta)*cos(psi);
-  
-  // calculate the axis of the ellipse wrt q-coord.
-  cos_nu = ella_x*q_x + ella_y*q_y;
-  cos_mu = ellb_x*q_x + ellb_y*q_y;
-  
-  // The following test should always pass
-  if (fabs(cos_val)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_val = 1.0;
-  }
-   if (fabs(cos_nu)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_nu = 1.0;
-  }
-   if (fabs(cos_mu)>1.0) {
-    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");
-    cos_mu = 1.0;
-  } 
-  // Call the IGOR library function to get the kernel
-  answer = triaxial_ellipsoid_kernel(pars, q, cos_val, cos_nu, cos_mu);
-
-  // Multiply by contrast^2
-  answer *= (pars->sldEll- pars->sldSolv)*(pars->sldEll- pars->sldSolv);
-
-  //normalize by cylinder volume
-  //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-  vol = 4.0* pi/3.0  * pars->semi_axisA * pars->semi_axisB * pars->semi_axisC;
-  answer *= vol;
-  //convert to [cm-1]
-  answer *= 1.0e8;
-  //Scale
-  answer *= pars->scale;
-
-  // add in the background
-  answer += pars->background;
-
-  return answer;
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the triaxial ellipsoid
- * @param q: q-value
- * @return: function value
- */
-static double triaxial_ellipsoid_analytical_2DXY(TriaxialEllipsoidParameters *pars, double qx, double qy) {
-  double q;
-  q = sqrt(qx*qx+qy*qy);
-  return triaxial_ellipsoid_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-
-TriaxialEllipsoidModel :: TriaxialEllipsoidModel() {
-  scale      = Parameter(1.0);
-  semi_axisA     = Parameter(35.0, true);
-  semi_axisA.set_min(0.0);
-  semi_axisB     = Parameter(100.0, true);
-  semi_axisB.set_min(0.0);
-  semi_axisC  = Parameter(400.0, true);
-  semi_axisC.set_min(0.0);
-  sldEll   = Parameter(1.0e-6);
-  sldSolv   = Parameter(6.3e-6);
-  background = Parameter(0.0);
-  axis_theta  = Parameter(57.325, true);
-  axis_phi    = Parameter(57.325, true);
-  axis_psi    = Parameter(0.0, true);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double TriaxialEllipsoidModel :: operator()(double q) {
-  double dp[7];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = semi_axisA();
-  dp[2] = semi_axisB();
-  dp[3] = semi_axisC();
-  dp[4] = sldEll();
-  dp[5] = sldSolv();
-  dp[6] = 0.0;
-
-  // Get the dispersion points for the semi axis A
-  vector<WeightPoint> weights_semi_axisA;
-  semi_axisA.get_weights(weights_semi_axisA);
-
-  // Get the dispersion points for the semi axis B
-  vector<WeightPoint> weights_semi_axisB;
-  semi_axisB.get_weights(weights_semi_axisB);
-
-  // Get the dispersion points for the semi axis C
-  vector<WeightPoint> weights_semi_axisC;
-  semi_axisC.get_weights(weights_semi_axisC);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over semi axis A weight points
-  for(int i=0; i< (int)weights_semi_axisA.size(); i++) {
-    dp[1] = weights_semi_axisA[i].value;
-
-    // Loop over semi axis B weight points
-    for(int j=0; j< (int)weights_semi_axisB.size(); j++) {
-      dp[2] = weights_semi_axisB[j].value;
-
-      // Loop over semi axis C weight points
-      for(int k=0; k< (int)weights_semi_axisC.size(); k++) {
-        dp[3] = weights_semi_axisC[k].value;
-        //Un-normalize  by volume
-        sum += weights_semi_axisA[i].weight
-            * weights_semi_axisB[j].weight * weights_semi_axisC[k].weight* TriaxialEllipsoid(dp, q)
-        * weights_semi_axisA[i].value*weights_semi_axisB[j].value*weights_semi_axisC[k].value;
-        //Find average volume
-        vol += weights_semi_axisA[i].weight
-            * weights_semi_axisB[j].weight * weights_semi_axisC[k].weight
-            * weights_semi_axisA[i].value*weights_semi_axisB[j].value*weights_semi_axisC[k].value;
-
-        norm += weights_semi_axisA[i].weight
-            * weights_semi_axisB[j].weight * weights_semi_axisC[k].weight;
-      }
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double TriaxialEllipsoidModel :: operator()(double qx, double qy) {
-  TriaxialEllipsoidParameters dp;
-  // Fill parameter array
-  dp.scale      = scale();
-  dp.semi_axisA   = semi_axisA();
-  dp.semi_axisB     = semi_axisB();
-  dp.semi_axisC     = semi_axisC();
-  dp.sldEll   = sldEll();
-  dp.sldSolv   = sldSolv();
-  dp.background = 0.0;
-  dp.axis_theta  = axis_theta();
-  dp.axis_phi    = axis_phi();
-  dp.axis_psi    = axis_psi();
-
-  // Get the dispersion points for the semi_axis A
-  vector<WeightPoint> weights_semi_axisA;
-  semi_axisA.get_weights(weights_semi_axisA);
-
-  // Get the dispersion points for the semi_axis B
-  vector<WeightPoint> weights_semi_axisB;
-  semi_axisB.get_weights(weights_semi_axisB);
-
-  // Get the dispersion points for the semi_axis C
-  vector<WeightPoint> weights_semi_axisC;
-  semi_axisC.get_weights(weights_semi_axisC);
-
-  // Get angular averaging for theta
-  vector<WeightPoint> weights_theta;
-  axis_theta.get_weights(weights_theta);
-
-  // Get angular averaging for phi
-  vector<WeightPoint> weights_phi;
-  axis_phi.get_weights(weights_phi);
-
-  // Get angular averaging for psi
-  vector<WeightPoint> weights_psi;
-  axis_psi.get_weights(weights_psi);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double norm_vol = 0.0;
-  double vol = 0.0;
-  double pi = 4.0*atan(1.0);
-  // Loop over semi axis A weight points
-  for(int i=0; i< (int)weights_semi_axisA.size(); i++) {
-    dp.semi_axisA = weights_semi_axisA[i].value;
-
-    // Loop over semi axis B weight points
-    for(int j=0; j< (int)weights_semi_axisB.size(); j++) {
-      dp.semi_axisB = weights_semi_axisB[j].value;
-
-      // Loop over semi axis C weight points
-      for(int k=0; k < (int)weights_semi_axisC.size(); k++) {
-        dp.semi_axisC = weights_semi_axisC[k].value;
-
-        // Average over theta distribution
-        for(int l=0; l< (int)weights_theta.size(); l++) {
-          dp.axis_theta = weights_theta[l].value;
-
-          // Average over phi distribution
-          for(int m=0; m <(int)weights_phi.size(); m++) {
-            dp.axis_phi = weights_phi[m].value;
-            // Average over psi distribution
-            for(int n=0; n <(int)weights_psi.size(); n++) {
-              dp.axis_psi = weights_psi[n].value;
-              //Un-normalize  by volume
-              double _ptvalue = weights_semi_axisA[i].weight
-                  * weights_semi_axisB[j].weight
-                  * weights_semi_axisC[k].weight
-                  * weights_theta[l].weight
-                  * weights_phi[m].weight
-                  * weights_psi[n].weight
-                  * triaxial_ellipsoid_analytical_2DXY(&dp, qx, qy)
-              * weights_semi_axisA[i].value*weights_semi_axisB[j].value*weights_semi_axisC[k].value;
-              if (weights_theta.size()>1) {
-                _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0));
-              }
-              sum += _ptvalue;
-              //Find average volume
-              vol += weights_semi_axisA[i].weight
-                  * weights_semi_axisB[j].weight
-                  * weights_semi_axisC[k].weight
-                  * weights_semi_axisA[i].value*weights_semi_axisB[j].value*weights_semi_axisC[k].value;
-              //Find norm for volume
-              norm_vol += weights_semi_axisA[i].weight
-                  * weights_semi_axisB[j].weight
-                  * weights_semi_axisC[k].weight;
-
-              norm += weights_semi_axisA[i].weight
-                  * weights_semi_axisB[j].weight
-                  * weights_semi_axisC[k].weight
-                  * weights_theta[l].weight
-                  * weights_phi[m].weight
-                  * weights_psi[n].weight;
-            }
-          }
-
-        }
-      }
-    }
-  }
-  // Averaging in theta needs an extra normalization
-  // factor to account for the sin(theta) term in the
-  // integration (see documentation).
-  if (weights_theta.size()>1) norm = norm / asin(1.0);
-
-  if (vol != 0.0 && norm_vol != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm_vol);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the triaxial ellipsoid
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double TriaxialEllipsoidModel :: evaluate_rphi(double q, double phi) {
-  double qx = q*cos(phi);
-  double qy = q*sin(phi);
-  return (*this).operator()(qx, qy);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double TriaxialEllipsoidModel :: calculate_ER() {
-  TriaxialEllipsoidParameters dp;
-
-  dp.semi_axisA   = semi_axisA();
-  dp.semi_axisB     = semi_axisB();
-  //polar axis C
-  dp.semi_axisC     = semi_axisC();
-
-  double rad_out = 0.0;
-  //Surface average radius at the equat. cross section.
-  double suf_rad = sqrt(dp.semi_axisA * dp.semi_axisB);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-  // Get the dispersion points for the semi_axis A
-  vector<WeightPoint> weights_semi_axisA;
-  semi_axisA.get_weights(weights_semi_axisA);
-
-  // Get the dispersion points for the semi_axis B
-  vector<WeightPoint> weights_semi_axisB;
-  semi_axisB.get_weights(weights_semi_axisB);
-
-  // Get the dispersion points for the semi_axis C
-  vector<WeightPoint> weights_semi_axisC;
-  semi_axisC.get_weights(weights_semi_axisC);
-
-  // Loop over semi axis A weight points
-  for(int i=0; i< (int)weights_semi_axisA.size(); i++) {
-    dp.semi_axisA = weights_semi_axisA[i].value;
-
-    // Loop over semi axis B weight points
-    for(int j=0; j< (int)weights_semi_axisB.size(); j++) {
-      dp.semi_axisB = weights_semi_axisB[j].value;
-
-      // Loop over semi axis C weight points
-      for(int k=0; k < (int)weights_semi_axisC.size(); k++) {
-        dp.semi_axisC = weights_semi_axisC[k].value;
-
-        //Calculate surface averaged radius
-        suf_rad = sqrt(dp.semi_axisA * dp.semi_axisB);
-
-        //Sum
-        sum += weights_semi_axisA[i].weight
-            * weights_semi_axisB[j].weight
-            * weights_semi_axisC[k].weight * DiamEllip(dp.semi_axisC, suf_rad)/2.0;
-        //Norm
-        norm += weights_semi_axisA[i].weight* weights_semi_axisB[j].weight
-            * weights_semi_axisC[k].weight;
-      }
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    rad_out = DiamEllip(dp.semi_axisC, suf_rad)/2.0;}
-
-  return rad_out;
-}
-double TriaxialEllipsoidModel :: calculate_VR() {
-  return 1.0;
-}
Index: c/sans/models/src/c_models/vesicle.cpp
===================================================================
--- src/sans/models/src/c_models/vesicle.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,213 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/**
- * Scattering model classes
- * The classes use the IGOR library found in
- *   sansmodels/src/libigor
- *
- */
-
-#include <math.h>
-#include "parameters.hh"
-#include <stdio.h>
-using namespace std;
-#include "vesicle.h"
-
-extern "C" {
-#include "libSphere.h"
-}
-
-typedef struct {
-  double scale;
-  double radius;
-  double thickness;
-  double solv_sld;
-  double shell_sld;
-  double background;
-} VesicleParameters;
-
-VesicleModel :: VesicleModel() {
-  scale      = Parameter(1.0);
-  radius     = Parameter(100.0, true);
-  radius.set_min(0.0);
-  thickness  = Parameter(30.0, true);
-  thickness.set_min(0.0);
-  solv_sld   = Parameter(6.36e-6);
-  shell_sld   = Parameter(5.0e-7);
-  background = Parameter(0.0);
-}
-
-/**
- * Function to evaluate 1D scattering function
- * The NIST IGOR library is used for the actual calculation.
- * @param q: q-value
- * @return: function value
- */
-double VesicleModel :: operator()(double q) {
-  double dp[6];
-
-  // Fill parameter array for IGOR library
-  // Add the background after averaging
-  dp[0] = scale();
-  dp[1] = radius();
-  dp[2] = thickness();
-  dp[3] = solv_sld();
-  dp[4] = shell_sld();
-  dp[5] = 0.0;
-
-
-  // Get the dispersion points for the core radius
-  vector<WeightPoint> weights_radius;
-  radius.get_weights(weights_radius);
-  // Get the dispersion points for the thickness
-  vector<WeightPoint> weights_thickness;
-  thickness.get_weights(weights_thickness);
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-  double vol = 0.0;
-
-  // Loop over radius weight points
-  for(int i=0; i< (int)weights_radius.size(); i++) {
-    dp[1] = weights_radius[i].value;
-    for(int j=0; j< (int)weights_thickness.size(); j++) {
-      dp[2] = weights_thickness[j].value;
-      sum += weights_radius[i].weight
-          * weights_thickness[j].weight * VesicleForm(dp, q)
-      *(pow(weights_radius[i].value+weights_thickness[j].value,3)-pow(weights_radius[i].value,3));
-      //Find average volume
-      vol += weights_radius[i].weight * weights_thickness[j].weight
-          *(pow(weights_radius[i].value+weights_thickness[j].value,3)-pow(weights_radius[i].value,3));
-      norm += weights_radius[i].weight * weights_thickness[j].weight;
-    }
-  }
-  if (vol != 0.0 && norm != 0.0) {
-    //Re-normalize by avg volume
-    sum = sum/(vol/norm);}
-
-  return sum/norm + background();
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param q_x: value of Q along x
- * @param q_y: value of Q along y
- * @return: function value
- */
-double VesicleModel :: operator()(double qx, double qy) {
-  double q = sqrt(qx*qx + qy*qy);
-  return (*this).operator()(q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the vesicle
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double VesicleModel :: evaluate_rphi(double q, double phi) {
-  return (*this).operator()(q);
-}
-/**
- * Function to calculate effective radius
- * @return: effective radius value
- */
-double VesicleModel :: calculate_ER() {
-  VesicleParameters dp;
-
-  dp.radius     = radius();
-  dp.thickness  = thickness();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum = 0.0;
-  double norm = 0.0;
-
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_thickness;
-  thickness.get_weights(weights_thickness);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Loop over major shell weight points
-  for(int j=0; j< (int)weights_thickness.size(); j++) {
-    dp.thickness = weights_thickness[j].value;
-    for(int k=0; k< (int)weights_radius.size(); k++) {
-      dp.radius = weights_radius[k].value;
-      sum += weights_thickness[j].weight
-          * weights_radius[k].weight*(dp.radius+dp.thickness);
-      norm += weights_thickness[j].weight* weights_radius[k].weight;
-    }
-  }
-  if (norm != 0){
-    //return the averaged value
-    rad_out =  sum/norm;}
-  else{
-    //return normal value
-    rad_out = (dp.radius+dp.thickness);}
-
-  return rad_out;
-}
-/**
- * Function to calculate volf_ratio for shell
- * @return: volf_ratio value
- */
-double VesicleModel :: calculate_VR() {
-  VesicleParameters dp;
-
-  dp.radius     = radius();
-  dp.thickness  = thickness();
-
-  double rad_out = 0.0;
-
-  // Perform the computation, with all weight points
-  double sum_tot = 0.0;
-  double sum_shell = 0.0;
-
-
-  // Get the dispersion points for the major shell
-  vector<WeightPoint> weights_thickness;
-  thickness.get_weights(weights_thickness);
-
-  // Get the dispersion points for the minor shell
-  vector<WeightPoint> weights_radius ;
-  radius.get_weights(weights_radius);
-
-  // Loop over major shell weight points
-  for(int j=0; j< (int)weights_thickness.size(); j++) {
-    dp.thickness = weights_thickness[j].value;
-    for(int k=0; k< (int)weights_radius.size(); k++) {
-      dp.radius = weights_radius[k].value;
-      sum_tot += weights_thickness[j].weight
-          * weights_radius[k].weight*pow((dp.radius+dp.thickness), 3);
-      sum_shell += weights_thickness[j].weight
-		  * weights_radius[k].weight*(pow((dp.radius+dp.thickness), 3)
-				  - pow((dp.radius), 3));
-    }
-  }
-  if (sum_tot == 0.0){
-    //return the default value
-    rad_out =  1.0;}
-  else{
-    //return ratio value
-    return sum_shell/sum_tot;
-  }
-}
Index: c/sans/models/src/c_smearer/smearer.cpp
===================================================================
--- src/sans/models/src/c_smearer/smearer.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,373 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2009, University of Tennessee
- */
-#include "smearer.hh"
-#include <stdio.h>
-#include <math.h>
-using namespace std;
-
-#if defined(_MSC_VER)
-extern "C" {
-#include "winFuncs.h"
-}
-#endif
-/**
- * Constructor for BaseSmearer
- *
- * @param qmin: minimum Q value
- * @param qmax: maximum Q value
- * @param nbins: number of Q bins
- */
-BaseSmearer :: BaseSmearer(double qmin, double qmax, int nbins) {
-	// Number of bins
-	this->nbins = nbins;
-	this->qmin = qmin;
-	this->qmax = qmax;
-	// Flag to keep track of whether we have a smearing matrix or
-	// whether we need to compute one
-	has_matrix = false;
-	even_binning = true;
-};
-
-/**
- * Constructor for BaseSmearer
- *
- * Used for uneven binning
- * @param q: array of Q values
- * @param nbins: number of Q bins
- */
-BaseSmearer :: BaseSmearer(double* q, int nbins) {
-	// Number of bins
-	this->nbins = nbins;
-	this->q_values = q;
-	// Flag to keep track of whether we have a smearing matrix or
-	// whether we need to compute one
-	has_matrix = false;
-	even_binning = false;
-};
-
-/**
- * Constructor for SlitSmearer
- *
- * @param width: slit width in Q units
- * @param height: slit height in Q units
- * @param qmin: minimum Q value
- * @param qmax: maximum Q value
- * @param nbins: number of Q bins
- */
-SlitSmearer :: SlitSmearer(double width, double height, double qmin, double qmax, int nbins) :
-	BaseSmearer(qmin, qmax, nbins){
-	this->height = height;
-	this->width = width;
-};
-
-/**
- * Constructor for SlitSmearer
- *
- * @param width: slit width in Q units
- * @param height: slit height in Q units
- * @param q: array of Q values
- * @param nbins: number of Q bins
- */
-SlitSmearer :: SlitSmearer(double width, double height, double* q, int nbins) :
-	BaseSmearer(q, nbins){
-	this->height = height;
-	this->width = width;
-};
-
-/**
- * Constructor for QSmearer
- *
- * @param width: array slit widths for each Q point, in Q units
- * @param qmin: minimum Q value
- * @param qmax: maximum Q value
- * @param nbins: number of Q bins
- */
-QSmearer :: QSmearer(double* width, double qmin, double qmax, int nbins) :
-	BaseSmearer(qmin, qmax, nbins){
-	this->width = width;
-};
-
-/**
- * Constructor for QSmearer
- *
- * @param width: array slit widths for each Q point, in Q units
- * @param q: array of Q values
- * @param nbins: number of Q bins
- */
-QSmearer :: QSmearer(double* width, double* q, int nbins) :
-	BaseSmearer(q, nbins){
-	this->width = width;
-};
-
-/**
- * Compute the slit smearing matrix
- *
- * For even binning (q_min to q_max with nbins):
- *
- *   step = (q_max-q_min)/(nbins-1)
- *   first bin goes from q_min to q_min+step
- *   last bin goes from q_max to q_max+step
- *
- * For binning according to q array:
- *
- * Each q point represents a bin going from half the distance between it
- * and the previous point to half the distance between it and the next point.
- *
- *    Example: bin i goes from (q_values[i-1]+q_values[i])/2 to (q_values[i]+q_values[i+1])/2
- *
- * The exceptions are the first and last bins, which are centered at the first and
- * last q-values, respectively. The width of the first and last bins is the distance between
- * their respective neighboring q-value.
- */
-void SlitSmearer :: compute_matrix(){
-
-	weights = new vector<double>(nbins*nbins,0);
-
-	// Check the length of the data
-	if (nbins<2) return;
-	int npts_h = height>0.0 ? npts : 1;
-	int npts_w = width>0.0 ? npts : 1;
-
-	// If both height and width are great than zero,
-	// modify the number of points in each direction so
-	// that the total number of points is still what
-	// the user would expect (downgrade resolution)
-	//if(npts_h>1 && npts_w>1){
-	//	npts_h = (int)ceil(sqrt((double)npts));
-	//	npts_w = npts_h;
-	//}
-	double shift_h, shift_w, hbin_size, wbin_size;
-	// Make sure height and width are all positive (FWMH/2)
-	// Assumption; height and width are all same for all q points
-	if(npts_h == 1){
-		shift_h = 0.0;
-	} else {
-		shift_h = fabs(height);
-	}
-	if(npts_w == 1){
-		shift_w = 0.0;
-	} else {
-		shift_w = fabs(width);
-	}
-	// size of the h bin and w bin
-	hbin_size = shift_h / nbins;
-	wbin_size = shift_w / nbins;
-
-	// Loop over all q-values
-	double q, q_min, q_max, q_0=0.0;
-	for(int i=0; i<nbins; i++) {
-		// Find Weights
-		// Find q where the resolution smearing calculation of I(q) occurs
-		get_bin_range(i, &q, &q_min, &q_max);
-		// Block q becomes <=0
-		if (q <= 0){
-			continue;
-		}
-		// Find q[0] value to normalize the weight later,
-		//  otherwise, we will have a precision problem.
-		if (i == 0){
-			q_0 = q;
-		}
-		// Loop over all qj-values
-		for(int j=0; j<nbins; j++) {
-			double q_j, q_high, q_low;
-			// Calculate bin size of q_j
-			get_bin_range(j, &q_j, &q_low, &q_high);
-			// Block q_j becomes <=0
-			if (q_j <= 0){
-				continue;
-			}
-			// Check q_low that can not be negative.
-			if (q_low < 0.0){
-				q_low = 0.0;
-			}
-			// default parameter values
-			(*weights)[i*nbins+j] = 0.0;
-			// protect for negative q
-			if (q <= 0.0 || q_j <= 0.0){
-					continue;
-			}
-			double shift_w = 0.0;
-			// Condition: zero slit smear.
-			if (npts_w == 1 && npts_h == 1){
-				if(q_j == q) {
-					(*weights)[i*nbins+j] = 1.0;
-				}
-			}
-			//Condition:Smear weight integration for width >0 when the height (=0) does not present.
-			//Or height << width.
-			else if((npts_w!=1 && npts_h == 1)|| (npts_w!=1 && npts_h != 1 && width/height > 100.0)){
-				shift_w = width;
-				//del_w = width/((double)npts_w-1.0);
-				double q_shifted_low = q - shift_w;
-				// High limit of the resolution range
-				double q_shifted_high = q + shift_w;
-				// Go through all the q_js for weighting those points
-				if(q_j >= q_shifted_low && q_j <= q_shifted_high) {
-					// The weighting factor comes,
-					// Give some weight (delq_bin) for the q_j within the resolution range
-					// Weight should be same for all qs except
-					// for the q bin size at j.
-					// Note that the division by q_0 is only due to the precision problem
-					// where q_high - q_low gets to very small.
-					// Later, it will be normalized again.
-					(*weights)[i*nbins+j] += (q_high - q_low)/q_0 ;
-				}
-			}
-			else{
-				// Loop for width (;Height is analytical.)
-				// Condition: height >>> width, otherwise, below is not accurate enough.
-				// Smear weight numerical iteration for width >0 when the height (>0) presents.
-				// When width = 0, the numerical iteration will be skipped.
-				// The resolution calculation for the height is done by direct integration,
-				// assuming the I(q'=sqrt(q_j^2-(q+shift_w)^2)) is constant within a q' bin, [q_high, q_low].
-				// In general, this weight numerical iteration for width >0 might be a rough approximation,
-				// but it must be good enough when height >>> width.
-				for(int k=(-npts_w + 1); k<npts_w; k++){
-					if(npts_w!=1){
-						shift_w = width/((double)npts_w-1.0)*(double)k;
-					}
-					// For each q-value, compute the weight of each other q-bin
-					// in the I(q) array
-					// Low limit of the resolution range
-					double q_shift = q + shift_w;
-					if (q_shift < 0.0){
-						q_shift = 0.0;
-					}
-					double q_shifted_low = q_shift;
-					// High limit of the resolution range
-					double q_shifted_high = sqrt(q_shift * q_shift + shift_h * shift_h);
-
-
-					// Go through all the q_js for weighting those points
-					if(q_j >= q_shifted_low && q_j <= q_shifted_high) {
-						// The weighting factor comes,
-						// Give some weight (delq_bin) for the q_j within the resolution range
-						// Weight should be same for all qs except
-						// for the q bin size at j.
-						// Note that the division by q_0 is only due to the precision problem
-						// where q_high - q_low gets to very small.
-						// Later, it will be normalized again.
-
-						// The fabs below are not necessary but in case: the weight should never be imaginary.
-						// At the edge of each sub_width. weight += u(at q_high bin) - u(0), where u(0) = 0,
-						// and weighted by (2.0* npts_w -1.0)once for each q.
-						//if (q == q_j) {
-						if (q_low <= q_shift && q_high > q_shift) {
-							//if (k==0)
-								(*weights)[i*nbins+j] += (sqrt(fabs((q_high)*(q_high)-q_shift * q_shift)))/q_0;// * (2.0*double(npts_w)-1.0);
-						}
-						// For the rest of sub_width. weight += u(at q_high bin) - u(at q_low bin)
-						else{// if (u > 0.0){
-							(*weights)[i*nbins+j] += (sqrt(fabs((q_high)*(q_high)- q_shift * q_shift))-sqrt(fabs((q_low)*(q_low)- q_shift * q_shift)))/q_0 ;
-						}
-					}
-				}
-			}
-		}
-	}
-};
-
-/**
- * Compute the point smearing matrix
- */
-void QSmearer :: compute_matrix(){
-	weights = new vector<double>(nbins*nbins,0);
-
-	// Loop over all q-values
-	double q, q_min, q_max;
-	double q_j, q_jmax, q_jmin;
-	for(int i=0; i<nbins; i++) {
-		get_bin_range(i, &q, &q_min, &q_max);
-
-		for(int j=0; j<nbins; j++) {
-			get_bin_range(j, &q_j, &q_jmin, &q_jmax);
-
-			// Compute the fraction of the Gaussian contributing
-			// to the q_j bin between q_jmin and q_jmax
-			long double value =  erf( (q_jmax-q)/(sqrt(2.0)*width[i]) );
-        	value -= erf( (q_jmin-q)/(sqrt(2.0)*width[i]) );
-        	(*weights)[i*nbins+j] += value;
-		}
-	}
-}
-
-/**
- * Computes the Q range of a given bin of the Q distribution.
- * The range is computed according the the data distribution that
- * was given to the object at initialization.
- *
- * @param i: number of the bin in the distribution
- * @param q: q-value of bin i
- * @param q_min: lower bound of the bin
- * @param q_max: higher bound of the bin
- *
- */
-int BaseSmearer :: get_bin_range(int i, double* q, double* q_min, double* q_max) {
-	if (even_binning) {
-		double step = (qmax-qmin)/((double)nbins-1.0);
-		*q = qmin + (double)i*step;
-		*q_min = *q - 0.5*step;
-		*q_max = *q + 0.5*step;
-		return 1;
-	} else if (i>=0 && i<nbins) {
-		*q = q_values[i];
-		if (i==0) {
-			double step = (q_values[1]-q_values[0])/2.0;
-			*q_min = *q - step;
-			*q_max = *q + step;
-		} else if (i==nbins-1) {
-			double step = (q_values[i]-q_values[i-1])/2.0;
-			*q_min = *q - step;
-			*q_max = *q + step;
-		} else {
-			*q_min = *q - (q_values[i]-q_values[i-1])/2.0;
-			*q_max = *q + (q_values[i+1]-q_values[i])/2.0;
-		}
-		return 1;
-	}
-	return -1;
-}
-
-/**
- * Perform smearing by applying the smearing matrix to the input Q array
- */
-void BaseSmearer :: smear(double *iq_in, double *iq_out, int first_bin, int last_bin){
-
-	// If we haven't computed the smearing matrix, do it now
-	if(!has_matrix) {
-		compute_matrix();
-		has_matrix = true;
-	}
-
-	// Loop over q-values and multiply apply matrix
-	for(int q_i=first_bin; q_i<=last_bin; q_i++){
-		double sum = 0.0;
-		double counts = 0.0;
-
-		for(int i=first_bin; i<=last_bin; i++){
-			// Skip if weight is less than 1e-03(this value is much smaller than
-			// the weight at the 3*sigma distance
-			// Will speed up a little bit...
-			if ((*weights)[q_i*nbins+i] < 1.0e-003){
-				continue;
-			}
-			sum += iq_in[i] * (*weights)[q_i*nbins+i];
-			counts += (*weights)[q_i*nbins+i];
-		}
-
-		// Normalize counts
-		iq_out[q_i] = (counts>0.0) ? sum/counts : 0.0;
-	}
-}
Index: c/sans/models/src/c_smearer/smearer.hh
===================================================================
--- src/sans/models/src/c_smearer/smearer.hh	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2009, University of Tennessee
- */
-#ifndef SMEARER_CLASS_H
-#define SMEARER_CLASS_H
-
-#include <vector>
-
-using namespace std;
-
-/**
- * Base smearer class, implementing the matrix multiplication only
- */
-class BaseSmearer {
-protected:
-	// Internal flag: true when the weights vector is filled
-	bool has_matrix;
-	// True when only qmin, qmax and nbins are given. Bins are equidistant
-	bool even_binning;
-	// Smearing matrix
-	vector<double>* weights;
-	// Q vector
-	double* q_values;
-    // Q_min (Min Q-value for I(q))
-    double qmin;
-    // Q_max (Max Q_value for I(q))
-    double qmax;
-    // Number of Q bins
-    int nbins;
-
-public:
-    // Constructor
-    BaseSmearer(double qmin, double qmax, int nbins);
-    BaseSmearer(double* q, int nbins);
-	// Smear function
-	virtual void smear(double *, double *, int, int);
-	// Compute the smearing matrix
-	virtual void compute_matrix(){};
-	// Utility function to check the number of bins
-	int get_nbins() { return nbins; }
-	// Get the q range of a particular bin
-	virtual int get_bin_range(int, double*, double*, double*);
-};
-
-
-/**
- * Slit smearer class
- */
-class SlitSmearer : public BaseSmearer {
-
-protected:
-    // Number of points used in the smearing computation
-    static const int npts   = 500;
-
-public:
-    // Slit width in Q units
-    double width;
-    // Slit height in Q units
-    double height;
-
-    // Constructor
-	SlitSmearer(double width, double height, double qmin, double qmax, int nbins);
-	SlitSmearer(double width, double height, double* q, int nbins);
-	// Compute the smearing matrix
-	virtual void compute_matrix();
-};
-
-
-/**
- * Point smearer class
- */
-class QSmearer : public BaseSmearer {
-
-protected:
-    // Standard deviation in Q [A-1]
-    double* width;
-
-public:
-
-    // Constructor
-    QSmearer(double* width, double qmin, double qmax, int nbins);
-    QSmearer(double* width, double* q, int nbins);
-	// Compute the smearing matrix
-	virtual void compute_matrix();
-};
-
-#endif
Index: c/sans/models/src/c_smearer/smearer2d_helper.cpp
===================================================================
--- src/sans/models/src/c_smearer/smearer2d_helper.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2009, University of Tennessee
- */
-#include "smearer2d_helper.hh"
-#include <stdio.h>
-#include <math.h>
-using namespace std;
-
-/**
- * Constructor for BaseSmearer
- *
- * binning
- * @param qx: array of Qx values
- * @param qy: array of Qy values
- * @param nrbins: number of r bins
- * @param nphibins: number of phi bins
- */
-Smearer_helper :: Smearer_helper(int npoints, double* qx, double* qy,
-		double* dqx, double* dqy, double rlimit, int nrbins, int nphibins) {
-	// Number of bins
-	this->npoints = npoints;
-	this->rlimit = rlimit;
-	this->nrbins = nrbins;
-	this->nphibins = nphibins;
-	this->qx_values = qx;
-	this->qy_values = qy;
-	this->dqx_values = dqx;
-	this->dqy_values = dqy;
-};
-
-/**
- * Compute the point smearing matrix
- */
-void Smearer_helper :: smear2d(double *weights, double *qx_out, double *qy_out){
-
-	double rbin_size = rlimit / double(nrbins);
-	double phibin_size = 0.0;
-	double rbin = 0.0;
-	double phibin = 0.0;
-	double qr = 0.0;
-	double qphi = 0.0;
-	double Pi = 4.0*atan(1.0);
-	
-	// Loop over q-values and multiply apply matrix
-	for(int i=0; i<nrbins; i++){
-		rbin = rbin_size * (double(i) + 0.5);
-		for(int j=0; j<nphibins; j++){
-			phibin_size =  2.0 * Pi / double(nphibins);
-			phibin = phibin_size * (double(j));
-			for(int q_i=0; q_i<npoints; q_i++){
-				qr = sqrt(qx_values[q_i]*qx_values[q_i] + qy_values[q_i]*qy_values[q_i]);
-				qphi = atan(qy_values[q_i]/qx_values[q_i]);
-				qx_out[q_i + npoints*(nrbins * j + i)] = (rbin*dqx_values[q_i]*cos(phibin) + qr)*cos(qphi)-
-										rbin*dqy_values[q_i]*sin(phibin)*sin(qphi);
-				qy_out[q_i + npoints*(nrbins * j + i)] = (rbin*dqx_values[q_i]*cos(phibin) + qr)*sin(qphi)+
-										rbin*dqy_values[q_i]*sin(phibin)*cos(qphi);
-				if (q_i==0){
-					weights[nrbins * j + i] = exp(-0.5 * ((rbin - rbin_size / 2.0) *
-							(rbin - rbin_size / 2.0)))- exp(-0.5 * ((rbin + rbin_size / 2.0 ) *
-									(rbin + rbin_size / 2.0)));
-			}
-		}
-	}
-	}
-}
-
Index: c/sans/models/src/c_smearer/smearer2d_helper.hh
===================================================================
--- src/sans/models/src/c_smearer/smearer2d_helper.hh	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2009, University of Tennessee
- */
-#ifndef SMEARER2D_HELPER_CLASS_H
-#define SMEARER2D_HELPER_CLASS_H
-
-#include <vector>
-
-using namespace std;
-
-/**
- * Base smearer class, implementing the matrix multiplication only
- */
-class Smearer_helper {
-protected:
-	// Smearing matrix
-	vector<double>* weights;
-	vector<double>* qx_out;
-	vector<double>* qy_out;
-	// Q vector
-	double* qx_values;
-	double* qy_values;
-	double* dqx_values;
-	double* dqy_values;
-    // r limit
-    double rlimit;
-    // Numbers
-    int npoints;
-    int nrbins;
-    int nphibins;
-
-public:
-    // Constructor
-	Smearer_helper(int npoints, double* qx, double* qy, double* dqx, double* dqy,
-			double rlimit, int nrbins, int nphibins);
-	// Smear function
-	virtual void smear2d(double *weights, double *qx_out, double *qy_out);
-};
-
-#endif
Index: c/sans/models/src/c_smearer/smearer2d_helper_module.cpp
===================================================================
--- src/sans/models/src/c_smearer/smearer2d_helper_module.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,128 +1,0 @@
-/**
-  Smearer module to perform point and slit smearing calculations
-
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	See the license text in license.txt
-
-	copyright 2009, University of Tennessee
- */
-#include <Python.h>
-#include <stdio.h>
-#include <smearer2d_helper.hh>
-
-// Utilities
-#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)
-
-#define OUTVECTOR(obj,buf,len) \
-    do { \
-        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
-        if (err < 0) return NULL; \
-        len /= sizeof(*buf); \
-    } while (0)
-
-
-/**
- * Delete a Smearer2d object
- */
-void del_smearer2d_helper(void *ptr){
-	Smearer_helper* smearer2d_helper = static_cast<Smearer_helper *>(ptr);
-	delete smearer2d_helper;
-	return;
-}
-
-/**
- * Create a QSmearer as a python object by supplying a q array
- */
-PyObject * new_Smearer_helper(PyObject *, PyObject *args) {
-	PyObject *qx_values_obj;
-	PyObject *qy_values_obj;
-	PyObject *dqx_values_obj;
-	PyObject *dqy_values_obj;
-	Py_ssize_t n_q;
-	//PyObject rlimit_obj;
-	//PyObject npoints_obj;
-	//PyObject nrbins_obj;
-	//PyObject nphibins_obj;
-	double* qx_values;
-	double* qy_values;
-	double* dqx_values;
-	double* dqy_values;
-	double rlimit;
-	int npoints;
-	int nrbins;
-	int nphibins;
-
-
-	if (!PyArg_ParseTuple(args, "OOOOdiii", &qx_values_obj, &qy_values_obj, &dqx_values_obj, &dqy_values_obj, &rlimit, &nrbins, &nphibins, &npoints)) return NULL;
-	OUTVECTOR(qx_values_obj, qx_values, n_q);
-	OUTVECTOR(qy_values_obj, qy_values, n_q);
-	OUTVECTOR(dqx_values_obj, dqx_values, n_q);
-	OUTVECTOR(dqy_values_obj, dqy_values, n_q);
-	Smearer_helper* smearer2d_helper = new Smearer_helper(npoints,qx_values,qy_values,dqx_values,dqy_values, rlimit, nrbins, nphibins);
-	return PyCObject_FromVoidPtr(smearer2d_helper, del_smearer2d_helper);
-}
-
-/**
- * Smear the given input according to a given smearer object
- */
-PyObject * smear2d_input(PyObject *, PyObject *args) {
-	PyObject *weights_obj;
-	Py_ssize_t w_out;
-	double *weights;
-	PyObject *qx_out_obj;
-	Py_ssize_t n_out;
-	double *qx_out;
-	PyObject *qy_out_obj;
-	//Py_ssize_t n_out;
-	double *qy_out;
-	PyObject *smear_obj;
-
-	if (!PyArg_ParseTuple(args, "OOOO",  &smear_obj, &weights_obj, &qx_out_obj, &qy_out_obj)) return NULL;
-	OUTVECTOR(weights_obj, weights, w_out);
-	OUTVECTOR(qx_out_obj, qx_out, n_out);
-	OUTVECTOR(qy_out_obj, qy_out, n_out);
-
-	// Sanity check
-	//if(n_in!=n_out) return Py_BuildValue("i",-1);
-
-	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(smear_obj);
-	Smearer_helper* s = static_cast<Smearer_helper *>(temp);
-
-	s->smear2d(weights, qx_out, qy_out);
-	//return PyCObject_FromVoidPtr(s, del_smearer2d_helper);
-	return Py_BuildValue("i",1);
-}
-
-
-/**
- * Define module methods
- */
-static PyMethodDef module_methods[] = {
-	{"new_Smearer_helper", (PyCFunction)new_Smearer_helper, METH_VARARGS,
-		  "Create a new Q Smearer object"},
-	{"smearer2d_helper",(PyCFunction)smear2d_input, METH_VARARGS,
-		  "Smear the given input array"},
-    {NULL}
-};
-
-
-#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
-#endif
-PyMODINIT_FUNC
-initsmearer2d_helper(void)
-{
-    PyObject* m;
-
-    m = Py_InitModule3("smearer2d_helper", module_methods,
-                       "Smearer2d_helper module");
-}
Index: c/sans/models/src/c_smearer/smearer_module.cpp
===================================================================
--- src/sans/models/src/c_smearer/smearer_module.cpp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,205 +1,0 @@
-/**
- *  Smearer module to perform point and slit smearing calculations
-
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	See the license text in license.txt
-
-	copyright 2009, University of Tennessee
- */
-#include <Python.h>
-#include <stdio.h>
-#include <smearer.hh>
-
-// Utilities
-#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)
-
-#define OUTVECTOR(obj,buf,len) \
-    do { \
-        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
-        if (err < 0) return NULL; \
-        len /= sizeof(*buf); \
-    } while (0)
-
-/**
- * Delete a SlitSmearer object
- */
-void del_slit_smearer(void *ptr){
-	SlitSmearer* smearer = static_cast<SlitSmearer *>(ptr);
-	delete smearer;
-	return;
-}
-
-/**
- * Create a SlitSmearer as a python object
- */
-PyObject * new_slit_smearer(PyObject *, PyObject *args) {
-	double width;
-	double height;
-	double qmin;
-	double qmax;
-	int nbins;
-
-	if (!PyArg_ParseTuple(args, "ddddi", &width, &height, &qmin, &qmax, &nbins)) return NULL;
-	SlitSmearer* smearer = new SlitSmearer(width, height, qmin, qmax, nbins);
-	return PyCObject_FromVoidPtr(smearer, del_slit_smearer);
-}
-
-/**
- * Create a SlitSmearer as a python object by supplying a q array
- */
-PyObject * new_slit_smearer_with_q(PyObject *, PyObject *args) {
-	PyObject *qvalues_obj;
-	Py_ssize_t n_q;
-	double* qvalues;
-	double width;
-	double height;
-
-	if (!PyArg_ParseTuple(args, "ddO", &width, &height, &qvalues_obj)) return NULL;
-	OUTVECTOR(qvalues_obj, qvalues, n_q);
-	SlitSmearer* smearer = new SlitSmearer(width, height, qvalues, n_q);
-	return PyCObject_FromVoidPtr(smearer, del_slit_smearer);
-}
-
-/**
- * Delete a QSmearer object
- */
-void del_q_smearer(void *ptr){
-	QSmearer* smearer = static_cast<QSmearer *>(ptr);
-	delete smearer;
-	return;
-}
-
-/**
- * Create a QSmearer as a python object
- */
-PyObject * new_q_smearer(PyObject *, PyObject *args) {
-	PyObject *width_obj;
-	Py_ssize_t n_w;
-	double* width;
-	double qmin;
-	double qmax;
-	int nbins;
-
-	if (!PyArg_ParseTuple(args, "Oddi", &width_obj, &qmin, &qmax, &nbins)) return NULL;
-	OUTVECTOR(width_obj, width, n_w);
-	QSmearer* smearer = new QSmearer(width, qmin, qmax, nbins);
-	return PyCObject_FromVoidPtr(smearer, del_q_smearer);
-}
-
-/**
- * Create a QSmearer as a python object by supplying a q array
- */
-PyObject * new_q_smearer_with_q(PyObject *, PyObject *args) {
-	PyObject *width_obj;
-	Py_ssize_t n_w;
-	double* width;
-	PyObject *qvalues_obj;
-	Py_ssize_t n_q;
-	double* qvalues;
-
-	if (!PyArg_ParseTuple(args, "OO", &width_obj, &qvalues_obj)) return NULL;
-	OUTVECTOR(width_obj, width, n_w);
-	OUTVECTOR(qvalues_obj, qvalues, n_q);
-	QSmearer* smearer = new QSmearer(width, qvalues, n_q);
-	return PyCObject_FromVoidPtr(smearer, del_q_smearer);
-}
-
-/**
- * Smear the given input according to a given smearer object
- */
-PyObject * smear_input(PyObject *, PyObject *args) {
-	PyObject *input_iq_obj;
-	PyObject *output_iq_obj;
-	PyObject *smear_obj;
-	Py_ssize_t n_in;
-	Py_ssize_t n_out;
-	double *input_iq;
-	double *output_iq;
-	int first_bin;
-	int last_bin;
-
-
-	if (!PyArg_ParseTuple(args, "OOOii", &smear_obj, &input_iq_obj, &output_iq_obj, &first_bin, &last_bin)) return NULL;
-	OUTVECTOR(input_iq_obj, input_iq, n_in);
-	OUTVECTOR(output_iq_obj, output_iq, n_out);
-
-	// Sanity check
-	if(n_in!=n_out) return Py_BuildValue("i",-1);
-
-	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(smear_obj);
-	BaseSmearer* s = static_cast<BaseSmearer *>(temp);
-
-	if(n_in!=s->get_nbins()) {
-		return Py_BuildValue("i",-2);
-	}
-
-	s->smear(input_iq, output_iq, first_bin, last_bin);
-
-	return Py_BuildValue("i",1);
-}
-
-/**
- * Get the q-value of a given bin
- */
-PyObject * get_q(PyObject *, PyObject *args) {
-	PyObject *smear_obj;
-	int bin;
-
-	if (!PyArg_ParseTuple(args, "Oi", &smear_obj, &bin)) return NULL;
-
-	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(smear_obj);
-	BaseSmearer* s = static_cast<BaseSmearer *>(temp);
-
-	if(s->get_nbins()<=0 || s->get_nbins()<=bin) {
-		return NULL;
-	}
-
-	double q, q_min, q_max;
-	if (s->get_bin_range(bin, &q, &q_min, &q_max)<0) {
-		return NULL;
-	}
-	return Py_BuildValue("d", q);
-}
-
-
-/**
- * Define module methods
- */
-static PyMethodDef module_methods[] = {
-	{"new_slit_smearer", (PyCFunction)new_slit_smearer, METH_VARARGS,
-		  "Create a new Slit Smearer object"},
-	{"new_slit_smearer_with_q", (PyCFunction)new_slit_smearer_with_q, METH_VARARGS,
-		  "Create a new Slit Smearer object by supplying an array of Q values"},
-	{"new_q_smearer", (PyCFunction)new_q_smearer, METH_VARARGS,
-		  "Create a new Q Smearer object"},
-	{"new_q_smearer_with_q", (PyCFunction)new_q_smearer_with_q, METH_VARARGS,
-		  "Create a new Q Smearer object by supplying an array of Q values"},
-	{"smear",(PyCFunction)smear_input, METH_VARARGS,
-		  "Smear the given input array"},
-	{"get_q",(PyCFunction)get_q, METH_VARARGS,
-		  "Get the q-value of a given bin"},
-    {NULL}
-};
-
-
-#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
-#endif
-PyMODINIT_FUNC
-initsmearer(void)
-{
-    PyObject* m;
-
-    m = Py_InitModule3("smearer", module_methods,
-                       "Q Smearing module");
-}
Index: c/sans/models/src/cephes/airy.c
===================================================================
--- src/sans/models/src/cephes/airy.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,966 +1,0 @@
-/*							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: c/sans/models/src/cephes/bdtr.c
===================================================================
--- src/sans/models/src/cephes/bdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,266 +1,0 @@
-/*							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: c/sans/models/src/cephes/btdtr.c
===================================================================
--- src/sans/models/src/cephes/btdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,65 +1,0 @@
-
-/*							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: c/sans/models/src/cephes/cephes.h
===================================================================
--- src/sans/models/src/cephes/cephes.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,10 +1,0 @@
-/*
- * 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: c/sans/models/src/cephes/chbevl.c
===================================================================
--- src/sans/models/src/cephes/chbevl.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,83 +1,0 @@
-/*							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: c/sans/models/src/cephes/chdtr.c
===================================================================
--- src/sans/models/src/cephes/chdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,203 +1,0 @@
-/*							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: c/sans/models/src/cephes/const.c
===================================================================
--- src/sans/models/src/cephes/const.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,253 +1,0 @@
-/*							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: c/sans/models/src/cephes/cprob.mak
===================================================================
--- src/sans/models/src/cephes/cprob.mak	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,14 +1,0 @@
-# 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: c/sans/models/src/cephes/drand.c
===================================================================
--- src/sans/models/src/cephes/drand.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,163 +1,0 @@
-/*							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: c/sans/models/src/cephes/expx2.c
===================================================================
--- src/sans/models/src/cephes/expx2.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*							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: c/sans/models/src/cephes/fdtr.c
===================================================================
--- src/sans/models/src/cephes/fdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,240 +1,0 @@
-/*							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: c/sans/models/src/cephes/gamma.c
===================================================================
--- src/sans/models/src/cephes/gamma.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,687 +1,0 @@
-/*							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: c/sans/models/src/cephes/gdtr.c
===================================================================
--- src/sans/models/src/cephes/gdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,132 +1,0 @@
-/*							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: c/sans/models/src/cephes/hyp2f1.c
===================================================================
--- src/sans/models/src/cephes/hyp2f1.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,461 +1,0 @@
-/*							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: c/sans/models/src/cephes/hyperg.c
===================================================================
--- src/sans/models/src/cephes/hyperg.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,388 +1,0 @@
-/*							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: c/sans/models/src/cephes/i0.c
===================================================================
--- src/sans/models/src/cephes/i0.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,399 +1,0 @@
-/*							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: c/sans/models/src/cephes/i1.c
===================================================================
--- src/sans/models/src/cephes/i1.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,407 +1,0 @@
-/*							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: c/sans/models/src/cephes/igam.c
===================================================================
--- src/sans/models/src/cephes/igam.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,212 +1,0 @@
-/*							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: c/sans/models/src/cephes/igami.c
===================================================================
--- src/sans/models/src/cephes/igami.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,188 +1,0 @@
-/*							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: c/sans/models/src/cephes/incbet.c
===================================================================
--- src/sans/models/src/cephes/incbet.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,413 +1,0 @@
-/*							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: c/sans/models/src/cephes/incbi.c
===================================================================
--- src/sans/models/src/cephes/incbi.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,314 +1,0 @@
-/*							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: c/sans/models/src/cephes/iv.c
===================================================================
--- src/sans/models/src/cephes/iv.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*							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: c/sans/models/src/cephes/j0.c
===================================================================
--- src/sans/models/src/cephes/j0.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,546 +1,0 @@
-/*							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: c/sans/models/src/cephes/j1.c
===================================================================
--- src/sans/models/src/cephes/j1.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,517 +1,0 @@
-/*							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: c/sans/models/src/cephes/jn.c
===================================================================
--- src/sans/models/src/cephes/jn.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,134 +1,0 @@
-/*							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: c/sans/models/src/cephes/jv.c
===================================================================
--- src/sans/models/src/cephes/jv.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,889 +1,0 @@
-/*							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: c/sans/models/src/cephes/k0.c
===================================================================
--- src/sans/models/src/cephes/k0.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,335 +1,0 @@
-/*							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: c/sans/models/src/cephes/k1.c
===================================================================
--- src/sans/models/src/cephes/k1.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,337 +1,0 @@
-/*							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: c/sans/models/src/cephes/kn.c
===================================================================
--- src/sans/models/src/cephes/kn.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,257 +1,0 @@
-/*							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: c/sans/models/src/cephes/kolmogorov.c
===================================================================
--- src/sans/models/src/cephes/kolmogorov.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,243 +1,0 @@
-
-/* 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: c/sans/models/src/cephes/mconf.h
===================================================================
--- src/sans/models/src/cephes/mconf.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,200 +1,0 @@
-/*							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: c/sans/models/src/cephes/msc.mak
===================================================================
--- src/sans/models/src/cephes/msc.mak	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,83 +1,0 @@
-# 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: c/sans/models/src/cephes/msc.rsp
===================================================================
--- src/sans/models/src/cephes/msc.rsp	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,6 +1,0 @@
-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: c/sans/models/src/cephes/mtherr.c
===================================================================
--- src/sans/models/src/cephes/mtherr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/*							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: c/sans/models/src/cephes/nbdtr.c
===================================================================
--- src/sans/models/src/cephes/nbdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,189 +1,0 @@
-/*							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: c/sans/models/src/cephes/ndtr.c
===================================================================
--- src/sans/models/src/cephes/ndtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,527 +1,0 @@
-/*							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: c/sans/models/src/cephes/ndtri.c
===================================================================
--- src/sans/models/src/cephes/ndtri.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,418 +1,0 @@
-/*							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: c/sans/models/src/cephes/pdtr.c
===================================================================
--- src/sans/models/src/cephes/pdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,187 +1,0 @@
-/*							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: c/sans/models/src/cephes/polevl.c
===================================================================
--- src/sans/models/src/cephes/polevl.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,98 +1,0 @@
-/*							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: c/sans/models/src/cephes/protos.h
===================================================================
--- src/sans/models/src/cephes/protos.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,184 +1,0 @@
-/*
- *   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: c/sans/models/src/cephes/psi.c
===================================================================
--- src/sans/models/src/cephes/psi.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,202 +1,0 @@
-/*							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: c/sans/models/src/cephes/stdtr.c
===================================================================
--- src/sans/models/src/cephes/stdtr.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,227 +1,0 @@
-/*							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: c/sans/models/src/cephes/struve.c
===================================================================
--- src/sans/models/src/cephes/struve.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,313 +1,0 @@
-/*							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: c/sans/models/src/cephes/unity.c
===================================================================
--- src/sans/models/src/cephes/unity.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/*							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: c/sans/models/src/cephes/yn.c
===================================================================
--- src/sans/models/src/cephes/yn.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/*							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 );
-}
Index: c/sans/models/src/libigor/2Y_OneYukawa.c
===================================================================
--- src/sans/models/src/libigor/2Y_OneYukawa.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,370 +1,0 @@
-/*
- *  Yukawa.c
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/12/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include "2Y_OneYukawa.h"
-#include "2Y_cpoly.h"
-#include "2Y_utility.h"
-#include "2Y_PairCorrelation.h"
-#include <stdio.h>
-#include <math.h>
-#include <stdlib.h>
-
-/*
-================================================================================================== 
- 
- Structure factor for the potential 
- 
- V(r) = -kB * T * K * exp[ -Z * (r - 1)] / r for r > 1
- V(r) = inf for r <= 1
- 
- The structure factor is parametrized by (a, b, c, d) 
- which depend on (Z, K, phi).  
- 
-================================================================================================== 
-*/
-
-double Y_sigma( double s, double Z, double a, double b, double c, double d )
-{
-	return -(a / 2. + b + c * exp( -Z )) / s + a * pow( s, -3 ) + b * pow( s, -2 ) + ( c + d ) * pow( s + Z, -1 );
-}
-
-double Y_tau( double s, double Z, double a, double b, double c )
-{
-	return b * pow( s, -2 ) + a * ( pow( s, -3 ) + pow( s, -2 ) ) - pow( s, -1 ) * c * Z * exp( -Z ) * pow( s + Z, -1 );
-} 
-
-double Y_q( double s, double Z, double a, double b, double c, double d )
-{
-	return Y_sigma(s, Z, a, b, c, d ) - exp( -s ) * Y_tau( s, Z, a, b, c );
-}
-
-double Y_g( double s, double phi, double Z, double a, double b, double c, double d )
-{
-	return s * Y_tau( s, Z, a, b, c ) * exp( -s ) / ( 1 - 12 * phi * Y_q( s, Z, a, b, c, d ) );
-}
-
-double Y_hq( double q, double Z, double K, double v )
-{
-	double t1, t2, t3, t4;
-
-	if ( q == 0) 
-	{
-		return (exp(-2*Z)*(v + (v*(-1 + Z) - 2*K*Z)*exp(Z))*(-(v*(1 + Z)) + (v + 2*K*Z*(1 + Z))*exp(Z))*pow(K,-1)*pow(Z,-4))/4.;
-	}
-	else 
-	{
-		
-		t1 = ( 1 - v / ( 2 * K * Z * exp( Z ) ) ) * ( ( 1 - cos( q ) ) / ( q*q ) - 1 / ( Z*Z + q*q ) );
-		t2 = ( v*v * ( q * cos( q ) - Z * sin( q ) ) ) / ( 4 * K * Z*Z * q * ( Z*Z + q*q ) );
-		t3 = ( q * cos( q ) + Z * sin( q ) ) / ( q * ( Z*Z + q*q ) );
-		t4 = v / ( Z * exp( Z ) ) - v*v / ( 4 * K * Z*Z * exp( 2 * Z ) ) - K;
-		
-		return v / Z * t1 - t2 + t3 * t4;
-	}
-}
-
-double Y_pc( double q, 
-			double Z, double K, double phi,
-			double a, double b, double c, double d )
-{	
-	double v = 24 * phi * K * exp( Z ) * Y_g( Z, phi, Z, a, b, c, d );
-	
-	double a0 = a * a;
-	double b0 = -12 * phi *( pow( a + b,2 ) / 2 + a * c * exp( -Z ) );
-	
-	double t1, t2, t3, t4;
-	
-	if ( q == 0 ) 
-	{
-		t1 = a0 / 3;
-		t2 = b0 / 4;
-		t3 = a0 * phi / 12;
-	}
-	else 
-	{
-		t1 = a0 * ( sin( q ) - q * cos( q ) ) / pow( q, 3 );
-		t2 = b0 * ( 2 * q * sin( q ) - ( q * q - 2 ) * cos( q ) - 2 ) / pow( q, 4 );
-		t3 = a0 * phi * ( ( q*q - 6 ) * 4 * q * sin( q ) - ( pow( q, 4 ) - 12 * q*q + 24) * cos( q ) + 24 ) / ( 2 * pow( q, 6 ) );
-	}
-	t4 = Y_hq( q, Z, K, v );
-	return -24 * phi * ( t1 + t2 + t3 + t4 );
-}
-
-double SqOneYukawa( double q, 
-				 double Z, double K, double phi,
-				 double a, double b, double c, double d )
-{
-	//structure factor one-yukawa potential
-	return 1. / ( 1. - Y_pc( q, Z, K, phi, a, b, c, d ) );
-}
-
-
-/*
-================================================================================================== 
-
- The structure factor S(q) for the one-Yukawa potential is parameterized by a,b,c,d which are
- the solution of a system of non-linear equations given Z,K, phi. There are at most 4 solutions 
- from which the physical one is chosen
- 
-================================================================================================== 
- */
-
-double Y_LinearEquation_1( double Z, double K, double phi, double a, double b, double c, double d )
-{
-	return b - 12*phi*(-a/8. - b/6. + d*pow(Z,-2) + c*(pow(Z,-2) - exp(-Z)*(0.5 + (1 + Z)*pow(Z,-2))));
-}
-
-double Y_LinearEquation_2( double Z, double K, double phi, double a, double b, double c, double d )
-{
-	return 1 - a - 12*phi*(-a/3. - b/2. + d*pow(Z,-1) + c*(pow(Z,-1) - (1 + Z)*exp(-Z)*pow(Z,-1)));
-}
-
-double Y_LinearEquation_3( double Z, double K, double phi, double a, double b, double c, double d )
-{
-	return K*exp(Z) - Z*d*(1-12*phi*Y_q(Z, Z, a, b, c, d));
-}
-
-double Y_NonlinearEquation( double Z, double K, double phi, double a, double b, double c, double d )
-{
-	return c + d - 12*phi*((c + d)*Y_sigma(Z, Z, a, b, c, d) - c*exp(-Z)*Y_tau(Z, Z, a, b, c));
-}
-
-// Check the computed solutions satisfy the system of equations 
-int Y_CheckSolution( double Z, double K, double phi, 
-					 double a, double b, double c, double d )
-{
-	double eq_1 = chop( Y_LinearEquation_1 ( Z, K, phi, a, b, c, d ) );
-	double eq_2 = chop( Y_LinearEquation_2 ( Z, K, phi, a, b, c, d ) );
-	double eq_3 = chop( Y_LinearEquation_3 ( Z, K, phi, a, b, c, d ) );
-	double eq_4 = chop( Y_NonlinearEquation( Z, K,  phi, a, b, c, d ) );
-	
-	// check if all equation are zero
-	return eq_1 == 0 && eq_2 == 0 && eq_3 == 0 && eq_4 == 0;
-}
-
-int Y_SolveEquations( double Z, double K, double phi, double* a, double* b, double* c, double* d, int debug )
-{
-	char buf[256];
-
-	// at most there are 4 solutions for a,b,c,d
-	double sol_a[4], sol_b[4], sol_c[4], sol_d[4];
-	
-	double m11 = (3*phi)/2.;
-	double m13 = 6*phi*exp(-Z)*(2 + Z*(2 + Z) - 2*exp(Z))*pow(Z,-2);
-	double m23 = -12*phi*exp(-Z)*(-1 - Z + exp(Z))*pow(Z,-1);
-	double m31 = -6*phi*exp(-Z)*pow(Z,-2)*(2*(1 + Z) + exp(Z)*(-2 + pow(Z,2)));
-	double m32 = -12*phi*(-1 + Z + exp(-Z))*pow(Z,-1);
-	double m33 = 6*phi*exp(-2*Z)*pow(-1 + exp(Z),2);
-	
-	double delta = m23*m31 - m13*m32 + m11*(-4*m13*m31 + (4*m23*m31)/3. + (8*m13*m32)/3. - m23*m32) + m33 + (4*(-3 + m11)*m11*m33)/9.;
-	double a1 = -(K*(m23 + (4*m11*(-3*m13 + m23))/3.)*exp(Z));
-	double a2 = -(m13*(m32 + 4*m11*Z)) + ((3 + 4*m11)*(m33 + m23*Z))/3.;
-	double a3 = -2*phi*pow(Z,-2)*(6*m23*m32 - 24*m11*m33 + 2*Z*((3 + 4*m11)*m33 - 3*m13*(m32 + 2*m11*Z)) + (3 + 4*m11)*m23*pow(Z,2));
-	
-	double b1 = -(K*((-3 + 8*m11)*m13 - 3*m11*m23)*exp(Z))/3.;
-	double b2 = m13*(m31 - Z + (8*m11*Z)/3.) - m11*(m33 + m23*Z);
-	double b3 = 2*phi*pow(Z,-2)*(m13*Z*(-6*m31 + 3*Z - 8*m11*Z) + 2*m33*(3 - 8*m11 + 3*m11*Z) + 3*m23*(2*m31 + m11*pow(Z,2)));
-	
-	double c1 = -(K*exp(Z)*pow(3 - 2*m11,2))/9.;
-	double c2 = -((3 + 4*m11)*m31)/3. + m11*m32 + Z + (4*(-3 + m11)*m11*Z)/9.;
-	double c3 = (-2*phi*pow(Z,-2)*(6*(12*m11*m31 + 3*m32 - 8*m11*m32) - 6*((3 + 4*m11)*m31 - 3*m11*m32)*Z + pow(3 - 2*m11,2)*pow(Z,2)))/3.;
-	
-	// determine d, as roots of the polynomial, from that build a,b,c
-	
-	double real_coefficient[5];
-	double imag_coefficient[5];
-	
-	double real_root[4];
-	double imag_root[4];
-	
-	double zeta = 24*phi*pow(-6*phi*Z*cosh(Z/2.) + (12*phi + (-1 + phi)*pow(Z,2))*sinh(Z/2.),2);	
-	double A[5];
-	int degree,i,j,n_roots;
-	double x,y;
-	int n,selected_root;
-	double qmax,q,dq,min,sum,dr;
-	double *sq,*gr;
-	
-	
-	A[0] = -(exp(3*Z)*pow(K,2)*pow(-1 + phi,2)*pow(Z,3) / zeta );
-	A[1] = K*Z*exp(Z)*(6*phi*(2 + 4*phi + (2 + phi)*Z) + exp(Z)*
-					   ((-24 + Z*(18 + (-6 + Z)*Z))*pow(phi,2) - 2*phi*(6 + (-3 + Z)*pow(Z,2)) + pow(Z,3))) / zeta;
-	A[2] = -12*K*phi*exp(Z)*pow(-1 + phi,2)*pow(Z,3)/zeta;
-	A[3] = 6*phi*Z*exp(-Z)*(-12*phi*(1 + 2*phi)*(-1 + exp(Z)) + 6*phi*Z*(3*phi + (2 + phi)*exp(Z)) + 
-							6*(-1 + phi)*phi*pow(Z,2) + pow(-1 + phi,2)*pow(Z,3))/zeta;
-	A[4] = -36*exp(-Z)*pow(-1 + phi,2)*pow(phi,2)*pow(Z,3)/zeta;
-/*	
-	if ( debug )
-	{
-		sprintf (buf, "(Z,K,phi) = (%g, %g, %g)\r", K, Z, phi );
-		XOPNotice(buf);
-		sprintf (buf, "A = (%g, %g, %g, %g, %g)\r", A[0], A[1], A[2], A[3], A[4] );
-		XOPNotice(buf);
-	}
-*/	
-	//integer degree of polynomial
-	degree = 4;
-	
-	// vector of real and imaginary coefficients in order of decreasing powers
-	for ( i = 0; i <= degree; i++ )
-	{
-		real_coefficient[i] = A[4-i];
-		imag_coefficient[i] = 0.;
-	}
-	
-	// Jenkins-Traub method to approximate the roots of the polynomial
-	cpoly( real_coefficient, imag_coefficient, degree, real_root, imag_root );
-	
-	// show the result if in debug mode
-/*
-	if ( debug )
-	{
-		for ( i = 0; i < degree; i++ )
-		{
-			x = real_root[i];
-			y = imag_root[i];
-			sprintf(buf, "root(%d) = %g + %g i\r", i+1, x, y );
-			XOPNotice(buf);
-		}
-		sprintf(buf, "\r" );
-		XOPNotice(buf);
-	}
- */
-	// determine the set of solutions for a,b,c,d,
-	j = 0;
-	for ( i = 0; i < degree; i++ ) 
-	{
-		x = real_root[i];
-		y = imag_root[i];
-		
-		if ( chop( y ) == 0 ) 
-		{
-			sol_a[j] = ( a1 + a2 * x + a3 * x * x ) / ( delta * x );
-			sol_b[j] = ( b1 + b2 * x + b3 * x * x ) / ( delta * x );
-			sol_c[j] = ( c1 + c2 * x + c3 * x * x ) / ( delta * x );
-			sol_d[j] = x;
-	
-			j++;
-		}
-	}
-
-	// number  remaining roots 
-	n_roots = j;
-	
-//	sprintf(buf, "inside Y_solveEquations OK, before malloc: n_roots = %d\r",n_roots);
-//	XOPNotice(buf);	
-	
-	// if there is still more than one root left, than choose the one with the minimum
-	// average value inside the hardcore
-	
-	
-	
-	if ( n_roots > 1 )
-	{
-		// the number of q values should be a power of 2
-		// in order to speed up the FFT
-		n = 1 << 14;		//= 16384
-		
-		// the maximum q value should be large enough 
-		// to enable a reasoble approximation of g(r)
-		qmax = 1000.;
-		dq = qmax / ( n - 1 );
-		
-		// step size for g(r) = dr
-		
-		// allocate memory for pair correlation function g(r)
-		// and structure factor S(q)
-		// (note that sq and gr are pointers)
-		sq = malloc( sizeof( double ) * n );
-		gr = malloc( sizeof( double ) * n );
-		
-		// loop over all remaining roots
-		min = 1e99;
-		selected_root=0;	
-		
-//		sprintf(buf, "after malloc: n,dq = %d  %g\r",n,dq);
-//		XOPNotice(buf);
-				
-		for ( j = 0; j < n_roots; j++) 
-		{
-			// calculate structure factor at different q values
-			for ( i = 0; i < n ; i++) 
-			{
-				q = dq * i;
-				sq[i] = SqOneYukawa( q, Z, K, phi, sol_a[j], sol_b[j], sol_c[j], sol_d[j] );
-/*				
-				if(i<20 && debug) {
-					sprintf(buf, "after SqOneYukawa: s(q) = %g\r",sq[i] );
-					XOPNotice(buf);	
-				}
- */
-			}
-						
-			// calculate pair correlation function for given
-			// structure factor, g(r) is computed at values
-			// r(i) = i * dr
-			PairCorrelation( phi, dq, sq, &dr, gr, n );
-			
-//			sprintf(buf, "after PairCorrelation: \r");
-//			XOPNotice(buf);
-			
-			// determine sum inside the hardcore 
-			// 0 =< r < 1 of the pair-correlation function
-			sum = 0;
-			for (i = 0; i < floor( 1. / dr ); i++ ) 
-			{
-				sum += fabs( gr[i] );
-/*				
-				if(i<20 && debug) {
-					sprintf(buf, "g(r) in core = %g\r",fabs(gr[i]));
-					XOPNotice(buf);
-				}
- */
-			}
-			
-//			sprintf(buf, "after hard core: sum, min = %g %g\r",sum,min);
-//			XOPNotice(buf);
-			
-			if ( sum < min )
-			{
-				min = sum;
-				selected_root = j;
-			}
-			
-			
-		}	
-		free( gr );
-		free( sq );
-		
-//		sprintf(buf, "after free: selected root = %d\r",selected_root);
-//		XOPNotice(buf);
-		
-		// physical solution was found
-		*a = sol_a[ selected_root ];
-		*b = sol_b[ selected_root ];
-		*c = sol_c[ selected_root ];
-		*d = sol_d[ selected_root ];
-		
-//		sprintf(buf, "after solution found (ret 1): \r");
-//		XOPNotice(buf);
-		
-		return 1;
-	}
-	else if ( n_roots == 1 ) 
-	{
-		*a = sol_a[0];
-		*b = sol_b[0];
-		*c = sol_c[0];
-		*d = sol_d[0];
-		
-		return 1;
-	}
-	// no solution was found
-	return 0;
-}
Index: c/sans/models/src/libigor/2Y_OneYukawa.h
===================================================================
--- src/sans/models/src/libigor/2Y_OneYukawa.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,14 +1,0 @@
-/*
- *  Yukawa.h
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/12/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-int Y_CheckSolution( double Z, double K, double phi, double a, double b, double c, double d );
-int Y_SolveEquations( double Z, double K, double phi, 
-					  double* a, double* b, double* c, double* d, int debug );
-double SqOneYukawa( double q, 
-				double Z, double K, double phi,
-				double a, double b, double c, double d );
Index: c/sans/models/src/libigor/2Y_PairCorrelation.c
===================================================================
--- src/sans/models/src/libigor/2Y_PairCorrelation.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,226 +1,0 @@
-/*
- *  PairCorrelation.c
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/9/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include "2Y_PairCorrelation.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-//#include <gsl/gsl_errno.h> 
-//#include <gsl/gsl_fft_real.h>
-
-/*
-=================================================================================================== 
-
- Source: J.B.Hayter: A Program for the fast bi-directional transforms
- between g(r) and S(Q), ILL internal scientific report, October 1979
- 
- The transformation between structure factor and pair correlation 
- function is given by 
- 
- g(x) = 1 + 1 / (12*pi*phi*x) * int( [S(q)-q]*q*sin(q*x), { 0, inf } )
- 
- where phi is the volume frcation, x and q are dimensionless variables, 
- scaled by the radius a of the particles:
- 
- r = x * a;
- Q = q / a
- 
- Discretizing the integral leads to
- 
- x[k] = 2*pi*k / (N * dq)
- g(x[k]) = 1 + N*dq^3 / (24*pi^2*phi*k) * Im{ sum(S[n]*exp(2*pi*i*n*k/N),{n,0,N-1}) }
- 
- where S[n] = n*(S(q[n])-1) with q[n]=n * dq
-
-=================================================================================================== 
-*/
-
-/*
-int PairCorrelation_GSL( double phi, double dq, double* Sq, double* dr, double* gr, int N )
-{
-	double* data = malloc( sizeof(double) * N );
-	int n;
-	for ( n = 0; n < N; n++ )
-		data[n] = n * ( Sq[n] - 1 );
-	
-	// data[k] -> sum( data[n] * exp(-2*pi*i*n*k/N), {n, 0, N-1 })
-	int stride = 1;
-	int error  = gsl_fft_real_radix2_transform( data, stride, N );
-	
-	// if no errors detected 
-	if ( error == GSL_SUCCESS ) 
-	{
-		double alpha = N * pow( dq, 3 ) / ( 24 * M_PI * M_PI * phi );
-	
-	
-		*dr = 2 * M_PI / ( N * dq );  
-		int k;
-		double real, imag;
-		for ( k = 0; k < N; k++ )
-		{
-			// the solutions of the transform is stored in data, 
-			// consult GSL manual for more details
-			if ( k == 0 || k == N / 2)
-			{ 
-				real = data[k];
-				imag = 0;
-			}
-			else if ( k < N / 2 ) 
-			{
-				real = data[k];
-				imag = data[N-k];
-			}
-			else if ( k > N / 2 )
-			{
-				real =  data[N-k];
-				imag = -data[k];	
-			}
-			
-			if ( k == 0 ) 
-				gr[k] = 0;
-			else
-				gr[k] = 1. + alpha / k * (-imag);
-		} 
-	} 
-	// if N is not a power of two
-	else if ( error == GSL_EDOM )
-	{
-		printf( "N is not a power of 2\n" );
-	}
-	else
-	{
-		printf( "Could not perform DFT (discrete fourier transform)\n" );
-	}
-	// release allocated memory
-	free( data );
-	
-	// return error value
-	return error;
-}
- */
-
-
-// this uses numerical recipes for the FFT
-//
-int PairCorrelation( double phi, double dq, double* Sq, double* dr, double* gr, int N )
-{
-	double* data = malloc( sizeof(double) * N * 2);
-	int n,error,k;
-	double alpha,real,imag;
-	double Pi = 3.14159265358979323846264338327950288;   /* pi */
-
-	
-	for ( n = 0; n < N; n++ ) {
-		data[2*n] = n * ( Sq[n] - 1 );
-		data[2*n+1] = 0;
-	}
-	//	printf("start of new fft\n");
-	
-	// data[k] -> sum( data[n] * exp(-2*pi*i*n*k/N), {n, 0, N-1 })
-	//	int error  = gsl_fft_real_radix2_transform( data, stride, N );
-	error  = 1;
-	dfour1( data-1, N, 1 );		//N is the number of complex points
-	
-	//	printf("dfour1 is done\n");
-	
-	// if no errors detected 
-	if ( error == 1 ) 
-	{
-		alpha = N * pow( dq, 3 ) / ( 24 * Pi * Pi * phi );
-		
-		*dr = 2 * Pi / ( N * dq );  
-		for ( k = 0; k < N; k++ )
-		{
-			// the solutions of the transform is stored in data, 
-			// consult GSL manual for more details
-			if ( 2*k == 0 || 2*k == 2*N / 2)
-			{ 
-				real = data[2*k];
-				imag = 0;
-			}
-			else if ( 2*k < 2*N / 2 ) 
-			{
-				real = data[2*k];
-				imag = data[2*k+1];
-			}
-			else if ( 2*k > 2*N / 2 )
-			{
-				real =  data[2*k];
-				imag = -data[2*k+1];	
-			}
-			
-			if ( k == 0 ) 
-				gr[k] = 0;
-			else
-//				gr[k] = 1. + alpha / k * (-imag);		//if using GSL
-				gr[k] = 1. + alpha / k * (imag);		//if using NR
-		} 
-	} 
-	
-	// release allocated memory
-	free( data );
-	
-//	printf(" done with FFT assignment -- Using Numerical Recipes, not GSL\n");
-	
-	// return error value
-	return error;
-}
-
-
-// isign == 1 means no scaling of output. isign == -1 multiplies output by nn
-//
-//
-#define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr
-
-void dfour1(double data[], unsigned long nn, int isign)
-{
-	unsigned long n,mmax,m,j,istep,i;
-	double wtemp,wr,wpr,wpi,wi,theta;
-	double tempr,tempi;
-	
-	n=nn << 1;
-	j=1;
-	for (i=1;i<n;i+=2) {
-		if (j > i) {
-			SWAP(data[j],data[i]);
-			SWAP(data[j+1],data[i+1]);
-		}
-		m=n >> 1;
-		while (m >= 2 && j > m) {
-			j -= m;
-			m >>= 1;
-		}
-		j += m;
-	}
-	mmax=2;
-	while (n > mmax) {
-		istep=mmax << 1;
-		theta=isign*(6.28318530717959/mmax);
-		wtemp=sin(0.5*theta);
-		wpr = -2.0*wtemp*wtemp;
-		wpi=sin(theta);
-		wr=1.0;
-		wi=0.0;
-		for (m=1;m<mmax;m+=2) {
-			for (i=m;i<=n;i+=istep) {
-				j=i+mmax;
-				tempr=wr*data[j]-wi*data[j+1];
-				tempi=wr*data[j+1]+wi*data[j];
-				data[j]=data[i]-tempr;
-				data[j+1]=data[i+1]-tempi;
-				data[i] += tempr;
-				data[i+1] += tempi;
-			}
-			wr=(wtemp=wr)*wpr-wi*wpi+wr;
-			wi=wi*wpr+wtemp*wpi+wi;
-		}
-		mmax=istep;
-	}
-}
-#undef SWAP
Index: c/sans/models/src/libigor/2Y_PairCorrelation.h
===================================================================
--- src/sans/models/src/libigor/2Y_PairCorrelation.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,13 +1,0 @@
-/*
- *  PairCorrelation.h
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/9/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-
-//int PairCorrelation_GSL( double phi, double dq, double* Sq, double* dr, double* gr, int N );
-int PairCorrelation( double phi, double dq, double* Sq, double* dr, double* gr, int N );
-
-void dfour1(double data[], unsigned long nn, int isign);
Index: c/sans/models/src/libigor/2Y_TwoYukawa.c
===================================================================
--- src/sans/models/src/libigor/2Y_TwoYukawa.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,1113 +1,0 @@
-/*
- *  twoyukawa.c
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/7/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include "2Y_TwoYukawa.h"
-#include "2Y_cpoly.h"
-#include "2Y_utility.h"
-#include "2Y_PairCorrelation.h"
-#include <stdio.h>
-#include <math.h>
-#include <stdlib.h>
-
-/*
- ================================================================================================== 
- 
- The two-yukawa structure factor is uniquley determined by 6 parameters a, b, c1, c2, d1, d2,
- which are the solution of a system of 6 equations ( 4 linear, 2 nonlinear ). The solution can 
- constructed by the roots of a polynomial of 22nd degree. For more details see attached 
- Mathematica snotebook, where a derivation is given
- 
- ================================================================================================== 
- */
-
-double TY_q22;
-double TY_qa12, TY_qa21, TY_qa22, TY_qa23, TY_qa32;
-double TY_qb12, TY_qb21, TY_qb22, TY_qb23, TY_qb32;
-double TY_qc112, TY_qc121, TY_qc122, TY_qc123, TY_qc132;
-double TY_qc212, TY_qc221, TY_qc222, TY_qc223, TY_qc232;
-double TY_A12, TY_A21, TY_A22, TY_A23, TY_A32, TY_A41, TY_A42, TY_A43, TY_A52;
-double TY_B12, TY_B14, TY_B21, TY_B22, TY_B23, TY_B24, TY_B25, TY_B32, TY_B34;
-double TY_F14, TY_F16, TY_F18, TY_F23, TY_F24, TY_F25, TY_F26, TY_F27, TY_F28, TY_F29, TY_F32, TY_F33, TY_F34, TY_F35, TY_F36, TY_F37, TY_F38, TY_F39, TY_F310;
-double TY_G13, TY_G14, TY_G15, TY_G16, TY_G17, TY_G18, TY_G19, TY_G110, TY_G111, TY_G112, TY_G113, TY_G22, TY_G23, TY_G24, TY_G25, TY_G26, TY_G27, TY_G28, TY_G29, TY_G210, TY_G211, TY_G212, TY_G213, TY_G214;
-double TY_w[23];
-
-double TY_sigma( double s, 
-				 double Z1, double Z2, 
-			     double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return -(a / 2. + b + c1 * exp( -Z1 ) + c2 * exp( -Z2 )) / s + a * pow( s, -3 ) + b * pow( s, -2 ) + 
-	( c1 + d1 ) * pow( s + Z1, -1 ) + ( c2 + d2 ) * pow( s + Z2, -1 );
-}
-
-double TY_tau( double s, 
-			   double Z1, double Z2, 
-		       double a, double b, double c1, double c2 )
-{
-	return b * pow( s, -2 ) + a * ( pow( s, -3 ) + pow( s, -2 ) ) - pow( s, -1 ) * ( c1 * Z1 * exp( -Z1 ) * 
-																					pow( s + Z1, -1 ) + c2 * Z2 * exp( -Z2 ) * pow( s + Z2, -1 ) );
-} 
-
-double TY_q( double s, 
-			     double Z1, double Z2, 
-			     double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return TY_sigma(s, Z1, Z2, a, b, c1, c2, d1, d2) - exp( -s ) * TY_tau(s, Z1, Z2, a,b, c1, c2);
-}
-
-double TY_g( double s, 
-		     double phi, double Z1, double Z2, 
-		     double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return s * TY_tau( s, Z1, Z2, a, b, c1, c2 ) * exp( -s ) / ( 1 - 12 * phi * TY_q( s, Z1, Z2, a, b, c1, c2, d1, d2 ) );
-}
-
-/*
- ================================================================================================== 
- 
- Structure factor for the potential 
- 
- V(r) = -kB * T * ( K1 * exp[ -Z1 * (r - 1)] / r + K2 * exp[ -Z2 * (r - 1)] / r ) for r > 1
- V(r) = inf for r <= 1
- 
- The structure factor is parametrized by (a, b, c1, c2, d1, d2) 
- which depend on (K1, K2, Z1, Z2, phi).  
- 
- ================================================================================================== 
- */
-
-double TY_hq( double q, double Z, double K, double v )
-{
-	double t1, t2, t3, t4;
-
-	if ( q == 0) 
-	{
-		return (exp(-2*Z)*(v + (v*(-1 + Z) - 2*K*Z)*exp(Z))*(-(v*(1 + Z)) + (v + 2*K*Z*(1 + Z))*exp(Z))*pow(K,-1)*pow(Z,-4))/4.;
-	}
-	else 
-	{
-		
-		t1 = ( 1 - v / ( 2 * K * Z * exp( Z ) ) ) * ( ( 1 - cos( q ) ) / ( q*q ) - 1 / ( Z*Z + q*q ) );
-		t2 = ( v*v * ( q * cos( q ) - Z * sin( q ) ) ) / ( 4 * K * Z*Z * q * ( Z*Z + q*q ) );
-		t3 = ( q * cos( q ) + Z * sin( q ) ) / ( q * ( Z*Z + q*q ) );
-		t4 = v / ( Z * exp( Z ) ) - v*v / ( 4 * K * Z*Z * exp( 2 * Z ) ) - K;
-		
-		return v / Z * t1 - t2 + t3 * t4;
-	}
-}
-
-double TY_pc( double q, 
-			  double Z1, double Z2,double K1, double K2, double phi,
-			  double a, double b, double c1, double c2, double d1, double d2 )
-{	
-	double v1 = 24 * phi * K1 * exp( Z1 ) * TY_g( Z1, phi, Z1, Z2, a, b, c1, c2, d1, d2 );
-	double v2 = 24 * phi * K2 * exp( Z2 ) * TY_g( Z2, phi, Z1, Z2, a, b, c1, c2, d1, d2 );
-	
-	double a0 = a * a;
-	double b0 = -12 * phi *( pow( a + b,2 ) / 2 + a * ( c1 * exp( -Z1 ) + c2 * exp( -Z2 ) ) );
-	
-	double t1, t2, t3,t4;
-	
-	if ( q == 0 ) 
-	{
-		t1 = a0 / 3;
-		t2 = b0 / 4;
-		t3 = a0 * phi / 12;
-	}
-	else 
-	{
-		t1 = a0 * ( sin( q ) - q * cos( q ) ) / pow( q, 3 );
-		t2 = b0 * ( 2 * q * sin( q ) - ( q * q - 2 ) * cos( q ) - 2 ) / pow( q, 4 );
-		t3 = a0 * phi * ( ( q*q - 6 ) * 4 * q * sin( q ) - ( pow( q, 4 ) - 12 * q*q + 24) * cos( q ) + 24 ) / ( 2 * pow( q, 6 ) );
-	}
-	t4 = TY_hq( q, Z1, K1, v1 ) + TY_hq( q, Z2, K2, v2 );
-	return -24 * phi * ( t1 + t2 + t3 + t4 );
-}
-
-double SqTwoYukawa( double q, 
-				    double Z1, double Z2, double K1, double K2, double phi,
-				    double a, double b, double c1, double c2, double d1, double d2 )
-{
-	if ( Z1 == Z2 ) 
-	{
-		// one-yukawa potential
-		return 0;
-	} 
-	else 
-	{
-		// two-yukawa potential
-		return 1. / ( 1. - TY_pc( q, Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	}
-}
-
-/*
-================================================================================================== 
-
- Non-linear eqaution system that determines the parameter for structure factor
-  
-================================================================================================== 
-*/
-
-double TY_LinearEquation_1( double Z1, double Z2, double K1, double K2, double phi, 
-						    double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return b - 12 * phi * ( -a / 8. - b / 6. + d1 * pow( Z1, -2 ) + c1 * ( pow( Z1, -2 )  - exp( -Z1 ) * 
-		    ( 0.5 + ( 1 + Z1 ) * pow( Z1, -2 ) ) ) + d2 * pow( Z2, -2 ) + c2 * ( pow( Z2, -2 ) - exp( -Z2 )
-			* ( 0.5 + ( 1 + Z2 ) * pow( Z2, -2 ) ) ) );
-}
-
-double TY_LinearEquation_2( double Z1, double Z2, double K1, double K2, double phi, 
-							double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return 1 - a - 12 * phi * ( -a / 3. - b / 2. + d1 * pow( Z1, -1 ) + c1 * ( pow( Z1, -1 ) - ( 1 + Z1 ) * 
-		   exp( -Z1 ) * pow( Z1, -1 ) ) + d2 * pow( Z2, -1 ) + c2 * ( pow( Z2, -1 ) - ( 1 + Z2 ) * exp( -Z2 ) * pow( Z2, -1 ) ) );
-}	
-
-double TY_LinearEquation_3( double Z1, double Z2, double K1, double K2, double phi, 
-						    double a, double b, double c1, double c2, double d1, double d2 )
-{								
-	return K1 * exp( Z1 ) - d1 * Z1 * ( 1 - 12 * phi * TY_q( Z1, Z1, Z2, a, b, c1, c2, d1, d2 ) ); 
-}
-
-double TY_LinearEquation_4( double Z1, double Z2, double K1, double K2, double phi, 
-						    double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return K2 * exp( Z2 ) - d2 * Z2 * ( 1 - 12 * phi * TY_q( Z2, Z1, Z2, a, b, c1, c2, d1, d2 ) );
-}
-
-double TY_NonlinearEquation_1( double Z1, double Z2, double K1, double K2, double phi, 
-						       double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return c1 + d1 - 12 * phi * ( ( c1 + d1 ) * TY_sigma( Z1, Z1, Z2, a, b, c1, c2, d1, d2 ) 
-								 - c1 * TY_tau( Z1, Z1, Z2, a, b, c1, c2 ) * exp( -Z1 ) );
-}
-
-double TY_NonlinearEquation_2( double Z1, double Z2, double K1, double K2, double phi, 
-						       double a, double b, double c1, double c2, double d1, double d2 )
-{
-	return c2 + d2 - 12 * phi * ( ( c2 + d2 ) * TY_sigma( Z2, Z1, Z2, a, b, c1, c2, d1, d2 ) 
-								 - c2 * TY_tau( Z2, Z1, Z2, a, b, c1, c2 ) * exp( -Z2 ) );
-}
-
-// Check the computed solutions satisfy the system of equations 
-int TY_CheckSolution( double Z1, double Z2, double K1, double K2, double phi, 
-				      double a, double b, double c1, double c2, double d1, double d2 )
-{
-	double eq_1 = chop( TY_LinearEquation_1( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	double eq_2 = chop( TY_LinearEquation_2( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	double eq_3 = chop( TY_LinearEquation_3( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	double eq_4 = chop( TY_LinearEquation_4( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	double eq_5 = chop( TY_NonlinearEquation_1( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	double eq_6 = chop( TY_NonlinearEquation_2( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ) );
-	
-	// check if all equation are zero
-	return eq_1 == 0 && eq_2 == 0 && eq_3 == 0 && eq_4 == 0 && eq_5 == 0 && eq_6 == 0;
-}
-
-void TY_ReduceNonlinearSystem( double Z1, double Z2, double K1, double K2, double phi, int debug )
-{
-	/* solution of the 4 linear equations depending on d1 and d2, the solution is polynomial
-	 in d1, d2. We represend the solution as determiants obtained by Cramer's rule
-	 which can be expressed by their coefficient matrices
-	 */
-	char buf[256];
-	
-	double m11 = (3*phi)/2.;
-	double m13 = 6*phi*exp(-Z1)*(2 + Z1*(2 + Z1) - 2*exp(Z1))*pow(Z1,-2);
-	double m14 = 6*phi*exp(-Z2)*(2 + Z2*(2 + Z2) - 2*exp(Z2))*pow(Z2,-2);
-	double m23 = -12*phi*exp(-Z1)*(-1 - Z1 + exp(Z1))*pow(Z1,-1);
-	double m24 = -12*phi*exp(-Z2)*(-1 - Z2 + exp(Z2))*pow(Z2,-1);
-	double m31 = -6*phi*exp(-Z1)*pow(Z1,-2)*(2*(1 + Z1) + exp(Z1)*(-2 + pow(Z1,2)));
-	double m32 = -12*phi*(-1 + Z1 + exp(-Z1))*pow(Z1,-1);
-	double m33 = 6*phi*exp(-2*Z1)*pow(-1 + exp(Z1),2);
-	double m34 = 12*phi*exp(-Z1 - Z2)*(Z2 - (Z1 + Z2)*exp(Z1) + Z1*exp(Z1 + Z2))*pow(Z1 + Z2,-1);
-	double m41 = -6*phi*exp(-Z2)*pow(Z2,-2)*(2*(1 + Z2) + exp(Z2)*(-2 + pow(Z2,2)));
-	double m42 = -12*phi*(-1 + Z2 + exp(-Z2))*pow(Z2,-1);
-	double m43 = 12*phi*exp(-Z1 - Z2)*(Z1 - (Z1 + Z2 - Z2*exp(Z1))*exp(Z2))*pow(Z1 + Z2,-1);	
-	double m44 = 6*phi*exp(-2*Z2)*pow(-1 + exp(Z2),2);
-	
-	/* determinant of the linear system expressed as coefficient matrix in d1, d2 */
-	
-	TY_q22 = m14*(-(m33*m42) + m23*(m32*m41 - m31*m42) + m32*m43 + (4*m11*(-3*m33*m41 + 2*m33*m42 + 3*m31*m43 - 2*m32*m43))/3.) + 
-		  m13*(m34*m42 + m24*(-(m32*m41) + m31*m42) - m32*m44 + (4*m11*(3*m34*m41 - 2*m34*m42 - 3*m31*m44 + 2*m32*m44))/3.) + (3*m24*
-		  (m33*(3*m41 + 4*m11*m41 - 3*m11*m42) + (-3*m31 - 4*m11*m31 + 3*m11*m32)*m43) + 3*m23*(-3*m34*m41 - 4*m11*m34*m41 + 
-		  3*m11*m34*m42 + 3*m31*m44 + 4*m11*m31*m44 - 3*m11*m32*m44) - (m34*m43 - m33*m44)*pow(3 - 2*m11,2))/9.;
-/*	
-	if( debug ) 
-	{
-		sprintf(buf,"\rDet = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t%f\r%f\t%f\r", 0., 0., 0., TY_q22 );
-		XOPNotice(buf);
-	}
-*/
-	
-	/* Matrix representation of the determinant of the of the system where row refering to 
-	 the variable a is replaced by solution vector */
-	
-	TY_qa12 = (K1*(3*m14*(m23*m42 - 4*m11*m43) - 3*m13*(m24*m42 - 4*m11*m44) + (3 + 4*m11)*(m24*m43 - m23*m44))*exp(Z1))/3.;
-	
-	TY_qa21 = -(K2*(3*m14*(m23*m32 - 4*m11*m33) - 3*m13*(m24*m32 - 4*m11*m34) + (3 + 4*m11)*(m24*m33 - m23*m34))*exp(Z2))/3.;
-	
-	TY_qa22 = m14*(-(m23*m42*Z1) + 4*m11*m43*Z1 - m33*(m42 + 4*m11*Z2) + m32*(m43 + m23*Z2)) + 
-		   (3*m13*(m24*m42*Z1 - 4*m11*m44*Z1 + m34*(m42 + 4*m11*Z2) - m32*(m44 + m24*Z2)) + 
-		   (3 + 4*m11)*(-(m24*m43*Z1) + m23*m44*Z1 - m34*(m43 + m23*Z2) + m33*(m44 + m24*Z2)))/3.;	
-	
-	TY_qa23 = 2*phi*pow(Z2,-2)*(m24*(2*(-3*m13*m42 + 3*m43 + 4*m11*m43)*Z1*pow(Z2,2) - m33*(Z1 + Z2)*(6*m42 + (3 + 4*m11)*pow(Z2,2)) + 
-		   3*m32*(Z1 + Z2)*(2*m43 + m13*pow(Z2,2))) + 
-		   m23*(2*(3*m14*m42 - 3*m44 - 4*m11*m44)*Z1*pow(Z2,2) + m34*(Z1 + Z2)*(6*m42 + (3 + 4*m11)*pow(Z2,2)) - 
-		   3*m32*(Z1 + Z2)*(2*m44 + m14*pow(Z2,2))) + 
-		   2*(3*(m14*m33*m42 - m13*m34*m42 - m14*m32*m43 + m34*m43 + m13*m32*m44 - m33*m44)*Z2*(Z1 + Z2) + 
-		   2*m11*(6*(-(m14*m43) + m13*m44)*Z1*pow(Z2,2) + m34*(Z1 + Z2)*(2*m43*(-3 + Z2) - 3*m13*pow(Z2,2)) + 
-		  m33*(Z1 + Z2)*(6*m44 - 2*m44*Z2 + 3*m14*pow(Z2,2)))))*pow(Z1 + Z2,-1);	
-	
-	TY_qa32 = 2*phi*pow(Z1,-2)*(m24*((-3*m13*m42 + (3 + 4*m11)*m43)*(Z1 + Z2)*pow(Z1,2) - 
-		   2*m33*(3*m42*(Z1 + Z2) + (3 + 4*m11)*Z2*pow(Z1,2)) + 6*m32*(m43*(Z1 + Z2) + m13*Z2*pow(Z1,2))) + 
-		   m23*((3*m14*m42 - (3 + 4*m11)*m44)*(Z1 + Z2)*pow(Z1,2) + m34*(6*m42*(Z1 + Z2) + 2*(3 + 4*m11)*Z2*pow(Z1,2)) - 
-		   6*m32*(m44*(Z1 + Z2) + m14*Z2*pow(Z1,2))) + 
-		   2*(3*(m14*m33*m42 - m13*m34*m42 - m14*m32*m43 + m34*m43 + m13*m32*m44 - m33*m44)*Z1*(Z1 + Z2) + 
-		   2*m11*(-3*(m14*m43 - m13*m44)*(Z1 + Z2)*pow(Z1,2) + 2*m34*(m43*(-3 + Z1)*(Z1 + Z2) - 3*m13*Z2*pow(Z1,2)) + 
-		  m33*(-2*m44*(-3 + Z1)*(Z1 + Z2) + 6*m14*Z2*pow(Z1,2)))))*pow(Z1 + Z2,-1);
-/*		
-	if( debug ) 
-	{
-		sprintf(buf,"\rDet_a = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t%f\t%f\r%f\t%f\t%f\r%f\t%f\t%f\r", 
-			   0., TY_qa12, 0., 
-			   TY_qa21, TY_qa22, TY_qa23, 
-			   0.,    TY_qa32, 0. );
-		XOPNotice(buf);
-	}
-*/
-	
-	/* Matrix representation of the determinant of the of the system where row refering to 
-	 the variable b is replaced by solution vector */
-	
-	TY_qb12 = (K1*(-3*m11*m24*m43 + m14*(-3*m23*m41 + (-3 + 8*m11)*m43) + 3*m11*m23*m44 + m13*(3*m24*m41 + 3*m44 - 8*m11*m44))*exp(Z1))/3.;
-	
-	TY_qb21 = (K2*(-3*m13*m24*m31 + 3*m11*m24*m33 + m14*(3*m23*m31 + (3 - 8*m11)*m33) - 3*m13*m34 + 8*m11*m13*m34 - 3*m11*m23*m34)*
-			exp(Z2))/3.;
-	
-	TY_qb22 = m13*(m31*m44 - m24*m41*Z1 - m44*Z1 + (8*m11*m44*Z1)/3. + m24*m31*Z2 + m34*(-m41 + Z2 - (8*m11*Z2)/3.)) + 
-		   m14*(m23*m41*Z1 + m43*Z1 - (8*m11*m43*Z1)/3. + m33*(m41 - Z2 + (8*m11*Z2)/3.) - m31*(m43 + m23*Z2)) + 
-		   m11*(m24*m43*Z1 - m23*m44*Z1 + m34*(m43 + m23*Z2) - m33*(m44 + m24*Z2));	
-	
-	TY_qb23 = 2*phi*(3*m14*m23*m31 - 3*m13*m24*m31 + 3*m14*m33 - 8*m11*m14*m33 + 3*m11*m24*m33 - 3*m13*m34 + 8*m11*m13*m34 - 
-		   3*m11*m23*m34 + 2*(3*m24*(m33*m41 - m31*m43) + m23*(-3*m34*m41 + 3*m31*m44) + (-3 + 8*m11)*(m34*m43 - m33*m44))*
-		   pow(Z2,-2) + 6*(-(m14*m33*m41) + m13*m34*m41 + m14*m31*m43 - m11*m34*m43 - m13*m31*m44 + m11*m33*m44)*pow(Z2,-1) + 
-		   2*(-3*m11*m24*m43 + m14*(-3*m23*m41 + (-3 + 8*m11)*m43) + 3*m11*m23*m44 + m13*(3*m24*m41 + 3*m44 - 8*m11*m44))*Z1*
-		   pow(Z1 + Z2,-1));
-	
-	TY_qb32 = 2*phi*pow(Z1,-2)*(6*(-(m34*(m23*m41 + m43)) + m24*(m33*m41 - m31*m43) + (m23*m31 + m33)*m44) + 
-		   6*(-(m14*m33*m41) + m13*m34*m41 + m14*m31*m43 - m13*m31*m44)*Z1 + 
-		   3*(m14*(2*m23*m31 + 2*m33 - m23*m41 - m43) + m13*(-2*m34 + m24*(-2*m31 + m41) + m44))*pow(Z1,2) + 
-		   (m11*Z2*(16*m34*m43 - 16*m33*m44 - 6*m34*m43*Z1 + 6*m33*m44*Z1 + 
-		   (6*m24*m33 - 3*m24*m43 + 8*m14*(-2*m33 + m43) + (8*m13 - 3*m23)*(2*m34 - m44))*pow(Z1,2)) + 
-		   m11*Z1*(2*m34*m43*(8 - 3*Z1) + 2*m33*m44*(-8 + 3*Z1) + (8*m14*m43 - 3*m24*m43 - 8*m13*m44 + 3*m23*m44)*pow(Z1,2)))*
-		   pow(Z1 + Z2,-1) + 6*(-(m14*(m23*m31 + m33)) + m13*(m24*m31 + m34))*pow(Z1,3)*pow(Z1 + Z2,-1));
-/*		
-	if( debug ) 
-	{
-		sprintf(buf,"\rDet_b = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t%f\t%f\r%f\t%f\t%f\r%f\t%f\t%f\r", 
-			   0., TY_qb12, 0.,
-			   TY_qb21, TY_qb22, TY_qb23,
-			   0., TY_qb32, 0. );
-		XOPNotice(buf);
-	}
-*/
-	
-	/* Matrix representation of the determinant of the of the system where row refering to 
-	 the variable c1 is replaced by solution vector */
-	
-	TY_qc112 = -(K1*exp(Z1)*(9*m24*m41 - 9*m14*m42 + 3*m11*(-12*m14*m41 + 4*m24*m41 + 8*m14*m42 - 3*m24*m42) + m44*pow(3 - 2*m11,2)))/9.;
-	
-	TY_qc121 = (K2*exp(Z2)*(9*m24*m31 - 9*m14*m32 + 3*m11*(-12*m14*m31 + 4*m24*m31 + 8*m14*m32 - 3*m24*m32) + m34*pow(3 - 2*m11,2)))/9.;
-	
-	TY_qc122 = m14*(-4*m11*m41*Z1 - m42*Z1 + (8*m11*m42*Z1)/3. + m32*(-m41 + Z2 - (8*m11*Z2)/3.) + m31*(m42 + 4*m11*Z2)) + 
-			(3*m34*((3 + 4*m11)*m41 - 3*m11*m42) + 9*m11*m32*m44 + 9*m24*m41*Z1 + 12*m11*m24*m41*Z1 - 9*m11*m24*m42*Z1 + 9*m44*Z1 - 
-			12*m11*m44*Z1 + 9*m11*m24*m32*Z2 - 3*(3 + 4*m11)*m31*(m44 + m24*Z2) - m34*Z2*pow(3 - 2*m11,2) + 4*m44*Z1*pow(m11,2))/9.;
-	
-	TY_qc123 = (2*phi*pow(Z2,-2)*(9*(m34*(Z1 + Z2)*(2*m42 + Z2*(-2*m41 + Z2)) - m32*(Z1 + Z2)*(2*m44 + m14*Z2*(-2*m41 + Z2)) - 
-			2*(m14*m42 - m44)*Z2*(-(Z1*Z2) + m31*(Z1 + Z2))) + 4*(-2*m44*Z1 + m34*(Z1 + Z2))*pow(m11,2)*pow(Z2,2) - 
-			3*m24*(2*(3*m41 + 4*m11*m41 - 3*m11*m42)*Z1*pow(Z2,2) + 3*m32*(Z1 + Z2)*(2*m41 + m11*pow(Z2,2)) - 
-			m31*(Z1 + Z2)*(6*m42 + (3 + 4*m11)*pow(Z2,2))) - 
-			6*m11*(-8*m32*m44*Z1 + m32*m44*(-8 + 3*Z1)*Z2 + (3*m32*m44 - 4*(m14*(m32 + 3*m41 - 2*m42) + m44)*Z1)*pow(Z2,2) + 
-			m34*(Z1 + Z2)*(8*m42 + 4*m41*(-3 + Z2) - 3*m42*Z2 + 2*pow(Z2,2)) + 2*m31*(Z1 + Z2)*(6*m44 - 2*m44*Z2 + 3*m14*pow(Z2,2)) - 
-			4*m14*m32*pow(Z2,3)))*pow(Z1 + Z2,-1))/3.;
-	
-	TY_qc132 = (-2*phi*pow(Z1,-2)*(9*((m14*m42 - m44)*(2*m31 - Z1)*Z1*(Z1 + Z2) - 2*m34*(m42*(Z1 + Z2) - Z1*(-(Z1*Z2) + m41*(Z1 + Z2))) + 
-			2*m32*(m44*(Z1 + Z2) - m14*Z1*(-(Z1*Z2) + m41*(Z1 + Z2)))) + 4*(-2*m34*Z2 + m44*(Z1 + Z2))*pow(m11,2)*pow(Z1,2) + 
-			3*m24*(((3 + 4*m11)*m41 - 3*m11*m42)*(Z1 + Z2)*pow(Z1,2) + 6*m32*(m41*(Z1 + Z2) + m11*Z2*pow(Z1,2)) - 
-			2*m31*(3*m42*(Z1 + Z2) + (3 + 4*m11)*Z2*pow(Z1,2))) + 
-			6*m11*(Z1*(-8*m32*m44 + m34*(m42*(8 - 3*Z1) + 4*m41*(-3 + Z1)) - 4*m31*m44*(-3 + Z1) + 3*m32*m44*Z1 - 
-			2*(3*m14*m41 - 2*m14*m42 + m44)*pow(Z1,2)) + 
-			Z2*(4*(3*m31 - 2*m32)*m44 + Z1*(-4*m31*m44 + 3*m32*m44 - 2*(m14*(-6*m31 + 4*m32 + 3*m41 - 2*m42) + m44)*Z1) + 
-			m34*(m42*(8 - 3*Z1) + 4*m41*(-3 + Z1) + 4*pow(Z1,2)))))*pow(Z1 + Z2,-1))/3.;
-/*		
-	if( debug ) 
-	{
-		sprintf(buf,"\rDet_c1 = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t%f\t%f\r%f\t%f\t%f\r%f\t%f\t%f\r", 
-			    0., TY_qc112, 0., 
-			   TY_qc121, TY_qc122, TY_qc123,
-			   0., TY_qc132, 0. );
-		XOPNotice(buf);
-	}
- */
-	/* Matrix representation of the determinant of the of the system where row refering to 
-	 the variable c1 is replaced by solution vector */
-	
-	TY_qc212 = (K1*exp(Z1)*(9*m23*m41 - 9*m13*m42 + 3*m11*(-12*m13*m41 + 4*m23*m41 + 8*m13*m42 - 3*m23*m42) + m43*pow(3 - 2*m11,2)))/9.;
-	
-	TY_qc221 = -(K2*exp(Z2)*(9*m23*m31 - 9*m13*m32 + 3*m11*(-12*m13*m31 + 4*m23*m31 + 8*m13*m32 - 3*m23*m32) + m33*pow(3 - 2*m11,2)))/9.;
-	
-	TY_qc222 = m13*(4*m11*m41*Z1 + m42*Z1 - (8*m11*m42*Z1)/3. + m32*(m41 - Z2 + (8*m11*Z2)/3.) - m31*(m42 + 4*m11*Z2)) + 
-			(9*m31*m43 - 9*(m23*m41 + m43)*Z1 + 9*m23*m31*Z2 + 3*m11*
-			((-4*m23*m41 + 3*m23*m42 + 4*m43)*Z1 + 4*m31*(m43 + m23*Z2) - 3*m32*(m43 + m23*Z2)) + 
-			m33*(-3*(3 + 4*m11)*m41 + 9*m11*m42 + Z2*pow(3 - 2*m11,2)) - 4*m43*Z1*pow(m11,2))/9.;
-	
-	TY_qc223 = (2*phi*pow(Z2,-2)*(9*(-(m33*(Z1 + Z2)*(2*m42 + Z2*(-2*m41 + Z2))) + m32*(Z1 + Z2)*(2*m43 + m13*Z2*(-2*m41 + Z2)) + 
-			2*(m13*m42 - m43)*Z2*(-(Z1*Z2) + m31*(Z1 + Z2))) - 4*(-2*m43*Z1 + m33*(Z1 + Z2))*pow(m11,2)*pow(Z2,2) + 
-			3*m23*(2*(3*m41 + 4*m11*m41 - 3*m11*m42)*Z1*pow(Z2,2) + 3*m32*(Z1 + Z2)*(2*m41 + m11*pow(Z2,2)) - 
-			m31*(Z1 + Z2)*(6*m42 + (3 + 4*m11)*pow(Z2,2))) + 
-			6*m11*(-8*m32*m43*Z1 + m32*m43*(-8 + 3*Z1)*Z2 + (3*m32*m43 - 4*(m13*(m32 + 3*m41 - 2*m42) + m43)*Z1)*pow(Z2,2) + 
-			m33*(Z1 + Z2)*(8*m42 + 4*m41*(-3 + Z2) - 3*m42*Z2 + 2*pow(Z2,2)) + 2*m31*(Z1 + Z2)*(6*m43 - 2*m43*Z2 + 3*m13*pow(Z2,2)) - 
-			4*m13*m32*pow(Z2,3)))*pow(Z1 + Z2,-1))/3.;
-	
-	TY_qc232 = (2*phi*pow(Z1,-2)*(9*((m13*m42 - m43)*(2*m31 - Z1)*Z1*(Z1 + Z2) - 2*m33*(m42*(Z1 + Z2) - Z1*(-(Z1*Z2) + m41*(Z1 + Z2))) + 
-			2*m32*(m43*(Z1 + Z2) - m13*Z1*(-(Z1*Z2) + m41*(Z1 + Z2)))) + 4*(-2*m33*Z2 + m43*(Z1 + Z2))*pow(m11,2)*pow(Z1,2) + 
-			3*m23*(((3 + 4*m11)*m41 - 3*m11*m42)*(Z1 + Z2)*pow(Z1,2) + 6*m32*(m41*(Z1 + Z2) + m11*Z2*pow(Z1,2)) - 
-			2*m31*(3*m42*(Z1 + Z2) + (3 + 4*m11)*Z2*pow(Z1,2))) + 
-			6*m11*(Z1*(-8*m32*m43 + m33*(m42*(8 - 3*Z1) + 4*m41*(-3 + Z1)) - 4*m31*m43*(-3 + Z1) + 3*m32*m43*Z1 - 
-			2*(3*m13*m41 - 2*m13*m42 + m43)*pow(Z1,2)) + 
-			Z2*(4*(3*m31 - 2*m32)*m43 + Z1*(-4*m31*m43 + 3*m32*m43 - 2*(m13*(-6*m31 + 4*m32 + 3*m41 - 2*m42) + m43)*Z1) + 
-			m33*(m42*(8 - 3*Z1) + 4*m41*(-3 + Z1) + 4*pow(Z1,2)))))*pow(Z1 + Z2,-1))/3.;
-/*		
-	if( debug ) 
-	{
-		sprintf(buf,"\rDet_c2 = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t%f\t%f\r%f\t%f\t%f\r%f\t%f\t%f\r", 
-			   0., TY_qc212, 0., 
-			   TY_qc221, TY_qc222, TY_qc223, 
-			   0., TY_qc232, 0. );
-		XOPNotice(buf);
-	}	
-*/
-	
-	/* coefficient matrices of nonlinear equation 1 */
-	
-	TY_A12 = 6*phi*TY_qc112*exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(2*TY_qc212*exp(Z1)*(-Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*(exp(2*Z1)*(Z1*(2*TY_qb12*(-1 + Z1)*(Z1 + Z2) - Z1*(2*TY_qc212*Z1 + TY_qc112*(Z1 + Z2))) + TY_qa12*(Z1 + Z2)*(-2 + pow(Z1,2))) - 
-		  TY_qc112*(Z1 + Z2)*pow(Z1,2) + 2*(Z1 + Z2)*exp(Z1)*(TY_qa12 + (TY_qa12 + TY_qb12)*Z1 + TY_qc112*pow(Z1,2))))*pow(Z1 + Z2,-1);
-	
-	TY_A21 = 6*phi*exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(2*(TY_qc121*TY_qc212 + TY_qc112*TY_qc221)*exp(Z1)*(-Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*(2*(TY_qa12*TY_qc121 + TY_qa21*TY_qc112*(1 + Z1) + Z1*(TY_qb21*TY_qc112 + TY_qc121*(TY_qa12 + TY_qb12 + 2*TY_qc112*Z1)))*(Z1 + Z2)*exp(Z1) + 
-		  exp(2*Z1)*(2*Z1*(TY_qb21*TY_qc112*(-1 + Z1)*(Z1 + Z2) + TY_qb12*TY_qc121*(-1 + Z1)*(Z1 + Z2) - 
-		  Z1*(TY_qc121*TY_qc212*Z1 + TY_qc112*(TY_qc121 + TY_qc221)*Z1 + TY_qc112*TY_qc121*Z2)) + TY_qa21*TY_qc112*(Z1 + Z2)*(-2 + pow(Z1,2)) + 
-		  TY_qa12*TY_qc121*(Z1 + Z2)*(-2 + pow(Z1,2))) - 2*TY_qc112*TY_qc121*(Z1 + Z2)*pow(Z1,2)))*pow(Z1 + Z2,-1);
-	
-	TY_A22 = exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(12*phi*(TY_qc122*TY_qc212 + TY_qc112*TY_qc222)*exp(Z1)*(-Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*(12*phi*(TY_qa12*TY_qc122 + TY_qa22*TY_qc112*(1 + Z1) + Z1*(TY_qb22*TY_qc112 + TY_qc122*(TY_qa12 + TY_qb12 + 2*TY_qc112*Z1)))*(Z1 + Z2)*exp(Z1) - 
-		  2*phi*TY_qc112*TY_qc122*(Z1 + Z2)*pow(Z1,2) + exp(2*Z1)*
-		  (6*phi*(2*Z1*(TY_qb22*TY_qc112*(-1 + Z1)*(Z1 + Z2) + TY_qb12*TY_qc122*(-1 + Z1)*(Z1 + Z2) - 
-		  Z1*(TY_qc122*TY_qc212*Z1 + TY_qc112*(TY_qc122 + TY_qc222)*Z1 + TY_qc112*TY_qc122*Z2)) + TY_qa22*TY_qc112*(Z1 + Z2)*(-2 + pow(Z1,2)) + 
-		  TY_qa12*TY_qc122*(Z1 + Z2)*(-2 + pow(Z1,2))) + TY_q22*TY_qc112*(Z1 + Z2)*pow(Z1,3))))*pow(Z1 + Z2,-1);
-	
-	TY_A23 = 6*phi*exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(2*(TY_qc123*TY_qc212 + TY_qc112*TY_qc223)*exp(Z1)*(-Z2 + (Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*(2*(TY_qa12*TY_qc123 + TY_qa23*TY_qc112*(1 + Z1) + Z1*(TY_qb23*TY_qc112 + TY_qc123*(TY_qa12 + TY_qb12 + 2*TY_qc112*Z1)))*(Z1 + Z2)*exp(Z1) + 
-		  exp(2*Z1)*(2*Z1*(TY_qb23*TY_qc112*(-1 + Z1)*(Z1 + Z2) + TY_qb12*TY_qc123*(-1 + Z1)*(Z1 + Z2) - 
-		  Z1*((TY_q22*TY_qc112 + TY_qc123*(TY_qc112 + TY_qc212) + TY_qc112*TY_qc223)*Z1 + TY_qc112*TY_qc123*Z2)) + TY_qa23*TY_qc112*(Z1 + Z2)*(-2 + pow(Z1,2)) + 
-		  TY_qa12*TY_qc123*(Z1 + Z2)*(-2 + pow(Z1,2))) - 2*TY_qc112*TY_qc123*(Z1 + Z2)*pow(Z1,2)))*pow(Z1 + Z2,-1);
-	
-	TY_A32 = exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(12*phi*(TY_qa23*TY_qc121 + TY_qa22*TY_qc122 + TY_qa21*TY_qc123 + TY_qa12*TY_qc132 + TY_qa32*TY_qc112*(1 + Z1) + 
-		  Z1*(TY_qb32*TY_qc112 + (TY_qa23 + TY_qb23)*TY_qc121 + (TY_qa21 + TY_qb21)*TY_qc123 + (TY_qa12 + TY_qb12)*TY_qc132 + TY_q22*TY_qc112*Z1 + 
-		  2*(TY_qc121*TY_qc123 + TY_qc112*TY_qc132)*Z1 + TY_qc122*(TY_qa22 + TY_qb22 + TY_qc122*Z1)))*(Z1 + Z2)*exp(Z1 + Z2) - 
-		  12*phi*(TY_qc132*TY_qc212 + TY_qc123*TY_qc221 + TY_qc122*TY_qc222 + TY_qc121*TY_qc223 + TY_qc112*TY_qc232)*Z2*exp(Z1)*pow(Z1,2) + 
-		  12*phi*((TY_q22 + TY_qc132)*TY_qc212 + TY_qc123*TY_qc221 + TY_qc122*TY_qc222 + TY_qc121*TY_qc223 + TY_qc112*TY_qc232)*(Z1 + Z2)*exp(2*Z1)*pow(Z1,2) - 
-		  6*phi*(Z1 + Z2)*exp(Z2)*(2*TY_qc121*TY_qc123 + 2*TY_qc112*TY_qc132 + pow(TY_qc122,2))*pow(Z1,2) + 
-		  exp(2*Z1 + Z2)*(TY_q22*(6*phi*(2*Z1*(TY_qb12*(-1 + Z1)*(Z1 + Z2) - Z1*((TY_qc112 + TY_qc121 + TY_qc212)*Z1 + TY_qc112*Z2)) + 
-		  TY_qa12*(Z1 + Z2)*(-2 + pow(Z1,2))) + TY_qc122*(Z1 + Z2)*pow(Z1,3)) + 
-		  6*phi*(-2*TY_qa22*TY_qc122*Z1 - 2*TY_qa21*TY_qc123*Z1 - 2*TY_qa12*TY_qc132*Z1 + TY_qa32*TY_qc112*(Z1 + Z2)*(-2 + pow(Z1,2)) + 
-		  TY_qa23*TY_qc121*(Z1 + Z2)*(-2 + pow(Z1,2)) - 2*TY_qb32*TY_qc112*pow(Z1,2) - 2*TY_qb23*TY_qc121*pow(Z1,2) - 2*TY_qb22*TY_qc122*pow(Z1,2) - 
-		  2*TY_qb21*TY_qc123*pow(Z1,2) - 2*TY_qb12*TY_qc132*pow(Z1,2) + 
-		  Z2*(-2*(TY_qa22*TY_qc122 + TY_qa21*TY_qc123 + TY_qa12*TY_qc132) - 2*(TY_qb32*TY_qc112 + TY_qb23*TY_qc121 + TY_qb22*TY_qc122 + TY_qb21*TY_qc123 + TY_qb12*TY_qc132)*Z1 + 
-		  (2*TY_qb32*TY_qc112 + 2*TY_qb23*TY_qc121 + (TY_qa22 + 2*TY_qb22 - TY_qc122)*TY_qc122 + (TY_qa21 + 2*TY_qb21 - 2*TY_qc121)*TY_qc123 + 
-		  (TY_qa12 + 2*TY_qb12 - 2*TY_qc112)*TY_qc132)*pow(Z1,2)) + 2*TY_qb32*TY_qc112*pow(Z1,3) + 2*TY_qb23*TY_qc121*pow(Z1,3) + TY_qa22*TY_qc122*pow(Z1,3) + 
-		  2*TY_qb22*TY_qc122*pow(Z1,3) + TY_qa21*TY_qc123*pow(Z1,3) + 2*TY_qb21*TY_qc123*pow(Z1,3) - 2*TY_qc121*TY_qc123*pow(Z1,3) + TY_qa12*TY_qc132*pow(Z1,3) + 
-		  2*TY_qb12*TY_qc132*pow(Z1,3) - 2*TY_qc112*TY_qc132*pow(Z1,3) - 2*TY_qc132*TY_qc212*pow(Z1,3) - 2*TY_qc123*TY_qc221*pow(Z1,3) - 
-		  2*TY_qc122*TY_qc222*pow(Z1,3) - 2*TY_qc121*TY_qc223*pow(Z1,3) - 2*TY_qc112*TY_qc232*pow(Z1,3) - pow(TY_qc122,2)*pow(Z1,3))))*pow(Z1 + Z2,-1);
-	
-	TY_A41 = 6*phi*exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(2*exp(Z1)*
-		  ((-(TY_qc132*TY_qc221) - TY_qc121*TY_qc232)*Z2 + ((TY_q22 + TY_qc132)*TY_qc221 + TY_qc121*TY_qc232)*(Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*(2*(TY_qa21*TY_qc132 + TY_qa32*TY_qc121*(1 + Z1) + Z1*(TY_qb32*TY_qc121 + (TY_qa21 + TY_qb21)*TY_qc132 + TY_qc121*(TY_q22 + 2*TY_qc132)*Z1))*(Z1 + Z2)*
-		  exp(Z1) - 2*TY_qc121*TY_qc132*(Z1 + Z2)*pow(Z1,2) + 
-		  exp(2*Z1)*(Z2*(-2*(TY_qa32*TY_qc121 + TY_qa21*(TY_q22 + TY_qc132)) - 2*(TY_qb32*TY_qc121 + TY_qb21*(TY_q22 + TY_qc132))*Z1 + 
-		  (TY_q22*(TY_qa21 + 2*TY_qb21 - 2*TY_qc121) + TY_qc121*(TY_qa32 + 2*TY_qb32 - 2*TY_qc132) + (TY_qa21 + 2*TY_qb21)*TY_qc132)*pow(Z1,2)) + 
-		  Z1*(-2*(TY_qa32*TY_qc121 + TY_qa21*(TY_q22 + TY_qc132)) - 2*(TY_qb32*TY_qc121 + TY_qb21*(TY_q22 + TY_qc132))*Z1 + 
-		  (TY_qa32*TY_qc121 + 2*TY_qb32*TY_qc121 + TY_qa21*TY_qc132 + 2*TY_qb21*TY_qc132 - 2*TY_qc121*TY_qc132 + TY_q22*(TY_qa21 + 2*TY_qb21 - 2*TY_qc121 - 2*TY_qc221) - 
-		  2*TY_qc132*TY_qc221 - 2*TY_qc121*TY_qc232)*pow(Z1,2)))))*pow(Z1 + Z2,-1);
-	
-	TY_A42 = exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(12*phi*(TY_qa22*TY_qc132 + TY_qa32*TY_qc122*(1 + Z1) + 
-		  Z1*(TY_qb32*TY_qc122 + (TY_qa22 + TY_qb22)*TY_qc132 + TY_qc122*(TY_q22 + 2*TY_qc132)*Z1))*(Z1 + Z2)*exp(Z1 + Z2) - 
-		  12*phi*(TY_qc132*TY_qc222 + TY_qc122*TY_qc232)*Z2*exp(Z1)*pow(Z1,2) + 
-		  12*phi*((TY_q22 + TY_qc132)*TY_qc222 + TY_qc122*TY_qc232)*(Z1 + Z2)*exp(2*Z1)*pow(Z1,2) - 12*phi*TY_qc122*TY_qc132*(Z1 + Z2)*exp(Z2)*pow(Z1,2) + 
-		  exp(2*Z1 + Z2)*(6*phi*(2*Z1*(TY_qb32*TY_qc122*(-1 + Z1)*(Z1 + Z2) + TY_qb22*TY_qc132*(-1 + Z1)*(Z1 + Z2) - 
-		  Z1*(TY_qc132*TY_qc222*Z1 + TY_qc122*(TY_qc132 + TY_qc232)*Z1 + TY_qc122*TY_qc132*Z2)) + TY_qa32*TY_qc122*(Z1 + Z2)*(-2 + pow(Z1,2)) + 
-		  TY_qa22*TY_qc132*(Z1 + Z2)*(-2 + pow(Z1,2))) + (Z1 + Z2)*pow(TY_q22,2)*pow(Z1,3) + 
-		  TY_q22*(6*phi*(2*Z1*(TY_qb22*(-1 + Z1)*(Z1 + Z2) - Z1*((TY_qc122 + TY_qc222)*Z1 + TY_qc122*Z2)) + TY_qa22*(Z1 + Z2)*(-2 + pow(Z1,2))) + 
-		  TY_qc132*(Z1 + Z2)*pow(Z1,3))))*pow(Z1 + Z2,-1);
-	
-	TY_A43 = -6*phi*exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(2*exp(Z1)*
-		  ((TY_qc132*TY_qc223 + TY_qc123*TY_qc232)*Z2 - ((TY_q22 + TY_qc132)*TY_qc223 + TY_qc123*TY_qc232)*(Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*(-2*(TY_qa23*TY_qc132 + TY_qa32*TY_qc123*(1 + Z1) + Z1*(TY_qb32*TY_qc123 + (TY_qa23 + TY_qb23)*TY_qc132 + TY_qc123*(TY_q22 + 2*TY_qc132)*Z1))*(Z1 + Z2)*
-		  exp(Z1) + 2*TY_qc123*TY_qc132*(Z1 + Z2)*pow(Z1,2) + 
-		  exp(2*Z1)*(Z2*(2*TY_qa32*TY_qc123 + 2*TY_qa23*(TY_q22 + TY_qc132) + 2*(TY_qb32*TY_qc123 + TY_qb23*(TY_q22 + TY_qc132))*Z1 - 
-		  (TY_q22*(TY_qa23 + 2*TY_qb23 - 2*TY_qc123) + TY_qc123*(TY_qa32 + 2*TY_qb32 - 2*TY_qc132) + (TY_qa23 + 2*TY_qb23)*TY_qc132)*pow(Z1,2)) + 
-		  Z1*(2*TY_qa32*TY_qc123 + 2*TY_qa23*(TY_q22 + TY_qc132) + 2*(TY_qb32*TY_qc123 + TY_qb23*(TY_q22 + TY_qc132))*Z1 + 
-		  (-(TY_qa32*TY_qc123) - (TY_qa23 + 2*TY_qb23)*TY_qc132 + TY_q22*(-TY_qa23 + 2*(-TY_qb23 + TY_qc123 + TY_qc132 + TY_qc223)) + 
-		  2*(-(TY_qb32*TY_qc123) + TY_qc132*(TY_qc123 + TY_qc223) + TY_qc123*TY_qc232) + 2*pow(TY_q22,2))*pow(Z1,2)))))*pow(Z1 + Z2,-1);
-	
-	TY_A52 = -6*phi*exp(-2*Z1 - Z2)*pow(TY_q22,-2)*pow(Z1,-3)*(2*TY_qc232*exp(Z1)*(TY_qc132*Z2 - (TY_q22 + TY_qc132)*(Z1 + Z2)*exp(Z1))*pow(Z1,2) + 
-		  exp(Z2)*((TY_q22 + TY_qc132)*exp(2*Z1)*(Z1*(-2*TY_qb32*(-1 + Z1)*(Z1 + Z2) + Z1*((TY_q22 + TY_qc132 + 2*TY_qc232)*Z1 + (TY_q22 + TY_qc132)*Z2)) - 
-		  TY_qa32*(Z1 + Z2)*(-2 + pow(Z1,2))) + (Z1 + Z2)*pow(TY_qc132,2)*pow(Z1,2) - 
-		  2*TY_qc132*(Z1 + Z2)*exp(Z1)*(TY_qa32 + (TY_qa32 + TY_qb32)*Z1 + (TY_q22 + TY_qc132)*pow(Z1,2))))*pow(Z1 + Z2,-1);
-	
-	// normalize A
-	/*double norm_A = sqrt(pow(TY_A52,2)+pow(TY_A43,2)+pow(TY_A42, 2)+pow(TY_A41, 2)+pow(TY_A32, 2)+
-						 pow(TY_A23,2)+pow(TY_A22,2)+pow(TY_A21, 2)+pow(TY_A12, 2));
-	TY_A12 /= norm_A;
-	TY_A21 /= norm_A;
-	TY_A22 /= norm_A;
-	TY_A23 /= norm_A;
-	TY_A32 /= norm_A;
-	TY_A41 /= norm_A;
-	TY_A42 /= norm_A;
-	TY_A43 /= norm_A;
-	TY_A52 /= norm_A;*/
-/*	
-	if( debug ) 
-	{
-		sprintf(buf,"\rNonlinear equation 1 = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\r", 0.,   TY_A12, 0.   );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\r", TY_A21, TY_A22, TY_A23 );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\r",  0.,  TY_A32, 0.   );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\r", TY_A41, TY_A42, TY_A43 );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\r", 0.,   TY_A52, 0. );		
-		XOPNotice(buf);
-	}
- */
-	
-	/* coefficient matrices of nonlinear equation 2 */
-	
-	TY_B12 = 6*phi*exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(-2*TY_qc212*TY_qc221*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 
-		  2*exp(Z2)*((Z1 + Z2)*(TY_qa12*TY_qc221 + TY_qa21*TY_qc212*(1 + Z2) + Z2*(TY_qb21*TY_qc212 + TY_qc221*(TY_qa12 + TY_qb12 + 2*TY_qc212*Z2)))*exp(Z1) + 
-		  (-(TY_qc121*TY_qc212) - TY_qc112*TY_qc221)*Z1*pow(Z2,2)) + 
-		  exp(2*Z2)*(exp(Z1)*(2*Z2*(TY_qb21*TY_qc212*(-1 + Z2)*(Z1 + Z2) + TY_qb12*TY_qc221*(-1 + Z2)*(Z1 + Z2) - 
-		  Z2*(TY_qc212*TY_qc221*Z1 + TY_qc112*TY_qc221*Z2 + TY_qc212*(TY_qc121 + TY_qc221)*Z2)) + TY_qa21*TY_qc212*(Z1 + Z2)*(-2 + pow(Z2,2)) + 
-		  TY_qa12*TY_qc221*(Z1 + Z2)*(-2 + pow(Z2,2))) + 2*(TY_qc121*TY_qc212 + TY_qc112*TY_qc221)*(Z1 + Z2)*pow(Z2,2)))*pow(Z1 + Z2,-1);
-	
-	TY_B14 = 6*phi*exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(-2*TY_qc212*TY_qc223*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 
-		  2*exp(Z2)*((Z1 + Z2)*(TY_qa12*TY_qc223 + TY_qa23*TY_qc212*(1 + Z2) + Z2*(TY_qb23*TY_qc212 + (TY_qa12 + TY_qb12)*TY_qc223 + TY_qc212*(TY_q22 + 2*TY_qc223)*Z2))*
-		  exp(Z1) + (-(TY_qc123*TY_qc212) - TY_qc112*TY_qc223)*Z1*pow(Z2,2)) + 
-		  exp(2*Z2)*(2*(TY_qc123*TY_qc212 + TY_qc112*(TY_q22 + TY_qc223))*(Z1 + Z2)*pow(Z2,2) + 
-		  exp(Z1)*(-2*(TY_qa23*TY_qc212 + TY_qa12*(TY_q22 + TY_qc223))*Z1 - 
-		  2*(TY_qa23*TY_qc212 + TY_qa12*(TY_q22 + TY_qc223) + (TY_qb23*TY_qc212 + TY_qb12*(TY_q22 + TY_qc223))*Z1)*Z2 + 
-		  (-2*(TY_qb23*TY_qc212 + TY_qb12*(TY_q22 + TY_qc223)) + (TY_q22*(TY_qa12 + 2*TY_qb12 - 2*TY_qc212) + TY_qc212*(TY_qa23 + 2*TY_qb23 - 2*TY_qc223) + 
-		  (TY_qa12 + 2*TY_qb12)*TY_qc223)*Z1)*pow(Z2,2) + 
-		  (TY_q22*(TY_qa12 + 2*TY_qb12 - 2*TY_qc112 - 2*TY_qc212) + TY_qc212*(TY_qa23 + 2*TY_qb23 - 2*TY_qc123 - 2*TY_qc223) + (TY_qa12 + 2*TY_qb12 - 2*TY_qc112)*TY_qc223)*
-		  pow(Z2,3))))*pow(Z1 + Z2,-1);
-	
-	TY_B21 = 6*phi*TY_qc221*exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(-(TY_qc221*(Z1 + Z2)*exp(Z1)*pow(Z2,2)) + 
-		  exp(2*Z2)*(exp(Z1)*(Z2*(2*TY_qb21*(-1 + Z2)*(Z1 + Z2) - Z2*(2*TY_qc121*Z2 + TY_qc221*(Z1 + Z2))) + TY_qa21*(Z1 + Z2)*(-2 + pow(Z2,2))) + 
-		  2*TY_qc121*(Z1 + Z2)*pow(Z2,2)) + 2*exp(Z2)*(-(TY_qc121*Z1*pow(Z2,2)) + (Z1 + Z2)*exp(Z1)*(TY_qa21 + (TY_qa21 + TY_qb21)*Z2 + TY_qc221*pow(Z2,2)))
-		  )*pow(Z1 + Z2,-1);
-	
-	TY_B22 = exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(-12*phi*TY_qc221*TY_qc222*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 
-		  12*phi*exp(Z2)*((Z1 + Z2)*(TY_qa21*TY_qc222 + TY_qa22*TY_qc221*(1 + Z2) + Z2*(TY_qb22*TY_qc221 + TY_qc222*(TY_qa21 + TY_qb21 + 2*TY_qc221*Z2)))*exp(Z1) + 
-		  (-(TY_qc122*TY_qc221) - TY_qc121*TY_qc222)*Z1*pow(Z2,2)) + 
-		  exp(2*Z2)*(12*phi*(TY_qc122*TY_qc221 + TY_qc121*TY_qc222)*(Z1 + Z2)*pow(Z2,2) + 
-		  exp(Z1)*(6*phi*(2*Z2*(TY_qb22*TY_qc221*(-1 + Z2)*(Z1 + Z2) + TY_qb21*TY_qc222*(-1 + Z2)*(Z1 + Z2) - 
-		  Z2*(TY_qc221*TY_qc222*Z1 + TY_qc121*TY_qc222*Z2 + TY_qc221*(TY_qc122 + TY_qc222)*Z2)) + TY_qa22*TY_qc221*(Z1 + Z2)*(-2 + pow(Z2,2)) + 
-		  TY_qa21*TY_qc222*(Z1 + Z2)*(-2 + pow(Z2,2))) + TY_q22*TY_qc221*(Z1 + Z2)*pow(Z2,3))))*pow(Z1 + Z2,-1);
-	
-	TY_B23 = exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(-6*phi*(Z1 + Z2)*exp(Z1)*(2*TY_qc221*TY_qc223 + 2*TY_qc212*TY_qc232 + pow(TY_qc222,2))*pow(Z2,2) + 
-		  12*phi*exp(Z2)*((Z1 + Z2)*exp(Z1)*(TY_qa23*TY_qc221 + TY_qa22*TY_qc222 + TY_qa21*TY_qc223 + TY_qa12*TY_qc232 + TY_qa32*TY_qc212*(1 + Z2) + 
-		  Z2*(TY_qb32*TY_qc212 + (TY_qa23 + TY_qb23)*TY_qc221 + (TY_qa22 + TY_qb22)*TY_qc222 + (TY_qa21 + TY_qb21)*TY_qc223 + (TY_qa12 + TY_qb12)*TY_qc232 + 
-		  Z2*(TY_q22*TY_qc221 + 2*TY_qc221*TY_qc223 + 2*TY_qc212*TY_qc232 + pow(TY_qc222,2)))) + 
-		  (-(TY_qc132*TY_qc212) - TY_qc123*TY_qc221 - TY_qc122*TY_qc222 - TY_qc121*TY_qc223 - TY_qc112*TY_qc232)*Z1*pow(Z2,2)) + 
-		  exp(2*Z2)*(12*phi*(TY_qc132*TY_qc212 + TY_qc123*TY_qc221 + TY_qc122*TY_qc222 + TY_qc121*(TY_q22 + TY_qc223) + TY_qc112*TY_qc232)*(Z1 + Z2)*pow(Z2,2) + 
-		  exp(Z1)*(TY_q22*TY_qc222*(Z1 + Z2)*pow(Z2,3) - 6*phi*
-		  (2*(TY_qa32*TY_qc212 + TY_qa23*TY_qc221 + TY_qa22*TY_qc222 + TY_qa21*(TY_q22 + TY_qc223) + TY_qa12*TY_qc232)*Z1 + 
-		  2*(TY_qa32*TY_qc212 + TY_qa23*TY_qc221 + TY_qa22*TY_qc222 + TY_qa21*(TY_q22 + TY_qc223) + TY_qa12*TY_qc232 + 
-		  (TY_qb32*TY_qc212 + TY_qb23*TY_qc221 + TY_qb22*TY_qc222 + TY_qb21*(TY_q22 + TY_qc223) + TY_qb12*TY_qc232)*Z1)*Z2 - 
-		  (-2*(TY_qb32*TY_qc212 + TY_qb23*TY_qc221 + TY_qb22*TY_qc222 + TY_qb21*(TY_q22 + TY_qc223) + TY_qb12*TY_qc232) + 
-		  (TY_q22*(TY_qa21 + 2*TY_qb21 - 2*TY_qc221) + (TY_qa22 + 2*TY_qb22 - TY_qc222)*TY_qc222 + TY_qc221*(TY_qa23 + 2*TY_qb23 - 2*TY_qc223) + TY_qa21*TY_qc223 + 
-		  2*TY_qb21*TY_qc223 + TY_qc212*(TY_qa32 + 2*TY_qb32 - 2*TY_qc232) + TY_qa12*TY_qc232 + 2*TY_qb12*TY_qc232)*Z1)*pow(Z2,2) - 
-		  (TY_q22*(TY_qa21 + 2*TY_qb21 - 2*TY_qc121 - 2*TY_qc212 - 2*TY_qc221) + (TY_qa22 + 2*TY_qb22 - 2*TY_qc122 - TY_qc222)*TY_qc222 + 
-		  TY_qc221*(TY_qa23 + 2*TY_qb23 - 2*TY_qc123 - 2*TY_qc223) + (TY_qa21 + 2*TY_qb21 - 2*TY_qc121)*TY_qc223 + 
-		  TY_qc212*(TY_qa32 + 2*TY_qb32 - 2*TY_qc132 - 2*TY_qc232) + (TY_qa12 + 2*TY_qb12 - 2*TY_qc112)*TY_qc232)*pow(Z2,3)))))*pow(Z1 + Z2,-1);
-	
-	TY_B24 = exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(12*phi*(Z1 + Z2)*
-		  (TY_qa22*TY_qc223 + TY_qa23*TY_qc222*(1 + Z2) + Z2*(TY_qb23*TY_qc222 + (TY_qa22 + TY_qb22)*TY_qc223 + TY_qc222*(TY_q22 + 2*TY_qc223)*Z2))*exp(Z1 + Z2) - 
-		  12*phi*TY_qc222*TY_qc223*(Z1 + Z2)*exp(Z1)*pow(Z2,2) - 12*phi*(TY_qc123*TY_qc222 + TY_qc122*TY_qc223)*Z1*exp(Z2)*pow(Z2,2) + 
-		  12*phi*(TY_qc123*TY_qc222 + TY_qc122*(TY_q22 + TY_qc223))*(Z1 + Z2)*exp(2*Z2)*pow(Z2,2) + 
-		  exp(Z1 + 2*Z2)*(6*phi*(2*Z2*(TY_qb23*TY_qc222*(-1 + Z2)*(Z1 + Z2) + TY_qb22*TY_qc223*(-1 + Z2)*(Z1 + Z2) - 
-		  Z2*(TY_qc222*TY_qc223*Z1 + TY_qc122*TY_qc223*Z2 + TY_qc222*(TY_qc123 + TY_qc223)*Z2)) + TY_qa23*TY_qc222*(Z1 + Z2)*(-2 + pow(Z2,2)) + 
-		  TY_qa22*TY_qc223*(Z1 + Z2)*(-2 + pow(Z2,2))) + (Z1 + Z2)*pow(TY_q22,2)*pow(Z2,3) + 
-		  TY_q22*(6*phi*(2*Z2*(TY_qb22*(-1 + Z2)*(Z1 + Z2) - Z2*(TY_qc222*Z1 + (TY_qc122 + TY_qc222)*Z2)) + TY_qa22*(Z1 + Z2)*(-2 + pow(Z2,2))) + 
-		  TY_qc223*(Z1 + Z2)*pow(Z2,3))))*pow(Z1 + Z2,-1);
-	
-	TY_B25 = -6*phi*exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*((Z1 + Z2)*exp(Z1)*pow(TY_qc223,2)*pow(Z2,2) + 
-		  (TY_q22 + TY_qc223)*exp(2*Z2)*(exp(Z1)*(Z2*(-2*TY_qb23*(-1 + Z2)*(Z1 + Z2) + Z2*((TY_q22 + TY_qc223)*Z1 + (TY_q22 + 2*TY_qc123 + TY_qc223)*Z2)) - 
-		  TY_qa23*(Z1 + Z2)*(-2 + pow(Z2,2))) - 2*TY_qc123*(Z1 + Z2)*pow(Z2,2)) + 
-		  2*TY_qc223*exp(Z2)*(TY_qc123*Z1*pow(Z2,2) - (Z1 + Z2)*exp(Z1)*(TY_qa23 + (TY_qa23 + TY_qb23)*Z2 + (TY_q22 + TY_qc223)*pow(Z2,2))))*pow(Z1 + Z2,-1);
-	
-	TY_B32 = 6*phi*exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(-2*TY_qc221*TY_qc232*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 
-		  2*exp(Z2)*((Z1 + Z2)*(TY_qa21*TY_qc232 + TY_qa32*TY_qc221*(1 + Z2) + Z2*(TY_qb32*TY_qc221 + TY_qc232*(TY_qa21 + TY_qb21 + 2*TY_qc221*Z2)))*exp(Z1) + 
-		  (-(TY_qc132*TY_qc221) - TY_qc121*TY_qc232)*Z1*pow(Z2,2)) + 
-		  exp(2*Z2)*(exp(Z1)*(2*Z2*(TY_qb32*TY_qc221*(-1 + Z2)*(Z1 + Z2) + TY_qb21*TY_qc232*(-1 + Z2)*(Z1 + Z2) - 
-		  Z2*(TY_qc221*TY_qc232*Z1 + TY_qc121*TY_qc232*Z2 + TY_qc221*(TY_q22 + TY_qc132 + TY_qc232)*Z2)) + TY_qa32*TY_qc221*(Z1 + Z2)*(-2 + pow(Z2,2)) + 
-		  TY_qa21*TY_qc232*(Z1 + Z2)*(-2 + pow(Z2,2))) + 2*(TY_qc132*TY_qc221 + TY_qc121*TY_qc232)*(Z1 + Z2)*pow(Z2,2)))*pow(Z1 + Z2,-1);
-	
-	TY_B34 = -6*phi*exp(-Z1 - 2*Z2)*pow(TY_q22,-2)*pow(Z2,-3)*(2*TY_qc223*TY_qc232*(Z1 + Z2)*exp(Z1)*pow(Z2,2) + 
-		  2*exp(Z2)*(-((Z1 + Z2)*(TY_qa23*TY_qc232 + TY_qa32*TY_qc223*(1 + Z2) + Z2*(TY_qb32*TY_qc223 + TY_qc232*(TY_qa23 + TY_qb23 + TY_q22*Z2 + 2*TY_qc223*Z2)))*exp(Z1)) + 
-		  (TY_qc132*TY_qc223 + TY_qc123*TY_qc232)*Z1*pow(Z2,2)) + exp(2*Z2)*
-		  (-2*(TY_qc132*(TY_q22 + TY_qc223) + TY_qc123*TY_qc232)*(Z1 + Z2)*pow(Z2,2) + 
-		  exp(Z1)*(2*(TY_qa32*(TY_q22 + TY_qc223) + TY_qa23*TY_qc232)*Z1 + 
-		  2*(TY_qa32*(TY_q22 + TY_qc223) + TY_qa23*TY_qc232 + (TY_qb32*(TY_q22 + TY_qc223) + TY_qb23*TY_qc232)*Z1)*Z2 - 
-		  (-2*(TY_qb32*(TY_q22 + TY_qc223) + TY_qb23*TY_qc232) + ((TY_qa32 + 2*TY_qb32)*(TY_q22 + TY_qc223) + (-2*TY_q22 + TY_qa23 + 2*TY_qb23 - 2*TY_qc223)*TY_qc232)*Z1)*
-		  pow(Z2,2) + ((2*TY_q22 - TY_qa32 - 2*TY_qb32 + 2*TY_qc132)*(TY_q22 + TY_qc223) + (2*TY_q22 - TY_qa23 + 2*(-TY_qb23 + TY_qc123 + TY_qc223))*TY_qc232)*pow(Z2,3))))*pow(Z1 + Z2,-1);
-	
-	/*double norm_B = sqrt(pow(TY_B12, 2)+pow(TY_B14, 2)+pow(TY_B21, 2)+pow(TY_B22, 2)+pow(TY_B23, 2)+pow(TY_B24, 2)+pow(TY_B25, 2)+pow(TY_B32, 2)+pow(TY_B34, 2));
-	
-	TY_B12 /= norm_B;
-	TY_B14 /= norm_B;
-	TY_B21 /= norm_B;
-	TY_B22 /= norm_B;
-	TY_B23 /= norm_B;
-	TY_B24 /= norm_B;
-	TY_B25 /= norm_B;
-	TY_B32 /= norm_B;
-	TY_B34 /= norm_B; */
-/*	
-	if( debug ) 
-	{
-		sprintf(buf,"\rNonlinear equation 2 = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0.,  TY_B12, 0.,  TY_B14, 0.  );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\r", TY_B21, TY_B22, TY_B23, TY_B24, TY_B25 );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0.,  TY_B32, 0.,  TY_B34, 0.  );
-		XOPNotice(buf);
-	}
-*/
-	
-	/* decrease order of nonlinear equation 1 by means of equation 2 */
-	
-	TY_F14 = -(TY_A32*TY_B12*TY_B32) + TY_A52*pow(TY_B12,2) + TY_A12*pow(TY_B32,2);
-	TY_F16 = 2*TY_A52*TY_B12*TY_B14 - TY_A32*TY_B14*TY_B32 - TY_A32*TY_B12*TY_B34 + 2*TY_A12*TY_B32*TY_B34;
-	TY_F18 = -(TY_A32*TY_B14*TY_B34) + TY_A52*pow(TY_B14,2) + TY_A12*pow(TY_B34,2);
-	TY_F23 = 2*TY_A52*TY_B12*TY_B21 - TY_A41*TY_B12*TY_B32 - TY_A32*TY_B21*TY_B32 + TY_A21*pow(TY_B32,2);
-	TY_F24 = 2*TY_A52*TY_B12*TY_B22 - TY_A42*TY_B12*TY_B32 - TY_A32*TY_B22*TY_B32 + TY_A22*pow(TY_B32,2);
-	TY_F25 = 2*TY_A52*TY_B14*TY_B21 + 2*TY_A52*TY_B12*TY_B23 - TY_A43*TY_B12*TY_B32 - TY_A41*TY_B14*TY_B32 - TY_A32*TY_B23*TY_B32 - TY_A41*TY_B12*TY_B34 - TY_A32*TY_B21*TY_B34 + 2*TY_A21*TY_B32*TY_B34 + TY_A23*pow(TY_B32,2);
-	TY_F26 = 2*TY_A52*TY_B14*TY_B22 + 2*TY_A52*TY_B12*TY_B24 - TY_A42*TY_B14*TY_B32 - TY_A32*TY_B24*TY_B32 - TY_A42*TY_B12*TY_B34 - TY_A32*TY_B22*TY_B34 + 2*TY_A22*TY_B32*TY_B34;
-	TY_F27 = 2*TY_A52*TY_B14*TY_B23 + 2*TY_A52*TY_B12*TY_B25 - TY_A43*TY_B14*TY_B32 - TY_A32*TY_B25*TY_B32 - TY_A43*TY_B12*TY_B34 - TY_A41*TY_B14*TY_B34 - TY_A32*TY_B23*TY_B34 + 2*TY_A23*TY_B32*TY_B34 + TY_A21*pow(TY_B34,2);
-	TY_F28 = 2*TY_A52*TY_B14*TY_B24 - TY_A42*TY_B14*TY_B34 - TY_A32*TY_B24*TY_B34 + TY_A22*pow(TY_B34,2);
-	TY_F29 = 2*TY_A52*TY_B14*TY_B25 - TY_A43*TY_B14*TY_B34 - TY_A32*TY_B25*TY_B34 + TY_A23*pow(TY_B34,2);
-	TY_F32 = -(TY_A41*TY_B21*TY_B32) + TY_A52*pow(TY_B21,2);
-	TY_F33 = 2*TY_A52*TY_B21*TY_B22 - TY_A42*TY_B21*TY_B32 - TY_A41*TY_B22*TY_B32;
-	TY_F34 = 2*TY_A52*TY_B21*TY_B23 - TY_A43*TY_B21*TY_B32 - TY_A42*TY_B22*TY_B32 - TY_A41*TY_B23*TY_B32 - TY_A41*TY_B21*TY_B34 + TY_A52*pow(TY_B22,2);
-	TY_F35 = 2*TY_A52*TY_B22*TY_B23 + 2*TY_A52*TY_B21*TY_B24 - TY_A43*TY_B22*TY_B32 - TY_A42*TY_B23*TY_B32 - TY_A41*TY_B24*TY_B32 - TY_A42*TY_B21*TY_B34 - TY_A41*TY_B22*TY_B34;
-	TY_F36 = 2*TY_A52*TY_B22*TY_B24 + 2*TY_A52*TY_B21*TY_B25 - TY_A43*TY_B23*TY_B32 - TY_A42*TY_B24*TY_B32 - TY_A41*TY_B25*TY_B32 - TY_A43*TY_B21*TY_B34 - TY_A42*TY_B22*TY_B34 - TY_A41*TY_B23*TY_B34 + TY_A52*pow(TY_B23,2);
-	TY_F37 = 2*TY_A52*TY_B23*TY_B24 + 2*TY_A52*TY_B22*TY_B25 - TY_A43*TY_B24*TY_B32 - TY_A42*TY_B25*TY_B32 - TY_A43*TY_B22*TY_B34 - TY_A42*TY_B23*TY_B34 - TY_A41*TY_B24*TY_B34;
-	TY_F38 = 2*TY_A52*TY_B23*TY_B25 - TY_A43*TY_B25*TY_B32 - TY_A43*TY_B23*TY_B34 - TY_A42*TY_B24*TY_B34 - TY_A41*TY_B25*TY_B34 + TY_A52*pow(TY_B24,2);
-	TY_F39 = 2*TY_A52*TY_B24*TY_B25 - TY_A43*TY_B24*TY_B34 - TY_A42*TY_B25*TY_B34;
-	TY_F310 = -(TY_A43*TY_B25*TY_B34) + TY_A52*pow(TY_B25,2);
-
-/*
-	if( debug ) 
-	{
-		sprintf(buf,"\rF = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0., 0.,  0.,  TY_F14, 0.,  TY_F16, 0.,  TY_F18, 0.,  0.    );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0., 0.,  TY_F23, TY_F24, TY_F25, TY_F26, TY_F27, TY_F28, TY_F29, 0.    );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0., TY_F32, TY_F33, TY_F34, TY_F35, TY_F36, TY_F37, TY_F38, TY_F39, TY_F310 );
-		XOPNotice(buf);
-	}
-*/
- 
-	TY_G13  = -(TY_B12*TY_F32);
-	TY_G14  = -(TY_B12*TY_F33);
-	TY_G15  = TY_B32*TY_F14 - TY_B14*TY_F32 - TY_B12*TY_F34;
-	TY_G16  = -(TY_B14*TY_F33) - TY_B12*TY_F35;
-	TY_G17  = TY_B34*TY_F14 + TY_B32*TY_F16 - TY_B14*TY_F34 - TY_B12*TY_F36;
-	TY_G18  = -(TY_B14*TY_F35) - TY_B12*TY_F37;
-	TY_G19  = TY_B34*TY_F16 + TY_B32*TY_F18 - TY_B14*TY_F36 - TY_B12*TY_F38;
-	TY_G110 = -(TY_B14*TY_F37) - TY_B12*TY_F39;
-	TY_G111 = TY_B34*TY_F18 - TY_B12*TY_F310 - TY_B14*TY_F38;
-	TY_G112 = -(TY_B14*TY_F39);
-	TY_G113 = -(TY_B14*TY_F310);
-	TY_G22  = -(TY_B21*TY_F32);
-	TY_G23  = -(TY_B22*TY_F32) - TY_B21*TY_F33;
-	TY_G24  = TY_B32*TY_F23 - TY_B23*TY_F32 - TY_B22*TY_F33 - TY_B21*TY_F34;
-	TY_G25  = TY_B32*TY_F24 - TY_B24*TY_F32 - TY_B23*TY_F33 - TY_B22*TY_F34 - TY_B21*TY_F35;
-	TY_G26  = TY_B34*TY_F23 + TY_B32*TY_F25 - TY_B25*TY_F32 - TY_B24*TY_F33 - TY_B23*TY_F34 - TY_B22*TY_F35 - TY_B21*TY_F36;
-	TY_G27  = TY_B34*TY_F24 + TY_B32*TY_F26 - TY_B25*TY_F33 - TY_B24*TY_F34 - TY_B23*TY_F35 - TY_B22*TY_F36 - TY_B21*TY_F37;
-	TY_G28  = TY_B34*TY_F25 + TY_B32*TY_F27 - TY_B25*TY_F34 - TY_B24*TY_F35 - TY_B23*TY_F36 - TY_B22*TY_F37 - TY_B21*TY_F38;
-	TY_G29  = TY_B34*TY_F26 + TY_B32*TY_F28 - TY_B25*TY_F35 - TY_B24*TY_F36 - TY_B23*TY_F37 - TY_B22*TY_F38 - TY_B21*TY_F39;
-	TY_G210 = TY_B34*TY_F27 + TY_B32*TY_F29 - TY_B21*TY_F310 - TY_B25*TY_F36 - TY_B24*TY_F37 - TY_B23*TY_F38 - TY_B22*TY_F39;
-	TY_G211 = TY_B34*TY_F28 - TY_B22*TY_F310 - TY_B25*TY_F37 - TY_B24*TY_F38 - TY_B23*TY_F39;
-	TY_G212 = TY_B34*TY_F29 - TY_B23*TY_F310 - TY_B25*TY_F38 - TY_B24*TY_F39;
-	TY_G213 = -(TY_B24*TY_F310) - TY_B25*TY_F39;
-	TY_G214 = -(TY_B25*TY_F310);
-/*	
-	if( debug ) 
-	{
-		sprintf(buf,"\rG = \r" );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0., 0.,  TY_G13, TY_G14, TY_G15, TY_G16, TY_G17, TY_G18, TY_G19, TY_G110, TY_G111, TY_G112, TY_G113, 0. );
-		XOPNotice(buf);
-		sprintf(buf, "%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\t\t%f\r", 0., TY_G22, TY_G23, TY_G24, TY_G25, TY_G26, TY_G27, TY_G28, TY_G29, TY_G210, TY_G211, TY_G212, TY_G213, TY_G214 );
-		XOPNotice(buf);
-	}
-*/	
-	// coefficients for polynomial
-	TY_w[0] = (-(TY_A21*TY_B12) + TY_A12*TY_B21)*(TY_A52*TY_B21 - TY_A41*TY_B32)*pow(TY_B21,2)*pow(TY_B32,3);
-	
-	TY_w[1] = 2*TY_B32*TY_G13*TY_G14 - TY_B24*TY_G13*TY_G22 - TY_B23*TY_G14*TY_G22 - TY_B22*TY_G15*TY_G22 - TY_B21*TY_G16*TY_G22 - TY_B23*TY_G13*TY_G23 - TY_B22*TY_G14*TY_G23 - TY_B21*TY_G15*TY_G23 + 2*TY_B14*TY_G22*TY_G23 - 
-	TY_B22*TY_G13*TY_G24 - TY_B21*TY_G14*TY_G24 + 2*TY_B12*TY_G23*TY_G24 - TY_B21*TY_G13*TY_G25 + 2*TY_B12*TY_G22*TY_G25;
-	
-	TY_w[2] = -(TY_B25*TY_G13*TY_G22) - TY_B24*TY_G14*TY_G22 - TY_B23*TY_G15*TY_G22 - TY_B22*TY_G16*TY_G22 - TY_B21*TY_G17*TY_G22 - TY_B24*TY_G13*TY_G23 - TY_B23*TY_G14*TY_G23 - TY_B22*TY_G15*TY_G23 - TY_B21*TY_G16*TY_G23 - 
-	TY_B23*TY_G13*TY_G24 - TY_B22*TY_G14*TY_G24 - TY_B21*TY_G15*TY_G24 + 2*TY_B14*TY_G22*TY_G24 - TY_B22*TY_G13*TY_G25 - TY_B21*TY_G14*TY_G25 + 2*TY_B12*TY_G23*TY_G25 - TY_B21*TY_G13*TY_G26 + 2*TY_B12*TY_G22*TY_G26 + 
-	TY_B34*pow(TY_G13,2) + TY_B32*(2*TY_G13*TY_G15 + pow(TY_G14,2)) + TY_B14*pow(TY_G23,2) + TY_B12*pow(TY_G24,2);
-	
-	TY_w[3] = 2*TY_B34*TY_G13*TY_G14 + 2*TY_B32*(TY_G14*TY_G15 + TY_G13*TY_G16) - TY_B25*TY_G14*TY_G22 - TY_B24*TY_G15*TY_G22 - TY_B23*TY_G16*TY_G22 - TY_B22*TY_G17*TY_G22 - TY_B21*TY_G18*TY_G22 - TY_B25*TY_G13*TY_G23 - 
-	TY_B24*TY_G14*TY_G23 - TY_B23*TY_G15*TY_G23 - TY_B22*TY_G16*TY_G23 - TY_B21*TY_G17*TY_G23 - TY_B24*TY_G13*TY_G24 - TY_B23*TY_G14*TY_G24 - TY_B22*TY_G15*TY_G24 - TY_B21*TY_G16*TY_G24 + 2*TY_B14*TY_G23*TY_G24 - 
-	TY_B23*TY_G13*TY_G25 - TY_B22*TY_G14*TY_G25 - TY_B21*TY_G15*TY_G25 + 2*TY_B14*TY_G22*TY_G25 + 2*TY_B12*TY_G24*TY_G25 - TY_B22*TY_G13*TY_G26 - TY_B21*TY_G14*TY_G26 + 2*TY_B12*TY_G23*TY_G26 - TY_B21*TY_G13*TY_G27 + 
-	2*TY_B12*TY_G22*TY_G27;
-	
-	TY_w[4] = -(TY_B25*TY_G15*TY_G22) - TY_B24*TY_G16*TY_G22 - TY_B23*TY_G17*TY_G22 - TY_B22*TY_G18*TY_G22 - TY_B21*TY_G19*TY_G22 - TY_B25*TY_G14*TY_G23 - TY_B24*TY_G15*TY_G23 - TY_B23*TY_G16*TY_G23 - TY_B22*TY_G17*TY_G23 - 
-	TY_B21*TY_G18*TY_G23 - TY_B25*TY_G13*TY_G24 - TY_B24*TY_G14*TY_G24 - TY_B23*TY_G15*TY_G24 - TY_B22*TY_G16*TY_G24 - TY_B21*TY_G17*TY_G24 - TY_B24*TY_G13*TY_G25 - TY_B23*TY_G14*TY_G25 - TY_B22*TY_G15*TY_G25 - 
-	TY_B21*TY_G16*TY_G25 + 2*TY_B14*TY_G23*TY_G25 - TY_B23*TY_G13*TY_G26 - TY_B22*TY_G14*TY_G26 - TY_B21*TY_G15*TY_G26 + 2*TY_B14*TY_G22*TY_G26 + 2*TY_B12*TY_G24*TY_G26 - TY_B22*TY_G13*TY_G27 - TY_B21*TY_G14*TY_G27 + 
-	2*TY_B12*TY_G23*TY_G27 - TY_B21*TY_G13*TY_G28 + 2*TY_B12*TY_G22*TY_G28 + TY_B34*(2*TY_G13*TY_G15 + pow(TY_G14,2)) + TY_B32*(2*TY_G14*TY_G16 + 2*TY_G13*TY_G17 + pow(TY_G15,2)) + TY_B14*pow(TY_G24,2) + 
-	TY_B12*pow(TY_G25,2);
-	
-	TY_w[5] = 2*TY_B34*(TY_G14*TY_G15 + TY_G13*TY_G16) + 2*TY_B32*(TY_G15*TY_G16 + TY_G14*TY_G17 + TY_G13*TY_G18) - TY_B21*TY_G110*TY_G22 - TY_B25*TY_G16*TY_G22 - TY_B24*TY_G17*TY_G22 - TY_B23*TY_G18*TY_G22 - TY_B22*TY_G19*TY_G22 - 
-	TY_B25*TY_G15*TY_G23 - TY_B24*TY_G16*TY_G23 - TY_B23*TY_G17*TY_G23 - TY_B22*TY_G18*TY_G23 - TY_B21*TY_G19*TY_G23 - TY_B25*TY_G14*TY_G24 - TY_B24*TY_G15*TY_G24 - TY_B23*TY_G16*TY_G24 - TY_B22*TY_G17*TY_G24 - 
-	TY_B21*TY_G18*TY_G24 - TY_B25*TY_G13*TY_G25 - TY_B24*TY_G14*TY_G25 - TY_B23*TY_G15*TY_G25 - TY_B22*TY_G16*TY_G25 - TY_B21*TY_G17*TY_G25 + 2*TY_B14*TY_G24*TY_G25 - TY_B24*TY_G13*TY_G26 - TY_B23*TY_G14*TY_G26 - 
-	TY_B22*TY_G15*TY_G26 - TY_B21*TY_G16*TY_G26 + 2*TY_B14*TY_G23*TY_G26 + 2*TY_B12*TY_G25*TY_G26 - TY_B23*TY_G13*TY_G27 - TY_B22*TY_G14*TY_G27 - TY_B21*TY_G15*TY_G27 + 2*TY_B14*TY_G22*TY_G27 + 2*TY_B12*TY_G24*TY_G27 - 
-	TY_B22*TY_G13*TY_G28 - TY_B21*TY_G14*TY_G28 + 2*TY_B12*TY_G23*TY_G28 - TY_B21*TY_G13*TY_G29 + 2*TY_B12*TY_G22*TY_G29;
-	
-	TY_w[6] = -(TY_B22*TY_G110*TY_G22) - TY_B21*TY_G111*TY_G22 - TY_B25*TY_G17*TY_G22 - TY_B24*TY_G18*TY_G22 - TY_B23*TY_G19*TY_G22 + TY_G210*(-(TY_B21*TY_G13) + 2*TY_B12*TY_G22) - TY_B21*TY_G110*TY_G23 - TY_B25*TY_G16*TY_G23 - 
-	TY_B24*TY_G17*TY_G23 - TY_B23*TY_G18*TY_G23 - TY_B22*TY_G19*TY_G23 - TY_B25*TY_G15*TY_G24 - TY_B24*TY_G16*TY_G24 - TY_B23*TY_G17*TY_G24 - TY_B22*TY_G18*TY_G24 - TY_B21*TY_G19*TY_G24 - TY_B25*TY_G14*TY_G25 - 
-	TY_B24*TY_G15*TY_G25 - TY_B23*TY_G16*TY_G25 - TY_B22*TY_G17*TY_G25 - TY_B21*TY_G18*TY_G25 - TY_B25*TY_G13*TY_G26 - TY_B24*TY_G14*TY_G26 - TY_B23*TY_G15*TY_G26 - TY_B22*TY_G16*TY_G26 - TY_B21*TY_G17*TY_G26 + 
-	2*TY_B14*TY_G24*TY_G26 - TY_B24*TY_G13*TY_G27 - TY_B23*TY_G14*TY_G27 - TY_B22*TY_G15*TY_G27 - TY_B21*TY_G16*TY_G27 + 2*TY_B14*TY_G23*TY_G27 + 2*TY_B12*TY_G25*TY_G27 - TY_B23*TY_G13*TY_G28 - TY_B22*TY_G14*TY_G28 - 
-	TY_B21*TY_G15*TY_G28 + 2*TY_B14*TY_G22*TY_G28 + 2*TY_B12*TY_G24*TY_G28 - TY_B22*TY_G13*TY_G29 - TY_B21*TY_G14*TY_G29 + 2*TY_B12*TY_G23*TY_G29 + TY_B34*(2*TY_G14*TY_G16 + 2*TY_G13*TY_G17 + pow(TY_G15,2)) + 
-	TY_B32*(2*(TY_G15*TY_G17 + TY_G14*TY_G18 + TY_G13*TY_G19) + pow(TY_G16,2)) + TY_B14*pow(TY_G25,2) + TY_B12*pow(TY_G26,2);
-	
-	TY_w[7] = 2*TY_B34*(TY_G15*TY_G16 + TY_G14*TY_G17 + TY_G13*TY_G18) + 2*TY_B32*(TY_G110*TY_G13 + TY_G16*TY_G17 + TY_G15*TY_G18 + TY_G14*TY_G19) - TY_B22*TY_G13*TY_G210 - TY_B21*TY_G14*TY_G210 - TY_B23*TY_G110*TY_G22 - 
-	TY_B22*TY_G111*TY_G22 - TY_B21*TY_G112*TY_G22 - TY_B25*TY_G18*TY_G22 - TY_B24*TY_G19*TY_G22 + TY_G211*(-(TY_B21*TY_G13) + 2*TY_B12*TY_G22) - TY_B22*TY_G110*TY_G23 - TY_B21*TY_G111*TY_G23 - TY_B25*TY_G17*TY_G23 - 
-	TY_B24*TY_G18*TY_G23 - TY_B23*TY_G19*TY_G23 + 2*TY_B12*TY_G210*TY_G23 - TY_B21*TY_G110*TY_G24 - TY_B25*TY_G16*TY_G24 - TY_B24*TY_G17*TY_G24 - TY_B23*TY_G18*TY_G24 - TY_B22*TY_G19*TY_G24 - TY_B25*TY_G15*TY_G25 - 
-	TY_B24*TY_G16*TY_G25 - TY_B23*TY_G17*TY_G25 - TY_B22*TY_G18*TY_G25 - TY_B21*TY_G19*TY_G25 - TY_B25*TY_G14*TY_G26 - TY_B24*TY_G15*TY_G26 - TY_B23*TY_G16*TY_G26 - TY_B22*TY_G17*TY_G26 - TY_B21*TY_G18*TY_G26 + 
-	2*TY_B14*TY_G25*TY_G26 - TY_B25*TY_G13*TY_G27 - TY_B24*TY_G14*TY_G27 - TY_B23*TY_G15*TY_G27 - TY_B22*TY_G16*TY_G27 - TY_B21*TY_G17*TY_G27 + 2*TY_B14*TY_G24*TY_G27 + 2*TY_B12*TY_G26*TY_G27 - TY_B24*TY_G13*TY_G28 - 
-	TY_B23*TY_G14*TY_G28 - TY_B22*TY_G15*TY_G28 - TY_B21*TY_G16*TY_G28 + 2*TY_B14*TY_G23*TY_G28 + 2*TY_B12*TY_G25*TY_G28 - TY_B23*TY_G13*TY_G29 - TY_B22*TY_G14*TY_G29 - TY_B21*TY_G15*TY_G29 + 2*TY_B14*TY_G22*TY_G29 + 
-	2*TY_B12*TY_G24*TY_G29;
-	
-	TY_w[8] = -(TY_B23*TY_G13*TY_G210) - TY_B22*TY_G14*TY_G210 - TY_B21*TY_G15*TY_G210 - TY_B22*TY_G13*TY_G211 - TY_B21*TY_G14*TY_G211 - TY_B21*TY_G13*TY_G212 - TY_B24*TY_G110*TY_G22 - TY_B23*TY_G111*TY_G22 - TY_B22*TY_G112*TY_G22 - 
-	TY_B21*TY_G113*TY_G22 - TY_B25*TY_G19*TY_G22 + 2*TY_B14*TY_G210*TY_G22 + 2*TY_B12*TY_G212*TY_G22 - TY_B23*TY_G110*TY_G23 - TY_B22*TY_G111*TY_G23 - TY_B21*TY_G112*TY_G23 - TY_B25*TY_G18*TY_G23 - TY_B24*TY_G19*TY_G23 + 
-	2*TY_B12*TY_G211*TY_G23 - TY_B22*TY_G110*TY_G24 - TY_B21*TY_G111*TY_G24 - TY_B25*TY_G17*TY_G24 - TY_B24*TY_G18*TY_G24 - TY_B23*TY_G19*TY_G24 + 2*TY_B12*TY_G210*TY_G24 - TY_B21*TY_G110*TY_G25 - TY_B25*TY_G16*TY_G25 - 
-	TY_B24*TY_G17*TY_G25 - TY_B23*TY_G18*TY_G25 - TY_B22*TY_G19*TY_G25 - TY_B25*TY_G15*TY_G26 - TY_B24*TY_G16*TY_G26 - TY_B23*TY_G17*TY_G26 - TY_B22*TY_G18*TY_G26 - TY_B21*TY_G19*TY_G26 - TY_B25*TY_G14*TY_G27 - 
-	TY_B24*TY_G15*TY_G27 - TY_B23*TY_G16*TY_G27 - TY_B22*TY_G17*TY_G27 - TY_B21*TY_G18*TY_G27 + 2*TY_B14*TY_G25*TY_G27 - TY_B25*TY_G13*TY_G28 - TY_B24*TY_G14*TY_G28 - TY_B23*TY_G15*TY_G28 - TY_B22*TY_G16*TY_G28 - 
-	TY_B21*TY_G17*TY_G28 + 2*TY_B14*TY_G24*TY_G28 + 2*TY_B12*TY_G26*TY_G28 - TY_B24*TY_G13*TY_G29 - TY_B23*TY_G14*TY_G29 - TY_B22*TY_G15*TY_G29 - TY_B21*TY_G16*TY_G29 + 2*TY_B14*TY_G23*TY_G29 + 2*TY_B12*TY_G25*TY_G29 + 
-	TY_B34*(2*(TY_G15*TY_G17 + TY_G14*TY_G18 + TY_G13*TY_G19) + pow(TY_G16,2)) + TY_B32*(2*(TY_G111*TY_G13 + TY_G110*TY_G14 + TY_G16*TY_G18 + TY_G15*TY_G19) + pow(TY_G17,2)) + TY_B14*pow(TY_G26,2) + 
-	TY_B12*pow(TY_G27,2);
-	
-	TY_w[9] = 2*TY_B34*(TY_G110*TY_G13 + TY_G16*TY_G17 + TY_G15*TY_G18 + TY_G14*TY_G19) + 2*TY_B32*(TY_G112*TY_G13 + TY_G111*TY_G14 + TY_G110*TY_G15 + TY_G17*TY_G18 + TY_G16*TY_G19) - TY_B24*TY_G13*TY_G210 - TY_B23*TY_G14*TY_G210 - 
-	TY_B22*TY_G15*TY_G210 - TY_B21*TY_G16*TY_G210 - TY_B23*TY_G13*TY_G211 - TY_B22*TY_G14*TY_G211 - TY_B21*TY_G15*TY_G211 - TY_B22*TY_G13*TY_G212 - TY_B21*TY_G14*TY_G212 - TY_B25*TY_G110*TY_G22 - TY_B24*TY_G111*TY_G22 - 
-	TY_B23*TY_G112*TY_G22 - TY_B22*TY_G113*TY_G22 + 2*TY_B14*TY_G211*TY_G22 + TY_G213*(-(TY_B21*TY_G13) + 2*TY_B12*TY_G22) - TY_B24*TY_G110*TY_G23 - TY_B23*TY_G111*TY_G23 - TY_B22*TY_G112*TY_G23 - 
-	TY_B21*TY_G113*TY_G23 - TY_B25*TY_G19*TY_G23 + 2*TY_B14*TY_G210*TY_G23 + 2*TY_B12*TY_G212*TY_G23 - TY_B23*TY_G110*TY_G24 - TY_B22*TY_G111*TY_G24 - TY_B21*TY_G112*TY_G24 - TY_B25*TY_G18*TY_G24 - TY_B24*TY_G19*TY_G24 + 
-	2*TY_B12*TY_G211*TY_G24 - TY_B22*TY_G110*TY_G25 - TY_B21*TY_G111*TY_G25 - TY_B25*TY_G17*TY_G25 - TY_B24*TY_G18*TY_G25 - TY_B23*TY_G19*TY_G25 + 2*TY_B12*TY_G210*TY_G25 - TY_B21*TY_G110*TY_G26 - TY_B25*TY_G16*TY_G26 - 
-	TY_B24*TY_G17*TY_G26 - TY_B23*TY_G18*TY_G26 - TY_B22*TY_G19*TY_G26 - TY_B25*TY_G15*TY_G27 - TY_B24*TY_G16*TY_G27 - TY_B23*TY_G17*TY_G27 - TY_B22*TY_G18*TY_G27 - TY_B21*TY_G19*TY_G27 + 2*TY_B14*TY_G26*TY_G27 - 
-	TY_B25*TY_G14*TY_G28 - TY_B24*TY_G15*TY_G28 - TY_B23*TY_G16*TY_G28 - TY_B22*TY_G17*TY_G28 - TY_B21*TY_G18*TY_G28 + 2*TY_B14*TY_G25*TY_G28 + 2*TY_B12*TY_G27*TY_G28 - TY_B25*TY_G13*TY_G29 - TY_B24*TY_G14*TY_G29 - 
-	TY_B23*TY_G15*TY_G29 - TY_B22*TY_G16*TY_G29 - TY_B21*TY_G17*TY_G29 + 2*TY_B14*TY_G24*TY_G29 + 2*TY_B12*TY_G26*TY_G29;
-	
-	TY_w[10] = -(TY_B25*TY_G13*TY_G210) - TY_B24*TY_G14*TY_G210 - TY_B23*TY_G15*TY_G210 - TY_B22*TY_G16*TY_G210 - TY_B21*TY_G17*TY_G210 - TY_B24*TY_G13*TY_G211 - TY_B23*TY_G14*TY_G211 - TY_B22*TY_G15*TY_G211 - TY_B21*TY_G16*TY_G211 - 
-	TY_B23*TY_G13*TY_G212 - TY_B22*TY_G14*TY_G212 - TY_B21*TY_G15*TY_G212 - TY_B22*TY_G13*TY_G213 - TY_B21*TY_G14*TY_G213 - TY_B21*TY_G13*TY_G214 - TY_B25*TY_G111*TY_G22 - TY_B24*TY_G112*TY_G22 - TY_B23*TY_G113*TY_G22 + 
-	2*TY_B14*TY_G212*TY_G22 + 2*TY_B12*TY_G214*TY_G22 - TY_B25*TY_G110*TY_G23 - TY_B24*TY_G111*TY_G23 - TY_B23*TY_G112*TY_G23 - TY_B22*TY_G113*TY_G23 + 2*TY_B14*TY_G211*TY_G23 + 2*TY_B12*TY_G213*TY_G23 - 
-	TY_B24*TY_G110*TY_G24 - TY_B23*TY_G111*TY_G24 - TY_B22*TY_G112*TY_G24 - TY_B21*TY_G113*TY_G24 - TY_B25*TY_G19*TY_G24 + 2*TY_B14*TY_G210*TY_G24 + 2*TY_B12*TY_G212*TY_G24 - TY_B23*TY_G110*TY_G25 - 
-	TY_B22*TY_G111*TY_G25 - TY_B21*TY_G112*TY_G25 - TY_B25*TY_G18*TY_G25 - TY_B24*TY_G19*TY_G25 + 2*TY_B12*TY_G211*TY_G25 - TY_B22*TY_G110*TY_G26 - TY_B21*TY_G111*TY_G26 - TY_B25*TY_G17*TY_G26 - TY_B24*TY_G18*TY_G26 - 
-	TY_B23*TY_G19*TY_G26 + 2*TY_B12*TY_G210*TY_G26 - TY_B21*TY_G110*TY_G27 - TY_B25*TY_G16*TY_G27 - TY_B24*TY_G17*TY_G27 - TY_B23*TY_G18*TY_G27 - TY_B22*TY_G19*TY_G27 - TY_B25*TY_G15*TY_G28 - TY_B24*TY_G16*TY_G28 - 
-	TY_B23*TY_G17*TY_G28 - TY_B22*TY_G18*TY_G28 - TY_B21*TY_G19*TY_G28 + 2*TY_B14*TY_G26*TY_G28 - TY_B25*TY_G14*TY_G29 - TY_B24*TY_G15*TY_G29 - TY_B23*TY_G16*TY_G29 - TY_B22*TY_G17*TY_G29 - TY_B21*TY_G18*TY_G29 + 
-	2*TY_B14*TY_G25*TY_G29 + 2*TY_B12*TY_G27*TY_G29 + TY_B34*(2*(TY_G111*TY_G13 + TY_G110*TY_G14 + TY_G16*TY_G18 + TY_G15*TY_G19) + pow(TY_G17,2)) + 
-	TY_B32*(2*(TY_G113*TY_G13 + TY_G112*TY_G14 + TY_G111*TY_G15 + TY_G110*TY_G16 + TY_G17*TY_G19) + pow(TY_G18,2)) + TY_B14*pow(TY_G27,2) + TY_B12*pow(TY_G28,2);
-	
-	TY_w[11] = 2*TY_B34*(TY_G112*TY_G13 + TY_G111*TY_G14 + TY_G110*TY_G15 + TY_G17*TY_G18 + TY_G16*TY_G19) + 2*TY_B32*(TY_G113*TY_G14 + TY_G112*TY_G15 + TY_G111*TY_G16 + TY_G110*TY_G17 + TY_G18*TY_G19) - TY_B25*TY_G14*TY_G210 - 
-	TY_B24*TY_G15*TY_G210 - TY_B23*TY_G16*TY_G210 - TY_B22*TY_G17*TY_G210 - TY_B21*TY_G18*TY_G210 - TY_B25*TY_G13*TY_G211 - TY_B24*TY_G14*TY_G211 - TY_B23*TY_G15*TY_G211 - TY_B22*TY_G16*TY_G211 - TY_B21*TY_G17*TY_G211 - 
-	TY_B24*TY_G13*TY_G212 - TY_B23*TY_G14*TY_G212 - TY_B22*TY_G15*TY_G212 - TY_B21*TY_G16*TY_G212 - TY_B23*TY_G13*TY_G213 - TY_B22*TY_G14*TY_G213 - TY_B21*TY_G15*TY_G213 - TY_B25*TY_G112*TY_G22 - TY_B24*TY_G113*TY_G22 + 
-	2*TY_B14*TY_G213*TY_G22 - TY_B25*TY_G111*TY_G23 - TY_B24*TY_G112*TY_G23 - TY_B23*TY_G113*TY_G23 + 2*TY_B14*TY_G212*TY_G23 - TY_G214*(TY_B22*TY_G13 + TY_B21*TY_G14 - 2*TY_B12*TY_G23) - TY_B25*TY_G110*TY_G24 - 
-	TY_B24*TY_G111*TY_G24 - TY_B23*TY_G112*TY_G24 - TY_B22*TY_G113*TY_G24 + 2*TY_B14*TY_G211*TY_G24 + 2*TY_B12*TY_G213*TY_G24 - TY_B24*TY_G110*TY_G25 - TY_B23*TY_G111*TY_G25 - TY_B22*TY_G112*TY_G25 - 
-	TY_B21*TY_G113*TY_G25 - TY_B25*TY_G19*TY_G25 + 2*TY_B14*TY_G210*TY_G25 + 2*TY_B12*TY_G212*TY_G25 - TY_B23*TY_G110*TY_G26 - TY_B22*TY_G111*TY_G26 - TY_B21*TY_G112*TY_G26 - TY_B25*TY_G18*TY_G26 - TY_B24*TY_G19*TY_G26 + 
-	2*TY_B12*TY_G211*TY_G26 - TY_B22*TY_G110*TY_G27 - TY_B21*TY_G111*TY_G27 - TY_B25*TY_G17*TY_G27 - TY_B24*TY_G18*TY_G27 - TY_B23*TY_G19*TY_G27 + 2*TY_B12*TY_G210*TY_G27 - TY_B21*TY_G110*TY_G28 - TY_B25*TY_G16*TY_G28 - 
-	TY_B24*TY_G17*TY_G28 - TY_B23*TY_G18*TY_G28 - TY_B22*TY_G19*TY_G28 + 2*TY_B14*TY_G27*TY_G28 - TY_B25*TY_G15*TY_G29 - TY_B24*TY_G16*TY_G29 - TY_B23*TY_G17*TY_G29 - TY_B22*TY_G18*TY_G29 - TY_B21*TY_G19*TY_G29 + 
-	2*TY_B14*TY_G26*TY_G29 + 2*TY_B12*TY_G28*TY_G29;
-	
-	TY_w[12] = -(TY_B25*TY_G15*TY_G210) - TY_B24*TY_G16*TY_G210 - TY_B23*TY_G17*TY_G210 - TY_B22*TY_G18*TY_G210 - TY_B21*TY_G19*TY_G210 - TY_B25*TY_G14*TY_G211 - TY_B24*TY_G15*TY_G211 - TY_B23*TY_G16*TY_G211 - TY_B22*TY_G17*TY_G211 - 
-	TY_B21*TY_G18*TY_G211 - TY_B25*TY_G13*TY_G212 - TY_B24*TY_G14*TY_G212 - TY_B23*TY_G15*TY_G212 - TY_B22*TY_G16*TY_G212 - TY_B21*TY_G17*TY_G212 - TY_B24*TY_G13*TY_G213 - TY_B23*TY_G14*TY_G213 - TY_B22*TY_G15*TY_G213 - 
-	TY_B21*TY_G16*TY_G213 - TY_B25*TY_G113*TY_G22 - TY_B25*TY_G112*TY_G23 - TY_B24*TY_G113*TY_G23 + 2*TY_B14*TY_G213*TY_G23 - TY_B25*TY_G111*TY_G24 - TY_B24*TY_G112*TY_G24 - TY_B23*TY_G113*TY_G24 + 
-	2*TY_B14*TY_G212*TY_G24 - TY_G214*(TY_B23*TY_G13 + TY_B22*TY_G14 + TY_B21*TY_G15 - 2*TY_B14*TY_G22 - 2*TY_B12*TY_G24) - TY_B25*TY_G110*TY_G25 - TY_B24*TY_G111*TY_G25 - TY_B23*TY_G112*TY_G25 - 
-	TY_B22*TY_G113*TY_G25 + 2*TY_B14*TY_G211*TY_G25 + 2*TY_B12*TY_G213*TY_G25 - TY_B24*TY_G110*TY_G26 - TY_B23*TY_G111*TY_G26 - TY_B22*TY_G112*TY_G26 - TY_B21*TY_G113*TY_G26 - TY_B25*TY_G19*TY_G26 + 
-	2*TY_B14*TY_G210*TY_G26 + 2*TY_B12*TY_G212*TY_G26 - TY_B23*TY_G110*TY_G27 - TY_B22*TY_G111*TY_G27 - TY_B21*TY_G112*TY_G27 - TY_B25*TY_G18*TY_G27 - TY_B24*TY_G19*TY_G27 + 2*TY_B12*TY_G211*TY_G27 - 
-	TY_B22*TY_G110*TY_G28 - TY_B21*TY_G111*TY_G28 - TY_B25*TY_G17*TY_G28 - TY_B24*TY_G18*TY_G28 - TY_B23*TY_G19*TY_G28 + 2*TY_B12*TY_G210*TY_G28 - TY_B21*TY_G110*TY_G29 - TY_B25*TY_G16*TY_G29 - TY_B24*TY_G17*TY_G29 - 
-	TY_B23*TY_G18*TY_G29 - TY_B22*TY_G19*TY_G29 + 2*TY_B14*TY_G27*TY_G29 + TY_B34*(2*(TY_G113*TY_G13 + TY_G112*TY_G14 + TY_G111*TY_G15 + TY_G110*TY_G16 + TY_G17*TY_G19) + pow(TY_G18,2)) + 
-	TY_B32*(2*(TY_G113*TY_G15 + TY_G112*TY_G16 + TY_G111*TY_G17 + TY_G110*TY_G18) + pow(TY_G19,2)) + TY_B14*pow(TY_G28,2) + TY_B12*pow(TY_G29,2);
-	
-	TY_w[13] = 2*TY_B32*(TY_G113*TY_G16 + TY_G112*TY_G17 + TY_G111*TY_G18 + TY_G110*TY_G19) + 2*TY_B34*(TY_G113*TY_G14 + TY_G112*TY_G15 + TY_G111*TY_G16 + TY_G110*TY_G17 + TY_G18*TY_G19) - TY_B21*TY_G110*TY_G210 - 
-	TY_B25*TY_G16*TY_G210 - TY_B24*TY_G17*TY_G210 - TY_B23*TY_G18*TY_G210 - TY_B22*TY_G19*TY_G210 - TY_B25*TY_G15*TY_G211 - TY_B24*TY_G16*TY_G211 - TY_B23*TY_G17*TY_G211 - TY_B22*TY_G18*TY_G211 - TY_B21*TY_G19*TY_G211 - 
-	TY_B25*TY_G14*TY_G212 - TY_B24*TY_G15*TY_G212 - TY_B23*TY_G16*TY_G212 - TY_B22*TY_G17*TY_G212 - TY_B21*TY_G18*TY_G212 - TY_B25*TY_G13*TY_G213 - TY_B24*TY_G14*TY_G213 - TY_B23*TY_G15*TY_G213 - TY_B22*TY_G16*TY_G213 - 
-	TY_B21*TY_G17*TY_G213 - TY_B25*TY_G113*TY_G23 - TY_B25*TY_G112*TY_G24 - TY_B24*TY_G113*TY_G24 + 2*TY_B14*TY_G213*TY_G24 - TY_B25*TY_G111*TY_G25 - TY_B24*TY_G112*TY_G25 - TY_B23*TY_G113*TY_G25 + 
-	2*TY_B14*TY_G212*TY_G25 - TY_G214*(TY_B24*TY_G13 + TY_B23*TY_G14 + TY_B22*TY_G15 + TY_B21*TY_G16 - 2*TY_B14*TY_G23 - 2*TY_B12*TY_G25) - TY_B25*TY_G110*TY_G26 - TY_B24*TY_G111*TY_G26 - TY_B23*TY_G112*TY_G26 - 
-	TY_B22*TY_G113*TY_G26 + 2*TY_B14*TY_G211*TY_G26 + 2*TY_B12*TY_G213*TY_G26 - TY_B24*TY_G110*TY_G27 - TY_B23*TY_G111*TY_G27 - TY_B22*TY_G112*TY_G27 - TY_B21*TY_G113*TY_G27 - TY_B25*TY_G19*TY_G27 + 
-	2*TY_B14*TY_G210*TY_G27 + 2*TY_B12*TY_G212*TY_G27 - TY_B23*TY_G110*TY_G28 - TY_B22*TY_G111*TY_G28 - TY_B21*TY_G112*TY_G28 - TY_B25*TY_G18*TY_G28 - TY_B24*TY_G19*TY_G28 + 2*TY_B12*TY_G211*TY_G28 - 
-	TY_B22*TY_G110*TY_G29 - TY_B21*TY_G111*TY_G29 - TY_B25*TY_G17*TY_G29 - TY_B24*TY_G18*TY_G29 - TY_B23*TY_G19*TY_G29 + 2*TY_B12*TY_G210*TY_G29 + 2*TY_B14*TY_G28*TY_G29;
-	
-	TY_w[14] = -(TY_B22*TY_G110*TY_G210) - TY_B21*TY_G111*TY_G210 - TY_B25*TY_G17*TY_G210 - TY_B24*TY_G18*TY_G210 - TY_B23*TY_G19*TY_G210 - TY_B21*TY_G110*TY_G211 - TY_B25*TY_G16*TY_G211 - TY_B24*TY_G17*TY_G211 - 
-	TY_B23*TY_G18*TY_G211 - TY_B22*TY_G19*TY_G211 - TY_B25*TY_G15*TY_G212 - TY_B24*TY_G16*TY_G212 - TY_B23*TY_G17*TY_G212 - TY_B22*TY_G18*TY_G212 - TY_B21*TY_G19*TY_G212 - TY_B25*TY_G14*TY_G213 - TY_B24*TY_G15*TY_G213 - 
-	TY_B23*TY_G16*TY_G213 - TY_B22*TY_G17*TY_G213 - TY_B21*TY_G18*TY_G213 - TY_B25*TY_G113*TY_G24 - TY_B25*TY_G112*TY_G25 - TY_B24*TY_G113*TY_G25 + 2*TY_B14*TY_G213*TY_G25 - TY_B25*TY_G111*TY_G26 - TY_B24*TY_G112*TY_G26 - 
-	TY_B23*TY_G113*TY_G26 + 2*TY_B14*TY_G212*TY_G26 - TY_G214*(TY_B25*TY_G13 + TY_B24*TY_G14 + TY_B23*TY_G15 + TY_B22*TY_G16 + TY_B21*TY_G17 - 2*TY_B14*TY_G24 - 2*TY_B12*TY_G26) - TY_B25*TY_G110*TY_G27 - 
-	TY_B24*TY_G111*TY_G27 - TY_B23*TY_G112*TY_G27 - TY_B22*TY_G113*TY_G27 + 2*TY_B14*TY_G211*TY_G27 + 2*TY_B12*TY_G213*TY_G27 - TY_B24*TY_G110*TY_G28 - TY_B23*TY_G111*TY_G28 - TY_B22*TY_G112*TY_G28 - 
-	TY_B21*TY_G113*TY_G28 - TY_B25*TY_G19*TY_G28 + 2*TY_B14*TY_G210*TY_G28 + 2*TY_B12*TY_G212*TY_G28 - TY_B23*TY_G110*TY_G29 - TY_B22*TY_G111*TY_G29 - TY_B21*TY_G112*TY_G29 - TY_B25*TY_G18*TY_G29 - TY_B24*TY_G19*TY_G29 + 
-	2*TY_B12*TY_G211*TY_G29 + TY_B32*(2*(TY_G113*TY_G17 + TY_G112*TY_G18 + TY_G111*TY_G19) + pow(TY_G110,2)) + 
-	TY_B34*(2*(TY_G113*TY_G15 + TY_G112*TY_G16 + TY_G111*TY_G17 + TY_G110*TY_G18) + pow(TY_G19,2)) + TY_B12*pow(TY_G210,2) + TY_B14*pow(TY_G29,2); 
-	
-	TY_w[15] = 2*TY_B34*(TY_G113*TY_G16 + TY_G112*TY_G17 + TY_G111*TY_G18 + TY_G110*TY_G19) + 2*TY_B32*(TY_G110*TY_G111 + TY_G113*TY_G18 + TY_G112*TY_G19) - TY_B23*TY_G110*TY_G210 - TY_B22*TY_G111*TY_G210 - 
-	TY_B21*TY_G112*TY_G210 - TY_B25*TY_G18*TY_G210 - TY_B24*TY_G19*TY_G210 - TY_B22*TY_G110*TY_G211 - TY_B21*TY_G111*TY_G211 - TY_B25*TY_G17*TY_G211 - TY_B24*TY_G18*TY_G211 - TY_B23*TY_G19*TY_G211 + 
-	2*TY_B12*TY_G210*TY_G211 - TY_B21*TY_G110*TY_G212 - TY_B25*TY_G16*TY_G212 - TY_B24*TY_G17*TY_G212 - TY_B23*TY_G18*TY_G212 - TY_B22*TY_G19*TY_G212 - TY_B25*TY_G15*TY_G213 - TY_B24*TY_G16*TY_G213 - 
-	TY_B23*TY_G17*TY_G213 - TY_B22*TY_G18*TY_G213 - TY_B21*TY_G19*TY_G213 - TY_B25*TY_G113*TY_G25 - TY_B25*TY_G112*TY_G26 - TY_B24*TY_G113*TY_G26 + 2*TY_B14*TY_G213*TY_G26 - TY_B25*TY_G111*TY_G27 - TY_B24*TY_G112*TY_G27 - 
-	TY_B23*TY_G113*TY_G27 + 2*TY_B14*TY_G212*TY_G27 - TY_G214*(TY_B25*TY_G14 + TY_B24*TY_G15 + TY_B23*TY_G16 + TY_B22*TY_G17 + TY_B21*TY_G18 - 2*TY_B14*TY_G25 - 2*TY_B12*TY_G27) - TY_B25*TY_G110*TY_G28 - 
-	TY_B24*TY_G111*TY_G28 - TY_B23*TY_G112*TY_G28 - TY_B22*TY_G113*TY_G28 + 2*TY_B14*TY_G211*TY_G28 + 2*TY_B12*TY_G213*TY_G28 - TY_B24*TY_G110*TY_G29 - TY_B23*TY_G111*TY_G29 - TY_B22*TY_G112*TY_G29 - 
-	TY_B21*TY_G113*TY_G29 - TY_B25*TY_G19*TY_G29 + 2*TY_B14*TY_G210*TY_G29 + 2*TY_B12*TY_G212*TY_G29;
-	
-	TY_w[16] = -(TY_B24*TY_G110*TY_G210) - TY_B23*TY_G111*TY_G210 - TY_B22*TY_G112*TY_G210 - TY_B21*TY_G113*TY_G210 - TY_B25*TY_G19*TY_G210 - TY_B23*TY_G110*TY_G211 - TY_B22*TY_G111*TY_G211 - TY_B21*TY_G112*TY_G211 - 
-	TY_B25*TY_G18*TY_G211 - TY_B24*TY_G19*TY_G211 - TY_B22*TY_G110*TY_G212 - TY_B21*TY_G111*TY_G212 - TY_B25*TY_G17*TY_G212 - TY_B24*TY_G18*TY_G212 - TY_B23*TY_G19*TY_G212 + 2*TY_B12*TY_G210*TY_G212 - 
-	TY_B21*TY_G110*TY_G213 - TY_B25*TY_G16*TY_G213 - TY_B24*TY_G17*TY_G213 - TY_B23*TY_G18*TY_G213 - TY_B22*TY_G19*TY_G213 - TY_B25*TY_G113*TY_G26 - TY_B25*TY_G112*TY_G27 - TY_B24*TY_G113*TY_G27 + 
-	2*TY_B14*TY_G213*TY_G27 - TY_B25*TY_G111*TY_G28 - TY_B24*TY_G112*TY_G28 - TY_B23*TY_G113*TY_G28 + 2*TY_B14*TY_G212*TY_G28 - 
-	TY_G214*(TY_B25*TY_G15 + TY_B24*TY_G16 + TY_B23*TY_G17 + TY_B22*TY_G18 + TY_B21*TY_G19 - 2*TY_B14*TY_G26 - 2*TY_B12*TY_G28) - TY_B25*TY_G110*TY_G29 - TY_B24*TY_G111*TY_G29 - TY_B23*TY_G112*TY_G29 - 
-	TY_B22*TY_G113*TY_G29 + 2*TY_B14*TY_G211*TY_G29 + 2*TY_B12*TY_G213*TY_G29 + TY_B34*(2*(TY_G113*TY_G17 + TY_G112*TY_G18 + TY_G111*TY_G19) + pow(TY_G110,2)) + 
-	TY_B32*(2*TY_G110*TY_G112 + 2*TY_G113*TY_G19 + pow(TY_G111,2)) + TY_B14*pow(TY_G210,2) + TY_B12*pow(TY_G211,2);
-	
-	TY_w[17] = 2*TY_B32*(TY_G111*TY_G112 + TY_G110*TY_G113) + 2*TY_B34*(TY_G110*TY_G111 + TY_G113*TY_G18 + TY_G112*TY_G19) - TY_B25*TY_G110*TY_G210 - TY_B24*TY_G111*TY_G210 - TY_B23*TY_G112*TY_G210 - TY_B22*TY_G113*TY_G210 - 
-	TY_B24*TY_G110*TY_G211 - TY_B23*TY_G111*TY_G211 - TY_B22*TY_G112*TY_G211 - TY_B21*TY_G113*TY_G211 - TY_B25*TY_G19*TY_G211 + 2*TY_B14*TY_G210*TY_G211 - TY_B23*TY_G110*TY_G212 - TY_B22*TY_G111*TY_G212 - 
-	TY_B21*TY_G112*TY_G212 - TY_B25*TY_G18*TY_G212 - TY_B24*TY_G19*TY_G212 + 2*TY_B12*TY_G211*TY_G212 - TY_B22*TY_G110*TY_G213 - TY_B21*TY_G111*TY_G213 - TY_B25*TY_G17*TY_G213 - TY_B24*TY_G18*TY_G213 - 
-	TY_B23*TY_G19*TY_G213 + 2*TY_B12*TY_G210*TY_G213 - TY_B25*TY_G113*TY_G27 - TY_B25*TY_G112*TY_G28 - TY_B24*TY_G113*TY_G28 + 2*TY_B14*TY_G213*TY_G28 - TY_B25*TY_G111*TY_G29 - TY_B24*TY_G112*TY_G29 - 
-	TY_B23*TY_G113*TY_G29 + 2*TY_B14*TY_G212*TY_G29 - TY_G214*(TY_B21*TY_G110 + TY_B25*TY_G16 + TY_B24*TY_G17 + TY_B23*TY_G18 + TY_B22*TY_G19 - 2*TY_B14*TY_G27 - 2*TY_B12*TY_G29);
-	
-	TY_w[18] = -(TY_B25*TY_G111*TY_G210) - TY_B24*TY_G112*TY_G210 - TY_B23*TY_G113*TY_G210 - TY_B25*TY_G110*TY_G211 - TY_B24*TY_G111*TY_G211 - TY_B23*TY_G112*TY_G211 - TY_B22*TY_G113*TY_G211 - TY_B24*TY_G110*TY_G212 - 
-	TY_B23*TY_G111*TY_G212 - TY_B22*TY_G112*TY_G212 - TY_B21*TY_G113*TY_G212 - TY_B25*TY_G19*TY_G212 + 2*TY_B14*TY_G210*TY_G212 - TY_B23*TY_G110*TY_G213 - TY_B22*TY_G111*TY_G213 - TY_B21*TY_G112*TY_G213 - 
-	TY_B25*TY_G18*TY_G213 - TY_B24*TY_G19*TY_G213 + 2*TY_B12*TY_G211*TY_G213 - TY_B25*TY_G113*TY_G28 - 
-	TY_G214*(TY_B22*TY_G110 + TY_B21*TY_G111 + TY_B25*TY_G17 + TY_B24*TY_G18 + TY_B23*TY_G19 - 2*TY_B12*TY_G210 - 2*TY_B14*TY_G28) - TY_B25*TY_G112*TY_G29 - TY_B24*TY_G113*TY_G29 + 2*TY_B14*TY_G213*TY_G29 + 
-	TY_B34*(2*TY_G110*TY_G112 + 2*TY_G113*TY_G19 + pow(TY_G111,2)) + TY_B32*(2*TY_G111*TY_G113 + pow(TY_G112,2)) + TY_B14*pow(TY_G211,2) + TY_B12*pow(TY_G212,2);
-	
-	TY_w[19] = 2*TY_B32*TY_G112*TY_G113 + 2*TY_B34*(TY_G111*TY_G112 + TY_G110*TY_G113) - TY_B25*TY_G112*TY_G210 - TY_B24*TY_G113*TY_G210 - TY_B25*TY_G111*TY_G211 - TY_B24*TY_G112*TY_G211 - TY_B23*TY_G113*TY_G211 - 
-	TY_B25*TY_G110*TY_G212 - TY_B24*TY_G111*TY_G212 - TY_B23*TY_G112*TY_G212 - TY_B22*TY_G113*TY_G212 + 2*TY_B14*TY_G211*TY_G212 - TY_B24*TY_G110*TY_G213 - TY_B23*TY_G111*TY_G213 - TY_B22*TY_G112*TY_G213 - 
-	TY_B21*TY_G113*TY_G213 - TY_B25*TY_G19*TY_G213 + 2*TY_B14*TY_G210*TY_G213 + 2*TY_B12*TY_G212*TY_G213 - TY_B25*TY_G113*TY_G29 - 
-	TY_G214*(TY_B23*TY_G110 + TY_B22*TY_G111 + TY_B21*TY_G112 + TY_B25*TY_G18 + TY_B24*TY_G19 - 2*TY_B12*TY_G211 - 2*TY_B14*TY_G29);
-	
-	TY_w[20] = -(TY_B25*TY_G113*TY_G210) - TY_B25*TY_G112*TY_G211 - TY_B24*TY_G113*TY_G211 - TY_B25*TY_G111*TY_G212 - TY_B24*TY_G112*TY_G212 - TY_B23*TY_G113*TY_G212 - TY_B25*TY_G110*TY_G213 - TY_B24*TY_G111*TY_G213 - 
-	TY_B23*TY_G112*TY_G213 - TY_B22*TY_G113*TY_G213 + 2*TY_B14*TY_G211*TY_G213 - (TY_B24*TY_G110 + TY_B23*TY_G111 + TY_B22*TY_G112 + TY_B21*TY_G113 + TY_B25*TY_G19 - 2*TY_B14*TY_G210 - 2*TY_B12*TY_G212)*TY_G214 + 
-	TY_B34*(2*TY_G111*TY_G113 + pow(TY_G112,2)) + TY_B32*pow(TY_G113,2) + TY_B14*pow(TY_G212,2) + TY_B12*pow(TY_G213,2);
-	
-	TY_w[21] = TY_B25*(TY_A23*TY_B14*(-3*TY_A52*TY_B24*TY_B25 + (2*TY_A43*TY_B24 + TY_A42*TY_B25)*TY_B34) + TY_B25*(TY_A22*TY_B14*(-(TY_A52*TY_B25) + TY_A43*TY_B34) 
-																			 + TY_A12*(4*TY_A52*TY_B24*TY_B25 - (3*TY_A43*TY_B24 + TY_A42*TY_B25)*TY_B34)))*pow(TY_B34,3);
-	
-	TY_w[22] = (-(TY_A23*TY_B14) + TY_A12*TY_B25)*(TY_A52*TY_B25 - TY_A43*TY_B34)*pow(TY_B25,2)*pow(TY_B34,3);
-/*	
-	if( debug ) 
-	{
-		sprintf(buf,"\rCoefficients of polynomial\r");
-		XOPNotice(buf);
-		int i;
-		for ( i = 0; i < 23; i ++ ) {
-			sprintf(buf, "w[%d] = %f\r", i, TY_w[i] );
-			XOPNotice(buf);
-		}
-		sprintf(buf, "\r" );
-		XOPNotice(buf);
-	}
- */
-}
-
-double TY_Q( double d2 )
-{
-	return d2 * TY_B32 + pow( d2, 3 ) *  TY_B34;
-}
-
-double TY_V( double d2 )
-{
-	return	-( pow( d2, 2 ) * TY_G13 + pow( d2, 3 ) * TY_G14 + pow( d2, 4 ) * TY_G15 + pow( d2, 5 ) * TY_G16 + 
-			  pow( d2, 6 ) * TY_G17 + pow( d2, 7 ) *  TY_G18 + pow( d2, 8 ) * TY_G19 + pow( d2, 9 ) * TY_G110 + 
-			  pow( d2, 10 ) *  TY_G111 + pow( d2, 11 ) *  TY_G112 + pow( d2, 12 ) *  TY_G113 );
-}
-
-double TY_W( double d2 )
-{
-	return d2  * TY_G22 + pow( d2, 2 ) * TY_G23 + pow( d2, 3 ) * TY_G24 + pow( d2, 4 ) * TY_G25 + pow( d2, 5 ) * TY_G26 + 
-	pow( d2, 6 ) * TY_G27 + pow( d2, 7 ) *  TY_G28 + pow( d2, 8 ) *  TY_G29 + pow( d2, 9 ) * TY_G210 + 
-	pow( d2, 10 ) * TY_G211 + pow( d2, 11 ) * TY_G212 + pow( d2, 12 ) * TY_G213 + pow( d2, 13 ) * TY_G214;
-}
-
-double TY_X( double d2 )
-{
-	return TY_V( d2 ) / TY_W( d2 );
-}
-
-// solve the linear system depending on d1, d2 using Cramer's rule
-void TY_SolveLinearEquations( double d1, double d2, 
-						      double* a, double* b, double* c1, double* c2)
-{
-	double det    = TY_q22 * d1 * d2;
-	double det_a  = TY_qa12  * d2 + TY_qa21  * d1 + TY_qa22  * d1 * d2 + TY_qa23  * d1 * pow( d2, 2 ) + TY_qa32  * pow( d1, 2 ) * d2; 
-	double det_b  = TY_qb12  * d2 + TY_qb21  * d1 + TY_qb22  * d1 * d2 + TY_qb23  * d1 * pow( d2, 2 ) + TY_qb32  * pow( d1, 2 ) * d2; 
-	double det_c1 = TY_qc112 * d2 + TY_qc121 * d1 + TY_qc122 * d1 * d2 + TY_qc123 * d1 * pow( d2, 2 ) + TY_qc132 * pow( d1, 2 ) * d2; 
-	double det_c2 = TY_qc212 * d2 + TY_qc221 * d1 + TY_qc222 * d1 * d2 + TY_qc223 * d1 * pow( d2, 2 ) + TY_qc232 * pow( d1, 2 ) * d2;
-	
-	*a  = det_a  / det;
-	*b  = det_b  / det;
-	*c1 = det_c1 / det;
-	*c2 = det_c2 / det;
-}
-
-//Solve the system of linear and nonlinear equations for given Zi, Ki, phi which gives at 
-// most 22 solutions for the parameters a,b,ci,di. From the set of solutions choose the 
-// physical one and return it.
-int TY_SolveEquations( double Z1, double Z2, double K1, double K2, double phi, 
-					   double* a, double* b, double* c1, double* c2, double* d1, double* d2, 
-				       int debug )
-{
-	
-	// the two coupled non-linear eqautions were reduced to a
-	// 22nd order polynomial, the roots are give all possible solutions 
-	// for d2, than d1 can be computed by the function X 
-	char buf[256];
-	
- 	double real_coefficient[23];
-	double imag_coefficient[23];
-	
-	double real_root[22];
-	double imag_root[22];
-	
-	//integer degree of polynomial
-	int degree = 22;
-	int i;
-	double x,y;
-	double var_a, var_b, var_c1, var_c2, var_d1, var_d2;
-	double sol_a[22], sol_b[22], sol_c1[22], sol_c2[22], sol_d1[22], sol_d2[22];
-	
-	int j = 0;
-	
-	int n_roots,n,selected_root;
-	double dr,qmax,q,dq,min,sum;
-	double *sq,*gr;
-	double Pi = 3.14159265358979323846264338327950288;   /* pi */
-	
-	
-	// reduce system to a polynomial from which all solution are extracted
-	// by doing that a lot of global background variables are set
-	TY_ReduceNonlinearSystem( Z1, Z2, K1, K2, phi, debug );
-	
-	// vector of real and imaginary coefficients in order of decreasing powers
-	for ( i = 0; i <= degree; i++ )
-	{
-		// the global variablw TY_w was set by TY_ReduceNonlinearSystem
-		real_coefficient[i] = TY_w[ 22 - i ];
-		imag_coefficient[i] = 0.;
-	}
-	
-	// Jenkins-Traub method to approximate the roots of the polynomial
-	cpoly( real_coefficient, imag_coefficient, degree, real_root, imag_root );
-	
-	// show the result if in debug mode
-/*	
-	if ( debug )
-	{
-		for ( i = 0; i < degree; i++ )
-		{
-			x = real_root[i];
-			y = imag_root[i];
-			if ( chop( y ) == 0 )
-				sprintf(buf, "root(%d) = %g\r", i+1, x );
-			else
-				sprintf(buf, "root(%d) = %g + %g i\r", i+1, x, y );
-			XOPNotice(buf);
-		}
-		sprintf(buf, "\r" );
-		XOPNotice(buf);
-	}
- */
-	
-	// select real roots and those satisfying Q(x) != 0 and W(x) != 0
-	// Paper: Cluster formation in two-Yukawa Fluids, J. Chem. Phys. 122, 2005
-	// The right set of (a, b, c1, c2, d1, d2) should have the following properties:
-	// (1) a > 0 
-	// (2) d1, d2 are real
-	// (3) vi/Ki > 0 <=> g(Zi) > 0
-	// (4) if there is still more than root, calculate g(r) for each root
-	//     and g(r) of the correct root should have the minimum average value 
-	//	   inside the hardcore	
-
-	for ( i = 0; i < degree; i++ )
-	{
-		x = real_root[i];
-		y = imag_root[i];
-		
-		if ( chop( y ) == 0 && TY_W( x ) != 0 && TY_Q( x ) != 0 )
-		{
-			var_d1 = TY_X( x );
-			var_d2 = x;
-			
-			// solution of linear system for given d1, d2 to obtain a,b,ci,di
-			TY_SolveLinearEquations( var_d1, var_d2, &var_a, &var_b, &var_c1, &var_c2 );
-			
-			// select physical solutions, for details check paper: "Cluster formation in
-			// two-Yukawa fluids", J. Chem. Phys. 122 (2005)
-			if ( var_a > 0 && 
-				 TY_g( Z1, phi, Z1, Z2, var_a, var_b, var_c1, var_c2, var_d1, var_d2 ) > 0 &&
-	 			 TY_g( Z2, phi, Z1, Z2, var_a, var_b, var_c1, var_c2, var_d1, var_d2 ) > 0 )
-			{
-				sol_a[j]  = var_a;
-				sol_b[j]  = var_b;
-				sol_c1[j] = var_c1;
-				sol_c2[j] = var_c2;
-				sol_d1[j] = var_d1;
-				sol_d2[j] = var_d2;
-/*				
-				if ( debug )
-				{
-					double eq1 = chop( TY_LinearEquation_1( Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] ) );
-					double eq2 = chop( TY_LinearEquation_2( Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] ) );
-					double eq3 = chop( TY_LinearEquation_3( Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] ) );
-					double eq4 = chop( TY_LinearEquation_4( Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] ) );
-					double eq5 = chop( TY_NonlinearEquation_1( Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] ) );
-					double eq6 = chop( TY_NonlinearEquation_2( Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] ) );
-					
-					sprintf(buf, "solution[%d] = (%g, %g, %g, %g, %g, %g), ( eq == 0 ) = (%g, %g, %g, %g, %g, %g)\r", j, 
-						   sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j], 
-						   eq1 , eq2, eq3, eq4, eq5, eq6 );
-					XOPNotice(buf);
-				}
- */
-				j++;
-			}
-		}
-	}
-	// number  remaining roots 
-	n_roots = j;
-	
-	
-	// if there is still more than one root left, than choose the one with the minimum
-	// average value inside the hardcore
-	if ( n_roots > 1 )
-	{
-		// the number of q values should be a power of 2
-		// in order to speed up the FFT
-		n = 1 << 14;
-		
-		// the maximum q value should be large enough 
-		// to enable a reasoble approximation of g(r)
-		qmax = 16 * 10 * 2 * Pi;
-		dq = qmax / ( n - 1 );
-		
-		// step size for g(r) = dr
-		
-		// allocate memory for pair correlation function g(r)
-		// and structure factor S(q)
-		sq = malloc( sizeof( double ) * n );
-		gr = malloc( sizeof( double ) * n );
-		
-		// loop over all remaining roots
-		min = 1e99;
-		selected_root = 10;	
-		sum = 0;
-		for ( j = 0; j < n_roots; j++) 
-		{
-			// calculate structure factor at different q values
-			for ( i = 0; i < n; i++) 
-			{
-				q = dq * i;
-				sq[i] = SqTwoYukawa( q, Z1, Z2, K1, K2, phi, sol_a[j], sol_b[j], sol_c1[j], sol_c2[j], sol_d1[j], sol_d2[j] );
-/*				
-				if(i<20 && debug) {
-					sprintf(buf, "after SqTwoYukawa: s(q) = %g\r",sq[i] );
-					XOPNotice(buf);	
-				}
- */
-			}
-			
-			// calculate pair correlation function for given
-			// structure factor, g(r) is computed at values
-			// r(i) = i * dr
-			PairCorrelation( phi, dq, sq, &dr, gr, n );
-			// determine sum inside the hardcore 
-			// 0 =< r < 1 of the pair-correlation function
-			sum = 0;
-			for (i = 0; i < floor( 1. / dr ); i++ )  {
-				sum += fabs( gr[i] );
-/*				
-				if(i<20 && debug) {
-					sprintf(buf, "g(r) in core = %g\r",fabs(gr[i]));
-					XOPNotice(buf);
-				}
-*/				
-			}
-
-			if ( sum < min )
-			{
-				min = sum;
-				selected_root = j;
-			}
-		}	
-		free( gr );
-		free( sq );
-		
-		// physical solution was found
-		*a  = sol_a [ selected_root ];//sol_a [ selected_root ];
-		*b  = sol_b [ selected_root ];
-		*c1 = sol_c1[ selected_root ];
-		*c2 = sol_c2[ selected_root ];
-		*d1 = sol_d1[ selected_root ];
-		*d2 = sol_d2[ selected_root ];
-		
-		return 1;
-	}
-	else if ( n_roots == 1 ) 
-	{
-		*a  = sol_a [0];
-		*b  = sol_b [0];
-		*c1 = sol_c1[0];
-		*c2 = sol_c2[0];
-		*d1 = sol_d1[0];
-		*d2 = sol_d2[0];
-		
-		return 1;
-	}
-
-	// no solution was found
-	return 0;
-}
Index: c/sans/models/src/libigor/2Y_TwoYukawa.h
===================================================================
--- src/sans/models/src/libigor/2Y_TwoYukawa.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,18 +1,0 @@
-/*
- *  TwoYukawa.h
- *  TwoYukawa
- *
- *  Created by Marcus Hennig on 5/8/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-int TY_SolveEquations( double Z1, double Z2, double K1, double K2, double phi, 
-				       double a[], double b[], double c1[], double c2[], double d1[], double d2[], 
-				       int debug );
-
-int TY_CheckSolution( double Z1, double Z2, double K1, double K2, double phi, 
-				      double a, double b, double c1, double c2, double d1, double d2 );
-
-double SqTwoYukawa( double q, 
-			        double Z1, double Z2, double K1, double K2, double phi,
-			        double a, double b, double c1, double c2, double d1, double d2 );
Index: c/sans/models/src/libigor/2Y_cpoly.c
===================================================================
--- src/sans/models/src/libigor/2Y_cpoly.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,660 +1,0 @@
-/*
- *******************************************************************************
- *
- *
- *                       Copyright (c) 2002
- *                       Henrik Vestermark
- *                       Denmark
- *
- *                       All Rights Reserved
- *
- *   This source file is subject to the terms and conditions of the
- *   Henrik Vestermark Software License Agreement which restricts the manner
- *   in which it may be used.
- *
- *******************************************************************************
- *
- *
- * Module name     :   cpoly.cpp
- * Module ID Nbr   :   
- * Description     :   cpoly.cpp -- Jenkins-Traub real polynomial root finder.
- *                     Translation of TOMS493 from FORTRAN to C. This
- *                     implementation of Jenkins-Traub partially adapts
- *                     the original code to a C environment by restruction
- *                     many of the 'goto' controls to better fit a block
- *                     structured form. It also eliminates the global memory
- *                     allocation in favor of local, dynamic memory management.
- *
- *                     The calling conventions are slightly modified to return
- *                     the number of roots found as the function value.
- *
- *                     INPUT:
- *                     opr - double precision vector of real coefficients in order of
- *                          decreasing powers.
- *                     opi - double precision vector of imaginary coefficients in order of
- *                          decreasing powers.
- *                     degree - integer degree of polynomial
- *
- *                     OUTPUT:
- *                     zeror,zeroi - output double precision vectors of the
- *                          real and imaginary parts of the zeros.
- *                            to be consistent with rpoly.cpp the zeros is inthe index
- *                            [0..max_degree-1]
- *
- *                     RETURN:
- *                     returnval:   -1 if leading coefficient is zero, otherwise
- *                          number of roots found. 
- * --------------------------------------------------------------------------
- * Change Record   :   
- *
- * Version	Author/Date		Description of changes
- * -------  -----------		----------------------
- * 01.01		HVE/021101		Initial release
- *
- * -- SRK changed name of *pi to *piw (and all occurances in this file) to avoid the conflict with pi in Apple's fp.h
- *
- * End of Change Record
- * --------------------------------------------------------------------------
- */
-
-
-/* define version string */
-
-#include <stdlib.h>
-#include <math.h>
-#include <float.h>
-
-static double sr, si, tr, ti, pvr, pvi, are, mre, eta, infin;
-static int nn;
-static double *pr, *piw, *hr, *hi, *qpr, *qpi, *qhr, *qhi, *shr, *shi; 
-
-static void noshft( const int l1 );
-static void fxshft( const int l2, double *zr, double *zi, int *conv );
-static void vrshft( const int l3, double *zr, double *zi, int *conv );
-static void calct( int *bol );
-static void nexth( const int bol );
-static void polyev( const int nn, const double sr, const double si, const double pr[], const double piw[], double qr[], double qi[], double *pvr, double *pvi );
-static double errev( const int nn, const double qr[], const double qi[], const double ms, const double mp, const double are, const double mre );
-static void cauchy( const int nn, double pt[], double q[], double *fn_val );
-static double scale( const int nn, const double pt[], const double eta, const double infin, const double smalno, const double base );
-static void cdivid( const double ar, const double ai, const double br, const double bi, double *cr, double *ci );
-static double cmod( const double r, const double i );
-static void mcon( double *eta, double *infiny, double *smalno, double *base );
-
-int cpoly( const double *opr, const double *opi, int degree, double *zeror, double *zeroi ) 
-{
-	int cnt1, cnt2, idnn2, i, conv;
-	double xx, yy, cosr, sinr, smalno, base, xxx, zr, zi, bnd;
-	
-	mcon( &eta, &infin, &smalno, &base );
-	are = eta;
-	mre = 2.0 * sqrt( 2.0 ) * eta;
-	xx = 0.70710678;
-	yy = -xx;
-	cosr = -0.060756474;
-	sinr = -0.99756405;
-	nn = degree;  
-	
-	// Algorithm fails if the leading coefficient is zero
-	if( opr[ 0 ] == 0 && opi[ 0 ] == 0 )
-		return -1;
-	
-	// Allocate arrays
-	pr = malloc( sizeof( double ) * ( degree + 1 ) );
-	piw = malloc( sizeof( double ) * ( degree + 1 ) );
-	hr =malloc( sizeof( double ) * ( degree + 1 ) );
-	hi = malloc( sizeof( double ) * ( degree + 1 ) );
-	qpr= malloc( sizeof( double ) * ( degree + 1 ) );
-	qpi= malloc( sizeof( double ) * ( degree + 1 ) );
-	qhr= malloc( sizeof( double ) * ( degree + 1 ) );
-	qhi= malloc( sizeof( double ) * ( degree + 1 ) );
-	shr= malloc( sizeof( double ) * ( degree + 1 ) );
-	shi= malloc( sizeof( double ) * ( degree + 1 ) );
-	
-	// Remove the zeros at the origin if any
-	while( opr[ nn ] == 0 && opi[ nn ] == 0 )
-	{
-		idnn2 = degree - nn;
-		zeror[ idnn2 ] = 0;
-		zeroi[ idnn2 ] = 0;
-		nn--;
-	}
-	
-	// Make a copy of the coefficients
-	for( i = 0; i <= nn; i++ )
-	{
-		pr[ i ] = opr[ i ];
-		piw[ i ] = opi[ i ];
-		shr[ i ] = cmod( pr[ i ], piw[ i ] );
-	}
-	
-	// Scale the polynomial
-	bnd = scale( nn, shr, eta, infin, smalno, base );
-	if( bnd != 1 )
-		for( i = 0; i <= nn; i++ )
-		{
-			pr[ i ] *= bnd;
-			piw[ i ] *= bnd;
-		}
-	
-search: 
-	if( nn <= 1 )
-	{
-		cdivid( -pr[ 1 ], -piw[ 1 ], pr[ 0 ], piw[ 0 ], &zeror[ degree-1 ], &zeroi[ degree-1 ] );
-		goto finish;
-	}
-	
-	// Calculate bnd, alower bound on the modulus of the zeros
-	for( i = 0; i<= nn; i++ )
-		shr[ i ] = cmod( pr[ i ], piw[ i ] );
-	
-	cauchy( nn, shr, shi, &bnd );
-	
-	// Outer loop to control 2 Major passes with different sequences of shifts
-	for( cnt1 = 1; cnt1 <= 2; cnt1++ )
-	{
-		// First stage  calculation , no shift
-		noshft( 5 );
-		
-		// Inner loop to select a shift
-		for( cnt2 = 1; cnt2 <= 9; cnt2++ )
-		{
-			// Shift is chosen with modulus bnd and amplitude rotated by 94 degree from the previous shif
-			xxx = cosr * xx - sinr * yy;
-			yy = sinr * xx + cosr * yy;
-			xx = xxx;
-			sr = bnd * xx;
-			si = bnd * yy;
-			
-			// Second stage calculation, fixed shift
-			fxshft( 10 * cnt2, &zr, &zi, &conv );
-			if( conv )
-            {
-				// The second stage jumps directly to the third stage ieration
-				// If successful the zero is stored and the polynomial deflated
-				idnn2 = degree - nn;
-				zeror[ idnn2 ] = zr;
-				zeroi[ idnn2 ] = zi;
-				nn--;
-				for( i = 0; i <= nn; i++ )
-				{
-					pr[ i ] = qpr[ i ];
-					piw[ i ] = qpi[ i ];
-				}
-				goto search;
-            }
-			// If the iteration is unsuccessful another shift is chosen
-		}
-		// if 9 shifts fail, the outer loop is repeated with another sequence of shifts
-	}
-	
-	// The zerofinder has failed on two major passes
-	// return empty handed with the number of roots found (less than the original degree)
-	degree -= nn;
-	
-finish:
-	// Deallocate arrays
-	free( pr );
-	free( piw );
-	free( hr );
-	free( hi );
-	free( qpr );
-	free( qpi );
-	free( qhr );
-	free( qhi );
-	free( shr );
-	free( shi );
-	
-	return degree;       
-}
-
-
-// COMPUTES  THE DERIVATIVE  POLYNOMIAL AS THE INITIAL H
-// POLYNOMIAL AND COMPUTES L1 NO-SHIFT H POLYNOMIALS.
-//
-static void noshft( const int l1 )
-{
-	int i, j, jj, n, nm1;
-	double xni, t1, t2;
-	
-	n = nn;
-	nm1 = n - 1;
-	for( i = 0; i < n; i++ )
-	{
-		xni = nn - i;
-		hr[ i ] = xni * pr[ i ] / n;
-		hi[ i ] = xni * piw[ i ] / n;
-	}
-	for( jj = 1; jj <= l1; jj++ )
-	{
-		if( cmod( hr[ n - 1 ], hi[ n - 1 ] ) > eta * 10 * cmod( pr[ n - 1 ], piw[ n - 1 ] ) )
-		{
-			cdivid( -pr[ nn ], -piw[ nn ], hr[ n - 1 ], hi[ n - 1 ], &tr, &ti );
-			for( i = 0; i < nm1; i++ )
-            {
-				j = nn - i - 1;
-				t1 = hr[ j - 1 ];
-				t2 = hi[ j - 1 ];
-				hr[ j ] = tr * t1 - ti * t2 + pr[ j ];
-				hi[ j ] = tr * t2 + ti * t1 + piw[ j ];
-            }
-			hr[ 0 ] = pr[ 0 ];
-			hi[ 0 ] = piw[ 0 ];
-		}
-		else
-		{
-			// If the constant term is essentially zero, shift H coefficients
-			for( i = 0; i < nm1; i++ )
-            {
-				j = nn - i - 1;
-				hr[ j ] = hr[ j - 1 ];
-				hi[ j ] = hi[ j - 1 ];
-            }
-			hr[ 0 ] = 0;
-			hi[ 0 ] = 0;
-		}
-	}
-}
-
-// COMPUTES L2 FIXED-SHIFT H POLYNOMIALS AND TESTS FOR CONVERGENCE.
-// INITIATES A VARIABLE-SHIFT ITERATION AND RETURNS WITH THE
-// APPROXIMATE ZERO IF SUCCESSFUL.
-// L2 - LIMIT OF FIXED SHIFT STEPS
-// ZR,ZI - APPROXIMATE ZERO IF CONV IS .TRUE.
-// CONV  - LOGICAL INDICATING CONVERGENCE OF STAGE 3 ITERATION
-//
-static void fxshft( const int l2, double *zr, double *zi, int *conv )
-{
-	int i, j, n;
-	int test, pasd, bol;
-	double otr, oti, svsr, svsi;
-	
-	n = nn;
-	polyev( nn, sr, si, pr, piw, qpr, qpi, &pvr, &pvi );
-	test = 1;
-	pasd = 0;
-	
-	// Calculate first T = -P(S)/H(S)
-	calct( &bol );
-	
-	// Main loop for second stage
-	for( j = 1; j <= l2; j++ )
-	{
-		otr = tr;
-		oti = ti;
-		
-		// Compute the next H Polynomial and new t
-		nexth( bol );
-		calct( &bol );
-		*zr = sr + tr;
-		*zi = si + ti;
-		
-		// Test for convergence unless stage 3 has failed once or this
-		// is the last H Polynomial
-		if( !( bol || !test || j == 12 ) )
-			if( cmod( tr - otr, ti - oti ) < 0.5 * cmod( *zr, *zi ) )
-            {
-				if( pasd )
-				{
-					// The weak convergence test has been passwed twice, start the third stage
-					// Iteration, after saving the current H polynomial and shift
-					for( i = 0; i < n; i++ )
-					{
-						shr[ i ] = hr[ i ];
-						shi[ i ] = hi[ i ];
-					}
-					svsr = sr;
-					svsi = si;
-					vrshft( 10, zr, zi, conv );
-					if( *conv ) return;
-					
-					//The iteration failed to converge. Turn off testing and restore h,s,pv and T
-					test = 0;
-					for( i = 0; i < n; i++ )
-					{
-						hr[ i ] = shr[ i ];
-						hi[ i ] = shi[ i ];
-					}
-					sr = svsr;
-					si = svsi;
-					polyev( nn, sr, si, pr, piw, qpr, qpi, &pvr, &pvi );
-					calct( &bol );
-					continue;
-				}
-				pasd = 1;
-            }
-			else
-				pasd = 0;
-	}
-	
-	// Attempt an iteration with final H polynomial from second stage
-	vrshft( 10, zr, zi, conv );
-}
-
-// CARRIES OUT THE THIRD STAGE ITERATION.
-// L3 - LIMIT OF STEPS IN STAGE 3.
-// ZR,ZI   - ON ENTRY CONTAINS THE INITIAL ITERATE, IF THE
-//           ITERATION CONVERGES IT CONTAINS THE FINAL ITERATE ON EXIT.
-// CONV    -  .TRUE. IF ITERATION CONVERGES
-//
-static void vrshft( const int l3, double *zr, double *zi, int *conv )
-{
-	int b, bol;
-	int i, j;
-	double mp, ms, omp, relstp, r1, r2, tp;
-	
-	*conv = 0;
-	b = 0;
-	sr = *zr;
-	si = *zi;
-	
-	// Main loop for stage three
-	for( i = 1; i <= l3; i++ )
-	{
-		// Evaluate P at S and test for convergence
-		polyev( nn, sr, si, pr, piw, qpr, qpi, &pvr, &pvi );
-		mp = cmod( pvr, pvi );
-		ms = cmod( sr, si );
-		if( mp <= 20 * errev( nn, qpr, qpi, ms, mp, are, mre ) )
-		{
-			// Polynomial value is smaller in value than a bound onthe error
-			// in evaluationg P, terminate the ietartion
-			*conv = 1;
-			*zr = sr;
-			*zi = si;
-			return;
-		}
-		if( i != 1 )
-		{
-			if( !( b || mp < omp || relstp >= 0.05 ) )
-            {
-				// Iteration has stalled. Probably a cluster of zeros. Do 5 fixed 
-				// shift steps into the cluster to force one zero to dominate
-				tp = relstp;
-				b = 1;
-				if( relstp < eta ) tp = eta;
-				r1 = sqrt( tp );
-				r2 = sr * ( 1 + r1 ) - si * r1;
-				si = sr * r1 + si * ( 1 + r1 );
-				sr = r2;
-				polyev( nn, sr, si, pr, piw, qpr, qpi, &pvr, &pvi );
-				for( j = 1; j <= 5; j++ )
-				{
-					calct( &bol );
-					nexth( bol );
-				}
-				omp = infin;
-				goto _20;
-            }
-			
-			// Exit if polynomial value increase significantly
-			if( mp *0.1 > omp ) return;
-		}
-		
-		omp = mp;
-		
-		// Calculate next iterate
-	_20:  calct( &bol );
-		nexth( bol );
-		calct( &bol );
-		if( !bol )
-		{
-			relstp = cmod( tr, ti ) / cmod( sr, si );
-			sr += tr;
-			si += ti;
-		}
-	}
-}
-
-// COMPUTES  T = -P(S)/H(S).
-// BOOL   - LOGICAL, SET TRUE IF H(S) IS ESSENTIALLY ZERO.
-static void calct( int *bol )
-{
-	int n;
-	double hvr, hvi;
-	
-	n = nn;
-	
-	// evaluate h(s)
-	polyev( n - 1, sr, si, hr, hi, qhr, qhi, &hvr, &hvi );
-	*bol = cmod( hvr, hvi ) <= are * 10 * cmod( hr[ n - 1 ], hi[ n - 1 ] ) ? 1 : 0;
-	if( !*bol )
-	{
-		cdivid( -pvr, -pvi, hvr, hvi, &tr, &ti );
-		return;
-	}
-	
-	tr = 0;
-	ti = 0;
-}
-
-// CALCULATES THE NEXT SHIFTED H POLYNOMIAL.
-// BOOL   -  LOGICAL, IF .TRUE. H(S) IS ESSENTIALLY ZERO
-//
-static void nexth( const int bol )
-{
-	int j, n;
-	double t1, t2;
-	
-	n = nn;
-	if( !bol )
-	{
-		for( j = 1; j < n; j++ )
-		{
-			t1 = qhr[ j - 1 ];
-			t2 = qhi[ j - 1 ];
-			hr[ j ] = tr * t1 - ti * t2 + qpr[ j ];
-			hi[ j ] = tr * t2 + ti * t1 + qpi[ j ];
-		}
-		hr[ 0 ] = qpr[ 0 ];
-		hi[ 0 ] = qpi[ 0 ];
-		return;
-	}
-	
-	// If h[s] is zero replace H with qh
-	for( j = 1; j < n; j++ )
-	{
-		hr[ j ] = qhr[ j - 1 ];
-		hi[ j ] = qhi[ j - 1 ];
-	}
-	hr[ 0 ] = 0;
-	hi[ 0 ] = 0;
-}
-
-// EVALUATES A POLYNOMIAL  P  AT  S  BY THE HORNER RECURRENCE
-// PLACING THE PARTIAL SUMS IN Q AND THE COMPUTED VALUE IN PV.
-//  
-static void polyev( const int nn, const double sr, const double si, const double pr[], const double piw[], double qr[], double qi[], double *pvr, double *pvi )  
-{
-	int i;
-	double t;
-	
-	qr[ 0 ] = pr[ 0 ];
-	qi[ 0 ] = piw[ 0 ];
-	*pvr = qr[ 0 ];
-	*pvi = qi[ 0 ];
-	
-	for( i = 1; i <= nn; i++ )
-	{
-		t = ( *pvr ) * sr - ( *pvi ) * si + pr[ i ];
-		*pvi = ( *pvr ) * si + ( *pvi ) * sr + piw[ i ];
-		*pvr = t;
-		qr[ i ] = *pvr;
-		qi[ i ] = *pvi;
-	}
-}
-
-// BOUNDS THE ERROR IN EVALUATING THE POLYNOMIAL BY THE HORNER RECURRENCE.
-// QR,QI - THE PARTIAL SUMS
-// MS    -MODULUS OF THE POINT
-// MP    -MODULUS OF POLYNOMIAL VALUE
-// ARE, MRE -ERROR BOUNDS ON COMPLEX ADDITION AND MULTIPLICATION
-//
-static double errev( const int nn, const double qr[], const double qi[], const double ms, const double mp, const double are, const double mre )
-{
-	int i;
-	double e;
-	
-	e = cmod( qr[ 0 ], qi[ 0 ] ) * mre / ( are + mre );
-	for( i = 0; i <= nn; i++ )
-		e = e * ms + cmod( qr[ i ], qi[ i ] );
-	
-	return e * ( are + mre ) - mp * mre;
-}
-
-// CAUCHY COMPUTES A LOWER BOUND ON THE MODULI OF THE ZEROS OF A
-// POLYNOMIAL - PT IS THE MODULUS OF THE COEFFICIENTS.
-//
-static void cauchy( const int nn, double pt[], double q[], double *fn_val )
-{
-	int i, n;
-	double x, xm, f, dx, df;
-	
-	pt[ nn ] = -pt[ nn ];
-	
-	// Compute upper estimate bound
-	n = nn;
-	x = exp( log( -pt[ nn ] ) - log( pt[ 0 ] ) ) / n;
-	if( pt[ n - 1 ] != 0 )
-	{
-		// Newton step at the origin is better, use it
-		xm = -pt[ nn ] / pt[ n - 1 ];
-		if( xm < x ) x = xm;
-	}
-	
-	// Chop the interval (0,x) until f < 0
-	while(1)
-	{
-		xm = x * 0.1;
-		f = pt[ 0 ];
-		for( i = 1; i <= nn; i++ )
-			f = f * xm + pt[ i ];
-		if( f <= 0 )
-			break;
-		x = xm;
-	}
-	dx = x;
-	
-	// Do Newton iteration until x converges to two decimal places
-	while( fabs( dx / x ) > 0.005 )
-	{
-		q[ 0 ] = pt[ 0 ];
-		for( i = 1; i <= nn; i++ )
-			q[ i ] = q[ i - 1 ] * x + pt[ i ];
-		f = q[ nn ];
-		df = q[ 0 ];
-		for( i = 1; i < n; i++ )
-			df = df * x + q[ i ];
-		dx = f / df;
-		x -= dx;
-	}
-	
-	*fn_val = x;
-}
-
-// RETURNS A SCALE FACTOR TO MULTIPLY THE COEFFICIENTS OF THE POLYNOMIAL.
-// THE SCALING IS DONE TO AVOID OVERFLOW AND TO AVOID UNDETECTED UNDERFLOW
-// INTERFERING WITH THE CONVERGENCE CRITERION.  THE FACTOR IS A POWER OF THE
-// BASE.
-// PT - MODULUS OF COEFFICIENTS OF P
-// ETA, INFIN, SMALNO, BASE - CONSTANTS DESCRIBING THE FLOATING POINT ARITHMETIC.
-//
-static double scale( const int nn, const double pt[], const double eta, const double infin, const double smalno, const double base )
-{
-	int i, l;
-	double hi, lo, max, min, x, sc;
-	double fn_val;
-	
-	// Find largest and smallest moduli of coefficients
-	hi = sqrt( infin );
-	lo = smalno / eta;
-	max = 0;
-	min = infin;
-	
-	for( i = 0; i <= nn; i++ )
-	{
-		x = pt[ i ];
-		if( x > max ) max = x;
-		if( x != 0 && x < min ) min = x;
-	}
-	
-	// Scale only if there are very large or very small components
-	fn_val = 1;
-	if( min >= lo && max <= hi ) return fn_val;
-	x = lo / min;
-	if( x <= 1 )
-		sc = 1 / ( sqrt( max )* sqrt( min ) );
-	else
-	{
-		sc = x;
-		if( infin / sc > max ) sc = 1;
-	}
-	l = (int)( log( sc ) / log(base ) + 0.5 );
-	fn_val = pow( base , l );
-	return fn_val;
-}
-
-// COMPLEX DIVISION C = A/B, AVOIDING OVERFLOW.
-//
-static void cdivid( const double ar, const double ai, const double br, const double bi, double *cr, double *ci )
-{
-	double r, d, t, infin;
-	
-	if( br == 0 && bi == 0 )
-	{
-		// Division by zero, c = infinity
-		mcon( &t, &infin, &t, &t );
-		*cr = infin;
-		*ci = infin;
-		return;
-	}
-	
-	if( fabs( br ) < fabs( bi ) )
-	{
-		r = br/ bi;
-		d = bi + r * br;
-		*cr = ( ar * r + ai ) / d;
-		*ci = ( ai * r - ar ) / d;
-		return;
-	}
-	
-	r = bi / br;
-	d = br + r * bi;
-	*cr = ( ar + ai * r ) / d;
-	*ci = ( ai - ar * r ) / d;
-}
-
-// MODULUS OF A COMPLEX NUMBER AVOIDING OVERFLOW.
-//
-static double cmod( const double r, const double i )
-{
-	double ar, ai;
-	
-	ar = fabs( r );
-	ai = fabs( i );
-	if( ar < ai )
-		return ai * sqrt( 1.0 + pow( ( ar / ai ), 2.0 ) );
-	
-	if( ar > ai )
-		return ar * sqrt( 1.0 + pow( ( ai / ar ), 2.0 ) );
-	
-	return ar * sqrt( 2.0 );
-}
-
-// MCON PROVIDES MACHINE CONSTANTS USED IN VARIOUS PARTS OF THE PROGRAM.
-// THE USER MAY EITHER SET THEM DIRECTLY OR USE THE STATEMENTS BELOW TO
-// COMPUTE THEM. THE MEANING OF THE FOUR CONSTANTS ARE -
-// ETA       THE MAXIMUM RELATIVE REPRESENTATION ERROR WHICH CAN BE DESCRIBED
-//           AS THE SMALLEST POSITIVE FLOATING-POINT NUMBER SUCH THAT
-//           1.0_dp + ETA &gt; 1.0.
-// INFINY    THE LARGEST FLOATING-POINT NUMBER
-// SMALNO    THE SMALLEST POSITIVE FLOATING-POINT NUMBER
-// BASE      THE BASE OF THE FLOATING-POINT NUMBER SYSTEM USED
-//
-static void mcon( double *eta, double *infiny, double *smalno, double *base )
-{
-	*base = 10;//DBL_RADIX;
-	*eta = DBL_EPSILON;
-	*infiny = DBL_MAX;
-	*smalno = DBL_MIN;
-}
Index: c/sans/models/src/libigor/2Y_cpoly.h
===================================================================
--- src/sans/models/src/libigor/2Y_cpoly.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/*
- *  cpoly.h
- *  TwoYukawa
- *
- *  Created by Marcus Hennig on 5/8/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-int cpoly( const double *opr, const double *opi, int degree, double *zeror, double *zeroi ); 
Index: c/sans/models/src/libigor/2Y_utility.c
===================================================================
--- src/sans/models/src/libigor/2Y_utility.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,17 +1,0 @@
-/*
- *  utility.c
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/13/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include "2Y_utility.h"
-double chop( double x )
-{
-	if ( fabs(x) < 1E-6 )
-		return 0;
-	else 
-		return x;
-}
Index: c/sans/models/src/libigor/2Y_utility.h
===================================================================
--- src/sans/models/src/libigor/2Y_utility.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,11 +1,0 @@
-/*
- *  utility.h
- *  twoyukawa
- *
- *  Created by Marcus Hennig on 5/13/10.
- *  Copyright 2010 __MyCompanyName__. All rights reserved.
- *
- */
-#include <math.h>
-
-double chop( double x );
Index: c/sans/models/src/libigor/GaussWeights.c
===================================================================
--- src/sans/models/src/libigor/GaussWeights.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,520 +1,0 @@
-/*
- *  GaussWeights.c
- *  SANSAnalysis
- *
- *  Created by Andrew Jackson on 4/23/07.
- *  Copyright 2007 __MyCompanyName__. All rights reserved.
- *
- */
-
-// Gaussians
-const double Gauss20Wt[20]={
-	.0176140071391521,
-	.0406014298003869,
-	.0626720483341091,
-	.0832767415767047,
-	.10193011981724,
-	.118194531961518,
-	.131688638449177,
-	.142096109318382,
-	.149172986472604,
-	.152753387130726,
-	.152753387130726,
-	.149172986472604,
-	.142096109318382,
-	.131688638449177,
-	.118194531961518,
-	.10193011981724,
-	.0832767415767047,
-	.0626720483341091,
-	.0406014298003869,
-	.0176140071391521
-};
-
-const double Gauss20Z[20]={
-	-.993128599185095,
-	-.963971927277914,
-	-.912234428251326,
-	-.839116971822219,
-	-.746331906460151,
-	-.636053680726515,
-	-.510867001950827,
-	-.37370608871542,
-	-.227785851141645,
-	-.076526521133497,
-	.0765265211334973,
-	.227785851141645,
-	.37370608871542,
-	.510867001950827,
-	.636053680726515,
-	.746331906460151,
-	.839116971822219,
-	.912234428251326,
-	.963971927277914,
-	.993128599185095
-};
-
-const double Gauss76Wt[76]={
-	.00126779163408536,		//0
-	.00294910295364247,
-	.00462793522803742,
-	.00629918049732845,
-	.00795984747723973,
-	.00960710541471375,
-	.0112381685696677,
-	.0128502838475101,
-	.0144407317482767,
-	.0160068299122486,
-	.0175459372914742,		//10
-	.0190554584671906,
-	.020532847967908,
-	.0219756145344162,
-	.0233813253070112,
-	.0247476099206597,
-	.026072164497986,
-	.0273527555318275,
-	.028587223650054,
-	.029773487255905,
-	.0309095460374916,		//20
-	.0319934843404216,
-	.0330234743977917,
-	.0339977794120564,
-	.0349147564835508,
-	.0357728593807139,
-	.0365706411473296,
-	.0373067565423816,
-	.0379799643084053,
-	.0385891292645067,
-	.0391332242205184,		//30
-	.0396113317090621,
-	.0400226455325968,
-	.040366472122844,
-	.0406422317102947,
-	.0408494593018285,
-	.040987805464794,
-	.0410570369162294,
-	.0410570369162294,
-	.040987805464794,
-	.0408494593018285,		//40
-	.0406422317102947,
-	.040366472122844,
-	.0400226455325968,
-	.0396113317090621,
-	.0391332242205184,
-	.0385891292645067,
-	.0379799643084053,
-	.0373067565423816,
-	.0365706411473296,
-	.0357728593807139,		//50
-	.0349147564835508,
-	.0339977794120564,
-	.0330234743977917,
-	.0319934843404216,
-	.0309095460374916,
-	.029773487255905,
-	.028587223650054,
-	.0273527555318275,
-	.026072164497986,
-	.0247476099206597,		//60
-	.0233813253070112,
-	.0219756145344162,
-	.020532847967908,
-	.0190554584671906,
-	.0175459372914742,
-	.0160068299122486,
-	.0144407317482767,
-	.0128502838475101,
-	.0112381685696677,
-	.00960710541471375,		//70
-	.00795984747723973,
-	.00629918049732845,
-	.00462793522803742,
-	.00294910295364247,
-	.00126779163408536		//75 (indexed from 0)
-};
-
-const double Gauss76Z[76]={
-	 .999505948362153*(-1.0),		//0
-	 .997397786355355*(-1.0),
-	 .993608772723527*(-1.0),
-	 .988144453359837*(-1.0),
-	 .981013938975656*(-1.0),
-	 .972229228520377*(-1.0),
-	 .961805126758768*(-1.0),
-	 .949759207710896*(-1.0),
-	 .936111781934811*(-1.0),
-	 .92088586125215*(-1.0),
-	 .904107119545567*(-1.0),		//10
-	 .885803849292083*(-1.0),
-	 .866006913771982*(-1.0),
-	 .844749694983342*(-1.0),
-	 .822068037328975*(-1.0),
-	 .7980001871612*(-1.0),
-	 .77258672828181*(-1.0),
-	 .74587051350361*(-1.0),
-	 .717896592387704*(-1.0),
-	 .688712135277641*(-1.0),
-	 .658366353758143*(-1.0),		//20
-	 .626910417672267*(-1.0),
-	 .594397368836793*(-1.0),
-	 .560882031601237*(-1.0),
-	 .526420920401243*(-1.0),
-	 .491072144462194*(-1.0),
-	 .454895309813726*(-1.0),
-	 .417951418780327*(-1.0),
-	 .380302767117504*(-1.0),
-	 .342012838966962*(-1.0),
-	 .303146199807908*(-1.0),		//30
-	 .263768387584994*(-1.0),
-	 .223945802196474*(-1.0),
-	 .183745593528914*(-1.0),
-	 .143235548227268*(-1.0),
-	 .102483975391227*(-1.0),
-	 .0615595913906112*(-1.0),
-	 .0205314039939986*(-1.0),
-	-.0205314039939986*(-1.0),
-	-.0615595913906112*(-1.0),
-	-.102483975391227*(-1.0),			//40
-	-.143235548227268*(-1.0),
-	-.183745593528914*(-1.0),
-	-.223945802196474*(-1.0),
-	-.263768387584994*(-1.0),
-	-.303146199807908*(-1.0),
-	-.342012838966962*(-1.0),
-	-.380302767117504*(-1.0),
-	-.417951418780327*(-1.0),
-	-.454895309813726*(-1.0),
-	-.491072144462194*(-1.0),		//50
-	-.526420920401243*(-1.0),
-	-.560882031601237*(-1.0),
-	-.594397368836793*(-1.0),
-	-.626910417672267*(-1.0),
-	-.658366353758143*(-1.0),
-	-.688712135277641*(-1.0),
-	-.717896592387704*(-1.0),
-	-.74587051350361*(-1.0),
-	-.77258672828181*(-1.0),
-	-.7980001871612*(-1.0),	//60
-	-.822068037328975*(-1.0),
-	-.844749694983342*(-1.0),
-	-.866006913771982*(-1.0),
-	-.885803849292083*(-1.0),
-	-.904107119545567*(-1.0),
-	-.92088586125215*(-1.0),
-	-.936111781934811*(-1.0),
-	-.949759207710896*(-1.0),
-	-.961805126758768*(-1.0),
-	-.972229228520377*(-1.0),		//70
-	-.981013938975656*(-1.0),
-	-.988144453359837*(-1.0),
-	-.993608772723527*(-1.0),
-	-.997397786355355*(-1.0),
-	-.999505948362153*(-1.0)		//75
-};
-
-const double Gauss150Z[150]={
-  	-0.9998723404457334,
-  	-0.9993274305065947,
-  	-0.9983473449340834,
-  	-0.9969322929775997,
-  	-0.9950828645255290,
-  	-0.9927998590434373,
-  	-0.9900842691660192,
-  	-0.9869372772712794,
-  	-0.9833602541697529,
-  	-0.9793547582425894,
-  	-0.9749225346595943,
-  	-0.9700655145738374,
-  	-0.9647858142586956,
-  	-0.9590857341746905,
-  	-0.9529677579610971,
-  	-0.9464345513503147,
-  	-0.9394889610042837,
-  	-0.9321340132728527,
-  	-0.9243729128743136,
-  	-0.9162090414984952,
-  	-0.9076459563329236,
-  	-0.8986873885126239,
-  	-0.8893372414942055,
-  	-0.8795995893549102,
-  	-0.8694786750173527,
-  	-0.8589789084007133,
-  	-0.8481048644991847,
-  	-0.8368612813885015,
-  	-0.8252530581614230,
-  	-0.8132852527930605,
-  	-0.8009630799369827,
-  	-0.7882919086530552,
-  	-0.7752772600680049,
-  	-0.7619248049697269,
-  	-0.7482403613363824,
-  	-0.7342298918013638,
-  	-0.7198995010552305,
-  	-0.7052554331857488,
-  	-0.6903040689571928,
-  	-0.6750519230300931,
-  	-0.6595056411226444,
-  	-0.6436719971150083,
-  	-0.6275578900977726,
-  	-0.6111703413658551,
-  	-0.5945164913591590,
-  	-0.5776035965513142,
-  	-0.5604390262878617,
-  	-0.5430302595752546,
-  	-0.5253848818220803,
-  	-0.5075105815339176,
-  	-0.4894151469632753,
-  	-0.4711064627160663,
-  	-0.4525925063160997,
-  	-0.4338813447290861,
-  	-0.4149811308476706,
-  	-0.3959000999390257,
-  	-0.3766465660565522,
-  	-0.3572289184172501,
-  	-0.3376556177463400,
-  	-0.3179351925907259,
-  	-0.2980762356029071,
-  	-0.2780873997969574,
-  	-0.2579773947782034,
-  	-0.2377549829482451,
-  	-0.2174289756869712,
-  	-0.1970082295132342,
-  	-0.1765016422258567,
-  	-0.1559181490266516,
-  	-0.1352667186271445,
-  	-0.1145563493406956,
-  	-0.0937960651617229,
-  	-0.0729949118337358,
-  	-0.0521619529078925,
-  	-0.0313062657937972,
-  	-0.0104369378042598,
-  	0.0104369378042598,
-  	0.0313062657937972,
-  	0.0521619529078925,
-  	0.0729949118337358,
-  	0.0937960651617229,
-  	0.1145563493406956,
-  	0.1352667186271445,
-  	0.1559181490266516,
-  	0.1765016422258567,
-  	0.1970082295132342,
-  	0.2174289756869712,
-  	0.2377549829482451,
-  	0.2579773947782034,
-  	0.2780873997969574,
-  	0.2980762356029071,
-  	0.3179351925907259,
-  	0.3376556177463400,
-  	0.3572289184172501,
-  	0.3766465660565522,
-  	0.3959000999390257,
-  	0.4149811308476706,
-  	0.4338813447290861,
-  	0.4525925063160997,
-  	0.4711064627160663,
-  	0.4894151469632753,
-  	0.5075105815339176,
-  	0.5253848818220803,
-  	0.5430302595752546,
-  	0.5604390262878617,
-  	0.5776035965513142,
-  	0.5945164913591590,
-  	0.6111703413658551,
-  	0.6275578900977726,
-  	0.6436719971150083,
-  	0.6595056411226444,
-  	0.6750519230300931,
-  	0.6903040689571928,
-  	0.7052554331857488,
-  	0.7198995010552305,
-  	0.7342298918013638,
-  	0.7482403613363824,
-  	0.7619248049697269,
-  	0.7752772600680049,
-  	0.7882919086530552,
-  	0.8009630799369827,
-  	0.8132852527930605,
-  	0.8252530581614230,
-  	0.8368612813885015,
-  	0.8481048644991847,
-  	0.8589789084007133,
-  	0.8694786750173527,
-  	0.8795995893549102,
-  	0.8893372414942055,
-  	0.8986873885126239,
-  	0.9076459563329236,
-  	0.9162090414984952,
-  	0.9243729128743136,
-  	0.9321340132728527,
-  	0.9394889610042837,
-  	0.9464345513503147,
-  	0.9529677579610971,
-  	0.9590857341746905,
-  	0.9647858142586956,
-  	0.9700655145738374,
-  	0.9749225346595943,
-  	0.9793547582425894,
-  	0.9833602541697529,
-  	0.9869372772712794,
-  	0.9900842691660192,
-  	0.9927998590434373,
-  	0.9950828645255290,
-  	0.9969322929775997,
-  	0.9983473449340834,
-  	0.9993274305065947,
-  	0.9998723404457334
-};
-
-const double Gauss150Wt[150]={
-  	0.0003276086705538,
-  	0.0007624720924706,
-  	0.0011976474864367,
-  	0.0016323569986067,
-  	0.0020663664924131,
-  	0.0024994789888943,
-  	0.0029315036836558,
-  	0.0033622516236779,
-  	0.0037915348363451,
-  	0.0042191661429919,
-  	0.0046449591497966,
-  	0.0050687282939456,
-  	0.0054902889094487,
-  	0.0059094573005900,
-  	0.0063260508184704,
-  	0.0067398879387430,
-  	0.0071507883396855,
-  	0.0075585729801782,
-  	0.0079630641773633,
-  	0.0083640856838475,
-  	0.0087614627643580,
-  	0.0091550222717888,
-  	0.0095445927225849,
-  	0.0099300043714212,
-  	0.0103110892851360,
-  	0.0106876814158841,
-  	0.0110596166734735,
-  	0.0114267329968529,
-  	0.0117888704247183,
-  	0.0121458711652067,
-  	0.0124975796646449,
-  	0.0128438426753249,
-  	0.0131845093222756,
-  	0.0135194311690004,
-  	0.0138484622795371,
-  	0.0141714592928592,
-  	0.0144882814685445,
-  	0.0147987907597169,
-  	0.0151028518701744,
-  	0.0154003323133401,
-  	0.0156911024699895,
-  	0.0159750356447283,
-  	0.0162520081211971,
-  	0.0165218992159766,
-  	0.0167845913311726,
-  	0.0170399700056559,
-  	0.0172879239649355,
-  	0.0175283451696437,
-  	0.0177611288626114,
-  	0.0179861736145128,
-  	0.0182033813680609,
-  	0.0184126574807331,
-  	0.0186139107660094,
-  	0.0188070535331042,
-  	0.0189920016251754,
-  	0.0191686744559934,
-  	0.0193369950450545,
-  	0.0194968900511231,
-  	0.0196482898041878,
-  	0.0197911283358190,
-  	0.0199253434079123,
-  	0.0200508765398072,
-  	0.0201676730337687,
-  	0.0202756819988200,
-  	0.0203748563729175,
-  	0.0204651529434560,
-  	0.0205465323660984,
-  	0.0206189591819181,
-  	0.0206824018328499,
-  	0.0207368326754401,
-  	0.0207822279928917,
-  	0.0208185680053983,
-  	0.0208458368787627,
-  	0.0208640227312962,
-  	0.0208731176389954,
-  	0.0208731176389954,
-  	0.0208640227312962,
-  	0.0208458368787627,
-  	0.0208185680053983,
-  	0.0207822279928917,
-  	0.0207368326754401,
-  	0.0206824018328499,
-  	0.0206189591819181,
-  	0.0205465323660984,
-  	0.0204651529434560,
-  	0.0203748563729175,
-  	0.0202756819988200,
-  	0.0201676730337687,
-  	0.0200508765398072,
-  	0.0199253434079123,
-  	0.0197911283358190,
-  	0.0196482898041878,
-  	0.0194968900511231,
-  	0.0193369950450545,
-  	0.0191686744559934,
-  	0.0189920016251754,
-  	0.0188070535331042,
-  	0.0186139107660094,
-  	0.0184126574807331,
-  	0.0182033813680609,
-  	0.0179861736145128,
-  	0.0177611288626114,
-  	0.0175283451696437,
-  	0.0172879239649355,
-  	0.0170399700056559,
-  	0.0167845913311726,
-  	0.0165218992159766,
-  	0.0162520081211971,
-  	0.0159750356447283,
-  	0.0156911024699895,
-  	0.0154003323133401,
-  	0.0151028518701744,
-  	0.0147987907597169,
-  	0.0144882814685445,
-  	0.0141714592928592,
-  	0.0138484622795371,
-  	0.0135194311690004,
-  	0.0131845093222756,
-  	0.0128438426753249,
-  	0.0124975796646449,
-  	0.0121458711652067,
-  	0.0117888704247183,
-  	0.0114267329968529,
-  	0.0110596166734735,
-  	0.0106876814158841,
-  	0.0103110892851360,
-  	0.0099300043714212,
-  	0.0095445927225849,
-  	0.0091550222717888,
-  	0.0087614627643580,
-  	0.0083640856838475,
-  	0.0079630641773633,
-  	0.0075585729801782,
-  	0.0071507883396855,
-  	0.0067398879387430,
-  	0.0063260508184704,
-  	0.0059094573005900,
-  	0.0054902889094487,
-  	0.0050687282939456,
-  	0.0046449591497966,
-  	0.0042191661429919,
-  	0.0037915348363451,
-  	0.0033622516236779,
-  	0.0029315036836558,
-  	0.0024994789888943,
-  	0.0020663664924131,
-  	0.0016323569986067,
-  	0.0011976474864367,
-  	0.0007624720924706,
-  	0.0003276086705538
-};
-
Index: c/sans/models/src/libigor/GaussWeights.h
===================================================================
--- src/sans/models/src/libigor/GaussWeights.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,24 +1,0 @@
-#ifndef GAUSSWEIGHTS_H
-#define GAUSSWEIGHTS_H
-/*
- *  GaussWeights.h
- *  SANSAnalysis
- *
- *  Created by Andrew Jackson on 4/23/07.
- *  Copyright 2007 __MyCompanyName__. All rights reserved.
- *
- */
-
-// Gaussians
-extern const double Gauss20Wt[20];
-
-extern const double Gauss20Z[20];
-
-extern const double Gauss76Wt[76];
-
-extern const double Gauss76Z[76];
-
-extern const double Gauss150Z[150];
-
-extern const double Gauss150Wt[150];
-#endif
Index: c/sans/models/src/libigor/StandardHeaders.h
===================================================================
--- src/sans/models/src/libigor/StandardHeaders.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,19 +1,0 @@
-/*
- *  StandardHeaders.h
- *  SANSAnalysis
- *
- *  Created by Andrew Jackson on 4/23/07.
- *  Copyright 2007 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include <math.h>
-#include <ctype.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef _WIN32
-#include <float.h>
-#include "winFuncs.h"
-#endif
Index: c/sans/models/src/libigor/libCylinder.c
===================================================================
--- src/sans/models/src/libigor/libCylinder.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,3311 +1,0 @@
-/*	CylinderFit.c
-
-A simplified project designed to act as a template for your curve fitting function.
-The fitting function is a Cylinder form factor. No resolution effects are included (yet)
-*/
-
-#include "StandardHeaders.h"			// Include ANSI headers, Mac headers
-#include "GaussWeights.h"
-#include "libCylinder.h"
-
-/////////functions for WRC implementation of flexible cylinders
-static double
-gammaln(double xx)
-{
-  double x,y,tmp,ser;
-  static double cof[6]={76.18009172947146,-86.50532032941677,
-    24.01409824083091,-1.231739572450155,
-    0.1208650973866179e-2,-0.5395239384953e-5};
-  int j;
-
-  y=x=xx;
-  tmp=x+5.5;
-  tmp -= (x+0.5)*log(tmp);
-  ser=1.000000000190015;
-  for (j=0;j<=5;j++) ser += cof[j]/++y;
-  return -tmp+log(2.5066282746310005*ser/x);
-}
-/////////functions for WRC implementation of flexible cylinders
-
-//
-static double
-AlphaSquare(double x)
-{
-    double yy;
-    yy = pow( (1.0 + (x/3.12)*(x/3.12) + (x/8.67)*(x/8.67)*(x/8.67)),(0.176/3.0) );
-
-    return (yy);
-}
-
-//
-static double
-Rgsquarezero(double q, double L, double b)
-{
-    double yy;
-    yy = (L*b/6.0) * (1.0 - 1.5*(b/L) + 1.5*pow((b/L),2) - 0.75*pow((b/L),3)*(1.0 - exp(-2.0*(L/b))));
-
-    return (yy);
-}
-
-//
-static double
-Rgsquareshort(double q, double L, double b)
-{
-    double yy;
-    yy = AlphaSquare(L/b) * Rgsquarezero(q,L,b);
-
-    return (yy);
-}
-
-//
-static double
-Rgsquare(double q, double L, double b)
-{
-    double yy;
-    yy = AlphaSquare(L/b)*L*b/6.0;
-
-    return (yy);
-}
-
-// ?? funciton is not used - but should the log actually be log10???
-/*
-static double
-miu(double x)
-{
-    double yy;
-    yy = (1.0/8.0)*(9.0*x - 2.0 + 2.0*log(1.0 + x)/x)*exp(1.0/2.565*(1.0/x + (1.0 - 1.0/(x*x))*log(1.0 + x)));
-
-    return (yy);
-}
-*/
-
-//WR named this w (too generic)
-static double
-w_WR(double x)
-{
-    double yy;
-    yy = 0.5*(1 + tanh((x - 1.523)/0.1477));
-
-    return (yy);
-}
-
-//
-static double
-u1(double q, double L, double b)
-{
-    double yy;
-
-    yy = Rgsquareshort(q,L,b)*q*q;
-
-    return (yy);
-}
-
-// was named u
-static double
-u_WR(double q, double L, double b)
-{
-    double yy;
-    yy = Rgsquare(q,L,b)*q*q;
-    return (yy);
-}
-
-
-//
-static double
-Sdebye1(double q, double L, double b)
-{
-    double yy;
-    yy = 2.0*(exp(-u1(q,L,b)) + u1(q,L,b) -1.0)/( pow((u1(q,L,b)),2.0) );
-
-    return (yy);
-}
-
-
-//
-static double
-Sdebye(double q, double L, double b)
-{
-    double yy;
-    yy = 2.0*(exp(-u_WR(q,L,b)) + u_WR(q,L,b) -1.0)/(pow((u_WR(q,L,b)),2));
-
-    return (yy);
-}
-
-//
-static double
-Sexv(double q, double L, double b)
-{
-    double yy,C1,C2,C3,miu,Rg2;
-    C1=1.22;
-    C2=0.4288;
-    C3=-1.651;
-    miu = 0.585;
-
-    Rg2 = Rgsquare(q,L,b);
-
-    yy = (1.0 - w_WR(q*sqrt(Rg2)))*Sdebye(q,L,b) + w_WR(q*sqrt(Rg2))*(C1*pow((q*sqrt(Rg2)),(-1.0/miu)) +  C2*pow((q*sqrt(Rg2)),(-2.0/miu)) +    C3*pow((q*sqrt(Rg2)),(-3.0/miu)));
-
-    return (yy);
-}
-
-// this must be WR modified version
-static double
-Sexvnew(double q, double L, double b)
-{
-    double yy,C1,C2,C3,miu;
-    double del=1.05,C_star2,Rg2;
-
-    C1=1.22;
-    C2=0.4288;
-    C3=-1.651;
-    miu = 0.585;
-
-    //calculating the derivative to decide on the corection (cutoff) term?
-    // I have modified this from WRs original code
-
-    if( (Sexv(q*del,L,b)-Sexv(q,L,b))/(q*del - q) >= 0.0 ) {
-        C_star2 = 0.0;
-    } else {
-        C_star2 = 1.0;
-    }
-
-    Rg2 = Rgsquare(q,L,b);
-
-  yy = (1.0 - w_WR(q*sqrt(Rg2)))*Sdebye(q,L,b) + C_star2*w_WR(q*sqrt(Rg2))*(C1*pow((q*sqrt(Rg2)),(-1.0/miu)) + C2*pow((q*sqrt(Rg2)),(-2.0/miu)) + C3*pow((q*sqrt(Rg2)),(-3.0/miu)));
-
-    return (yy);
-}
-
-// these are the messy ones
-static double
-a2short(double q, double L, double b, double p1short, double p2short, double q0)
-{
-    double yy,Rg2_sh;
-    double t1,E,Rg2_sh2,Et1,Emt1,q02,q0p;
-    double pi;
-
-    E = 2.718281828459045091;
-  pi = 4.0*atan(1.0);
-    Rg2_sh = Rgsquareshort(q,L,b);
-    Rg2_sh2 = Rg2_sh*Rg2_sh;
-    t1 = ((q0*q0*Rg2_sh)/(b*b));
-    Et1 = pow(E,t1);
-    Emt1 =pow(E,-t1);
-    q02 = q0*q0;
-    q0p = pow(q0,(-4.0 + p2short) );
-
-    //E is the number e
-    yy = ((-(1.0/(L*((p1short - p2short))*Rg2_sh2)*((b*Emt1*q0p*((8.0*b*b*b*L - 8.0*b*b*b*Et1*L - 2.0*b*b*b*L*p1short + 2.0*b*b*b*Et1*L*p1short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 2.0*b*Et1*L*p1short*q02*Rg2_sh - Et1*pi*q02*q0*Rg2_sh2 + Et1*p1short*pi*q02*q0*Rg2_sh2)))))));
-
-    return (yy);
-}
-
-//
-static double
-a1short(double q, double L, double b, double p1short, double p2short, double q0)
-{
-    double yy,Rg2_sh;
-    double t1,E,Rg2_sh2,Et1,Emt1,q02,q0p,b3;
-  double pi;
-
-    E = 2.718281828459045091;
-  pi = 4.0*atan(1.0);
-    Rg2_sh = Rgsquareshort(q,L,b);
-    Rg2_sh2 = Rg2_sh*Rg2_sh;
-    b3 = b*b*b;
-    t1 = ((q0*q0*Rg2_sh)/(b*b));
-    Et1 = pow(E,t1);
-    Emt1 =pow(E,-t1);
-    q02 = q0*q0;
-    q0p = pow(q0,(-4.0 + p1short) );
-
-    yy = ((1.0/(L*((p1short - p2short))*Rg2_sh2)*((b*Emt1*q0p*((8.0*b3*L - 8.0*b3*Et1*L - 2.0*b3*L*p2short + 2.0*b3*Et1*L*p2short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 2.0*b*Et1*L*p2short*q02*Rg2_sh - Et1*pi*q02*q0*Rg2_sh2 + Et1*p2short*pi*q02*q0*Rg2_sh2))))));
-
-    return(yy);
-}
-
-
-//need to define this on my own
-static double
-sech_WR(double x)
-{
-  return(1/cosh(x));
-}
-
-// this one will be lots of trouble
-static double
-a2long(double q, double L, double b, double p1, double p2, double q0)
-{
-    double yy,C1,C2,C3,C4,C5,miu,C,Rg2;
-    double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,pi;
-    double E,b2,b3,b4,q02,q03,q04,q05,Rg22;
-
-    pi = 4.0*atan(1.0);
-    E = 2.718281828459045091;
-    if( L/b > 10.0) {
-        C = 3.06/pow((L/b),0.44);
-    } else {
-        C = 1.0;
-    }
-
-    C1 = 1.22;
-    C2 = 0.4288;
-    C3 = -1.651;
-    C4 = 1.523;
-    C5 = 0.1477;
-    miu = 0.585;
-
-    Rg2 = Rgsquare(q,L,b);
-    Rg22 = Rg2*Rg2;
-    b2 = b*b;
-    b3 = b*b*b;
-    b4 = b3*b;
-    q02 = q0*q0;
-    q03 = q0*q0*q0;
-    q04 = q03*q0;
-    q05 = q04*q0;
-
-    t1 = (1.0/(b* p1*pow(q0,((-1.0) - p1 - p2)) - b*p2*pow(q0,((-1.0) - p1 - p2)) ));
-
-    t2 = (b*C*(((-1.0*((14.0*b3)/(15.0*q03*Rg2))) + (14.0*b3*pow(E,(-((q02*Rg2)/b2))))/(15.0*q03*Rg2) + (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*((11.0/15.0 + (7*b2)/(15.0*q02*Rg2)))*Rg2)/b)))/L;
-
-    t3 = (sqrt(Rg2)*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2.0))/(2.0*C5);
-
-    t4 = (b4*sqrt(Rg2)*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2))/(C5*q04*Rg22);
-
-    t5 = (2.0*b4*(((2.0*q0*Rg2)/b - (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*Rg2)/b))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))/(q04*Rg22);
-
-    t6 = (8.0*b4*b*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))/(q05*Rg22);
-
-    t7 = (((-((3.0*C3*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 3.0/miu)))/miu)) - (2.0*C2*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 2.0/miu)))/miu - (C1*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 1.0/miu)))/miu));
-
-    t8 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)));
-
-    t9 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + (7.0*b2)/(15*q02*Rg2))) + (7.0*b2)/(15.0*q02*Rg2))))/L;
-
-    t10 = (2.0*b4*(((-1) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))/(q04*Rg22);
-
-
-    yy = ((-1.0*(t1* ((-pow(q0,-p1)*(((b2*pi)/(L*q02) + t2 + t3 - t4 + t5 - t6 + 1.0/2.0*t7*t8)) - b*p1*pow(q0,((-1.0) - p1))*(((-((b*pi)/(L*q0))) + t9 + t10 + 1.0/2.0*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))*((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))))));
-
-    return (yy);
-}
-//
-static double
-a1long(double q, double L, double b, double p1, double p2, double q0)
-{
-    double yy,C,C1,C2,C3,C4,C5,miu,Rg2;
-    double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15;
-    double E,pi;
-    double b2,b3,b4,q02,q03,q04,q05,Rg22;
-
-    pi = 4.0*atan(1.0);
-    E = 2.718281828459045091;
-
-    if( L/b > 10.0) {
-        C = 3.06/pow((L/b),0.44);
-    } else {
-        C = 1.0;
-    }
-
-    C1 = 1.22;
-    C2 = 0.4288;
-    C3 = -1.651;
-    C4 = 1.523;
-    C5 = 0.1477;
-    miu = 0.585;
-
-    Rg2 = Rgsquare(q,L,b);
-    Rg22 = Rg2*Rg2;
-    b2 = b*b;
-    b3 = b*b*b;
-    b4 = b3*b;
-    q02 = q0*q0;
-    q03 = q0*q0*q0;
-    q04 = q03*q0;
-    q05 = q04*q0;
-
-    t1 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + (7.0*b2)/(15.0*q02*Rg2))) + (7.0*b2)/(15.0*q02*Rg2))));
-
-    t2 = (2.0*b4*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))));
-
-    t3 = ((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))));
-
-    t4 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)));
-
-    t5 = (1.0/(b*p1*pow(q0,((-1.0) - p1 - p2)) - b*p2*pow(q0,((-1.0) - p1 - p2))));
-
-    t6 = (b*C*(((-((14.0*b3)/(15.0*q03*Rg2))) + (14.0*b3*pow(E,(-((q02*Rg2)/b2))))/(15.0*q03*Rg2) + (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*((11.0/15.0 + (7.0*b2)/(15.0*q02*Rg2)))*Rg2)/b)));
-
-    t7 = (sqrt(Rg2)*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2));
-
-    t8 = (b4*sqrt(Rg2)*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2));
-
-    t9 = (2.0*b4*(((2.0*q0*Rg2)/b - (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*Rg2)/b))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))));
-
-    t10 = (8.0*b4*b*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))));
-
-    t11 = (((-((3.0*C3*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 3.0/miu)))/miu)) - (2.0*C2*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 2.0/miu)))/miu - (C1*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 1.0/miu)))/miu));
-
-    t12 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)));
-
-    t13 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + (7.0*b2)/(15.0*q02* Rg2))) + (7.0*b2)/(15.0*q02*Rg2))));
-
-    t14 = (2.0*b4*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))));
-
-    t15 = ((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))));
-
-
-    yy = (pow(q0,p1)*(((-((b*pi)/(L*q0))) +t1/L +t2/(q04*Rg22) + 1.0/2.0*t3*t4)) + (t5*((pow(q0,(p1 - p2))*(((-pow(q0,(-p1)))*(((b2*pi)/(L*q02) +t6/L +t7/(2.0*C5) -t8/(C5*q04*Rg22) +t9/(q04*Rg22) -t10/(q05*Rg22) + 1.0/2.0*t11*t12)) - b*p1*pow(q0,((-1.0) - p1))*(((-((b*pi)/(L*q0))) +t13/L +t14/(q04*Rg22) + 1.0/2.0*t15*((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))))))));
-
-    return (yy);
-}
-
-
-static double
-Sk_WR(double q, double L, double b)
-{
-  //
-  double p1,p2,p1short,p2short,q0;
-  double C,ans,q0short,Sexvmodify,pi;
-
-  pi = 4.0*atan(1.0);
-
-  p1 = 4.12;
-  p2 = 4.42;
-  p1short = 5.36;
-  p2short = 5.62;
-  q0 = 3.1;
-  //
-  q0short = fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0);
-
-  //
-  if(L/b > 10.0) {
-    C = 3.06/pow((L/b),0.44);
-  } else {
-    C = 1.0;
-  }
-  //
-
-  if( L > 4*b ) { // Longer Chains
-    if (q*b <= 3.1) {   //Modified by Yun on Oct. 15,
-      Sexvmodify = Sexvnew(q, L, b);
-      ans = Sexvmodify + C * (4.0/15.0 + 7.0/(15.0*u_WR(q,L,b)) - (11.0/15.0 + 7.0/(15.0*u_WR(q,L,b)))*exp(-u_WR(q,L,b)))*(b/L);
-    } else { //q(i)*b > 3.1
-      ans = a1long(q, L, b, p1, p2, q0)/(pow((q*b),p1)) + a2long(q, L, b, p1, p2, q0)/(pow((q*b),p2)) + pi/(q*L);
-    }
-  } else { //L <= 4*b Shorter Chains
-    if (q*b <= fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0) ) {
-      if (q*b<=0.01) {
-        ans = 1.0 - Rgsquareshort(q,L,b)*(q*q)/3.0;
-      } else {
-        ans = Sdebye1(q,L,b);
-      }
-    } else {  //q*b > max(1.9/sqrt(Rgsquareshort(q(i),L,b)),3)
-      ans = a1short(q,L,b,p1short,p2short,q0short)/(pow((q*b),p1short)) + a2short(q,L,b,p1short,p2short,q0short)/(pow((q*b),p2short)) + pi/(q*L);
-    }
-  }
-
-  return(ans);
-  //return(a2long(q, L, b, p1, p2, q0));
-}
-
-/*	CylinderForm  :  calculates the form factor of a cylinder at the give x-value p->x
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-CylinderForm(double dp[], double q)
-{
-
-	int i;
-	double Pi;
-	double scale,radius,length,delrho,bkg,halfheight,sldCyl,sldSolv;		//local variables of coefficient wave
-	int nord=76;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,vcyl;			//running tally of integration
-	
-	Pi = 4.0*atan(1.0);
-	lolim = 0.0;
-	uplim = Pi/2.0;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	radius = dp[1];
-	length = dp[2];
-	sldCyl = dp[3];
-	sldSolv = dp[4];
-	bkg = dp[5];
-	
-	delrho = sldCyl-sldSolv;
-	halfheight = length/2.0;
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * CylKernel(q, radius, halfheight, zi);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by cylinder volume
-	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-	vcyl=Pi*radius*radius*length;
-	answer *= vcyl;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	EllipCyl76X  :  calculates the form factor of a elliptical cylinder at the given x-value p->x
-
-Uses 76 pt Gaussian quadrature for both integrals
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-EllipCyl76(double dp[], double q)
-{
-	int i,j;
-	double Pi,slde,sld;
-	double scale,ra,nu,length,delrho,bkg;		//local variables of coefficient wave
-	int nord=76;			//order of integration
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer,vell;			//running tally of integration
-	double summj,vaj,vbj,zij,arg, si;			//for the inner integration
-
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//orintational average, outer integral
-	vaj=0.0;
-	vbj=Pi;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	ra = dp[1];
-	nu = dp[2];
-	length = dp[3];
-	slde = dp[4];
-	sld = dp[5];
-	delrho = slde - sld;
-	bkg = dp[6];
-	
-	for(i=0;i<nord;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "x" dummy
-		arg = ra*sqrt(1.0-zi*zi);
-		for(j=0;j<nord;j++) {
-			//76 gauss points for the inner integral as well
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "y" dummy
-			yyy = Gauss76Wt[j] * EllipCylKernel(q,arg,nu,zij);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		//divide integral by Pi
-		answer /=Pi;
-		
-		//now calculate outer integral
-		arg = q*length*zi/2.0;
-		if (arg == 0.0){
-			si = 1.0;
-		}else{
-			si = sin(arg) * sin(arg) / arg / arg;
-		}
-		yyy = Gauss76Wt[i] * answer * si;
-		summ += yyy;
-	}
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by cylinder volume
-	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-	vell = Pi*ra*(nu*ra)*length;
-	answer *= vell;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	EllipCyl20X  :  calculates the form factor of a elliptical cylinder at the given x-value p->x
-
-Uses 76 pt Gaussian quadrature for orientational integral
-Uses 20 pt quadrature for the inner integral over the elliptical cross-section
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-EllipCyl20(double dp[], double q)
-{
-	int i,j;
-	double Pi,slde,sld;
-	double scale,ra,nu,length,delrho,bkg;		//local variables of coefficient wave
-	int nordi=76;			//order of integration
-	int nordj=20;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer,vell;			//running tally of integration
-	double summj,vaj,vbj,zij,arg,si;			//for the inner integration
-
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//orintational average, outer integral
-	vaj=0.0;
-	vbj=Pi;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	ra = dp[1];
-	nu = dp[2];
-	length = dp[3];
-	slde = dp[4];
-	sld = dp[5];
-	delrho = slde - sld;
-	bkg = dp[6];
-	
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "x" dummy
-		arg = ra*sqrt(1.0-zi*zi);
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss20Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "y" dummy
-			yyy = Gauss20Wt[j] * EllipCylKernel(q,arg,nu,zij);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		//divide integral by Pi
-		answer /=Pi;
-		
-		//now calculate outer integral
-		arg = q*length*zi/2.0;
-		if (arg == 0.0){
-			si = 1.0;
-		}else{
-			si = sin(arg) * sin(arg) / arg / arg;
-		}
-		yyy = Gauss76Wt[i] * answer * si;
-		summ += yyy;
-	}
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by cylinder volume
-	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-	vell = Pi*ra*(nu*ra)*length;
-	answer *= vell;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-
-	return answer;
-}
-
-/*	TriaxialEllipsoidX  :  calculates the form factor of a Triaxial Ellipsoid at the given x-value p->x
-
-Uses 76 pt Gaussian quadrature for both integrals
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-TriaxialEllipsoid(double dp[], double q)
-{
-	int i,j;
-	double Pi;
-	double scale,aa,bb,cc,delrho,bkg;		//local variables of coefficient wave
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij,slde,sld;			//for the inner integration
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//orintational average, outer integral
-	vaj = 0.0;
-	vbj = 1.0;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	aa = dp[1];
-	bb = dp[2];
-	cc = dp[3];
-	slde = dp[4];
-	sld = dp[5];
-	delrho = slde - sld;
-	bkg = dp[6];
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "x" dummy
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "y" dummy
-			yyy = Gauss76Wt[j] * TriaxialKernel(q,aa,bb,cc,zi,zij);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		
-		//now calculate outer integral
-		yyy = Gauss76Wt[i] * answer;
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by ellipsoid volume
-	answer *= 4.0*Pi/3.0*aa*bb*cc;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	ParallelepipedX  :  calculates the form factor of a Parallelepiped (a rectangular solid)
-at the given x-value p->x
-
-Uses 76 pt Gaussian quadrature for both integrals
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-Parallelepiped(double dp[], double q)
-{
-	int i,j;
-	double scale,aa,bb,cc,delrho,bkg;		//local variables of coefficient wave
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj;			//for the inner integration
-	double mu,mudum,arg,sigma,uu,vol,sldp,sld;
-	
-	
-	//	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//orintational average, outer integral
-	vaj = 0.0;
-	vbj = 1.0;		//endpoints of inner integral
-
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	aa = dp[1];
-	bb = dp[2];
-	cc = dp[3];
-	sldp = dp[4];
-	sld = dp[5];
-	delrho = sldp - sld;
-	bkg = dp[6];
-	
-	mu = q*bb;
-	vol = aa*bb*cc;
-	// normalize all WRT bb
-	aa = aa/bb;
-	cc = cc/bb;
-	
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		sigma = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the outer dummy
-		
-		for(j=0;j<nordj;j++) {
-			//76 gauss points for the inner integral
-			uu = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the inner dummy
-			mudum = mu*sqrt(1.0-sigma*sigma);
-			yyy = Gauss76Wt[j] * PPKernel(aa,mudum,uu);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-
-		arg = mu*cc*sigma/2.0;
-		if ( arg == 0.0 ) {
-			answer *= 1.0;
-		} else {
-			answer *= sin(arg)*sin(arg)/arg/arg;
-		}
-		
-		//now sum up the outer integral
-		yyy = Gauss76Wt[i] * answer;
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by volume
-	answer *= vol;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	HollowCylinderX  :  calculates the form factor of a Hollow Cylinder
-at the given x-value p->x
-
-Uses 76 pt Gaussian quadrature for the single integral
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-HollowCylinder(double dp[], double q)
-{
-	int i;
-	double scale,rcore,rshell,length,delrho,bkg;		//local variables of coefficient wave
-	int nord=76;			//order of integration
-	double va,vb,zi;		//upper and lower integration limits
-	double summ,answer,pi,sldc,sld;			//running tally of integration
-	
-	pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//limits of numerical integral
-
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];		//make local copies in case memory moves
-	rcore = dp[1];
-	rshell = dp[2];
-	length = dp[3];
-	sldc = dp[4];
-	sld = dp[5];
-	delrho = sldc - sld;
-	bkg = dp[6];
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;
-		summ += Gauss76Wt[i] * HolCylKernel(q, rcore, rshell, length, zi);
-	}
- 	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by volume
-	answer *= pi*(rshell*rshell-rcore*rcore)*length;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	EllipsoidFormX  :  calculates the form factor of an ellipsoid of revolution with semiaxes a:a:nua
-at the given x-value p->x
-
-Uses 76 pt Gaussian quadrature for the single integral
-
-Warning:
-The call to WaveData() below returns a pointer to the middle
-of an unlocked Macintosh handle. In the unlikely event that your
-calculations could cause memory to move, you should copy the coefficient
-values to local variables or an array before such operations.
-*/
-double
-EllipsoidForm(double dp[], double q)
-{
-	int i;
-	double scale,a,nua,delrho,bkg;		//local variables of coefficient wave
-	int nord=76;			//order of integration
-	double va,vb,zi;		//upper and lower integration limits
-	double summ,answer,pi,slde,sld;			//running tally of integration
-	
-	pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//limits of numerical integral
-
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	nua = dp[1];
-	a = dp[2];
-	slde = dp[3];
-	sld = dp[4];
-	delrho = slde - sld;
-	bkg = dp[5];
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;
-		summ += Gauss76Wt[i] * EllipsoidKernel(q, a, nua, zi);
-	}
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= delrho*delrho;
-	//normalize by volume
-	answer *= 4.0*pi/3.0*a*a*nua;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-
-/*	Cyl_PolyRadiusX  :  calculates the form factor of a cylinder at the given x-value p->x
-the cylinder has a polydisperse cross section
-
-*/
-double
-Cyl_PolyRadius(double dp[], double q)
-{
-	int i;
-	double scale,radius,length,pd,delrho,bkg;		//local variables of coefficient wave
-	int nord=20;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,Vpoly;			//running tally of integration
-	double range,zz,Pi,sldc,sld;
-	
-	Pi = 4.0*atan(1.0);
-	range = 3.4;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	radius = dp[1];
-	length = dp[2];
-	pd = dp[3];
-	sldc = dp[4];
-	sld = dp[5];
-	delrho = sldc - sld;
-	bkg = dp[6];
-	
-	zz = (1.0/pd)*(1.0/pd) - 1.0;
-	
-	lolim = radius*(1.0-range*pd);		//set the upper/lower limits to cover the distribution
-	if(lolim<0.0) {
-		lolim = 0.0;
-	}
-	if(pd>0.3) {
-		range = 3.4 + (pd-0.3)*18.0;
-	}
-	uplim = radius*(1.0+range*pd);
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss20Wt[i] * Cyl_PolyRadKernel(q, radius, length, zz, delrho, zi);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	//normalize by average cylinder volume
-	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-	Vpoly=Pi*radius*radius*length*(zz+2.0)/(zz+1.0);
-	answer /= Vpoly;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	Cyl_PolyLengthX  :  calculates the form factor of a cylinder at the given x-value p->x
-the cylinder has a polydisperse Length
-
-*/
-double
-Cyl_PolyLength(double dp[], double q)
-{
-	int i;
-	double scale,radius,length,pd,delrho,bkg;		//local variables of coefficient wave
-	int nord=20;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,Vpoly;			//running tally of integration
-	double range,zz,Pi,sldc,sld;
-	
-	
-	Pi = 4.0*atan(1.0);
-	range = 3.4;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	radius = dp[1];
-	length = dp[2];
-	pd = dp[3];
-	sldc = dp[4];
-	sld = dp[5];
-	delrho = sldc - sld;
-	bkg = dp[6];
-	
-	zz = (1.0/pd)*(1.0/pd) - 1.0;
-	
-	lolim = length*(1.0-range*pd);		//set the upper/lower limits to cover the distribution
-	if(lolim<0.0) {
-		lolim = 0.0;
-	}
-	if(pd>0.3) {
-		range = 3.4 + (pd-0.3)*18.0;
-	}
-	uplim = length*(1.0+range*pd);
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss20Wt[i] * Cyl_PolyLenKernel(q, radius, length, zz, delrho, zi);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	//normalize by average cylinder volume (first moment)
-	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-	Vpoly=Pi*radius*radius*length;
-	answer /= Vpoly;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	CoreShellCylinderX  :  calculates the form factor of a cylinder at the given x-value p->x
-the cylinder has a core-shell structure
-
-*/
-double
-CoreShellCylinder(double dp[], double q)
-{
-	int i;
-	double scale,rcore,length,bkg;		//local variables of coefficient wave
-	double thick,rhoc,rhos,rhosolv;
-	int nord=76;			//order of integration
-	double uplim,lolim,halfheight;		//upper and lower integration limits
-	double summ,zi,yyy,answer,Vcyl;			//running tally of integration
-	double Pi;
-	
-	Pi = 4.0*atan(1.0);
-	
-	lolim = 0.0;
-	uplim = Pi/2.0;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];		//make local copies in case memory moves
-	rcore = dp[1];
-	thick = dp[2];
-	length = dp[3];
-	rhoc = dp[4];
-	rhos = dp[5];
-	rhosolv = dp[6];
-	bkg = dp[7];
-	
-	halfheight = length/2.0;
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * CoreShellCylKernel(q, rcore, thick, rhoc,rhos,rhosolv, halfheight, zi);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	// length is the total core length 
-	Vcyl=Pi*(rcore+thick)*(rcore+thick)*(length+2.0*thick);
-	answer /= Vcyl;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-
-/*	PolyCoShCylinderX  :  calculates the form factor of a core-shell cylinder at the given x-value p->x
-the cylinder has a polydisperse CORE radius
-
-*/
-double
-PolyCoShCylinder(double dp[], double q)
-{
-	int i;
-	double scale,radius,length,sigma,bkg;		//local variables of coefficient wave
-	double rad,radthick,facthick,rhoc,rhos,rhosolv;
-	int nord=20;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,yyy,answer,Vpoly;			//running tally of integration
-	double Pi,AR,Rsqrsumm,Rsqryyy,Rsqr;
-		
-	Pi = 4.0*atan(1.0);
-	
-	summ = 0.0;			//initialize intergral
-	Rsqrsumm = 0.0;
-	
-	scale = dp[0];
-	radius = dp[1];
-	sigma = dp[2];				//sigma is the standard mean deviation
-	length = dp[3];
-	radthick = dp[4];
-	facthick= dp[5];
-	rhoc = dp[6];
-	rhos = dp[7];
-	rhosolv = dp[8];
-	bkg = dp[9];
-	
-	lolim = exp(log(radius)-(4.*sigma));
-	if (lolim<0.0) {
-		lolim=0.0;		//to avoid numerical error when  va<0 (-ve r value)
-	}
-	uplim = exp(log(radius)+(4.*sigma));
-	
-	for(i=0;i<nord;i++) {
-		rad = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		AR=(1.0/(rad*sigma*sqrt(2.0*Pi)))*exp(-(0.5*((log(radius/rad))/sigma)*((log(radius/rad))/sigma)));
-		yyy = AR* Gauss20Wt[i] * CSCylIntegration(q,rad,radthick,facthick,rhoc,rhos,rhosolv,length);
-		Rsqryyy= Gauss20Wt[i] * AR * (rad+radthick)*(rad+radthick);		//SRK normalize to total dimensions
-		summ += yyy;
-		Rsqrsumm += Rsqryyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	Rsqr = (uplim-lolim)/2.0*Rsqrsumm;
-	//normalize by average cylinder volume
-	Vpoly = Pi*Rsqr*(length+2*facthick);
-	answer /= Vpoly;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	OblateFormX  :  calculates the form factor of a core-shell Oblate ellipsoid at the given x-value p->x
-the ellipsoid has a core-shell structure
-
-*/
-double
-OblateForm(double dp[], double q)
-{
-	int i;
-	double scale,crmaj,crmin,trmaj,trmin,delpc,delps,bkg;
-	int nord=76;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,oblatevol;			//running tally of integration
-	double Pi,sldc,slds,sld;
-	
-	Pi = 4.0*atan(1.0);
-	
-	lolim = 0.0;
-	uplim = 1.0;
-	
-	summ = 0.0;			//initialize intergral
-	
-	
-	scale = dp[0];		//make local copies in case memory moves
-	crmaj = dp[1];
-	crmin = dp[2];
-	trmaj = dp[3];
-	trmin = dp[4];
-	sldc = dp[5];
-	slds = dp[6];
-	sld = dp[7];
-	delpc = sldc - slds;	//core - shell
-	delps = slds - sld;		//shell - solvent
-	bkg = dp[8];
-
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * gfn4(zi,crmaj,crmin,trmaj,trmin,delpc,delps,q);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	// normalize by particle volume
-	oblatevol = 4.0*Pi/3.0*trmaj*trmaj*trmin;
-	answer /= oblatevol;
-	
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	ProlateFormX  :  calculates the form factor of a core-shell Prolate ellipsoid at the given x-value p->x
-the ellipsoid has a core-shell structure
-
-*/
-double
-ProlateForm(double dp[], double q)
-{
-	int i;
-	double scale,crmaj,crmin,trmaj,trmin,delpc,delps,bkg;
-	int nord=76;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,prolatevol;			//running tally of integration
-	double Pi,sldc,slds,sld;
-	
-	Pi = 4.0*atan(1.0);
-	
-	lolim = 0.0;
-	uplim = 1.0;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];		//make local copies in case memory moves
-	crmaj = dp[1];
-	crmin = dp[2];
-	trmaj = dp[3];
-	trmin = dp[4];
-	sldc = dp[5];
-	slds = dp[6];
-	sld = dp[7];
-	delpc = sldc - slds;		//core - shell
-	delps = slds - sld;		//shell  - sovent
-	bkg = dp[8];
-
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * gfn2(zi,crmaj,crmin,trmaj,trmin,delpc,delps,q);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	// normalize by particle volume
-	prolatevol = 4.0*Pi/3.0*trmaj*trmin*trmin;
-	answer /= prolatevol;
-	
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-
-/*	StackedDiscsX  :  calculates the form factor of a stacked "tactoid" of core shell disks
-like clay platelets that are not exfoliated
-
-*/
-double
-StackedDiscs(double dp[], double q)
-{
-	int i;
-	double scale,length,bkg,rcore,thick,rhoc,rhol,rhosolv,N,gsd;		//local variables of coefficient wave
-	double va,vb,vcyl,summ,yyy,zi,halfheight,d,answer;
-	int nord=76;			//order of integration
-	double Pi;
-	
-	
-	Pi = 4.0*atan(1.0);
-	
-	va = 0.0;
-	vb = Pi/2.0;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];
-	rcore = dp[1];
-	length = dp[2];
-	thick = dp[3];
-	rhoc = dp[4];
-	rhol = dp[5];
-	rhosolv = dp[6];
-	N = dp[7];
-	gsd = dp[8];
-	bkg = dp[9];
-	
-	d=2.0*thick+length;
-	halfheight = length/2.0;
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(vb-va) + vb + va )/2.0;
-		yyy = Gauss76Wt[i] * Stackdisc_kern(q, rcore, rhoc,rhol,rhosolv, halfheight,thick,zi,gsd,d,N);
-		summ += yyy;
-	}
-	
-	answer = (vb-va)/2.0*summ;
-	// length is the total core length 
-	vcyl=Pi*rcore*rcore*(2.0*thick+length)*N;
-	answer /= vcyl;
-	//Convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-
-/*	LamellarFFX  :  calculates the form factor of a lamellar structure - no S(q) effects included
-
-*/
-double
-LamellarFF(double dp[], double q)
-{
-	double scale,del,sig,contr,bkg;		//local variables of coefficient wave
-	double inten, qval,Pq;
-	double Pi,sldb,sld;
-	
-	
-	Pi = 4.0*atan(1.0);
-	scale = dp[0];
-	del = dp[1];
-	sig = dp[2]*del;
-	sldb = dp[3];
-	sld = dp[4];
-	contr = sldb - sld;
-	bkg = dp[5];
-	qval=q;
-	
-	Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)*exp(-0.5*qval*qval*sig*sig));
-	
-	inten = 2.0*Pi*scale*Pq/(qval*qval);		//this is now dimensionless...
-	
-	inten /= del;			//normalize by the thickness (in A)
-	
-	inten *= 1.0e8;		// 1/A to 1/cm
-	
-	return(inten+bkg);
-}
-
-/*	LamellarPSX  :  calculates the form factor of a lamellar structure - with S(q) effects included
---- now the proper resolution effects are used - the "default" resolution is turned off (= 0) and the
-model is smeared just like any other function
-*/
-double
-LamellarPS(double dp[], double q)
-{
-	double scale,dd,del,sig,contr,NN,Cp,bkg;		//local variables of coefficient wave
-	double inten,qval,Pq,Sq,alpha,temp,t1,t2,t3,dQ;
-	double Pi,Euler,dQDefault,fii,sldb,sld;
-	int ii,NNint;
-//	char buf[256];
-
-	
-	Euler = 0.5772156649;		// Euler's constant
-//	dQDefault = 0.0025;		//[=] 1/A, q-resolution, default value
-	dQDefault = 0.0;
-	dQ = dQDefault;
-	
-	Pi = 4.0*atan(1.0);
-	qval = q;
-	
-	scale = dp[0];
-	dd = dp[1];
-	del = dp[2];
-	sig = dp[3]*del;
-	sldb = dp[4];
-	sld = dp[5];
-	contr = sldb - sld;
-	NN = trunc(dp[6]);		//be sure that NN is an integer
-	Cp = dp[7];
-	bkg = dp[8];
-	
-	Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)*exp(-0.5*qval*qval*sig*sig));
-	
-	NNint = (int)NN;		//cast to an integer for the loop
-	
-//	sprintf(buf, "qval = %g\r", qval);
-//	XOPNotice(buf);
-	
-	ii=0;
-	Sq = 0.0;
-	for(ii=1;ii<(NNint-1);ii+=1) {
-        
-		fii = (double)ii;		//do I really need to do this?
-		
-		temp = 0.0;
-		alpha = Cp/4.0/Pi/Pi*(log(Pi*fii) + Euler);
-		t1 = 2.0*dQ*dQ*dd*dd*alpha;
-		t2 = 2.0*qval*qval*dd*dd*alpha;
-		t3 = dQ*dQ*dd*dd*fii*fii;
-		
-		temp = 1.0-fii/NN;
-		temp *= cos(dd*qval*fii/(1.0+t1));
-		temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
-		temp /= sqrt(1.0+t1);
-		
-		Sq += temp;
-	}
-	
-	Sq *= 2.0;
-	Sq += 1.0;
-	
-	inten = 2.0*Pi*scale*Pq*Sq/(dd*qval*qval);
-	
-	inten *= 1.0e8;		// 1/A to 1/cm
-	
-    return(inten+bkg);
-}
-
-
-/*	LamellarPS_HGX  :  calculates the form factor of a lamellar structure - with S(q) effects included
---- now the proper resolution effects are used - the "default" resolution is turned off (= 0) and the
-model is smeared just like any other function
-*/
-double
-LamellarPS_HG(double dp[], double q)
-{
-	double scale,dd,delT,delH,SLD_T,SLD_H,SLD_S,NN,Cp,bkg;		//local variables of coefficient wave
-	double inten,qval,Pq,Sq,alpha,temp,t1,t2,t3,dQ,drh,drt;
-	double Pi,Euler,dQDefault,fii;
-	int ii,NNint;
-	
-	
-	Euler = 0.5772156649;		// Euler's constant
-//	dQDefault = 0.0025;		//[=] 1/A, q-resolution, default value
-	dQDefault = 0.0;
-	dQ = dQDefault;
-	
-	Pi = 4.0*atan(1.0);
-	qval= q;
-	
-	scale = dp[0];
-	dd = dp[1];
-	delT = dp[2];
-	delH = dp[3];
-	SLD_T = dp[4];
-	SLD_H = dp[5];
-	SLD_S = dp[6];
-	NN = trunc(dp[7]);		//be sure that NN is an integer
-	Cp = dp[8];
-	bkg = dp[9];
-	
-	
-	drh = SLD_H - SLD_S;
-	drt = SLD_T - SLD_S;	//correction 13FEB06 by L.Porcar
-	
-	Pq = drh*(sin(qval*(delH+delT))-sin(qval*delT)) + drt*sin(qval*delT);
-	Pq *= Pq;
-	Pq *= 4.0/(qval*qval);
-	
-	NNint = (int)NN;		//cast to an integer for the loop
-	ii=0;
-	Sq = 0.0;
-	for(ii=1;ii<(NNint-1);ii+=1) {
-        
-		fii = (double)ii;		//do I really need to do this?
-		
-		temp = 0.0;
-		alpha = Cp/4.0/Pi/Pi*(log(Pi*ii) + Euler);
-		t1 = 2.0*dQ*dQ*dd*dd*alpha;
-		t2 = 2.0*qval*qval*dd*dd*alpha;
-		t3 = dQ*dQ*dd*dd*ii*ii;
-		
-		temp = 1.0-ii/NN;
-		temp *= cos(dd*qval*ii/(1.0+t1));
-		temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
-		temp /= sqrt(1.0+t1);
-		
-		Sq += temp;
-	}
-	
-	Sq *= 2.0;
-	Sq += 1.0;
-	
-	inten = 2.0*Pi*scale*Pq*Sq/(dd*qval*qval);
-	
-	inten *= 1.0e8;		// 1/A to 1/cm
-	
-	return(inten+bkg);
-}
-
-/*	LamellarFF_HGX  :  calculates the form factor of a lamellar structure - no S(q) effects included
-but extra SLD for head groups is included
-
-*/
-double
-LamellarFF_HG(double dp[], double q)
-{
-	double scale,delT,delH,slds,sldh,sldt,bkg;		//local variables of coefficient wave
-	double inten, qval,Pq,drh,drt;
-	double Pi;
-	
-	
-	Pi = 4.0*atan(1.0);
-	qval= q;
-	scale = dp[0];
-	delT = dp[1];
-	delH = dp[2];
-	sldt = dp[3];
-	sldh = dp[4];
-	slds = dp[5];
-	bkg = dp[6];
-	
-	
-	drh = sldh - slds;
-	drt = sldt - slds;		//correction 13FEB06 by L.Porcar
-	
-	Pq = drh*(sin(qval*(delH+delT))-sin(qval*delT)) + drt*sin(qval*delT);
-	Pq *= Pq;
-	Pq *= 4.0/(qval*qval);
-	
-	inten = 2.0*Pi*scale*Pq/(qval*qval);		//dimensionless...
-	
-	inten /= 2.0*(delT+delH);			//normalize by the bilayer thickness
-	
-	inten *= 1.0e8;		// 1/A to 1/cm
-	
-	return(inten+bkg);
-}
-
-/*	FlexExclVolCylX  :  calculates the form factor of a flexible cylinder with a circular cross section
--- incorporates Wei-Ren Chen's fixes - 2006
-
-	*/
-double
-FlexExclVolCyl(double dp[], double q)
-{
-	double scale,L,B,bkg,rad,qr,cont,sldc,slds;
-	double Pi,flex,crossSect,answer;
-	
-	
-	Pi = 4.0*atan(1.0);
-	
-	scale = dp[0];		//make local copies in case memory moves
-	L = dp[1];
-	B = dp[2];
-	rad = dp[3];
-	sldc = dp[4];
-	slds = dp[5];
-	cont = sldc-slds;
-	bkg = dp[6];
-	
-    
-	qr = q*rad;
-	
-	flex = Sk_WR(q,L,B);
-	
-	crossSect = (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr);
-	flex *= crossSect;
-	flex *= Pi*rad*rad*L;
-	flex *= cont*cont;
-	flex *= 1.0e8;
-	answer = scale*flex + bkg;
-	
-	return answer;
-}
-
-/*	FlexCyl_EllipX  :  calculates the form factor of a flexible cylinder with an elliptical cross section
--- incorporates Wei-Ren Chen's fixes - 2006
-
-	*/
-double
-FlexCyl_Ellip(double dp[], double q)
-{
-	double scale,L,B,bkg,rad,qr,cont,ellRatio,slds,sldc;
-	double Pi,flex,crossSect,answer;
-	
-	
-	Pi = 4.0*atan(1.0);
-	scale = dp[0];		//make local copies in case memory moves
-	L = dp[1];
-	B = dp[2];
-	rad = dp[3];
-	ellRatio = dp[4];
-	sldc = dp[5];
-	slds = dp[6];
-	bkg = dp[7];
-	
-	cont = sldc - slds;
-	qr = q*rad;
-	
-	flex = Sk_WR(q,L,B);
-	
-	crossSect = EllipticalCross_fn(q,rad,(rad*ellRatio));
-	flex *= crossSect;
-	flex *= Pi*rad*rad*ellRatio*L;
-	flex *= cont*cont;
-	flex *= 1.0e8;
-	answer = scale*flex + bkg;
-	
-	return answer;
-}
-
-double
-EllipticalCross_fn(double qq, double a, double b)
-{
-    double uplim,lolim,Pi,summ,arg,zi,yyy,answer;
-    int i,nord=76;
-    
-    Pi = 4.0*atan(1.0);
-    lolim=0.0;
-    uplim=Pi/2.0;
-    summ=0.0;
-    
-    for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		arg = qq*sqrt(a*a*sin(zi)*sin(zi)+b*b*cos(zi)*cos(zi));
-		yyy = pow((2.0 * NR_BessJ1(arg) / arg),2);
-		yyy *= Gauss76Wt[i];
-		summ += yyy;
-    }
-    answer = (uplim-lolim)/2.0*summ;
-    answer *= 2.0/Pi;
-    return(answer);
-	
-}
-/*	FlexCyl_PolyLenX  :  calculates the form factor of a flecible cylinder at the given x-value p->x
-the cylinder has a polydisperse Length
-
-*/
-double
-FlexCyl_PolyLen(double dp[], double q)
-{
-	int i;
-	double scale,radius,length,pd,bkg,lb,delrho,sldc,slds;		//local variables of coefficient wave
-	int nord=20;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,Vpoly;			//running tally of integration
-	double range,zz,Pi;
-	
-	Pi = 4.0*atan(1.0);
-	range = 3.4;
-	
-	summ = 0.0;			//initialize intergral
-	scale = dp[0];			//make local copies in case memory moves
-	length = dp[1];			//radius
-	pd = dp[2];			// average length
-	lb = dp[3];
-	radius = dp[4];
-	sldc = dp[5];
-	slds = dp[6];
-	bkg = dp[7];
-	
-	delrho = sldc - slds;
-	zz = (1.0/pd)*(1.0/pd) - 1.0;
-	
-	lolim = length*(1.0-range*pd);		//set the upper/lower limits to cover the distribution
-	if(lolim<0.0) {
-		lolim = 0.0;
-	}
-	if(pd>0.3) {
-		range = 3.4 + (pd-0.3)*18.0;
-	}
-	uplim = length*(1.0+range*pd);
-	
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss20Wt[i] * FlePolyLen_kernel(q,radius,length,lb,zz,delrho,zi);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	//normalize by average cylinder volume (first moment), using the average length
-	Vpoly=Pi*radius*radius*length;
-	answer /= Vpoly;
-	
-	answer *=delrho*delrho;
-	
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-/*	FlexCyl_PolyLenX  :  calculates the form factor of a flexible cylinder at the given x-value p->x
-the cylinder has a polydisperse cross sectional radius
-
-*/
-double
-FlexCyl_PolyRad(double dp[], double q)
-{
-	int i;
-	double scale,radius,length,pd,delrho,bkg,lb,sldc,slds;		//local variables of coefficient wave
-	int nord=76;			//order of integration
-	double uplim,lolim;		//upper and lower integration limits
-	double summ,zi,yyy,answer,Vpoly;			//running tally of integration
-	double range,zz,Pi;
-	
-	
-	Pi = 4.0*atan(1.0);
-	range = 3.4;
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];			//make local copies in case memory moves
-	length = dp[1];			//radius
-	lb = dp[2];			// average length
-	radius = dp[3];
-	pd = dp[4];
-	sldc = dp[5];
-	slds = dp[6];
-	bkg = dp[7];
-	
-	delrho = sldc-slds;
-	zz = (1.0/pd)*(1.0/pd) - 1.0;
-	
-	lolim = radius*(1.0-range*pd);		//set the upper/lower limits to cover the distribution
-	if(lolim<0.0) {
-		lolim = 0.0;
-	}
-	if(pd>0.3) {
-		range = 3.4 + (pd-0.3)*18.0;
-	}
-	uplim = radius*(1.0+range*pd);
-	
-	for(i=0;i<nord;i++) {
-		//zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		//yyy = Gauss20Wt[i] * FlePolyRad_kernel(q,radius,length,lb,zz,delrho,zi);
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * FlePolyRad_kernel(q,radius,length,lb,zz,delrho,zi);
-		summ += yyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	//normalize by average cylinder volume (second moment), using the average radius
-	Vpoly = Pi*radius*radius*length*(zz+2.0)/(zz+1.0);
-	answer /= Vpoly;
-	
-	answer *=delrho*delrho;
-	
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
-
-
-///////////////
-
-//
-//     FUNCTION gfn2:    CONTAINS F(Q,A,B,mu)**2  AS GIVEN
-//                       BY (53) AND (56,57) IN CHEN AND 
-//                       KOTLARCHYK REFERENCE
-//
-//     <PROLATE ELLIPSOIDS>
-//
-double
-gfn2(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq)
-{
-	// local variables
-	double aa,bb,u2,ut2,uq,ut,vc,vt,siq,sit,gfnc,gfnt,gfn2,pi43,gfn,Pi;
-
-	Pi = 4.0*atan(1.0);
-	
-	pi43=4.0/3.0*Pi;
-	aa = crmaj;
-	bb = crmin;
-	u2 = (aa*aa*xx*xx + bb*bb*(1.0-xx*xx));
-	ut2 = (trmaj*trmaj*xx*xx + trmin*trmin*(1.0-xx*xx));
-	uq = sqrt(u2)*qq;
-	ut= sqrt(ut2)*qq;
-	vc = pi43*aa*bb*bb;
-	vt = pi43*trmaj*trmin*trmin;
-   	if (uq == 0.0){
-   		siq = 1.0/3.0;
-   	}else{
-   		siq = (sin(uq)/uq/uq - cos(uq)/uq)/uq;
-   	}
-   	if (ut == 0.0){
-   		sit = 1.0/3.0;
-   	}else{
-   		sit = (sin(ut)/ut/ut - cos(ut)/ut)/ut;
-   	}
-	gfnc = 3.0*siq*vc*delpc;
-	gfnt = 3.0*sit*vt*delps;
-	gfn = gfnc+gfnt;
-	gfn2 = gfn*gfn;
-	
-	return (gfn2);
-}
-
-//
-//     FUNCTION gfn4:    CONTAINS F(Q,A,B,MU)**2  AS GIVEN
-//                       BY (53) & (58-59) IN CHEN AND
-//                       KOTLARCHYK REFERENCE
-//
-//       <OBLATE ELLIPSOID>
-// function gfn4 for oblate ellipsoids 
-double
-gfn4(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq)
-{
-	// local variables
-	double aa,bb,u2,ut2,uq,ut,vc,vt,siq,sit,gfnc,gfnt,tgfn,gfn4,pi43,Pi;
-
-	Pi = 4.0*atan(1.0);
-	pi43=4.0/3.0*Pi;
-  	aa = crmaj;
- 	bb = crmin;
- 	u2 = (bb*bb*xx*xx + aa*aa*(1.0-xx*xx));
- 	ut2 = (trmin*trmin*xx*xx + trmaj*trmaj*(1.0-xx*xx));
-   	uq = sqrt(u2)*qq;
- 	ut= sqrt(ut2)*qq;
-	vc = pi43*aa*aa*bb;
-   	vt = pi43*trmaj*trmaj*trmin;
-   	if (uq == 0.0){
-   		siq = 1.0/3.0;
-   	}else{
-   		siq = (sin(uq)/uq/uq - cos(uq)/uq)/uq;
-   	}
-   	if (ut == 0.0){
-   		sit = 1.0/3.0;
-   	}else{
-   		sit = (sin(ut)/ut/ut - cos(ut)/ut)/ut;
-   	}
-   	gfnc = 3.0*siq*vc*delpc;
-  	gfnt = 3.0*sit*vt*delps;
-  	tgfn = gfnc+gfnt;
-  	gfn4 = tgfn*tgfn;
-  	
-  	return (gfn4);
-}
-
-double
-FlePolyLen_kernel(double q, double radius, double length, double lb, double zz, double delrho, double zi)
-{
-    double Pq,vcyl,dl;
-    double Pi,qr;
-    
-    Pi = 4.0*atan(1.0);
-    qr = q*radius;
-    
-    Pq = Sk_WR(q,zi,lb);		//does not have cross section term
-    if (qr !=0){
-    	Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr);
-    } 
-    vcyl=Pi*radius*radius*zi;
-    Pq *= vcyl*vcyl;
-    
-    dl = SchulzPoint_cpr(zi,length,zz);
-    return (Pq*dl);	
-	
-}
-
-double
-FlePolyRad_kernel(double q, double ravg, double Lc, double Lb, double zz, double delrho, double zi)
-{
-    double Pq,vcyl,dr;
-    double Pi,qr;
-    
-    Pi = 4.0*atan(1.0);
-    qr = q*zi;
-    
-    Pq = Sk_WR(q,Lc,Lb);		//does not have cross section term
-    if (qr !=0){
-    	Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr);
-    }
-
-    vcyl=Pi*zi*zi*Lc;
-    Pq *= vcyl*vcyl;
-    
-    dr = SchulzPoint_cpr(zi,ravg,zz);
-    return (Pq*dr);	
-	
-}
-
-double
-CSCylIntegration(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length)
-{
-	double answer,halfheight,Pi;
-	double lolim,uplim,summ,yyy,zi;
-	int nord,i;
-	
-	// set up the integration end points 
-	Pi = 4.0*atan(1.0);
-	nord = 76;
-	lolim = 0.0;
-	uplim = Pi/2.0;
-	halfheight = length/2.0;
-	
-	summ = 0.0;				// initialize integral
-	i=0;
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * CScyl(qq, rad, radthick, facthick, rhoc,rhos,rhosolv, halfheight, zi);
-		summ += yyy;
-	}
-	
-	// calculate value of integral to return
-	answer = (uplim-lolim)/2.0*summ;
-	return (answer);
-}
-
-double
-CScyl(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length, double dum)
-{	
-	// qq is the q-value for the calculation (1/A)
-	// radius is the core radius of the cylinder (A)
-	//  radthick and facthick are the radial and face layer thicknesses
-	// rho(n) are the respective SLD's
-	// length is the *Half* CORE-LENGTH of the cylinder 
-	// dum is the dummy variable for the integration (theta)
-
-	double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2,si1,si2,be1,be2,t1,t2,retval;
-	double Pi;
-	
-	Pi = 4.0*atan(1.0); 
-	
-	dr1 = rhoc-rhos;
-	dr2 = rhos-rhosolv;
-	vol1 = Pi*rad*rad*(2.0*length);
-	vol2 = Pi*(rad+radthick)*(rad+radthick)*(2.0*length+2.0*facthick);
-	
-	besarg1 = qq*rad*sin(dum);
-	besarg2 = qq*(rad+radthick)*sin(dum);
-	sinarg1 = qq*length*cos(dum);
-	sinarg2 = qq*(length+facthick)*cos(dum);
-	if (besarg1 == 0.0){
-		be1 = 0.5;
-	}else{
-		be1 = NR_BessJ1(besarg1)/besarg1;
-	}
-	if (besarg2 == 0.0){
-		be2 = 0.5;
-	}else{
-		be2 = NR_BessJ1(besarg2)/besarg2;
-	}
-	if (sinarg1 == 0.0){
-		si1 = 1.0;
-	}else{
-		si1 = sin(sinarg1)/sinarg1;
-	}
-	if (sinarg2 == 0.0){
-		si2 = 1.0;
-	}else{
-		si2 = sin(sinarg2)/sinarg2;
-	}
-
-	t1 = 2.0*vol1*dr1*si1*be1;
-	t2 = 2.0*vol2*dr2*si2*be2;
-
-	retval = ((t1+t2)*(t1+t2))*sin(dum);
-	return (retval);
-    
-}
-
-
-double
-CoreShellCylKernel(double qq, double rcore, double thick, double rhoc, double rhos, double rhosolv, double length, double dum)
-{
-
-    double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2,si1,si2,be1,be2,t1,t2,retval;
-    double Pi;
-    
-    Pi = 4.0*atan(1.0);
-    
-    dr1 = rhoc-rhos;
-    dr2 = rhos-rhosolv;
-    vol1 = Pi*rcore*rcore*(2.0*length);
-    vol2 = Pi*(rcore+thick)*(rcore+thick)*(2.0*length+2.0*thick);
-    
-    besarg1 = qq*rcore*sin(dum);
-    besarg2 = qq*(rcore+thick)*sin(dum);
-    sinarg1 = qq*length*cos(dum);
-    sinarg2 = qq*(length+thick)*cos(dum);
-
-	if (besarg1 == 0.0){
-		be1 = 0.5;
-	}else{
-		be1 = NR_BessJ1(besarg1)/besarg1;
-	}
-	if (besarg2 == 0.0){
-		be2 = 0.5;
-	}else{
-		be2 = NR_BessJ1(besarg2)/besarg2;
-	}
-	if (sinarg1 == 0.0){
-		si1 = 1.0;
-	}else{
-		si1 = sin(sinarg1)/sinarg1;
-	}
-	if (sinarg2 == 0.0){
-		si2 = 1.0;
-	}else{
-		si2 = sin(sinarg2)/sinarg2;
-	}
-
-    t1 = 2.0*vol1*dr1*si1*be1;
-    t2 = 2.0*vol2*dr2*si2*be2;
-
-    retval = ((t1+t2)*(t1+t2))*sin(dum);
-	
-    return (retval);
-}
-
-double
-Cyl_PolyLenKernel(double q, double radius, double len_avg, double zz, double delrho, double dumLen)
-{
-	
-    double halfheight,uplim,lolim,zi,summ,yyy,Pi;
-    double answer,dr,Vcyl;
-    int i,nord;
-    
-    Pi = 4.0*atan(1.0);
-    lolim = 0.0;
-    uplim = Pi/2.0;
-    halfheight = dumLen/2.0;
-    nord=20;
-    summ = 0.0;
-    
-    //do the cylinder orientational average
-    for(i=0;i<nord;i++) {
-		zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss20Wt[i] * CylKernel(q, radius, halfheight, zi);
-		summ += yyy;
-    }
-    answer = (uplim-lolim)/2.0*summ;
-    // Multiply by contrast^2
-    answer *= delrho*delrho;
-    // don't do the normal scaling to volume here
-    // instead, multiply by VCyl^2 to get rid of the normalization for this radius of cylinder
-    Vcyl = Pi*radius*radius*dumLen;
-    answer *= Vcyl*Vcyl;
-    
-    dr = SchulzPoint_cpr(dumLen,len_avg,zz);
-    return(dr*answer);
-}
-
-
-double
-Stackdisc_kern(double qq, double rcore, double rhoc, double rhol, double rhosolv, double length, double thick, double dum, double gsd, double d, double N)
-{         	
-	// qq is the q-value for the calculation (1/A)
-	// rcore is the core radius of the cylinder (A)
-	// rho(n) are the respective SLD's
-	// length is the *Half* CORE-LENGTH of the cylinder = L (A)
-	// dum is the dummy variable for the integration (x in Feigin's notation)
-
-	//Local variables
-	double totald,dr1,dr2,besarg1,besarg2,be1,be2,si1,si2,area,sinarg1,sinarg2,t1,t2,retval,sqq,dexpt;
-	double Pi;
-	int kk;
-	
-	Pi = 4.0*atan(1.0);
-	
-	dr1 = rhoc-rhosolv;
-	dr2 = rhol-rhosolv;
-	area = Pi*rcore*rcore;
-	totald=2.0*(thick+length);
-	
-	besarg1 = qq*rcore*sin(dum);
-	besarg2 = qq*rcore*sin(dum);
-	
-	sinarg1 = qq*length*cos(dum);
-	sinarg2 = qq*(length+thick)*cos(dum);
-
-	if (besarg1 == 0.0){
-		be1 = 0.5;
-	}else{
-		be1 = NR_BessJ1(besarg1)/besarg1;
-	}
-	if (besarg2 == 0.0){
-		be2 = 0.5;
-	}else{
-		be2 = NR_BessJ1(besarg2)/besarg2;
-	}
-	if (sinarg1 == 0.0){
-		si1 = 1.0;
-	}else{
-		si1 = sin(sinarg1)/sinarg1;
-	}
-	if (sinarg2 == 0.0){
-		si2 = 1.0;
-	}else{
-		si2 = sin(sinarg2)/sinarg2;
-	}
-
-	t1 = 2.0*area*(2.0*length)*dr1*(si1)*(be1);
-	t2 = 2.0*area*dr2*(totald*si2-2.0*length*si1)*(be2);
-
-	retval =((t1+t2)*(t1+t2))*sin(dum);
-	
-	// loop for the structure facture S(q)
-	sqq=0.0;
-	for(kk=1;kk<N;kk+=1) {
-		dexpt=qq*cos(dum)*qq*cos(dum)*d*d*gsd*gsd*kk/2.0;
-		sqq=sqq+(N-kk)*cos(qq*cos(dum)*d*kk)*exp(-1.*dexpt);
-	}			
-	
-	// end of loop for S(q)
-	sqq=1.0+2.0*sqq/N;
-	retval *= sqq;
-    
-	return(retval);
-}
-
-
-double
-Cyl_PolyRadKernel(double q, double radius, double length, double zz, double delrho, double dumRad)
-{
-	
-    double halfheight,uplim,lolim,zi,summ,yyy,Pi;
-    double answer,dr,Vcyl;
-    int i,nord;
-    
-    Pi = 4.0*atan(1.0);
-    lolim = 0.0;
-    uplim = Pi/2.0;
-    halfheight = length/2.0;
-	//    nord=20;
-    nord=76;
-    summ = 0.0;
-    
-    //do the cylinder orientational average
-	//    for(i=0;i<nord;i++) {
-	//            zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-	//            yyy = Gauss20Wt[i] * CylKernel(q, dumRad, halfheight, zi);
-	//            summ += yyy;
-	//    }
-    for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * CylKernel(q, dumRad, halfheight, zi);
-		summ += yyy;
-    }
-    answer = (uplim-lolim)/2.0*summ;
-    // Multiply by contrast^2
-    answer *= delrho*delrho;
-    // don't do the normal scaling to volume here
-    // instead, multiply by VCyl^2 to get rid of the normalization for this radius of cylinder
-    Vcyl = Pi*dumRad*dumRad*length;
-    answer *= Vcyl*Vcyl;
-    
-    dr = SchulzPoint_cpr(dumRad,radius,zz);
-    return(dr*answer);
-}
-
-double
-SchulzPoint_cpr(double dumRad, double radius, double zz)
-{
-    double dr;
-    
-    dr = zz*log(dumRad) - gammaln(zz+1.0) + (zz+1.0)*log((zz+1.0)/radius)-(dumRad/radius*(zz+1.0));
-    return(exp(dr));
-}
-
-
-double
-EllipsoidKernel(double qq, double a, double nua, double dum)
-{
-    double arg,nu,retval;		//local variables
-	
-    nu = nua/a;
-    arg = qq*a*sqrt(1.0+dum*dum*(nu*nu-1.0));
-    if (arg == 0.0){
-    	retval =1.0/3.0;
-    }else{
-    	retval = (sin(arg)-arg*cos(arg))/(arg*arg*arg);
-    }
-    retval *= retval;
-    retval *= 9.0;
-
-    return(retval);
-}//Function EllipsoidKernel()
-
-double
-HolCylKernel(double qq, double rcore, double rshell, double length, double dum)
-{
-    double gamma,arg1,arg2,lam1,lam2,psi,sinarg,t2,retval;		//local variables
-    
-    gamma = rcore/rshell;
-    arg1 = qq*rshell*sqrt(1.0-dum*dum);		//1=shell (outer radius)
-    arg2 = qq*rcore*sqrt(1.0-dum*dum);			//2=core (inner radius)
-    if (arg1 == 0.0){
-    	lam1 = 1.0;
-    }else{
-    	lam1 = 2.0*NR_BessJ1(arg1)/arg1;
-    }
-    if (arg2 == 0.0){
-    	lam2 = 1.0;
-    }else{
-    	lam2 = 2.0*NR_BessJ1(arg2)/arg2;
-    }
-    //Todo: Need to check psi behavior as gamma goes to 1.
-    psi = 1.0/(1.0-gamma*gamma)*(lam1 -  gamma*gamma*lam2);		//SRK 10/19/00
-    sinarg = qq*length*dum/2.0;
-    if (sinarg == 0.0){
-    	t2 = 1.0;
-    }else{
-    	t2 = sin(sinarg)/sinarg;
-    }
-
-    retval = psi*psi*t2*t2;
-    
-    return(retval);
-}//Function HolCylKernel()
-
-double
-PPKernel(double aa, double mu, double uu)
-{
-    // mu passed in is really mu*sqrt(1-sig^2)
-    double arg1,arg2,Pi,tmp1,tmp2;			//local variables
-	
-    Pi = 4.0*atan(1.0);
-    
-    //handle arg=0 separately, as sin(t)/t -> 1 as t->0
-    arg1 = (mu/2.0)*cos(Pi*uu/2.0);
-    arg2 = (mu*aa/2.0)*sin(Pi*uu/2.0);
-    if(arg1==0.0) {
-		tmp1 = 1.0;
-	} else {
-		tmp1 = sin(arg1)*sin(arg1)/arg1/arg1;
-    }
-
-    if (arg2==0.0) {
-		tmp2 = 1.0;
-	} else {
-		tmp2 = sin(arg2)*sin(arg2)/arg2/arg2;
-    }
-	
-    return (tmp1*tmp2);
-	
-}//Function PPKernel()
-
-
-double
-TriaxialKernel(double q, double aa, double bb, double cc, double dx, double dy)
-{
-	
-    double arg,val,pi;			//local variables
-	
-    pi = 4.0*atan(1.0);
-    
-    arg = aa*aa*cos(pi*dx/2)*cos(pi*dx/2);
-    arg += bb*bb*sin(pi*dx/2)*sin(pi*dx/2)*(1-dy*dy);
-    arg += cc*cc*dy*dy;
-    arg = q*sqrt(arg);
-    if (arg == 0.0){
-    	val = 1.0; // as arg --> 0, val should go to 1.0
-    }else{
-    	val = 9.0 * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ) * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) );
-    }
-    return (val);
-	
-}//Function TriaxialKernel()
-
-
-double
-CylKernel(double qq, double rr,double h, double theta)
-{
-	
-	// qq is the q-value for the calculation (1/A)
-	// rr is the radius of the cylinder (A)
-	// h is the HALF-LENGTH of the cylinder = L/2 (A)
-
-    double besarg,bj,retval,d1,t1,b1,t2,b2,siarg,be,si;		 //Local variables
-
-
-    besarg = qq*rr*sin(theta);
-    siarg = qq * h * cos(theta);
-    bj =NR_BessJ1(besarg);
-	
-	//* Computing 2nd power */
-    d1 = sin(siarg);
-    t1 = d1 * d1;
-	//* Computing 2nd power */
-    d1 = bj;
-    t2 = d1 * d1 * 4.0 * sin(theta);
-	//* Computing 2nd power */
-    d1 = siarg;
-    b1 = d1 * d1;
-	//* Computing 2nd power */
-    d1 = qq * rr * sin(theta);
-    b2 = d1 * d1;
-    if (besarg == 0.0){
-    	be = sin(theta);
-    }else{
-    	be = t2 / b2;
-    }
-    if (siarg == 0.0){
-    	si = 1.0;
-    }else{
-    	si = t1 / b1;
-    }
-    retval = be * si;
-
-    return (retval);
-	
-}//Function CylKernel()
-
-double
-EllipCylKernel(double qq, double ra,double nu, double theta)
-{
-	//this is the function LAMBDA1^2 in Feigin's notation	
-	// qq is the q-value for the calculation (1/A)
-	// ra is the transformed radius"a" in Feigin's notation
-	// nu is the ratio (major radius)/(minor radius) of the Ellipsoid [=] ---
-	// theta is the dummy variable of the integration
-	
-	double retval,arg;		 //Local variables 
-	
-	arg = qq*ra*sqrt((1.0+nu*nu)/2+(1.0-nu*nu)*cos(theta)/2);
-	if (arg == 0.0){
-		retval = 1.0;
-	}else{
-		retval = 2.0*NR_BessJ1(arg)/arg;
-	}
-
-	//square it
-	retval *= retval;
-	
-    return(retval);
-	
-}//Function EllipCylKernel()
-
-double NR_BessJ1(double x)
-{
-	double ax,z;
-	double xx,y,ans,ans1,ans2;
-	
-	if ((ax=fabs(x)) < 8.0) {
-		y=x*x;
-		ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1
-												  +y*(-2972611.439+y*(15704.48260+y*(-30.16036606))))));
-		ans2=144725228442.0+y*(2300535178.0+y*(18583304.74
-											   +y*(99447.43394+y*(376.9991397+y*1.0))));
-		ans=ans1/ans2;
-	} else {
-		z=8.0/ax;
-		y=z*z;
-		xx=ax-2.356194491;
-		ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4
-								   +y*(0.2457520174e-5+y*(-0.240337019e-6))));
-		ans2=0.04687499995+y*(-0.2002690873e-3
-							  +y*(0.8449199096e-5+y*(-0.88228987e-6
-													 +y*0.105787412e-6)));
-		ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2);
-		if (x < 0.0) ans = -ans;
-	}
-	
-	return(ans);
-}
-
-/*	Lamellar_ParaCrystal - Pedersen's model
-
-*/
-double
-Lamellar_ParaCrystal(double w[], double q)
-{
-//	 Input (fitting) variables are:
-	//[0] scale factor
-	//[1]	thickness
-	//[2]	number of layers
-	//[3]	spacing between layers
-	//[4]	polydispersity of spacing
-	//[5] SLD lamellar
-	//[6] SLD solvent
-	//[7] incoherent background
-//	give them nice names
-	double inten,qval,scale,th,nl,davg,pd,contr,bkg,xn;
-	double xi,ww,Pbil,Znq,Snq,an,sldLayer,sldSolvent,pi;
-	long n1,n2;
-	
-	pi = 4.0*atan(1.0);
-	scale = w[0];
-	th = w[1];
-	nl = w[2];
-	davg = w[3];
-	pd = w[4];
-	sldLayer = w[5];
-	sldSolvent = w[6];
-	bkg = w[7];
-	
-	contr = w[5] - w[6];
-	qval = q;
-		
-	//get the fractional part of nl, to determine the "mixing" of N's
-	
-	n1 = trunc(nl);		//rounds towards zero
-	n2 = n1 + 1;
-	xn = (double)n2 - nl;			//fractional contribution of n1
-	
-	ww = exp(-qval*qval*pd*pd*davg*davg/2.0);
-	
-	//calculate the n1 contribution
-	an = paraCryst_an(ww,qval,davg,n1);
-	Snq = paraCryst_sn(ww,qval,davg,n1,an);
-	
-	Znq = xn*Snq;
-	
-	//calculate the n2 contribution
-	an = paraCryst_an(ww,qval,davg,n2);
-	Snq = paraCryst_sn(ww,qval,davg,n2,an);
-	
-	Znq += (1.0-xn)*Snq;
-	
-	//and the independent contribution
-	Znq += (1.0-ww*ww)/(1.0+ww*ww-2.0*ww*cos(qval*davg));
-	
-	//the limit when NL approaches infinity
-//	Zq = (1-ww^2)/(1+ww^2-2*ww*cos(qval*davg))
-	
-	xi = th/2.0;		//use 1/2 the bilayer thickness
-	Pbil = (sin(qval*xi)/(qval*xi))*(sin(qval*xi)/(qval*xi));
-	
-	inten = 2.0*pi*contr*contr*Pbil*Znq/(qval*qval);
-	inten *= 1.0e8;
-	
-	return(scale*inten+bkg);
-}
-
-// functions for the lamellar paracrystal model
-double
-paraCryst_sn(double ww, double qval, double davg, long nl, double an) {
-	
-	double Snq;
-	
-	Snq = an/( (double)nl*pow((1.0+ww*ww-2.0*ww*cos(qval*davg)),2) );
-	
-	return(Snq);
-}
-
-
-double
-paraCryst_an(double ww, double qval, double davg, long nl) {
-	
-	double an;
-	
-	an = 4.0*ww*ww - 2.0*(ww*ww*ww+ww)*cos(qval*davg);
-	an -= 4.0*pow(ww,(nl+2))*cos((double)nl*qval*davg);
-	an += 2.0*pow(ww,(nl+3))*cos((double)(nl-1)*qval*davg);
-	an += 2.0*pow(ww,(nl+1))*cos((double)(nl+1)*qval*davg);
-	
-	return(an);
-}
-
-
-/*	Spherocylinder  :
-
-Uses 76 pt Gaussian quadrature for both integrals
-*/
-double
-Spherocylinder(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,contr,bkg,sldc,slds;
-	double len,rad,hDist,endRad;
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	double SphCyl_tmp[7],arg1,arg2,inner,be;
-	
-	
-	scale = w[0];
-	rad = w[1];
-	len = w[2];
-	sldc = w[3];
-	slds = w[4];
-	bkg = w[5];
-	
-	SphCyl_tmp[0] = w[0];
-	SphCyl_tmp[1] = w[1];
-	SphCyl_tmp[2] = w[2];
-	SphCyl_tmp[3] = w[1];		//end radius is same as cylinder radius
-	SphCyl_tmp[4] = w[3];
-	SphCyl_tmp[5] = w[4];
-	SphCyl_tmp[6] = w[5];
-	
-	hDist = 0;		//by definition for this model
-	endRad = rad;
-	
-	contr = sldc-slds;
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = Pi/2.0;		//orintational average, outer integral
-	vaj = -1.0*hDist/endRad;
-	vbj = 1.0;		//endpoints of inner integral
-
-	summ = 0.0;			//initialize intergral
-
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "theta" dummy
-		
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
-			yyy = Gauss76Wt[j] * SphCyl_kernel(SphCyl_tmp,x,zij,zi);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		inner = (vbj-vaj)/2.0*summj;
-		inner *= 4.0*Pi*endRad*endRad*endRad;
-		
-		//now calculate outer integrand
-		arg1 = x*len/2.0*cos(zi);
-		arg2 = x*rad*sin(zi);
-		yyy = inner;
-
-		if(arg2 == 0) {
-			be = 0.5;
-		} else {
-			be = NR_BessJ1(arg2)/arg2;
-		}
-		
-		if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
-			yyy += Pi*rad*rad*len*2.0*be;
-		} else {
-			yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-		}
-		yyy *= yyy;
-		yyy *= sin(zi);		// = |A(q)|^2*sin(theta)
-		yyy *= Gauss76Wt[i];
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-
-	answer /= Pi*rad*rad*len + Pi*4.0*endRad*endRad*endRad/3.0;		//divide by volume
-	answer *= 1.0e8;		//convert to cm^-1
-	answer *= contr*contr;
-	answer *= scale;
-	answer += bkg;
-		
-	return answer;
-}
-
-
-// inner integral of the sphereocylinder model, special case of hDist = 0
-//
-double
-SphCyl_kernel(double w[], double x, double tt, double theta) {
-
-	double val,arg1,arg2;
-	double scale,bkg,sldc,slds;
-	double len,rad,hDist,endRad,be;
-	scale = w[0];
-	rad = w[1];
-	len = w[2];
-	endRad = w[3];
-	sldc = w[4];
-	slds = w[5];
-	bkg = w[6];
-	
-	hDist = 0.0;
-		
-	arg1 = x*cos(theta)*(endRad*tt+hDist+len/2.0);
-	arg2 = x*endRad*sin(theta)*sqrt(1.0-tt*tt);
-	
-	if(arg2 == 0) {
-		be = 0.5;
-	} else {
-		be = NR_BessJ1(arg2)/arg2;
-	}
-	val = cos(arg1)*(1.0-tt*tt)*be;
-	
-	return(val);
-}
-
-
-/*	Convex Lens  : special case where L ~ 0 and hDist < 0
-
-Uses 76 pt Gaussian quadrature for both integrals
-*/
-double
-ConvexLens(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,contr,bkg,sldc,slds;
-	double len,rad,hDist,endRad;
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	double CLens_tmp[7],arg1,arg2,inner,hh,be;
-	
-	
-	scale = w[0];
-	rad = w[1];
-//	len = w[2]
-	endRad = w[2];
-	sldc = w[3];
-	slds = w[4];
-	bkg = w[5];
-	
-	len = 0.01;
-	
-	CLens_tmp[0] = w[0];
-	CLens_tmp[1] = w[1];
-	CLens_tmp[2] = len;			//length is some small number, essentially zero
-	CLens_tmp[3] = w[2];
-	CLens_tmp[4] = w[3];
-	CLens_tmp[5] = w[4];
-	CLens_tmp[6] = w[5];
-		
-	hDist = -1.0*sqrt(fabs(endRad*endRad-rad*rad));		//by definition for this model
-	
-	contr = sldc-slds;
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = Pi/2.0;		//orintational average, outer integral
-	vaj = -1.0*hDist/endRad;
-	vbj = 1.0;		//endpoints of inner integral
-
-	summ = 0.0;			//initialize intergral
-
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "theta" dummy
-		
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
-			yyy = Gauss76Wt[j] * ConvLens_kernel(CLens_tmp,x,zij,zi);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		inner = (vbj-vaj)/2.0*summj;
-		inner *= 4.0*Pi*endRad*endRad*endRad;
-		
-		//now calculate outer integrand
-		arg1 = x*len/2.0*cos(zi);
-		arg2 = x*rad*sin(zi);
-		yyy = inner;
-		
-		if(arg2 == 0) {
-			be = 0.5;
-		} else {
-			be = NR_BessJ1(arg2)/arg2;
-		}
-		
-		if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
-			yyy += Pi*rad*rad*len*2.0*be;
-		} else {
-			yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-		}
-		yyy *= yyy;
-		yyy *= sin(zi);		// = |A(q)|^2*sin(theta)
-		yyy *= Gauss76Wt[i];
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-
-	hh = fabs(hDist);		//need positive value for spherical cap volume
-	answer /= 2.0*(1.0/3.0*Pi*(endRad-hh)*(endRad-hh)*(2.0*endRad+hh));		//divide by volume
-	answer *= 1.0e8;		//convert to cm^-1
-	answer *= contr*contr;
-	answer *= scale;
-	answer += bkg;
-		
-	return answer;
-}
-
-/*	Capped Cylinder  : special case where L is nonzero and hDist < 0
-
- -- uses the same Kernel as the Convex Lens
- 
-Uses 76 pt Gaussian quadrature for both integrals
-*/
-double
-CappedCylinder(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,contr,bkg,sldc,slds;
-	double len,rad,hDist,endRad;
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	double arg1,arg2,inner,hh,be;
-	
-	
-	scale = w[0];
-	rad = w[1];
-	len = w[2];
-	endRad = w[3];
-	sldc = w[4];
-	slds = w[5];
-	bkg = w[6];
-		
-	hDist = -1.0*sqrt(fabs(endRad*endRad-rad*rad));		//by definition for this model
-	
-	contr = sldc-slds;
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = Pi/2.0;		//orintational average, outer integral
-	vaj = -1.0*hDist/endRad;
-	vbj = 1.0;		//endpoints of inner integral
-
-	summ = 0.0;			//initialize intergral
-
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "theta" dummy
-		
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
-			yyy = Gauss76Wt[j] * ConvLens_kernel(w,x,zij,zi);		//uses the same kernel as ConvexLens, except here L != 0
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		inner = (vbj-vaj)/2.0*summj;
-		inner *= 4.0*Pi*endRad*endRad*endRad;
-		
-		//now calculate outer integrand
-		arg1 = x*len/2.0*cos(zi);
-		arg2 = x*rad*sin(zi);
-		yyy = inner;
-		
-		if(arg2 == 0) {
-			be = 0.5;
-		} else {
-			be = NR_BessJ1(arg2)/arg2;
-		}
-		
-		if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
-			yyy += Pi*rad*rad*len*2.0*be;
-		} else {
-			yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-		}
-		
-		
-		
-		yyy *= yyy;
-		yyy *= sin(zi);		// = |A(q)|^2*sin(theta)
-		yyy *= Gauss76Wt[i];
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-
-	hh = fabs(hDist);		//need positive value for spherical cap volume
-	answer /= Pi*rad*rad*len + 2.0*(1.0/3.0*Pi*(endRad-hh)*(endRad-hh)*(2.0*endRad+hh));		//divide by volume
-	answer *= 1.0e8;		//convert to cm^-1
-	answer *= contr*contr;
-	answer *= scale;
-	answer += bkg;
-		
-	return answer;
-}
-
-
-
-// inner integral of the ConvexLens model, special case where L ~ 0 and hDist < 0
-//
-double
-ConvLens_kernel(double w[], double x, double tt, double theta) {
-
-	double val,arg1,arg2;
-	double scale,bkg,sldc,slds;
-	double len,rad,hDist,endRad,be;
-	scale = w[0];
-	rad = w[1];
-	len = w[2];
-	endRad = w[3];
-	sldc = w[4];
-	slds = w[5];
-	bkg = w[6];
-	
-	hDist = -1.0*sqrt(fabs(endRad*endRad-rad*rad));
-		
-	arg1 = x*cos(theta)*(endRad*tt+hDist+len/2.0);
-	arg2 = x*endRad*sin(theta)*sqrt(1.0-tt*tt);
-	
-	if(arg2 == 0) {
-		be = 0.5;
-	} else {
-		be = NR_BessJ1(arg2)/arg2;
-	}
-	
-	val = cos(arg1)*(1.0-tt*tt)*be;
-	
-	return(val);
-}
-
-
-/*	Dumbbell  : special case where L ~ 0 and hDist > 0
-
-Uses 76 pt Gaussian quadrature for both integrals
-*/
-double
-Dumbbell(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,contr,bkg,sldc,slds;
-	double len,rad,hDist,endRad;
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	double Dumb_tmp[7],arg1,arg2,inner,be;
-	
-	
-	scale = w[0];
-	rad = w[1];
-//	len = w[2]
-	endRad = w[2];
-	sldc = w[3];
-	slds = w[4];
-	bkg = w[5];
-	
-	len = 0.01;
-	
-	Dumb_tmp[0] = w[0];
-	Dumb_tmp[1] = w[1];
-	Dumb_tmp[2] = len;		//length is some small number, essentially zero
-	Dumb_tmp[3] = w[2];
-	Dumb_tmp[4] = w[3];
-	Dumb_tmp[5] = w[4];
-	Dumb_tmp[6] = w[5];
-			
-	hDist = sqrt(fabs(endRad*endRad-rad*rad));		//by definition for this model
-	
-	contr = sldc-slds;
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = Pi/2.0;		//orintational average, outer integral
-	vaj = -1.0*hDist/endRad;
-	vbj = 1.0;		//endpoints of inner integral
-
-	summ = 0.0;			//initialize intergral
-
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "theta" dummy
-		
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
-			yyy = Gauss76Wt[j] * Dumb_kernel(Dumb_tmp,x,zij,zi);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		inner = (vbj-vaj)/2.0*summj;
-		inner *= 4.0*Pi*endRad*endRad*endRad;
-		
-		//now calculate outer integrand
-		arg1 = x*len/2.0*cos(zi);
-		arg2 = x*rad*sin(zi);
-		yyy = inner;
-		
-		if(arg2 == 0) {
-			be = 0.5;
-		} else {
-			be = NR_BessJ1(arg2)/arg2;
-		}
-		
-		if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
-			yyy += Pi*rad*rad*len*2.0*be;
-		} else {
-			yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-		}
-		yyy *= yyy;
-		yyy *= sin(zi);		// = |A(q)|^2*sin(theta)
-		yyy *= Gauss76Wt[i];
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-
-	answer /= 2.0*Pi*(2.0*endRad*endRad*endRad/3.0+endRad*endRad*hDist-hDist*hDist*hDist/3.0);		//divide by volume
-	answer *= 1.0e8;		//convert to cm^-1
-	answer *= contr*contr;
-	answer *= scale;
-	answer += bkg;
-		
-	return answer;
-}
-
-
-/*	Barbell  : "normal" case where L is nonzero 0 and hDist > 0
-
--- uses the same kernel as the Dumbbell case
-
-Uses 76 pt Gaussian quadrature for both integrals
-*/
-double
-Barbell(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,contr,bkg,sldc,slds;
-	double len,rad,hDist,endRad;
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	double arg1,arg2,inner,be;
-	
-	
-	scale = w[0];
-	rad = w[1];
-	len = w[2];
-	endRad = w[3];
-	sldc = w[4];
-	slds = w[5];
-	bkg = w[6];
-			
-	hDist = sqrt(fabs(endRad*endRad-rad*rad));		//by definition for this model
-	
-	contr = sldc-slds;
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = Pi/2.0;		//orintational average, outer integral
-	vaj = -1.0*hDist/endRad;
-	vbj = 1.0;		//endpoints of inner integral
-
-	summ = 0.0;			//initialize intergral
-
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the "theta" dummy
-		
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
-			yyy = Gauss76Wt[j] * Dumb_kernel(w,x,zij,zi);		//uses the same Kernel as the Dumbbell, here L>0
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		inner = (vbj-vaj)/2.0*summj;
-		inner *= 4.0*Pi*endRad*endRad*endRad;
-		
-		//now calculate outer integrand
-		arg1 = x*len/2.0*cos(zi);
-		arg2 = x*rad*sin(zi);
-		yyy = inner;
-		
-		if(arg2 == 0) {
-			be = 0.5;
-		} else {
-			be = NR_BessJ1(arg2)/arg2;
-		}
-		
-		if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
-			yyy += Pi*rad*rad*len*2.0*be;
-		} else {
-			yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
-		}
-		yyy *= yyy;
-		yyy *= sin(zi);		// = |A(q)|^2*sin(theta)
-		yyy *= Gauss76Wt[i];
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-
-	answer /= Pi*rad*rad*len + 2.0*Pi*(2.0*endRad*endRad*endRad/3.0+endRad*endRad*hDist-hDist*hDist*hDist/3.0);		//divide by volume
-	answer *= 1.0e8;		//convert to cm^-1
-	answer *= contr*contr;
-	answer *= scale;
-	answer += bkg;
-		
-	return answer;
-}
-
-
-
-// inner integral of the Dumbbell model, special case where L ~ 0 and hDist > 0
-//
-// inner integral of the Barbell model if L is nonzero
-//
-double
-Dumb_kernel(double w[], double x, double tt, double theta) {
-
-	double val,arg1,arg2;
-	double scale,bkg,sldc,slds;
-	double len,rad,hDist,endRad,be;
-	scale = w[0];
-	rad = w[1];
-	len = w[2];
-	endRad = w[3];
-	sldc = w[4];
-	slds = w[5];
-	bkg = w[6];
-	
-	hDist = sqrt(fabs(endRad*endRad-rad*rad));
-		
-	arg1 = x*cos(theta)*(endRad*tt+hDist+len/2.0);
-	arg2 = x*endRad*sin(theta)*sqrt(1.0-tt*tt);
-	
-	if(arg2 == 0) {
-		be = 0.5;
-	} else {
-		be = NR_BessJ1(arg2)/arg2;
-	}
-	val = cos(arg1)*(1.0-tt*tt)*be;
-	
-	return(val);
-}
-
-double PolyCoreBicelle(double dp[], double q)
-{
-	int i;
-	int nord = 20;
-	double scale, length, sigma, bkg, radius, radthick, facthick;
-	double rhoc, rhoh, rhor, rhosolv;
-	double answer, Vpoly;
-	double Pi,lolim,uplim,summ,yyy,rad,AR,Rsqr,Rsqrsumm,Rsqryyy;
-	
-	scale = dp[0];
-	radius = dp[1];
-	sigma = dp[2];				//sigma is the standard mean deviation
-	length = dp[3];
-	radthick = dp[4];
-	facthick= dp[5];
-	rhoc = dp[6];
-	rhoh = dp[7];
-	rhor=dp[8];
-	rhosolv = dp[9];
-	bkg = dp[10];
-	
-	Pi = 4.0*atan(1.0);
-	
-	lolim = exp(log(radius)-(4.*sigma));
-	if (lolim<0.0) {
-		lolim=0.0;		//to avoid numerical error when  va<0 (-ve r value)
-	}
-	uplim = exp(log(radius)+(4.*sigma));
-	
-	summ = 0.0;
-	Rsqrsumm = 0.0;
-	
-	for(i=0;i<nord;i++) {
-		rad = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		AR=(1.0/(rad*sigma*sqrt(2.0*Pi)))*exp(-(0.5*((log(radius/rad))/sigma)*((log(radius/rad))/sigma)));
-		yyy = AR* Gauss20Wt[i] * BicelleIntegration(q,rad,radthick,facthick,rhoc,rhoh,rhor,rhosolv,length);
-		Rsqryyy= Gauss20Wt[i] * AR * (rad+radthick)*(rad+radthick);		//SRK normalize to total dimensions
-		summ += yyy;
-		Rsqrsumm += Rsqryyy;
-	}
-	
-	answer = (uplim-lolim)/2.0*summ;
-	Rsqr = (uplim-lolim)/2.0*Rsqrsumm;
-	//normalize by average cylinder volume
-	Vpoly = Pi*Rsqr*(length+2*facthick);
-	answer /= Vpoly;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-		
-	return answer;
-	
-}
-
-double
-BicelleIntegration(double qq, double rad, double radthick, double facthick, double rhoc, double rhoh, double rhor, double rhosolv, double length){
-
-	double answer,halfheight,Pi;
-	double lolim,uplim,summ,yyy,zi;
-	int nord,i;
-	
-	// set up the integration end points 
-	Pi = 4.0*atan(1.0);
-	nord = 76;
-	lolim = 0.0;
-	uplim = Pi/2;
-	halfheight = length/2.0;
-	
-	summ = 0.0;				// initialize integral
-	i=0;
-	for(i=0;i<nord;i++) {
-		zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
-		yyy = Gauss76Wt[i] * BicelleKernel(qq, rad, radthick, facthick, rhoc, rhoh, rhor,rhosolv, halfheight, zi);
-		summ += yyy;
-	}
-	
-	// calculate value of integral to return
-	answer = (uplim-lolim)/2.0*summ;
-	return(answer);	
-}
-
-double
-BicelleKernel(double qq, double rad, double radthick, double facthick, double rhoc, double rhoh, double rhor, double rhosolv, double length, double dum)
-{
-	double dr1,dr2,dr3;
-	double besarg1,besarg2;
-	double vol1,vol2,vol3;
-	double sinarg1,sinarg2;
-	double t1,t2,t3;
-	double retval,si1,si2,be1,be2;
-	
-	double Pi = 4.0*atan(1.0);
-	
-	dr1 = rhoc-rhoh;
-	dr2 = rhor-rhosolv;
-	dr3=  rhoh-rhor;
-	vol1 = Pi*rad*rad*(2.0*length);
-	vol2 = Pi*(rad+radthick)*(rad+radthick)*(2.0*length+2.0*facthick);
-	vol3= Pi*(rad)*(rad)*(2.0*length+2.0*facthick);
-	besarg1 = qq*rad*sin(dum);
-	besarg2 = qq*(rad+radthick)*sin(dum);
-	sinarg1 = qq*length*cos(dum);
-	sinarg2 = qq*(length+facthick)*cos(dum);
-	
-	if(besarg1 == 0) {
-		be1 = 0.5;
-	} else {
-		be1 = NR_BessJ1(besarg1)/besarg1;
-	}
-	if(besarg2 == 0) {
-		be2 = 0.5;
-	} else {
-		be2 = NR_BessJ1(besarg2)/besarg2;
-	}	
-	if(sinarg1 == 0) {
-		si1 = 1.0;
-	} else {
-		si1 = sin(sinarg1)/sinarg1;
-	}
-	if(sinarg2 == 0) {
-		si2 = 1.0;
-	} else {
-		si2 = sin(sinarg2)/sinarg2;
-	}
-	t1 = 2.0*vol1*dr1*si1*be1;
-	t2 = 2.0*vol2*dr2*si2*be2;
-	t3 = 2.0*vol3*dr3*si2*be1;
-	
-	retval = ((t1+t2+t3)*(t1+t2+t3))*sin(dum);
-	return(retval);
-	
-}
-
-
-double
-CSPPKernel(double dp[], double mu, double uu)
-{	
-	double aa,bb,cc, ta,tb,tc; 
-	double Vin,Vot,V1,V2;
-	double rhoA,rhoB,rhoC, rhoP, rhosolv;
-	double dr0, drA,drB, drC;
-	double arg1,arg2,arg3,arg4,t1,t2, t3, t4;
-	double Pi,retVal;
-
-	aa = dp[1];
-	bb = dp[2];
-	cc = dp[3];
-	ta = dp[4];
-	tb = dp[5];
-	tc = dp[6];
-	rhoA=dp[7];
-	rhoB=dp[8];
-	rhoC=dp[9];
-	rhoP=dp[10];
-	rhosolv=dp[11];
-	dr0=rhoP-rhosolv;
-	drA=rhoA-rhosolv;
-	drB=rhoB-rhosolv;
-	drC=rhoC-rhosolv; 
-	Vin=(aa*bb*cc);
-	Vot=(aa*bb*cc+2.0*ta*bb*cc+2.0*aa*tb*cc+2.0*aa*bb*tc);
-	V1=(2.0*ta*bb*cc);   //  incorrect V1 (aa*bb*cc+2*ta*bb*cc)
-	V2=(2.0*aa*tb*cc);  // incorrect V2(aa*bb*cc+2*aa*tb*cc)
-	aa = aa/bb;
-	ta=(aa+2.0*ta)/bb;
-	tb=(aa+2.0*tb)/bb;
-	
-	Pi = 4.0*atan(1.0);
-	
-	arg1 = (mu*aa/2.0)*sin(Pi*uu/2.0);
-	arg2 = (mu/2.0)*cos(Pi*uu/2.0);
-	arg3=  (mu*ta/2.0)*sin(Pi*uu/2.0);
-	arg4=  (mu*tb/2.0)*cos(Pi*uu/2.0);
-			 
-	if(arg1==0.0){
-		t1 = 1.0;
-	} else {
-		t1 = (sin(arg1)/arg1);                //defn for CSPP model sin(arg1)/arg1    test:  (sin(arg1)/arg1)*(sin(arg1)/arg1)   
-	}
-	if(arg2==0.0){
-		t2 = 1.0;
-	} else {
-		t2 = (sin(arg2)/arg2);           //defn for CSPP model sin(arg2)/arg2   test: (sin(arg2)/arg2)*(sin(arg2)/arg2)    
-	}	
-	if(arg3==0.0){
-		t3 = 1.0;
-	} else {
-		t3 = sin(arg3)/arg3;
-	}
-	if(arg4==0.0){
-		t4 = 1.0;
-	} else {
-		t4 = sin(arg4)/arg4;
-	}
-	retVal =( dr0*t1*t2*Vin + drA*(t3-t1)*t2*V1+ drB*t1*(t4-t2)*V2 )*( dr0*t1*t2*Vin + drA*(t3-t1)*t2*V1+ drB*t1*(t4-t2)*V2 );   //  correct FF : square of sum of phase factors
-	return(retVal); 
-
-}
-
-/*	CSParallelepiped  :  calculates the form factor of a Parallelepiped with a core-shell structure
- -- different SLDs can be used for the face and rim
-
-Uses 76 pt Gaussian quadrature for both integrals
-*/
-double
-CSParallelepiped(double dp[], double q)
-{
-	int i,j;
-	double scale,aa,bb,cc,ta,tb,tc,rhoA,rhoB,rhoC,rhoP,rhosolv,bkg;		//local variables of coefficient wave
-	int nordi=76;			//order of integration
-	int nordj=76;
-	double va,vb;		//upper and lower integration limits
-	double summ,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj;			//for the inner integration
-	double mu,mudum,arg,sigma,uu,vol;
-	
-	
-	//	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 1.0;		//orintational average, outer integral
-	vaj = 0.0;
-	vbj = 1.0;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = dp[0];
-	aa = dp[1];
-	bb = dp[2];
-	cc = dp[3];
-	ta  = dp[4];
-	tb  = dp[5];
-	tc  = dp[6];   // is 0 at the moment  
-	rhoA=dp[7];   //rim A SLD
-	rhoB=dp[8];   //rim B SLD
-	rhoC=dp[9];    //rim C SLD
-	rhoP = dp[10];   //Parallelpiped core SLD
-	rhosolv=dp[11];  // Solvent SLD
-	bkg = dp[12];
-	
-	mu = q*bb;
-	vol = aa*bb*cc+2.0*ta*bb*cc+2.0*aa*tb*cc+2.0*aa*bb*tc;		//calculate volume before rescaling
-	
-	// do the rescaling here, not in the kernel
-	// normalize all WRT bb
-	aa = aa/bb;
-	cc = cc/bb;
-	
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		sigma = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;		//the outer dummy
-		
-		for(j=0;j<nordj;j++) {
-			//76 gauss points for the inner integral
-			uu = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the inner dummy
-			mudum = mu*sqrt(1.0-sigma*sigma);
-			yyy = Gauss76Wt[j] * CSPPKernel(dp,mudum,uu);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		
-		//finish the outer integral cc already scaled
-		arg = mu*cc*sigma/2.0;
-		if ( arg == 0.0 ) {
-			answer *= 1.0;
-		} else {
-			answer *= sin(arg)*sin(arg)/arg/arg;
-		}
-		
-		//now sum up the outer integral
-		yyy = Gauss76Wt[i] * answer;
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-
-	//normalize by volume
-	answer /= vol;
-	//convert to [cm-1]
-	answer *= 1.0e8;
-	//Scale
-	answer *= scale;
-	// add in the background
-	answer += bkg;
-	
-	return answer;
-}
-
Index: c/sans/models/src/libigor/libCylinder.h
===================================================================
--- src/sans/models/src/libigor/libCylinder.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,70 +1,0 @@
-/*
-	libCylinderFit.h -- equates for CylinderFit XOP
-*/
-#if defined(_MSC_VER)
-#include "winFuncs.h"
-#endif
-
-/* Prototypes */
-/* IGOR Fit Functions */
-double CylinderForm(double dp[], double q);
-double EllipCyl76(double dp[], double q);
-double EllipCyl20(double dp[], double q);
-double TriaxialEllipsoid(double dp[], double q);
-double Parallelepiped(double dp[], double q);
-double HollowCylinder(double dp[], double q);
-double EllipsoidForm(double dp[], double q);
-double Cyl_PolyRadius(double dp[], double q);
-double Cyl_PolyLength(double dp[], double q);
-double CoreShellCylinder(double dp[], double q);
-double OblateForm(double dp[], double q);
-double ProlateForm(double dp[], double q);
-double FlexExclVolCyl(double dp[], double q);
-double FlexCyl_PolyLen(double dp[], double q);
-double FlexCyl_PolyRad(double dp[], double q);
-double FlexCyl_Ellip(double dp[], double q);
-double PolyCoShCylinder(double dp[], double q);
-double StackedDiscs(double dp[], double q);
-double LamellarFF(double dp[], double q);
-double LamellarFF_HG(double dp[], double q);
-double LamellarPS(double dp[], double q);
-double LamellarPS_HG(double dp[], double q);
-double Lamellar_ParaCrystal(double dp[], double q);
-double Spherocylinder(double dp[], double q);
-double ConvexLens(double dp[], double q);
-double Dumbbell(double dp[], double q);
-double CappedCylinder(double dp[], double q);
-double Barbell(double dp[], double q);
-double PolyCoreBicelle(double dp[], double q);
-double CSParallelepiped(double dp[], double q);
-
-/* internal functions */
-double CylKernel(double qq, double rr,double h, double theta);
-double NR_BessJ1(double x);
-double EllipCylKernel(double qq, double ra,double nu, double theta);
-double TriaxialKernel(double q, double aa, double bb, double cc, double dx, double dy);
-double PPKernel(double aa, double mu, double uu);
-double HolCylKernel(double qq, double rcore, double rshell, double length, double dum);
-double EllipsoidKernel(double qq, double a, double va, double dum);
-double Cyl_PolyRadKernel(double q, double radius, double length, double zz, double delrho, double dumRad);
-double SchulzPoint_cpr(double dumRad, double radius, double zz);
-double Cyl_PolyLenKernel(double q, double radius, double len_avg, double zz, double delrho, double dumLen);
-double CoreShellCylKernel(double qq, double rcore, double thick, double rhoc, double rhos, double rhosolv, double length, double dum);
-double gfn4(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq);
-double gfn2(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq);
-double FlePolyLen_kernel(double q, double radius, double length, double lb, double zz, double delrho, double zi);
-double FlePolyRad_kernel(double q, double ravg, double Lc, double Lb, double zz, double delrho, double zi);
-double EllipticalCross_fn(double qq, double a, double b);
-double CScyl(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length, double dum);
-double CSCylIntegration(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length);
-double Stackdisc_kern(double qq, double rcore, double rhoc, double rhol, double rhosolv, double length, double thick, double dum, double gsd, double d, double N);
-double paraCryst_sn(double ww, double qval, double davg, long nl, double an);
-double paraCryst_an(double ww, double qval, double davg, long nl);
-double SphCyl_kernel(double w[], double x, double tt, double Theta);
-double ConvLens_kernel(double w[], double x, double tt, double theta);
-double Dumb_kernel(double w[], double x, double tt, double theta);
-double BicelleKernel(double qq, double rad, double radthick, double facthick, double rhoc, double rhoh, double rhor, double rhosolv, double length, double dum);
-double BicelleIntegration(double qq, double rad, double radthick, double facthick, double rhoc, double rhoh, double rhor, double rhosolv, double length);
-double CSPPKernel(double dp[], double mu, double uu);
-
-
Index: c/sans/models/src/libigor/libSANSAnalysis.h
===================================================================
--- src/sans/models/src/libigor/libSANSAnalysis.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,194 +1,0 @@
-/*
- *  libSANSAnalysis.h
- *  SANSAnalysis
- *
- *  Created by Andrew Jackson on 4/24/07.
- *  Copyright 2007 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include "libCylinder.h"
-#include "libSphere.h"
-#include "libStructureFactor.h"
-#include "libTwoPhase.h"
-
-/*This should not be necessary AJJ May 09*/
-/* IGOR Fit Functions */
-/*
-double CylinderForm(double dp[], double q);
-double EllipCyl76(double dp[], double q);
-double EllipCyl20(double dp[], double q);
-double TriaxialEllipsoid(double dp[], double q);
-double Parallelepiped(double dp[], double q);
-double HollowCylinder(double dp[], double q);
-double EllipsoidForm(double dp[], double q);
-double Cyl_PolyRadius(double dp[], double q);
-double Cyl_PolyLength(double dp[], double q);
-double CoreShellCylinder(double dp[], double q);
-double OblateForm(double dp[], double q);
-double ProlateForm(double dp[], double q);
-double FlexExclVolCyl(double dp[], double q);
-double FlexCyl_PolyLen(double dp[], double q);
-double FlexCyl_PolyRad(double dp[], double q);
-double FlexCyl_Ellip(double dp[], double q);
-double PolyCoShCylinder(double dp[], double q);
-double StackedDiscs(double dp[], double q);
-double LamellarFF(double dp[], double q);
-double LamellarFF_HG(double dp[], double q);
-double LamellarPS(double dp[], double q);
-double LamellarPS_HG(double dp[], double q);
-//
-double Lamellar_ParaCrystal(double dp[], double q);
-double Spherocylinder(double dp[], double q);
-double ConvexLens(double dp[], double q);
-double Dumbbell(double dp[], double q);
-double CappedCylinder(double dp[], double q);
-double Barbell(double dp[], double q);
-double PolyCoreBicelle(double dp[], double q);
-*/
-
-/* internal functions */
-/*
-double CylKernel(double qq, double rr,double h, double theta);
-double NR_BessJ1(double x);
-double EllipCylKernel(double qq, double ra,double nu, double theta);
-double TriaxialKernel(double q, double aa, double bb, double cc, double dx, double dy);
-double PPKernel(double aa, double mu, double uu);
-double HolCylKernel(double qq, double rcore, double rshell, double length, double dum);
-double EllipsoidKernel(double qq, double a, double va, double dum);
-double Cyl_PolyRadKernel(double q, double radius, double length, double zz, double delrho, double dumRad);
-double SchulzPoint_cpr(double dumRad, double radius, double zz);
-double Cyl_PolyLenKernel(double q, double radius, double len_avg, double zz, double delrho, double dumLen);
-double CoreShellCylKernel(double qq, double rcore, double thick, double rhoc, double rhos, double rhosolv, double length, double dum);
-double gfn4(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq);
-double gfn2(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq);
-double FlePolyLen_kernel(double q, double radius, double length, double lb, double zz, double delrho, double zi);
-double FlePolyRad_kernel(double q, double ravg, double Lc, double Lb, double zz, double delrho, double zi);
-double EllipticalCross_fn(double qq, double a, double b);
-double CScyl(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length, double dum);
-double CSCylIntegration(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length);
-double Stackdisc_kern(double qq, double rcore, double rhoc, double rhol, double rhosolv, double length, double thick, double dum, double gsd, double d, double N);
-double BicelleKernel(double qq, double rad, double radthick, double facthick, double rhoc, double rhoh, double rhor, double rhosolv, double length, double dum);
-double BicelleIntegration(double qq, double rad, double radthick, double facthick, double rhoc, double rhoh, double rhor, double rhosolv, double length);
-*/
-
-
-//
-/* IGOR Fit Functions */
-/*
-double MultiShell(double dp[], double q);
-double PolyMultiShell(double dp[], double q);
-double SphereForm(double dp[], double q);
-double CoreShellForm(double dp[], double q);
-double PolyCoreForm(double dp[], double q);
-double PolyCoreShellRatio(double dp[], double q);
-double VesicleForm(double dp[], double q);
-double SchulzSpheres(double dp[], double q);
-double PolyRectSpheres(double dp[], double q);
-double PolyHardSphereIntensity(double dp[], double q);
-double BimodalSchulzSpheres(double dp[], double q);
-double GaussPolySphere(double dp[], double q);
-double LogNormalPolySphere(double dp[], double q);
-double BinaryHS(double dp[], double q);
-double BinaryHS_PSF11(double dp[], double q);
-double BinaryHS_PSF12(double dp[], double q);
-double BinaryHS_PSF22(double dp[], double q);
-//
-double OneShell(double dp[], double q);
-double TwoShell(double dp[], double q);
-double ThreeShell(double dp[], double q);
-double FourShell(double dp[], double q);
-double PolyOneShell(double dp[], double q);
-double PolyTwoShell(double dp[], double q);
-double PolyThreeShell(double dp[], double q);
-double PolyFourShell(double dp[], double q);
-double BCC_ParaCrystal(double dp[], double q);
-double FCC_ParaCrystal(double dp[], double q);
-double SC_ParaCrystal(double dp[], double q);
-
-//function prototypes
-double F_func(double qr);
-double MultiShellGuts(double q,double rcore,double ts,double tw,double rhocore,double rhoshel,int num);
-double fnt2(double yy, double zz);
-double fnt3(double yy, double pp, double zz);
-double SchulzSphere_Fn(double scale, double ravg, double pd, double rho, double rhos, double x);
-int ashcroft(double qval, double r2, double nf2, double aa, double phi, double *s11, double *s22, double *s12);
-
-
-////
-double HardSphereStruct(double dp[], double q);
-double SquareWellStruct(double dp[], double q);
-double StickyHS_Struct(double dp[], double q);
-double HayterPenfoldMSA(double dp[], double q);
-double DiamCyl(double a, double b);
-double DiamEllip(double a, double b);
-double sqhcal(double qq);
-int sqfun(int ix, int ir);
-int sqcoef(int ir);
-*/
-////
-/* IGOR Fit Functions */
-/*
-double TeubnerStreyModel(double dp[], double q);
-double Power_Law_Model(double dp[], double q);
-double Peak_Lorentz_Model(double dp[], double q);
-double Peak_Gauss_Model(double dp[], double q);
-double Lorentz_Model(double dp[], double q);
-double Fractal(double dp[], double q);
-double DAB_Model(double dp[], double q);
-double OneLevel(double dp[], double q);
-double TwoLevel(double dp[], double q);
-double ThreeLevel(double dp[], double q);
-double FourLevel(double dp[], double q);
-//
-double BroadPeak(double dp[], double q);
-double CorrLength(double dp[], double q);
-double TwoLorentzian(double dp[], double q);
-double TwoPowerLaw(double dp[], double q);
-double PolyGaussCoil(double dp[], double q);
-double GaussLorentzGel(double dp[], double q);
-double GaussianShell(double dp[], double q);
-*/
-
-// since the XOP and the library are separate chunks of compiled code
-// it is imperative to set ALL the structure alignments to be two-byte
-// rather than leave it to the whim of the compiler
-/* SRK08
-#include "XOPStructureAlignmentTwoByte.h"
-
-typedef struct {
-    double scale;
-    double radius;
-    double length;
-    double contrast;
-	double background;    
-    double cyl_theta;
-    double cyl_phi;    
-} CylinderParameters;
-
-typedef struct {
-    double scale;
-    double radius;
-    double length;
-    double contrast;
-	double background;
-    double cyl_theta;
-    double cyl_phi; 
-    double sigma_theta;
-    double sigma_phi;
-    double sigma_radius;
-} SmearCylinderParameters;
-
-#include "XOPStructureAlignmentReset.h"
-
-/// 1D scattering function
-double cylinder_analytical_1D(CylinderParameters *pars, double q);
-/// 2D scattering function
-double cylinder_analytical_2D(CylinderParameters *pars, double q, double phi);
-/// 1D scattering function
-double smeared_cylinder_analytical_1D(SmearCylinderParameters *pars, double q);
-/// 2D scattering function
-double dist_cylinder_2D(double pars[], double q, double phi);
-double smeared_cylinder_analytical_2D(SmearCylinderParameters *pars, double q, double phi);
-double smeared_cylinder_dist( double x, double mean, double sigma );
-*/
Index: c/sans/models/src/libigor/libSphere.c
===================================================================
--- src/sans/models/src/libigor/libSphere.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,2332 +1,0 @@
-/*	SimpleFit.c
-
-A simplified project designed to act as a template for your curve fitting function.
-The fitting function is a simple polynomial. It works but is of no practical use.
-*/
-
-#include "StandardHeaders.h"			// Include ANSI headers, Mac headers
-#include "GaussWeights.h"
-#include "libSphere.h"
-
-
-static double
-gammln(double xx) {
-    double x,y,tmp,ser;
-    static double cof[6]={76.18009172947146,-86.50532032941677,
-    24.01409824083091,-1.231739572450155,
-    0.1208650973866179e-2,-0.5395239384953e-5};
-    int j;
-
-    y=x=xx;
-    tmp=x+5.5;
-    tmp -= (x+0.5)*log(tmp);
-    ser=1.000000000190015;
-    for (j=0;j<=5;j++) ser += cof[j]/++y;
-    return -tmp+log(2.5066282746310005*ser/x);
-}
-
-static double
-LogNormal_distr(double sig, double mu, double pt)
-{
-  double retval,pi;
-
-  pi = 4.0*atan(1.0);
-  retval = (1.0/ (sig*pt*sqrt(2.0*pi)) )*exp( -0.5*(log(pt) - mu)*(log(pt) - mu)/sig/sig );
-  return(retval);
-}
-
-static double
-Gauss_distr(double sig, double avg, double pt)
-{
-  double retval,Pi;
-
-  Pi = 4.0*atan(1.0);
-  retval = (1.0/ (sig*sqrt(2.0*Pi)) )*exp(-(avg-pt)*(avg-pt)/sig/sig/2.0);
-  return(retval);
-}
-
-static double SchulzPoint(double x, double avg, double zz) {
-    double dr;
-    dr = zz*log(x) - gammln(zz+1.0)+(zz+1.0)*log((zz+1.0)/avg)-(x/avg*(zz+1.0));
-    return (exp(dr));
-};
-
-
-// scattering from a sphere - hardly needs to be an XOP...
-double
-SphereForm(double dp[], double q)
-{
-	double scale,radius,delrho,bkg,sldSph,sldSolv;		//my local names
-	double bes,f,vol,f2,pi,qr;
-
-	pi = 4.0*atan(1.0);
-	scale = dp[0];
-	radius = dp[1];
-	sldSph = dp[2];
-	sldSolv = dp[3];
-	bkg = dp[4];
-	
-	delrho = sldSph - sldSolv;
-	//handle qr==0 separately
-	qr = q*radius;
-	if(qr == 0.0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	
-	vol = 4.0*pi/3.0*radius*radius*radius;
-	f = vol*bes*delrho;		// [=] A-1
-							// normalize to single particle volume, convert to 1/cm
-	f2 = f * f / vol * 1.0e8;		// [=] 1/cm
-	
-	return(scale*f2+bkg);	//scale, and add in the background
-}
-
-// scattering from a monodisperse core-shell sphere - hardly needs to be an XOP...
-double
-CoreShellForm(double dp[], double q)
-{
-	double x,pi;
-	double scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg;		//my local names
-	double bes,f,vol,qr,contr,f2;
-	
-	pi = 4.0*atan(1.0);
-	x=q;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	thick = dp[2];
-	rhocore = dp[3];
-	rhoshel = dp[4];
-	rhosolv = dp[5];
-	bkg = dp[6];
-	// core first, then add in shell
-	qr=x*rcore;
-	contr = rhocore-rhoshel;
-	if(qr == 0.0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*rcore*rcore*rcore;
-	f = vol*bes*contr;
-	//now the shell
-	qr=x*(rcore+thick);
-	contr = rhoshel-rhosolv;
-	if(qr == 0.0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*pow((rcore+thick),3);
-	f += vol*bes*contr;
-
-	// normalize to particle volume and rescale from [A-1] to [cm-1]
-	f2 = f*f/vol*1.0e8;
-	
-	//scale if desired
-	f2 *= scale;
-	// then add in the background
-	f2 += bkg;
-	
-	return(f2);
-}
-
-// scattering from a unilamellar vesicle - hardly needs to be an XOP...
-// same functional form as the core-shell sphere, but more intuitive for a vesicle
-double
-VesicleForm(double dp[], double q)
-{
-	double x,pi;
-	double scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg;		//my local names
-	double bes,f,vol,qr,contr,f2;
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	thick = dp[2];
-	rhocore = dp[3];
-	rhosolv = rhocore;
-	rhoshel = dp[4];
-	bkg = dp[5];
-	// core first, then add in shell
-	qr=x*rcore;
-	contr = rhocore-rhoshel;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*rcore*rcore*rcore;
-	f = vol*bes*contr;
-	//now the shell
-	qr=x*(rcore+thick);
-	contr = rhoshel-rhosolv;
-	if(qr == 0.0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*pow((rcore+thick),3);
-	f += vol*bes*contr;
-
-	// normalize to the particle volume and rescale from [A-1] to [cm-1]
-	//note that for the vesicle model, the volume is ONLY the shell volume
-	vol = 4.0*pi/3.0*(pow((rcore+thick),3)-pow(rcore,3));
-	f2 = f*f/vol*1.0e8;
-	
-	//scale if desired
-	f2 *= scale;
-	// then add in the background
-	f2 += bkg;
-	
-	return(f2);
-}
-
-
-// scattering from a core shell sphere with a (Schulz) polydisperse core and constant shell thickness
-//
-double
-PolyCoreForm(double dp[], double q)
-{
-	double pi;
-	double scale,corrad,sig,zz,del,drho1,drho2,form,bkg;		//my local names
-	double d, g ,h;
-	double qq, x, y, c1, c2, c3, c4, c5, c6, c7, c8, c9, t1, t2, t3;
-	double t4, t5, tb, cy, sy, tb1, tb2, tb3, c2y, zp1, zp2;
-	double zp3,vpoly;
-	double s2y, arg1, arg2, arg3, drh1, drh2;
-	
-	pi = 4.0*atan(1.0);
-	qq= q;
-	scale = dp[0];
-	corrad = dp[1];
-	sig = dp[2];
-	del = dp[3];
-	drho1 = dp[4]-dp[5];		//core-shell
-	drho2 = dp[5]-dp[6];		//shell-solvent
-	bkg = dp[7];
-	
-	zz = (1.0/sig)*(1.0/sig) - 1.0;   
-	
-	h=qq;
-	
-	drh1 = drho1;
-	drh2 = drho2;
-	g = drh2 * -1. / drh1;
-	zp1 = zz + 1.;
-	zp2 = zz + 2.;
-	zp3 = zz + 3.;
-	vpoly = 4*pi/3*zp3*zp2/zp1/zp1*pow((corrad+del),3);
-	
-	
-	// remember that h is the passed in value of q for the calculation
-	y = h *del;
-	x = h *corrad;
-	d = atan(x * 2. / zp1);
-	arg1 = zp1 * d;
-	arg2 = zp2 * d;
-	arg3 = zp3 * d;
-	sy = sin(y);
-	cy = cos(y);
-	s2y = sin(y * 2.);
-	c2y = cos(y * 2.);
-	c1 = .5 - g * (cy + y * sy) + g * g * .5 * (y * y + 1.);
-	c2 = g * y * (g - cy);
-	c3 = (g * g + 1.) * .5 - g * cy;
-	c4 = g * g * (y * cy - sy) * (y * cy - sy) - c1;
-	c5 = g * 2. * sy * (1. - g * (y * sy + cy)) + c2;
-	c6 = c3 - g * g * sy * sy;
-	c7 = g * sy - g * .5 * g * (y * y + 1.) * s2y - c5;
-	c8 = c4 - .5 + g * cy - g * .5 * g * (y * y + 1.) * c2y;
-	c9 = g * sy * (1. - g * cy);
-	
-	tb = log(zp1 * zp1 / (zp1 * zp1 + x * 4. * x));
-	tb1 = exp(zp1 * .5 * tb);
-	tb2 = exp(zp2 * .5 * tb);
-	tb3 = exp(zp3 * .5 * tb);
-	
-	t1 = c1 + c2 * x + c3 * x * x * zp2 / zp1;
-	t2 = tb1 * (c4 * cos(arg1) + c7 * sin(arg1));
-	t3 = x * tb2 * (c5 * cos(arg2) + c8 * sin(arg2));
-	t4 = zp2 / zp1 * x * x * tb3 * (c6 * cos(arg3) + c9 * sin(arg3));
-	t5 = t1 + t2 + t3 + t4;
-	form = t5 * 16. * pi * pi * drh1 * drh1 / pow(qq,6);
-	//	normalize by the average volume !!! corrected for polydispersity
-	// and convert to cm-1
-	form /= vpoly;
-	form *= 1.0e8;
-	//Scale
-	form *= scale;
-	// then add in the background
-	form += bkg;
-	
-	return(form);
-}
-
-// scattering from a uniform sphere with a (Schulz) size distribution
-// structure factor effects are explicitly and correctly included.
-//
-double
-PolyHardSphereIntensity(double dp[], double q)
-{
-	double pi;
-	double rad,z2,phi,cont,bkg,sigma;		//my local names
-	double mu,mu1,d1,d2,d3,d4,d5,d6,capd,rho;
-	double ll,l1,bb,cc,chi,chi1,chi2,ee,t1,t2,t3,pp;
-	double ka,zz,v1,v2,p1,p2;
-	double h1,h2,h3,h4,e1,yy,y1,s1,s2,s3,hint1,hint2;
-	double capl,capl1,capmu,capmu1,r3,pq;
-	double ka2,r1,heff;
-	double hh,k,slds,sld;
-	
-	pi = 4.0*atan(1.0);
-	k= q;
-	
-	rad = dp[0];		// radius (A)
-	z2 = dp[1];		//polydispersity (0<z2<1)
-	phi = dp[2];		// volume fraction (0<phi<1)
-	slds = dp[3];
-	sld = dp[4];
-	cont = (slds - sld)*1.0e4;		// contrast (odd units)
-	bkg = dp[5];
-	sigma = 2*rad;
-	
-	zz=1.0/(z2*z2)-1.0;
-	bb = sigma/(zz+1.0);
-	cc = zz+1.0;
-	
-	//*c   Compute the number density by <r-cubed>, not <r> cubed*/
-	r1 = sigma/2.0;
-	r3 = r1*r1*r1;
-	r3 *= (zz+2.0)*(zz+3.0)/((zz+1.0)*(zz+1.0));
-	rho=phi/(1.3333333333*pi*r3);
-	t1 = rho*bb*cc;
-	t2 = rho*bb*bb*cc*(cc+1.0);
-	t3 = rho*bb*bb*bb*cc*(cc+1.0)*(cc+2.0);
-	capd = 1.0-pi*t3/6.0;
-	//************
-	v1=1.0/(1.0+bb*bb*k*k);
-	v2=1.0/(4.0+bb*bb*k*k);
-	pp=pow(v1,(cc/2.0))*sin(cc*atan(bb*k));
-	p1=bb*cc*pow(v1,((cc+1.0)/2.0))*sin((cc+1.0)*atan(bb*k));
-	p2=cc*(cc+1.0)*bb*bb*pow(v1,((cc+2.0)/2.0))*sin((cc+2.0)*atan(bb*k));
-	mu=pow(2,cc)*pow(v2,(cc/2.0))*sin(cc*atan(bb*k/2.0));
-	mu1=pow(2,(cc+1.0))*bb*cc*pow(v2,((cc+1.0)/2.0))*sin((cc+1.0)*atan(k*bb/2.0));
-	s1=bb*cc;
-	s2=cc*(cc+1.0)*bb*bb;
-	s3=cc*(cc+1.0)*(cc+2.0)*bb*bb*bb;
-	chi=pow(v1,(cc/2.0))*cos(cc*atan(bb*k));
-	chi1=bb*cc*pow(v1,((cc+1.0)/2.0))*cos((cc+1.0)*atan(bb*k));
-	chi2=cc*(cc+1.0)*bb*bb*pow(v1,((cc+2.0)/2.0))*cos((cc+2.0)*atan(bb*k));
-	ll=pow(2,cc)*pow(v2,(cc/2.0))*cos(cc*atan(bb*k/2.0));
-	l1=pow(2,(cc+1.0))*bb*cc*pow(v2,((cc+1.0)/2.0))*cos((cc+1.0)*atan(k*bb/2.0));
-	d1=(pi/capd)*(2.0+(pi/capd)*(t3-(rho/k)*(k*s3-p2)));
-	d2=pow((pi/capd),2)*(rho/k)*(k*s2-p1);
-	d3=(-1.0)*pow((pi/capd),2)*(rho/k)*(k*s1-pp);
-	d4=(pi/capd)*(k-(pi/capd)*(rho/k)*(chi1-s1));
-	d5=pow((pi/capd),2)*((rho/k)*(chi-1.0)+0.5*k*t2);
-	d6=pow((pi/capd),2)*(rho/k)*(chi2-s2);
-	
-	e1=pow((pi/capd),2)*pow((rho/k/k),2)*((chi-1.0)*(chi2-s2)-(chi1-s1)*(chi1-s1)-(k*s1-pp)*(k*s3-p2)+pow((k*s2-p1),2));
-	ee=1.0-(2.0*pi/capd)*(1.0+0.5*pi*t3/capd)*(rho/k/k/k)*(k*s1-pp)-(2.0*pi/capd)*rho/k/k*((chi1-s1)+(0.25*pi*t2/capd)*(chi2-s2))-e1;
-	y1=pow((pi/capd),2)*pow((rho/k/k),2)*((k*s1-pp)*(chi2-s2)-2.0*(k*s2-p1)*(chi1-s1)+(k*s3-p2)*(chi-1.0));
-	yy = (2.0*pi/capd)*(1.0+0.5*pi*t3/capd)*(rho/k/k/k)*(chi+0.5*k*k*s2-1.0)-(2.0*pi*rho/capd/k/k)*(k*s2-p1+(0.25*pi*t2/capd)*(k*s3-p2))-y1;    
-	
-	capl=2.0*pi*cont*rho/k/k/k*(pp-0.5*k*(s1+chi1));
-	capl1=2.0*pi*cont*rho/k/k/k*(p1-0.5*k*(s2+chi2));
-	capmu=2.0*pi*cont*rho/k/k/k*(1.0-chi-0.5*k*p1);
-	capmu1=2.0*pi*cont*rho/k/k/k*(s1-chi1-0.5*k*p2);
-	
-	h1=capl*(capl*(yy*d1-ee*d6)+capl1*(yy*d2-ee*d4)+capmu*(ee*d1+yy*d6)+capmu1*(ee*d2+yy*d4));
-	h2=capl1*(capl*(yy*d2-ee*d4)+capl1*(yy*d3-ee*d5)+capmu*(ee*d2+yy*d4)+capmu1*(ee*d3+yy*d5));
-	h3=capmu*(capl*(ee*d1+yy*d6)+capl1*(ee*d2+yy*d4)+capmu*(ee*d6-yy*d1)+capmu1*(ee*d4-yy*d2));
-	h4=capmu1*(capl*(ee*d2+yy*d4)+capl1*(ee*d3+yy*d5)+capmu*(ee*d4-yy*d2)+capmu1*(ee*d5-yy*d3));
-	
-	//*  This part computes the second integral in equation (1) of the paper.*/
-	
-	hint1 = -2.0*(h1+h2+h3+h4)/(k*k*k*(ee*ee+yy*yy));
-	
-	//*  This part computes the first integral in equation (1).  It also
-	// generates the KC approximated effective structure factor.*/
-	
-	pq=4.0*pi*cont*(sin(k*sigma/2.0)-0.5*k*sigma*cos(k*sigma/2.0));
-	hint2=8.0*pi*pi*rho*cont*cont/(k*k*k*k*k*k)*(1.0-chi-k*p1+0.25*k*k*(s2+chi2));
-	
-	ka=k*(sigma/2.0);
-	//
-	hh=hint1+hint2;		// this is the model intensity
-						//
-	heff=1.0+hint1/hint2;
-	ka2=ka*ka;
-	//*
-	//  heff is PY analytical solution for intensity divided by the 
-	//   form factor.  happ is the KC approximated effective S(q)
-	 
-	 //*******************
-	 //  add in the background then return the intensity value
-	 
-	 return(hh+bkg);	//scale, and add in the background
-}
-
-// scattering from a uniform sphere with a (Schulz) size distribution, bimodal population
-// NO CROSS TERM IS ACCOUNTED FOR == DILUTE SOLUTION!!
-//
-double
-BimodalSchulzSpheres(double dp[], double q)
-{
-	double x,pq;
-	double scale,ravg,pd,bkg,rho,rhos;		//my local names
-	double scale2,ravg2,pd2,rho2;		//my local names
-	
-	x= q;
-	
-	scale = dp[0];
-	ravg = dp[1];
-	pd = dp[2];
-	rho = dp[3];
-	scale2 = dp[4];
-	ravg2 = dp[5];
-	pd2 = dp[6];
-	rho2 = dp[7];
-	rhos = dp[8];
-	bkg = dp[9];
-	
-	pq = SchulzSphere_Fn( scale,  ravg,  pd,  rho,  rhos, x);
-	pq += SchulzSphere_Fn( scale2,  ravg2,  pd2,  rho2,  rhos, x);
-	// add in the background
-	pq += bkg;
-	
-	return (pq);
-}
-
-// scattering from a uniform sphere with a (Schulz) size distribution
-//
-double
-SchulzSpheres(double dp[], double q)
-{
-	double x,pq;
-	double scale,ravg,pd,bkg,rho,rhos;		//my local names
-	
-	x= q;
-	
-	scale = dp[0];
-	ravg = dp[1];
-	pd = dp[2];
-	rho = dp[3];
-	rhos = dp[4];
-	bkg = dp[5];
-	pq = SchulzSphere_Fn( scale,  ravg,  pd,  rho,  rhos, x);
-	// add in the background
-	pq += bkg;
-	
-	return(pq);
-}
-
-// calculates everything but the background
-double
-SchulzSphere_Fn(double scale, double ravg, double pd, double rho, double rhos, double x)
-{
-	double zp1,zp2,zp3,zp4,zp5,zp6,zp7,vpoly;
-	double aa,at1,at2,rt1,rt2,rt3,t1,t2,t3;
-	double v1,v2,v3,g1,pq,pi,delrho,zz;
-	double i_zero,Rg2,zp8;
-	
-	pi = 4.0*atan(1.0);
-	delrho = rho-rhos;
-	zz = (1.0/pd)*(1.0/pd) - 1.0;   
-	
-	zp1 = zz + 1.0;
-	zp2 = zz + 2.0;
-	zp3 = zz + 3.0;
-	zp4 = zz + 4.0;
-	zp5 = zz + 5.0;
-	zp6 = zz + 6.0;
-	zp7 = zz + 7.0;
-	//
-	
-	//small QR limit - use Guinier approx
-	zp8 = zz+8.0;
-	if(x*ravg < 0.1) {
-		i_zero = scale*delrho*delrho*1.e8*4.*pi/3.*pow(ravg,3);
-		i_zero *= zp6*zp5*zp4/zp1/zp1/zp1;		//6th moment / 3rd moment
-		Rg2 = 3.*zp8*zp7/5./(zp1*zp1)*ravg*ravg;
-		pq = i_zero*exp(-x*x*Rg2/3.);
-		//pq += bkg;		//unlike the Igor code, the backgorund is added in the wrapper (above)
-		return(pq);
-	}
-	//
-
-	aa = (zz+1.0)/x/ravg;
-	
-	at1 = atan(1.0/aa);
-	at2 = atan(2.0/aa);
-	//
-	//  calculations are performed to avoid  large # errors
-	// - trick is to propogate the a^(z+7) term through the g1
-	// 
-	t1 = zp7*log10(aa) - zp1/2.0*log10(aa*aa+4.0);
-	t2 = zp7*log10(aa) - zp3/2.0*log10(aa*aa+4.0);
-	t3 = zp7*log10(aa) - zp2/2.0*log10(aa*aa+4.0);
-	//	print t1,t2,t3
-	rt1 = pow(10,t1);
-	rt2 = pow(10,t2);
-	rt3 = pow(10,t3);
-	v1 = pow(aa,6) - rt1*cos(zp1*at2);
-	v2 = zp1*zp2*( pow(aa,4) + rt2*cos(zp3*at2) );
-	v3 = -2.0*zp1*rt3*sin(zp2*at2);
-	g1 = (v1+v2+v3);
-	
-	pq = log10(g1) - 6.0*log10(zp1) + 6.0*log10(ravg);
-	pq = pow(10,pq)*8.0*pi*pi*delrho*delrho;
-	
-	//
-	// beta factor is not used here, but could be for the 
-	// decoupling approximation
-	// 
-	//	g11 = g1
-	//	gd = -zp7*log(aa)
-	//	g1 = log(g11) + gd
-	//                       
-	//	t1 = zp1*at1
-	//	t2 = zp2*at1
-	//	g2 = sin( t1 ) - zp1/sqrt(aa*aa+1)*cos( t2 )
-	//	g22 = g2*g2
-	//	beta = zp1*log(aa) - zp1*log(aa*aa+1) - g1 + log(g22) 
-	//	beta = 2*alog(beta)
-	
-	//re-normalize by the average volume
-	vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*ravg*ravg*ravg;
-	pq /= vpoly;
-	//scale, convert to cm^-1
-	pq *= scale * 1.0e8;
-    
-    return(pq);
-}
-
-// scattering from a uniform sphere with a rectangular size distribution
-//
-double
-PolyRectSpheres(double dp[], double q)
-{
-	double pi,x;
-	double scale,rad,pd,cont,bkg;		//my local names
-	double inten,h1,qw,qr,width,sig,averad3,Rg2,slds,sld;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	scale = dp[0];
-	rad = dp[1];		// radius (A)
-	pd = dp[2];		//polydispersity of rectangular distribution
-	slds = dp[3];
-	sld = dp[4];
-	cont = slds - sld;		// contrast (A^-2)
-	bkg = dp[5];
-	
-	// as usual, poly = sig/ravg
-	// for the rectangular distribution, sig = width/sqrt(3)
-	// width is the HALF- WIDTH of the rectangular distrubution
-	
-	sig = pd*rad;
-	width = sqrt(3.0)*sig;
-	
-	//x is the q-value
-	qw = x*width;
-	qr = x*rad;
-	
-	// as for the numerical inatabilities at low QR, the function is calculating the sines and cosines
-	// just fine - the problem seems to be that the 
-	// leading terms nearly cancel with the last term (the -6*qr... term), to within machine
-	// precision - the difference is on the order of 10^-20
-	// so just use the limiting Guiner value
-	if(qr<0.1) {
-		h1 = scale*cont*cont*1.e8*4.*pi/3.0*pow(rad,3);
-		h1 *= 	(1. + 15.*pow(pd,2) + 27.*pow(pd,4) +27./7.*pow(pd,6) );				//6th moment
-		h1 /= (1.+3.*pd*pd);	//3rd moment
-		Rg2 = 3.0/5.0*rad*rad*( 1.+28.*pow(pd,2)+126.*pow(pd,4)+108.*pow(pd,6)+27.*pow(pd,8) );
-		Rg2 /= (1.+15.*pow(pd,2)+27.*pow(pd,4)+27./7.*pow(pd,6));
-		h1 *= exp(-1./3.*Rg2*x*x);
-		h1 += bkg;
-		return(h1);
-	}
-	
-	// normal calculation
-	h1 = -0.5*qw + qr*qr*qw + (qw*qw*qw)/3.0;
-	h1 -= 5.0/2.0*cos(2.0*qr)*sin(qw)*cos(qw);
-	h1 += 0.5*qr*qr*cos(2.0*qr)*sin(2.0*qw);
-	h1 += 0.5*qw*qw*cos(2.0*qr)*sin(2.0*qw);
-	h1 += qw*qr*sin(2.0*qr)*cos(2.0*qw);
-	h1 += 3.0*qw*(cos(qr)*cos(qw))*(cos(qr)*cos(qw));
-	h1+= 3.0*qw*(sin(qr)*sin(qw))*(sin(qr)*sin(qw));
-	h1 -= 6.0*qr*cos(qr)*sin(qr)*cos(qw)*sin(qw);
-	
-	// calculate P(q) = <f^2>
-	inten = 8.0*pi*pi*cont*cont/width/pow(x,7)*h1;
-	
-	// beta(q) would be calculated as 2/width/x/h1*h2*h2
-	// with 
-	// h2 = 2*sin(x*rad)*sin(x*width)-x*rad*cos(x*rad)*sin(x*width)-x*width*sin(x*rad)*cos(x*width)
-	
-	// normalize to the average volume
-	// <R^3> = ravg^3*(1+3*pd^2)
-	// or... "zf"  = (1 + 3*p^2), which will be greater than one
-	
-	averad3 =  rad*rad*rad*(1.0+3.0*pd*pd);
-	inten /= 4.0*pi/3.0*averad3;
-	//resacle to 1/cm
-	inten *= 1.0e8;
-	//scale the result
-	inten *= scale;
-	// then add in the background
-	inten += bkg;
-	
-	return(inten);
-}
-
-
-// scattering from a uniform sphere with a Gaussian size distribution
-//
-double
-GaussPolySphere(double dp[], double q)
-{
-	double pi,x;
-	double scale,rad,pd,sig,rho,rhos,bkg,delrho;		//my local names
-	double va,vb,zi,yy,summ,inten;
-	int nord=20,ii;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	scale=dp[0];
-	rad=dp[1];
-	pd=dp[2];
-	sig=pd*rad;
-	rho=dp[3];
-	rhos=dp[4];
-	delrho=rho-rhos;
-	bkg=dp[5];
-	
-	va = -4.0*sig + rad;
-	if (va<0.0) {
-		va=0.0;		//to avoid numerical error when  va<0 (-ve q-value)
-	}
-	vb = 4.0*sig +rad;
-	
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss20Z[ii]*(vb-va) + vb + va )/2.0;
-		// calculate sphere scattering
-		//return(3*(sin(qr) - qr*cos(qr))/(qr*qr*qr)); pass qr
-		yy = F_func(x*zi)*(4.0*pi/3.0*zi*zi*zi)*delrho;
-		yy *= yy;
-		yy *= Gauss20Wt[ii] *  Gauss_distr(sig,rad,zi);
-		
-		summ += yy;		//add to the running total of the quadrature
-   	}
-	// calculate value of integral to return
-	inten = (vb-va)/2.0*summ;
-	
-	//re-normalize by polydisperse sphere volume
-	inten /= (4.0*pi/3.0*rad*rad*rad)*(1.0+3.0*pd*pd);
-	
-	inten *= 1.0e8;
-	inten *= scale;
-	inten += bkg;
-	
-    return(inten);	//scale, and add in the background
-}
-
-// scattering from a uniform sphere with a LogNormal size distribution
-//
-double
-LogNormalPolySphere(double dp[], double q)
-{
-	double pi,x;
-	double scale,rad,sig,rho,rhos,bkg,delrho,mu,r3;		//my local names
-	double va,vb,zi,yy,summ,inten;
-	int nord=76,ii;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	scale=dp[0];
-	rad=dp[1];		//rad is the median radius
-	mu = log(dp[1]);
-	sig=dp[2];
-	rho=dp[3];
-	rhos=dp[4];
-	delrho=rho-rhos;
-	bkg=dp[5];
-	
-	va = -3.5*sig + mu;
-	va = exp(va);
-	if (va<0.0) {
-		va=0.0;		//to avoid numerical error when  va<0 (-ve q-value)
-	}
-	vb = 3.5*sig*(1.0+sig) +mu;
-	vb = exp(vb);
-	
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss76Z[ii]*(vb-va) + vb + va )/2.0;
-		// calculate sphere scattering
-		//return(3*(sin(qr) - qr*cos(qr))/(qr*qr*qr)); pass qr
-		yy = F_func(x*zi)*(4.0*pi/3.0*zi*zi*zi)*delrho;
-		yy *= yy;
-		yy *= Gauss76Wt[ii] *  LogNormal_distr(sig,mu,zi);
-		
-		summ += yy;		//add to the running total of the quadrature
-   	}
-	// calculate value of integral to return
-	inten = (vb-va)/2.0*summ;
-	
-	//re-normalize by polydisperse sphere volume
-	r3 = exp(3.0*mu + 9.0/2.0*sig*sig);		// <R^3> directly
-	inten /= (4.0*pi/3.0*r3);		//polydisperse volume
-	
-	inten *= 1.0e8;
-	inten *= scale;
-	inten += bkg;
-	
-	return(inten);
-}
-
-/*
-static double
-LogNormal_distr(double sig, double mu, double pt)
-{	
-	double retval,pi;
-	
-	pi = 4.0*atan(1.0);
-	retval = (1.0/ (sig*pt*sqrt(2.0*pi)) )*exp( -0.5*(log(pt) - mu)*(log(pt) - mu)/sig/sig );
-	return(retval);
-}
-
-static double
-Gauss_distr(double sig, double avg, double pt)
-{	
-	double retval,Pi;
-	
-	Pi = 4.0*atan(1.0);
-	retval = (1.0/ (sig*sqrt(2.0*Pi)) )*exp(-(avg-pt)*(avg-pt)/sig/sig/2.0);
-	return(retval);
-}
-*/
-
-// scattering from a core shell sphere with a (Schulz) polydisperse core and constant ratio (shell thickness)/(core radius)
-// - the polydispersity is of the WHOLE sphere
-//
-double
-PolyCoreShellRatio(double dp[], double q)
-{
-	double pi,x;
-	double scale,corrad,thick,shlrad,pp,drho1,drho2,sig,zz,bkg;		//my local names
-	double sld1,sld2,sld3,zp1,zp2,zp3,vpoly;
-	double pi43,c1,c2,form,volume,arg1,arg2;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	scale = dp[0];
-	corrad = dp[1];
-	thick = dp[2];
-	sig = dp[3];
-	sld1 = dp[4];
-	sld2 = dp[5];
-	sld3 = dp[6];
-	bkg = dp[7];
-	
-	zz = (1.0/sig)*(1.0/sig) - 1.0;   
-	shlrad = corrad + thick;
-	drho1 = sld1-sld2;		//core-shell
-	drho2 = sld2-sld3;		//shell-solvent
-	zp1 = zz + 1.;
-	zp2 = zz + 2.;
-	zp3 = zz + 3.;
-	vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*pow((corrad+thick),3);
-	
-	// the beta factor is not calculated
- 	// the calculated form factor <f^2> has units [length^2]
- 	// and must be multiplied by number density [l^-3] and the correct unit
- 	// conversion to get to absolute scale
-	
-	pi43=4.0/3.0*pi;
- 	pp=corrad/shlrad;
- 	volume=pi43*shlrad*shlrad*shlrad;
- 	c1=drho1*volume;
- 	c2=drho2*volume;
-	
-	arg1 = x*shlrad*pp;
-	arg2 = x*shlrad;
-	
-	form=pow(pp,6)*c1*c1*fnt2(arg1,zz);
-	form += c2*c2*fnt2(arg2,zz);
-	form += 2.0*c1*c2*fnt3(arg2,pp,zz);
-	
-	//convert the result to [cm^-1]
-	
-	//scale the result
-	// - divide by the polydisperse volume, mult by 10^8
-	form  /= vpoly;
-	form *= 1.0e8;
-	form *= scale;
-	
-	//add in the background
-	form += bkg;
-	
-	return(form);
-}
-
-//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-//c
-//c      function fnt2(y,z)
-//c
-double
-fnt2(double yy, double zz)
-{
-	double z1,z2,z3,u,ww,term1,term2,term3,ans;
-	
-	z1=zz+1.0;
-	z2=zz+2.0;
-	z3=zz+3.0;
-	u=yy/z1;
-	ww=atan(2.0*u);
-	term1=cos(z1*ww)/pow((1.0+4.0*u*u),(z1/2.0));
-	term2=2.0*yy*sin(z2*ww)/pow((1.0+4.0*u*u),(z2/2.0));
-	term3=1.0+cos(z3*ww)/pow((1.0+4.0*u*u),(z3/2.0));
-	ans=(4.50/z1/pow(yy,6))*(z1*(1.0-term1-term2)+yy*yy*z2*term3);
-	
-	return(ans);
-}
-
-//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-//c
-//c      function fnt3(y,p,z)
-//c
-double
-fnt3(double yy, double pp, double zz)
-{     	
-	double z1,z2,z3,yp,yn,up,un,vp,vn,term1,term2,term3,term4,term5,term6,ans;
-	
-	z1=zz+1.0;
-	z2=zz+2.0;
-	z3=zz+3.0;
-	yp=(1.0+pp)*yy;
-	yn=(1.0-pp)*yy;
-	up=yp/z1;
-	un=yn/z1;
-	vp=atan(up);
-	vn=atan(un);
-	term1=cos(z1*vn)/pow((1.0+un*un),(z1/2.0));
-	term2=cos(z1*vp)/pow((1.0+up*up),(z1/2.0));
-	term3=cos(z3*vn)/pow((1.0+un*un),(z3/2.0));
-	term4=cos(z3*vp)/pow((1.0+up*up),(z3/2.0));
-	term5=yn*sin(z2*vn)/pow((1.0+un*un),(z2/2.0));
-	term6=yp*sin(z2*vp)/pow((1.0+up*up),(z2/2.0));
-	ans=4.5/z1/pow(yy,6);
-	ans *=(z1*(term1-term2)+yy*yy*pp*z2*(term3+term4)+z1*(term5-term6));
-	
-	return(ans);
-}
-
-// scattering from a a binary population of hard spheres, 3 partial structure factors
-// are properly accounted for...
-//	 Input (fitting) variables are:
-//	larger sphere radius(angstroms) = guess[0]
-// 	smaller sphere radius (A) = w[1]
-//	number fraction of larger spheres = guess[2]
-//	total volume fraction of spheres = guess[3]
-//	size ratio, alpha(0<a<1) = derived
-//	SLD(A-2) of larger particle = guess[4]
-//	SLD(A-2) of smaller particle = guess[5]
-//	SLD(A-2) of the solvent = guess[6]
-//	background = guess[7]
-double
-BinaryHS(double dp[], double q)
-{
-	double x,pi;
-	double r2,r1,nf2,phi,aa,rho2,rho1,rhos,inten,bgd;		//my local names
-	double psf11,psf12,psf22;
-	double phi1,phi2,phr,a3;
-	double v1,v2,n1,n2,qr1,qr2,b1,b2,sc1,sc2;
-	int err;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	r2 = dp[0];
-	r1 = dp[1];
-	phi2 = dp[2];
-	phi1 = dp[3];
-	rho2 = dp[4];
-	rho1 = dp[5];
-	rhos = dp[6];
-	bgd = dp[7];
-	
-	
-	phi = phi1 + phi2;
-	aa = r1/r2;
-	//calculate the number fraction of larger spheres (eqn 2 in reference)
-	a3=aa*aa*aa;
-	phr=phi2/phi;
-	nf2 = phr*a3/(1.0-phr+phr*a3);
-	// calculate the PSF's here
-	err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12);
-	
-	// /* do form factor calculations  */
-	
-	v1 = 4.0*pi/3.0*r1*r1*r1;
-	v2 = 4.0*pi/3.0*r2*r2*r2;
-	
-	n1 = phi1/v1;
-	n2 = phi2/v2;
-	
-	qr1 = r1*x;
-	qr2 = r2*x;
-
-	if (qr1 == 0){
-		sc1 = 1.0/3.0;
-	}else{
-		sc1 = (sin(qr1)-qr1*cos(qr1))/qr1/qr1/qr1;
-	}
-	if (qr2 == 0){
-		sc2 = 1.0/3.0;
-	}else{
-		sc2 = (sin(qr2)-qr2*cos(qr2))/qr2/qr2/qr2;
-	}
-	b1 = r1*r1*r1*(rho1-rhos)*4.0*pi*sc1;
-	b2 = r2*r2*r2*(rho2-rhos)*4.0*pi*sc2;
-	inten = n1*b1*b1*psf11;
-	inten += sqrt(n1*n2)*2.0*b1*b2*psf12;
-	inten += n2*b2*b2*psf22;
-	///* convert I(1/A) to (1/cm)  */
-	inten *= 1.0e8;
-	
-	inten += bgd;
-	
-	return(inten);
-}
-
-double
-BinaryHS_PSF11(double dp[], double q)
-{
-	double x,pi;
-	double r2,r1,nf2,phi,aa,rho2,rho1,rhos,bgd;		//my local names
-	double psf11,psf12,psf22;
-	double phi1,phi2,phr,a3;
-	int err;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	r2 = dp[0];
-	r1 = dp[1];
-	phi2 = dp[2];
-	phi1 = dp[3];
-	rho2 = dp[4];
-	rho1 = dp[5];
-	rhos = dp[6];
-	bgd = dp[7];
-	phi = phi1 + phi2;
-	aa = r1/r2;
-	//calculate the number fraction of larger spheres (eqn 2 in reference)
-	a3=aa*aa*aa;
-	phr=phi2/phi;
-	nf2 = phr*a3/(1.0-phr+phr*a3);
-	// calculate the PSF's here
-	err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12);
-	
-    return(psf11);	//scale, and add in the background
-}
-
-double
-BinaryHS_PSF12(double dp[], double q)
-{
-	double x,pi;
-	double r2,r1,nf2,phi,aa,rho2,rho1,rhos,bgd;		//my local names
-	double psf11,psf12,psf22;
-	double phi1,phi2,phr,a3;
-	int err;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	r2 = dp[0];
-	r1 = dp[1];
-	phi2 = dp[2];
-	phi1 = dp[3];
-	rho2 = dp[4];
-	rho1 = dp[5];
-	rhos = dp[6];
-	bgd = dp[7];
-	phi = phi1 + phi2;
-	aa = r1/r2;
-	//calculate the number fraction of larger spheres (eqn 2 in reference)
-	a3=aa*aa*aa;
-	phr=phi2/phi;
-	nf2 = phr*a3/(1.0-phr+phr*a3);
-	// calculate the PSF's here
-	err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12);
-	
-    return(psf12);	//scale, and add in the background
-}
-
-double
-BinaryHS_PSF22(double dp[], double q)
-{
-	double x,pi;
-	double r2,r1,nf2,phi,aa,rho2,rho1,rhos,bgd;		//my local names
-	double psf11,psf12,psf22;
-	double phi1,phi2,phr,a3;
-	int err;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	r2 = dp[0];
-	r1 = dp[1];
-	phi2 = dp[2];
-	phi1 = dp[3];
-	rho2 = dp[4];
-	rho1 = dp[5];
-	rhos = dp[6];
-	bgd = dp[7];
-	phi = phi1 + phi2;
-	aa = r1/r2;
-	//calculate the number fraction of larger spheres (eqn 2 in reference)
-	a3=aa*aa*aa;
-	phr=phi2/phi;
-	nf2 = phr*a3/(1.0-phr+phr*a3);
-	// calculate the PSF's here
-	err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12);
-	
-    return(psf22);	//scale, and add in the background
-}
-
-int
-ashcroft(double qval, double r2, double nf2, double aa, double phi, double *s11, double *s22, double *s12)
-{
-	//	variable qval,r2,nf2,aa,phi,&s11,&s22,&s12
-	
-	//   calculate constant terms
-	double s1,s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4;
-	double a1,a2i,a2,b1,b2,b12,gm1,gm12;
-	double err=0.0,yy,ay,ay2,ay3,t1,t2,t3,f11,y2,y3,tt1,tt2,tt3;
-	double c11,c22,c12,f12,f22,ttt1,ttt2,ttt3,ttt4,yl,y13;
-	double t21,t22,t23,t31,t32,t33,t41,t42,yl3,wma3,y1;
-	
-	s2 = 2.0*r2;
-	s1 = aa*s2;
-	v = phi;
-	a3 = aa*aa*aa;
-	v1=((1.-nf2)*a3/(nf2+(1.-nf2)*a3))*v;
-	v2=(nf2/(nf2+(1.-nf2)*a3))*v;
-	g11=((1.+.5*v)+1.5*v2*(aa-1.))/(1.-v)/(1.-v);
-	g22=((1.+.5*v)+1.5*v1*(1./aa-1.))/(1.-v)/(1.-v);
-	g12=((1.+.5*v)+1.5*(1.-aa)*(v1-v2)/(1.+aa))/(1.-v)/(1.-v);
-	wmv = 1/(1.-v);
-	wmv3 = wmv*wmv*wmv;
-	wmv4 = wmv*wmv3;
-	a1=3.*wmv4*((v1+a3*v2)*(1.+v+v*v)-3.*v1*v2*(1.-aa)*(1.-aa)*(1.+v1+aa*(1.+v2))) + ((v1+a3*v2)*(1.+2.*v)+(1.+v+v*v)-3.*v1*v2*(1.-aa)*(1.-aa)-3.*v2*(1.-aa)*(1.-aa)*(1.+v1+aa*(1.+v2)))*wmv3;
-	a2i=((v1+a3*v2)*(1.+v+v*v)-3.*v1*v2*(1.-aa)*(1.-aa)*(1.+v1+aa*(1.+v2)))*3*wmv4 + ((v1+a3*v2)*(1.+2.*v)+a3*(1.+v+v*v)-3.*v1*v2*(1.-aa)*(1.-aa)*aa-3.*v1*(1.-aa)*(1.-aa)*(1.+v1+aa*(1.+v2)))*wmv3;
-	a2=a2i/a3;
-	b1=-6.*(v1*g11*g11+.25*v2*(1.+aa)*(1.+aa)*aa*g12*g12);
-	b2=-6.*(v2*g22*g22+.25*v1/a3*(1.+aa)*(1.+aa)*g12*g12);
-	b12=-3.*aa*(1.+aa)*(v1*g11/aa/aa+v2*g22)*g12;
-	gm1=(v1*a1+a3*v2*a2)*.5;
-	gm12=2.*gm1*(1.-aa)/aa;
-	//c  
-	//c   calculate the direct correlation functions and print results
-	//c
-	//	do 20 j=1,npts
-	
-	yy=qval*s2;
-	//c   calculate direct correlation functions
-	//c   ----c11
-	ay=aa*yy;
-	ay2 = ay*ay;
-	ay3 = ay*ay*ay;
-	t1=a1*(sin(ay)-ay*cos(ay));
-	t2=b1*(2.*ay*sin(ay)-(ay2-2.)*cos(ay)-2.)/ay;
-	t3=gm1*((4.*ay*ay2-24.*ay)*sin(ay)-(ay2*ay2-12.*ay2+24.)*cos(ay)+24.)/ay3;
-	f11=24.*v1*(t1+t2+t3)/ay3;
-	
-	//c ------c22
-	y2=yy*yy;
-	y3=yy*y2;
-	tt1=a2*(sin(yy)-yy*cos(yy));
-	tt2=b2*(2.*yy*sin(yy)-(y2-2.)*cos(yy)-2.)/yy;
-	tt3=gm1*((4.*y3-24.*yy)*sin(yy)-(y2*y2-12.*y2+24.)*cos(yy)+24.)/ay3;
-	f22=24.*v2*(tt1+tt2+tt3)/y3;
-	
-	//c   -----c12
-	yl=.5*yy*(1.-aa);
-	yl3=yl*yl*yl;
-	wma3 = (1.-aa)*(1.-aa)*(1.-aa);
-	y1=aa*yy;
-	y13 = y1*y1*y1;
-	ttt1=3.*wma3*v*sqrt(nf2)*sqrt(1.-nf2)*a1*(sin(yl)-yl*cos(yl))/((nf2+(1.-nf2)*a3)*yl3);
-	t21=b12*(2.*y1*cos(y1)+(y1*y1-2.)*sin(y1));
-	t22=gm12*((3.*y1*y1-6.)*cos(y1)+(y1*y1*y1-6.*y1)*sin(y1)+6.)/y1;
-	t23=gm1*((4.*y13-24.*y1)*cos(y1)+(y13*y1-12.*y1*y1+24.)*sin(y1))/(y1*y1);
-	t31=b12*(2.*y1*sin(y1)-(y1*y1-2.)*cos(y1)-2.);
-	t32=gm12*((3.*y1*y1-6.)*sin(y1)-(y1*y1*y1-6.*y1)*cos(y1))/y1;
-  	t33=gm1*((4.*y13-24.*y1)*sin(y1)-(y13*y1-12.*y1*y1+24.)*cos(y1)+24.)/(y1*y1);
-	t41=cos(yl)*((sin(y1)-y1*cos(y1))/(y1*y1) + (1.-aa)/(2.*aa)*(1.-cos(y1))/y1);
-	t42=sin(yl)*((cos(y1)+y1*sin(y1)-1.)/(y1*y1) + (1.-aa)/(2.*aa)*sin(y1)/y1);
-	ttt2=sin(yl)*(t21+t22+t23)/(y13*y1);
-	ttt3=cos(yl)*(t31+t32+t33)/(y13*y1);
-	ttt4=a1*(t41+t42)/y1;
-	f12=ttt1+24.*v*sqrt(nf2)*sqrt(1.-nf2)*a3*(ttt2+ttt3+ttt4)/(nf2+(1.-nf2)*a3);
-	
-	c11=f11;
-	c22=f22;
-	c12=f12;
-	*s11=1./(1.+c11-(c12)*c12/(1.+c22));
-	*s22=1./(1.+c22-(c12)*c12/(1.+c11)); 
-	*s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12));   
-	
-	return(err);
-}
-
-
-
-/*
- // calculates the scattering from a spherical particle made up of a core (aqueous) surrounded
- // by N spherical layers, each of which is a PAIR of shells, solvent + surfactant since there
- //must always be a surfactant layer on the outside
- //
- // bragg peaks arise naturally from the periodicity of the sample
- // resolution smeared version gives he most appropriate view of the model
- 
-	Warning:
- The call to WaveData() below returns a pointer to the middle
- of an unlocked Macintosh handle. In the unlikely event that your
- calculations could cause memory to move, you should copy the coefficient
- values to local variables or an array before such operations.
- */
-double
-MultiShell(double dp[], double q)
-{
-	double x;
-	double scale,rcore,tw,ts,rhocore,rhoshel,num,bkg;		//my local names
-	int ii;
-	double fval,voli,ri,sldi;
-	double pi;
-	
-	pi = 4.0*atan(1.0);
-	
-	x= q;
-	scale = dp[0];
-	rcore = dp[1];
-	ts = dp[2];
-	tw = dp[3];
-	rhocore = dp[4];
-	rhoshel = dp[5];
-	num = dp[6];
-	bkg = dp[7];
-	
-	//calculate with a loop, two shells at a time
-	
-	ii=0;
-	fval=0.0;
-	
-	do {
-		ri = rcore + (double)ii*ts + (double)ii*tw;
-		voli = 4.0*pi/3.0*ri*ri*ri;
-		sldi = rhocore-rhoshel;
-		fval += voli*sldi*F_func(ri*x);
-		ri += ts;
-		voli = 4.0*pi/3.0*ri*ri*ri;
-		sldi = rhoshel-rhocore;
-		fval += voli*sldi*F_func(ri*x);
-		ii+=1;		//do 2 layers at a time
-	} while(ii<=num-1);  //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03)
-	
-	fval *= fval;		//square it
-	fval /= voli;		//normalize by the overall volume
-	fval *= scale*1.0e8;
-	fval += bkg;
-	
-	return(fval);
-}
-
-/*
- // calculates the scattering from a POLYDISPERSE spherical particle made up of a core (aqueous) surrounded
- // by N spherical layers, each of which is a PAIR of shells, solvent + surfactant since there
- //must always be a surfactant layer on the outside
- //
- // bragg peaks arise naturally from the periodicity of the sample
- // resolution smeared version gives he most appropriate view of the model
- //
- // Polydispersity is of the total (outer) radius. This is converted into a distribution of MLV's
- // with integer numbers of layers, with a minimum of one layer... a vesicle... depending
- // on the parameters, the "distribution" of MLV's that is used may be truncated
- //
-	Warning:
- The call to WaveData() below returns a pointer to the middle
- of an unlocked Macintosh handle. In the unlikely event that your
- calculations could cause memory to move, you should copy the coefficient
- values to local variables or an array before such operations.
- */
-double
-PolyMultiShell(double dp[], double q)
-{
-	double x;
-	double scale,rcore,tw,ts,rhocore,rhoshel,bkg;		//my local names
-	int ii,minPairs,maxPairs,first;
-	double fval,ri,pi;
-	double avg,pd,zz,lo,hi,r1,r2,d1,d2,distr;
-	
-	pi = 4.0*atan(1.0);	
-	x= q;
-	
-	scale = dp[0];
-	avg = dp[1];		// average (total) outer radius
-	pd = dp[2];
-	rcore = dp[3];
-	ts = dp[4];
-	tw = dp[5];
-	rhocore = dp[6];
-	rhoshel = dp[7];
-	bkg = dp[8];
-	
-	zz = (1.0/pd)*(1.0/pd)-1.0;
-	
-	//max radius set to be 5 std deviations past mean
-	hi = avg + pd*avg*5.0;
-	lo = avg - pd*avg*5.0;
-	
-	maxPairs = trunc( (hi-rcore+tw)/(ts+tw) );
-	minPairs = trunc( (lo-rcore+tw)/(ts+tw) );
-	minPairs = (minPairs < 1) ? 1 : minPairs;	// need a minimum of one
-	
-	ii=minPairs;
-	fval=0.0;
-	d1 = 0.0;
-	d2 = 0.0;
-	r1 = 0.0;
-	r2 = 0.0;
-	distr = 0.0;
-	first = 1.0;
-	do {
-		//make the current values old
-		r1 = r2;
-		d1 = d2;
-		
-		ri = (double)ii*(ts+tw) - tw + rcore;
-		fval += SchulzPoint(ri,avg,zz) * MultiShellGuts(x, rcore, ts, tw, rhocore, rhoshel, ii) * (4*pi/3*ri*ri*ri);
-		// get a running integration of the fraction of the distribution used, but not the first time
-		r2 = ri;
-		d2 = SchulzPoint(ri,avg,zz);
-		if( !first ) {
-			distr += 0.5*(d1+d2)*(r2-r1);		//cheap trapezoidal integration
-		}
-		ii+=1;
-		first = 0;
-	} while(ii<=maxPairs);
-	
-	fval /= 4.0*pi/3.0*avg*avg*avg;		//normalize by the overall volume
-	fval /= distr;
-	fval *= scale;
-	fval += bkg;
-	
-	return(fval);
-}
-
-double
-MultiShellGuts(double x,double rcore,double ts,double tw,double rhocore,double rhoshel,int num) {
-	
-    double ri,sldi,fval,voli,pi;
-    int ii;
-    
-	pi = 4.0*atan(1.0);
-    ii=0;
-    fval=0.0;
-    
-    do {
-        ri = rcore + (double)ii*ts + (double)ii*tw;
-        voli = 4.0*pi/3.0*ri*ri*ri;
-        sldi = rhocore-rhoshel;
-        fval += voli*sldi*F_func(ri*x);
-        ri += ts;
-        voli = 4.0*pi/3.0*ri*ri*ri;
-        sldi = rhoshel-rhocore;
-        fval += voli*sldi*F_func(ri*x);
-        ii+=1;		//do 2 layers at a time
-    } while(ii<=num-1);  //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03)
-    
-    fval *= fval;
-    fval /= voli;
-    fval *= 1.0e8;
-    
-    return(fval);	// this result still needs to be multiplied by scale and have background added
-}
-
-/*
-static double
-SchulzPoint(double x, double avg, double zz) {
-	
-    double dr;
-    
-    dr = zz*log(x) - gammln(zz+1.0)+(zz+1.0)*log((zz+1.0)/avg)-(x/avg*(zz+1.0));
-    return (exp(dr));
-}
-
-static double
-gammln(double xx) {
-	
-    double x,y,tmp,ser;
-    static double cof[6]={76.18009172947146,-86.50532032941677,
-		24.01409824083091,-1.231739572450155,
-		0.1208650973866179e-2,-0.5395239384953e-5};
-    int j;
-	
-    y=x=xx;
-    tmp=x+5.5;
-    tmp -= (x+0.5)*log(tmp);
-    ser=1.000000000190015;
-    for (j=0;j<=5;j++) ser += cof[j]/++y;
-    return -tmp+log(2.5066282746310005*ser/x);
-}
-*/
-
-double
-F_func(double qr) {
-	double sc;
-	if (qr == 0.0){
-		sc = 1.0;
-	}else{
-		sc=(3.0*(sin(qr) - qr*cos(qr))/(qr*qr*qr));
-	}
-	return sc;
-}
-
-double
-OneShell(double dp[], double q)
-{
-	// variables are:
-	//[0] scale factor
-	//[1] radius of core [ï¿œ]
-	//[2] SLD of the core	[ï¿œ-2]
-	//[3] thickness of the shell	[ï¿œ]
-	//[4] SLD of the shell
-	//[5] SLD of the solvent
-	//[6] background	[cm-1]
-	
-	double x,pi;
-	double scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg;		//my local names
-	double bes,f,vol,qr,contr,f2;
-	
-	pi = 4.0*atan(1.0);
-	x=q;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	rhocore = dp[2];
-	thick = dp[3];
-	rhoshel = dp[4];
-	rhosolv = dp[5];
-	bkg = dp[6];
-	
-	// core first, then add in shell
-	qr=x*rcore;
-	contr = rhocore-rhoshel;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*rcore*rcore*rcore;
-	f = vol*bes*contr;
-	//now the shell
-	qr=x*(rcore+thick);
-	contr = rhoshel-rhosolv;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*pow((rcore+thick),3);
-	f += vol*bes*contr;
-	
-	// normalize to particle volume and rescale from [ï¿œ-1] to [cm-1]
-	f2 = f*f/vol*1.0e8;
-	
-	//scale if desired
-	f2 *= scale;
-	// then add in the background
-	f2 += bkg;
-	
-	return(f2);
-}
-
-double
-TwoShell(double dp[], double q)
-{
-	// variables are:
-	//[0] scale factor
-	//[1] radius of core [ï¿œ]
-	//[2] SLD of the core	[ï¿œ-2]
-	//[3] thickness of shell 1 [ï¿œ]
-	//[4] SLD of shell 1
-	//[5] thickness of shell 2 [ï¿œ]
-	//[6] SLD of shell 2
-	//[7] SLD of the solvent
-	//[8] background	[cm-1]
-	
-	double x,pi;
-	double scale,rcore,thick1,rhocore,rhoshel1,rhosolv,bkg;		//my local names
-	double bes,f,vol,qr,contr,f2;
-	double rhoshel2,thick2;
-	
-	pi = 4.0*atan(1.0);
-	x=q;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	rhocore = dp[2];
-	thick1 = dp[3];
-	rhoshel1 = dp[4];
-	thick2 = dp[5];
-	rhoshel2 = dp[6];	
-	rhosolv = dp[7];
-	bkg = dp[8];
-		// core first, then add in shells
-	qr=x*rcore;
-	contr = rhocore-rhoshel1;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*rcore*rcore*rcore;
-	f = vol*bes*contr;
-	//now the shell (1)
-	qr=x*(rcore+thick1);
-	contr = rhoshel1-rhoshel2;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1)*(rcore+thick1)*(rcore+thick1);
-	f += vol*bes*contr;
-	//now the shell (2)
-	qr=x*(rcore+thick1+thick2);
-	contr = rhoshel2-rhosolv;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1+thick2)*(rcore+thick1+thick2)*(rcore+thick1+thick2);
-	f += vol*bes*contr;
-	
-		
-	// normalize to particle volume and rescale from [ï¿œ-1] to [cm-1]
-	f2 = f*f/vol*1.0e8;
-	
-	//scale if desired
-	f2 *= scale;
-	// then add in the background
-	f2 += bkg;
-	
-	return(f2);
-}
-
-double
-ThreeShell(double dp[], double q)
-{
-	// variables are:
-	//[0] scale factor
-	//[1] radius of core [ï¿œ]
-	//[2] SLD of the core	[ï¿œ-2]
-	//[3] thickness of shell 1 [ï¿œ]
-	//[4] SLD of shell 1
-	//[5] thickness of shell 2 [ï¿œ]
-	//[6] SLD of shell 2
-	//[7] thickness of shell 3
-	//[8] SLD of shell 3
-	//[9] SLD of solvent
-	//[10] background	[cm-1]
-	
-	double x,pi;
-	double scale,rcore,thick1,rhocore,rhoshel1,rhosolv,bkg;		//my local names
-	double bes,f,vol,qr,contr,f2;
-	double rhoshel2,thick2,rhoshel3,thick3;
-	
-	pi = 4.0*atan(1.0);
-	x=q;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	rhocore = dp[2];
-	thick1 = dp[3];
-	rhoshel1 = dp[4];
-	thick2 = dp[5];
-	rhoshel2 = dp[6];	
-	thick3 = dp[7];
-	rhoshel3 = dp[8];	
-	rhosolv = dp[9];
-	bkg = dp[10];
-	
-		// core first, then add in shells
-	qr=x*rcore;
-	contr = rhocore-rhoshel1;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*rcore*rcore*rcore;
-	f = vol*bes*contr;
-	//now the shell (1)
-	qr=x*(rcore+thick1);
-	contr = rhoshel1-rhoshel2;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1)*(rcore+thick1)*(rcore+thick1);
-	f += vol*bes*contr;
-	//now the shell (2)
-	qr=x*(rcore+thick1+thick2);
-	contr = rhoshel2-rhoshel3;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1+thick2)*(rcore+thick1+thick2)*(rcore+thick1+thick2);
-	f += vol*bes*contr;
-	//now the shell (3)
-	qr=x*(rcore+thick1+thick2+thick3);
-	contr = rhoshel3-rhosolv;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1+thick2+thick3)*(rcore+thick1+thick2+thick3)*(rcore+thick1+thick2+thick3);
-	f += vol*bes*contr;
-		
-	// normalize to particle volume and rescale from [ï¿œ-1] to [cm-1]
-	f2 = f*f/vol*1.0e8;
-	
-	//scale if desired
-	f2 *= scale;
-	// then add in the background
-	f2 += bkg;
-	
-	return(f2);
-}
-
-double
-FourShell(double dp[], double q)
-{
-	// variables are:
-	//[0] scale factor
-	//[1] radius of core [ï¿œ]
-	//[2] SLD of the core	[ï¿œ-2]
-	//[3] thickness of shell 1 [ï¿œ]
-	//[4] SLD of shell 1
-	//[5] thickness of shell 2 [ï¿œ]
-	//[6] SLD of shell 2
-	//[7] thickness of shell 3
-	//[8] SLD of shell 3
-	//[9] thickness of shell 3
-	//[10] SLD of shell 3
-	//[11] SLD of solvent
-	//[12] background	[cm-1]
-	
-	double x,pi;
-	double scale,rcore,thick1,rhocore,rhoshel1,rhosolv,bkg;		//my local names
-	double bes,f,vol,qr,contr,f2;
-	double rhoshel2,thick2,rhoshel3,thick3,rhoshel4,thick4;
-	
-	pi = 4.0*atan(1.0);
-	x=q;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	rhocore = dp[2];
-	thick1 = dp[3];
-	rhoshel1 = dp[4];
-	thick2 = dp[5];
-	rhoshel2 = dp[6];	
-	thick3 = dp[7];
-	rhoshel3 = dp[8];
-	thick4 = dp[9];
-	rhoshel4 = dp[10];	
-	rhosolv = dp[11];
-	bkg = dp[12];
-	
-		// core first, then add in shells
-	qr=x*rcore;
-	contr = rhocore-rhoshel1;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*rcore*rcore*rcore;
-	f = vol*bes*contr;
-	//now the shell (1)
-	qr=x*(rcore+thick1);
-	contr = rhoshel1-rhoshel2;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1)*(rcore+thick1)*(rcore+thick1);
-	f += vol*bes*contr;
-	//now the shell (2)
-	qr=x*(rcore+thick1+thick2);
-	contr = rhoshel2-rhoshel3;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1+thick2)*(rcore+thick1+thick2)*(rcore+thick1+thick2);
-	f += vol*bes*contr;
-	//now the shell (3)
-	qr=x*(rcore+thick1+thick2+thick3);
-	contr = rhoshel3-rhoshel4;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1+thick2+thick3)*(rcore+thick1+thick2+thick3)*(rcore+thick1+thick2+thick3);
-	f += vol*bes*contr;
-	//now the shell (4)
-	qr=x*(rcore+thick1+thick2+thick3+thick4);
-	contr = rhoshel4-rhosolv;
-	if(qr == 0){
-		bes = 1.0;
-	}else{
-		bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr);
-	}
-	vol = 4.0*pi/3.0*(rcore+thick1+thick2+thick3+thick4)*(rcore+thick1+thick2+thick3+thick4)*(rcore+thick1+thick2+thick3+thick4);
-	f += vol*bes*contr;
-	
-		
-	// normalize to particle volume and rescale from [ï¿œ-1] to [cm-1]
-	f2 = f*f/vol*1.0e8;
-	
-	//scale if desired
-	f2 *= scale;
-	// then add in the background
-	f2 += bkg;
-	
-	return(f2);
-}
-
-double
-PolyOneShell(double dp[], double x)
-{
-	double scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg,pd,zz;		//my local names
-	double va,vb,summ,yyy,zi;
-	double answer,zp1,zp2,zp3,vpoly,range,temp_1sf[7],pi;
-	int nord=76,ii;
-	
-	pi = 4.0*atan(1.0);
-	
-	scale = dp[0];
-	rcore = dp[1];
-	pd = dp[2];
-	rhocore = dp[3];
-	thick = dp[4];
-	rhoshel = dp[5];
-	rhosolv = dp[6];
-	bkg = dp[7];
-		
-	zz = (1.0/pd)*(1.0/pd)-1.0;		//polydispersity of the core only
-	
-	range = 8.0;			//std deviations for the integration
-	va = rcore*(1.0-range*pd);
-	if (va<0.0) {
-		va=0.0;		//otherwise numerical error when pd >= 0.3, making a<0
-	}
-	if (pd>0.3) {
-		range = range + (pd-0.3)*18.0;		//stretch upper range to account for skewed tail
-	}
-	vb = rcore*(1.0+range*pd);		// is this far enough past avg radius?
-	
-	//temp set scale=1 and bkg=0 for quadrature calc
-	temp_1sf[0] = 1.0;
-	temp_1sf[1] = dp[1];	//the core radius will be changed in the loop
-	temp_1sf[2] = dp[3];
-	temp_1sf[3] = dp[4];
-	temp_1sf[4] = dp[5];
-	temp_1sf[5] = dp[6];
-	temp_1sf[6] = 0.0;
-	
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss76Z[ii]*(vb-va) + vb + va )/2.0;
-		temp_1sf[1] = zi;
-		yyy = Gauss76Wt[ii] * SchulzPoint(zi,rcore,zz) * OneShell(temp_1sf,x);
-		//un-normalize by volume
-		yyy *= 4.0*pi/3.0*pow((zi+thick),3);
-		summ += yyy;		//add to the running total of the quadrature
-   	}
-	// calculate value of integral to return
-	answer = (vb-va)/2.0*summ;
-   	
-	//re-normalize by the average volume
-	zp1 = zz + 1.0;
-	zp2 = zz + 2.0;
-	zp3 = zz + 3.0;
-	vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*pow((rcore+thick),3);
-	answer /= vpoly;
-//scale
-	answer *= scale;
-// add in the background
-	answer += bkg;
-		
-    return(answer);
-}
-
-double
-PolyTwoShell(double dp[], double x)
-{
-	double scale,rcore,rhocore,rhosolv,bkg,pd,zz;		//my local names
-	double va,vb,summ,yyy,zi;
-	double answer,zp1,zp2,zp3,vpoly,range,temp_2sf[9],pi;
-	int nord=76,ii;
-	double thick1,thick2;
-	double rhoshel1,rhoshel2;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	pd = dp[2];
-	rhocore = dp[3];
-	thick1 = dp[4];
-	rhoshel1 = dp[5];
-	thick2 = dp[6];
-	rhoshel2 = dp[7];
-	rhosolv = dp[8];
-	bkg = dp[9];
-	
-	pi = 4.0*atan(1.0);
-		
-	zz = (1.0/pd)*(1.0/pd)-1.0;		//polydispersity of the core only
-	
-	range = 8.0;			//std deviations for the integration
-	va = rcore*(1.0-range*pd);
-	if (va<0.0) {
-		va=0.0;		//otherwise numerical error when pd >= 0.3, making a<0
-	}
-	if (pd>0.3) {
-		range = range + (pd-0.3)*18.0;		//stretch upper range to account for skewed tail
-	}
-	vb = rcore*(1.0+range*pd);		// is this far enough past avg radius?
-	
-	//temp set scale=1 and bkg=0 for quadrature calc
-	temp_2sf[0] = 1.0;
-	temp_2sf[1] = dp[1];		//the core radius will be changed in the loop
-	temp_2sf[2] = dp[3];
-	temp_2sf[3] = dp[4];
-	temp_2sf[4] = dp[5];
-	temp_2sf[5] = dp[6];
-	temp_2sf[6] = dp[7];
-	temp_2sf[7] = dp[8];
-	temp_2sf[8] = 0.0;
-	
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss76Z[ii]*(vb-va) + vb + va )/2.0;
-		temp_2sf[1] = zi;
-		yyy = Gauss76Wt[ii] * SchulzPoint(zi,rcore,zz) * TwoShell(temp_2sf,x);
-		//un-normalize by volume
-		yyy *= 4.0*pi/3.0*pow((zi+thick1+thick2),3);
-		summ += yyy;		//add to the running total of the quadrature
-   	}
-	// calculate value of integral to return
-	answer = (vb-va)/2.0*summ;
-   	
-	//re-normalize by the average volume
-	zp1 = zz + 1.0;
-	zp2 = zz + 2.0;
-	zp3 = zz + 3.0;
-	vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*pow((rcore+thick1+thick2),3);
-	answer /= vpoly;
-//scale
-	answer *= scale;
-// add in the background
-	answer += bkg;
-		
-    return(answer);
-}
-
-double
-PolyThreeShell(double dp[], double x)
-{
-	double scale,rcore,rhocore,rhosolv,bkg,pd,zz;		//my local names
-	double va,vb,summ,yyy,zi;
-	double answer,zp1,zp2,zp3,vpoly,range,temp_3sf[11],pi;
-	int nord=76,ii;
-	double thick1,thick2,thick3;
-	double rhoshel1,rhoshel2,rhoshel3;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	pd = dp[2];
-	rhocore = dp[3];
-	thick1 = dp[4];
-	rhoshel1 = dp[5];
-	thick2 = dp[6];
-	rhoshel2 = dp[7];
-	thick3 = dp[8];
-	rhoshel3 = dp[9];
-	rhosolv = dp[10];
-	bkg = dp[11];
-	
-	pi = 4.0*atan(1.0);
-		
-	zz = (1.0/pd)*(1.0/pd)-1.0;		//polydispersity of the core only
-	
-	range = 8.0;			//std deviations for the integration
-	va = rcore*(1.0-range*pd);
-	if (va<0) {
-		va=0;		//otherwise numerical error when pd >= 0.3, making a<0
-	}
-	if (pd>0.3) {
-		range = range + (pd-0.3)*18.0;		//stretch upper range to account for skewed tail
-	}
-	vb = rcore*(1.0+range*pd);		// is this far enough past avg radius?
-	
-	//temp set scale=1 and bkg=0 for quadrature calc
-	temp_3sf[0] = 1.0;
-	temp_3sf[1] = dp[1];		//the core radius will be changed in the loop
-	temp_3sf[2] = dp[3];
-	temp_3sf[3] = dp[4];
-	temp_3sf[4] = dp[5];
-	temp_3sf[5] = dp[6];
-	temp_3sf[6] = dp[7];
-	temp_3sf[7] = dp[8];
-	temp_3sf[8] = dp[9];
-	temp_3sf[9] = dp[10];
-	temp_3sf[10] = 0.0;
-	
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss76Z[ii]*(vb-va) + vb + va )/2.0;
-		temp_3sf[1] = zi;
-		yyy = Gauss76Wt[ii] * SchulzPoint(zi,rcore,zz) * ThreeShell(temp_3sf,x);
-		//un-normalize by volume
-		yyy *= 4.0*pi/3.0*pow((zi+thick1+thick2+thick3),3);
-		summ += yyy;		//add to the running total of the quadrature
-   	}
-	// calculate value of integral to return
-	answer = (vb-va)/2.0*summ;
-   	
-	//re-normalize by the average volume
-	zp1 = zz + 1.0;
-	zp2 = zz + 2.0;
-	zp3 = zz + 3.0;
-	vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*pow((rcore+thick1+thick2+thick3),3);
-	answer /= vpoly;
-//scale
-	answer *= scale;
-// add in the background
-	answer += bkg;
-		
-    return(answer);
-}
-
-double
-PolyFourShell(double dp[], double x)
-{
-	double scale,rcore,rhocore,rhosolv,bkg,pd,zz;		//my local names
-	double va,vb,summ,yyy,zi;
-	double answer,zp1,zp2,zp3,vpoly,range,temp_4sf[13],pi;
-	int nord=76,ii;
-	double thick1,thick2,thick3,thick4;
-	double rhoshel1,rhoshel2,rhoshel3,rhoshel4;
-	
-	scale = dp[0];
-	rcore = dp[1];
-	pd = dp[2];
-	rhocore = dp[3];
-	thick1 = dp[4];
-	rhoshel1 = dp[5];
-	thick2 = dp[6];
-	rhoshel2 = dp[7];
-	thick3 = dp[8];
-	rhoshel3 = dp[9];
-	thick4 = dp[10];
-	rhoshel4 = dp[11];
-	rhosolv = dp[12];
-	bkg = dp[13];
-	
-	pi = 4.0*atan(1.0);
-		
-	zz = (1.0/pd)*(1.0/pd)-1.0;		//polydispersity of the core only
-	
-	range = 8.0;			//std deviations for the integration
-	va = rcore*(1.0-range*pd);
-	if (va<0) {
-		va=0;		//otherwise numerical error when pd >= 0.3, making a<0
-	}
-	if (pd>0.3) {
-		range = range + (pd-0.3)*18.0;		//stretch upper range to account for skewed tail
-	}
-	vb = rcore*(1.0+range*pd);		// is this far enough past avg radius?
-	
-	//temp set scale=1 and bkg=0 for quadrature calc
-	temp_4sf[0] = 1.0;
-	temp_4sf[1] = dp[1];		//the core radius will be changed in the loop
-	temp_4sf[2] = dp[3];
-	temp_4sf[3] = dp[4];
-	temp_4sf[4] = dp[5];
-	temp_4sf[5] = dp[6];
-	temp_4sf[6] = dp[7];
-	temp_4sf[7] = dp[8];
-	temp_4sf[8] = dp[9];
-	temp_4sf[9] = dp[10];
-	temp_4sf[10] = dp[11];
-	temp_4sf[11] = dp[12];
-	temp_4sf[12] = 0.0;
-		
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss76Z[ii]*(vb-va) + vb + va )/2.0;
-		temp_4sf[1] = zi;
-		yyy = Gauss76Wt[ii] * SchulzPoint(zi,rcore,zz) * FourShell(temp_4sf,x);
-		//un-normalize by volume
-		yyy *= 4.0*pi/3.0*pow((zi+thick1+thick2+thick3+thick4),3);
-		summ += yyy;		//add to the running total of the quadrature
-   	}
-	// calculate value of integral to return
-	answer = (vb-va)/2.0*summ;
-   	
-	//re-normalize by the average volume
-	zp1 = zz + 1.0;
-	zp2 = zz + 2.0;
-	zp3 = zz + 3.0;
-	vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*pow((rcore+thick1+thick2+thick3+thick4),3);
-	answer /= vpoly;
-//scale
-	answer *= scale;
-// add in the background
-	answer += bkg;
-		
-    return(answer);
-}
-
-
-/*	BCC_ParaCrystal  :  calculates the form factor of a Triaxial Ellipsoid at the given x-value p->x
-
-Uses 150 pt Gaussian quadrature for both integrals
-
-*/
-double
-BCC_ParaCrystal(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,Dnn,gg,Rad,contrast,background,latticeScale,sld,sldSolv;		//local variables of coefficient wave
-	int nordi=150;			//order of integration
-	int nordj=150;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 2.0*Pi;		//orintational average, outer integral
-	vaj = 0.0;
-	vbj = Pi;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = w[0];
-	Dnn = w[1];					//Nearest neighbor distance A
-	gg = w[2];					//Paracrystal distortion factor
-	Rad = w[3];					//Sphere radius
-	sld = w[4];
-	sldSolv = w[5];
-	background = w[6]; 
-	
-	contrast = sld - sldSolv;
-	
-	//Volume fraction calculated from lattice symmetry and sphere radius
-	latticeScale = 2.0*(4.0/3.0)*Pi*(Rad*Rad*Rad)/pow(Dnn/sqrt(3.0/4.0),3);
-	
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss150Z[i]*(vb-va) + va + vb )/2.0;		//the outer dummy is phi
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss150Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the inner dummy is theta
-			yyy = Gauss150Wt[j] * BCC_Integrand(w,x,zi,zij);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		
-		//now calculate outer integral
-		yyy = Gauss150Wt[i] * answer;
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= SphereForm_Paracrystal(Rad,contrast,x)*scale*latticeScale;
-	// add in the background
-	answer += background;
-	
-	return answer;
-}
-
-// xx is phi (outer)
-// yy is theta (inner)
-double
-BCC_Integrand(double w[], double qq, double xx, double yy) {
-	
-	double retVal,temp1,temp3,aa,Da,Dnn,gg,Pi;
-	
-	Dnn = w[1]; //Nearest neighbor distance A
-	gg = w[2]; //Paracrystal distortion factor
-	aa = Dnn;
-	Da = gg*aa;
-	
-	Pi = 4.0*atan(1.0);
-	temp1 = qq*qq*Da*Da;
-	temp3 = qq*aa;	
-	
-	retVal = BCCeval(yy,xx,temp1,temp3);
-	retVal /=4.0*Pi;
-	
-	return(retVal);
-}
-
-double
-BCCeval(double Theta, double Phi, double temp1, double temp3) {
-
-	double temp6,temp7,temp8,temp9,temp10;
-	double result;
-	
-	temp6 = sin(Theta);
-	temp7 = sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi)+cos(Theta);
-	temp8 = -1.0*sin(Theta)*cos(Phi)-sin(Theta)*sin(Phi)+cos(Theta);
-	temp9 = -1.0*sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi)-cos(Theta);
-	temp10 = exp((-1.0/8.0)*temp1*((temp7*temp7)+(temp8*temp8)+(temp9*temp9)));
-	result = pow(1.0-(temp10*temp10),3)*temp6/((1.0-2.0*temp10*cos(0.5*temp3*(temp7))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp8))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp9))+(temp10*temp10)));
-	
-	return (result);
-}
-
-double
-SphereForm_Paracrystal(double radius, double delrho, double x) {					
-	
-	double bes,f,vol,f2,pi;
-	pi = 4.0*atan(1.0);
-	//
-	//handle q==0 separately
-	if(x==0) {
-		f = 4.0/3.0*pi*radius*radius*radius*delrho*delrho*1.0e8;
-		return(f);
-	}
-	
-	bes = 3.0*(sin(x*radius)-x*radius*cos(x*radius))/(x*x*x)/(radius*radius*radius);
-	vol = 4.0*pi/3.0*radius*radius*radius;
-	f = vol*bes*delrho	;	// [=] ï¿œ
-	// normalize to single particle volume, convert to 1/cm
-	f2 = f * f / vol * 1.0e8;		// [=] 1/cm
-	
-	return (f2);
-}
-
-/*	FCC_ParaCrystal  :  calculates the form factor of a Triaxial Ellipsoid at the given x-value p->x
-
-Uses 150 pt Gaussian quadrature for both integrals
-
-*/
-double
-FCC_ParaCrystal(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,Dnn,gg,Rad,contrast,background,latticeScale,sld,sldSolv;		//local variables of coefficient wave
-	int nordi=150;			//order of integration
-	int nordj=150;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = 2.0*Pi;		//orintational average, outer integral
-	vaj = 0.0;
-	vbj = Pi;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = w[0];
-	Dnn = w[1];					//Nearest neighbor distance A
-	gg = w[2];					//Paracrystal distortion factor
-	Rad = w[3];					//Sphere radius
-	sld = w[4];
-	sldSolv = w[5];
-	background = w[6]; 
-	
-	contrast = sld - sldSolv;
-	//Volume fraction calculated from lattice symmetry and sphere radius
-	latticeScale = 4.0*(4.0/3.0)*Pi*(Rad*Rad*Rad)/pow(Dnn*sqrt(2.0),3);
-	
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss150Z[i]*(vb-va) + va + vb )/2.0;		//the outer dummy is phi
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss150Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the inner dummy is theta
-			yyy = Gauss150Wt[j] * FCC_Integrand(w,x,zi,zij);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		
-		//now calculate outer integral
-		yyy = Gauss150Wt[i] * answer;
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= SphereForm_Paracrystal(Rad,contrast,x)*scale*latticeScale;
-	// add in the background
-	answer += background;
-	
-	return answer;
-}
-
-
-// xx is phi (outer)
-// yy is theta (inner)
-double
-FCC_Integrand(double w[], double qq, double xx, double yy) {
-	
-	double retVal,temp1,temp3,aa,Da,Dnn,gg,Pi;
-	
-	Pi = 4.0*atan(1.0);
-	Dnn = w[1]; //Nearest neighbor distance A
-	gg = w[2]; //Paracrystal distortion factor
-	aa = Dnn;
-	Da = gg*aa;
-	
-	temp1 = qq*qq*Da*Da;
-	temp3 = qq*aa;
-	
-	retVal = FCCeval(yy,xx,temp1,temp3);
-	retVal /=4*Pi;
-	
-	return(retVal);
-}
-
-double
-FCCeval(double Theta, double Phi, double temp1, double temp3) {
-
-	double temp6,temp7,temp8,temp9,temp10;
-	double result;
-	
-	temp6 = sin(Theta);
-	temp7 = sin(Theta)*sin(Phi)+cos(Theta);
-	temp8 = -1.0*sin(Theta)*cos(Phi)+cos(Theta);
-	temp9 = -1.0*sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi);
-	temp10 = exp((-1.0/8.0)*temp1*((temp7*temp7)+(temp8*temp8)+(temp9*temp9)));
-	result = pow((1.0-(temp10*temp10)),3)*temp6/((1.0-2.0*temp10*cos(0.5*temp3*(temp7))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp8))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp9))+(temp10*temp10)));
-	
-	return (result);
-}
-
-
-/*	SC_ParaCrystal  :  calculates the form factor of a Triaxial Ellipsoid at the given x-value p->x
-
-Uses 150 pt Gaussian quadrature for both integrals
-
-*/
-double
-SC_ParaCrystal(double w[], double x)
-{
-	int i,j;
-	double Pi;
-	double scale,Dnn,gg,Rad,contrast,background,latticeScale,sld,sldSolv;		//local variables of coefficient wave
-	int nordi=150;			//order of integration
-	int nordj=150;
-	double va,vb;		//upper and lower integration limits
-	double summ,zi,yyy,answer;			//running tally of integration
-	double summj,vaj,vbj,zij;			//for the inner integration
-	
-	Pi = 4.0*atan(1.0);
-	va = 0.0;
-	vb = Pi/2.0;		//orintational average, outer integral
-	vaj = 0.0;
-	vbj = Pi/2.0;		//endpoints of inner integral
-	
-	summ = 0.0;			//initialize intergral
-	
-	scale = w[0];
-	Dnn = w[1];					//Nearest neighbor distance A
-	gg = w[2];					//Paracrystal distortion factor
-	Rad = w[3];					//Sphere radius
-	sld = w[4];
-	sldSolv = w[5];
-	background = w[6]; 
-	
-	contrast = sld - sldSolv;
-	//Volume fraction calculated from lattice symmetry and sphere radius
-	latticeScale = (4.0/3.0)*Pi*(Rad*Rad*Rad)/pow(Dnn,3);
-	
-	for(i=0;i<nordi;i++) {
-		//setup inner integral over the ellipsoidal cross-section
-		summj=0.0;
-		zi = ( Gauss150Z[i]*(vb-va) + va + vb )/2.0;		//the outer dummy is phi
-		for(j=0;j<nordj;j++) {
-			//20 gauss points for the inner integral
-			zij = ( Gauss150Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the inner dummy is theta
-			yyy = Gauss150Wt[j] * SC_Integrand(w,x,zi,zij);
-			summj += yyy;
-		}
-		//now calculate the value of the inner integral
-		answer = (vbj-vaj)/2.0*summj;
-		
-		//now calculate outer integral
-		yyy = Gauss150Wt[i] * answer;
-		summ += yyy;
-	}		//final scaling is done at the end of the function, after the NT_FP64 case
-	
-	answer = (vb-va)/2.0*summ;
-	// Multiply by contrast^2
-	answer *= SphereForm_Paracrystal(Rad,contrast,x)*scale*latticeScale;
-	// add in the background
-	answer += background;
-	
-	return answer;
-}
-
-// xx is phi (outer)
-// yy is theta (inner)
-double
-SC_Integrand(double w[], double qq, double xx, double yy) {
-	
-	double retVal,temp1,temp2,temp3,temp4,temp5,aa,Da,Dnn,gg,Pi;
-	
-	Pi = 4.0*atan(1.0);
-	Dnn = w[1]; //Nearest neighbor distance A
-	gg = w[2]; //Paracrystal distortion factor
-	aa = Dnn;
-	Da = gg*aa;
-	
-	temp1 = qq*qq*Da*Da;
-	temp2 = pow( 1.0-exp(-1.0*temp1) ,3);
-	temp3 = qq*aa;
-	temp4 = 2.0*exp(-0.5*temp1);
-	temp5 = exp(-1.0*temp1);
-	
-	
-	retVal = temp2*SCeval(yy,xx,temp3,temp4,temp5);
-	retVal *= 2.0/Pi;
-	
-	return(retVal);
-}
-
-double
-SCeval(double Theta, double Phi, double temp3, double temp4, double temp5) { //Function to calculate integrand values for simple cubic structure
-
-	double temp6,temp7,temp8,temp9; //Theta and phi dependent parts of the equation
-	double result;
-	
-	temp6 = sin(Theta);
-	temp7 = -1.0*temp3*sin(Theta)*cos(Phi);
-	temp8 = temp3*sin(Theta)*sin(Phi);
-	temp9 = temp3*cos(Theta);
-	result = temp6/((1.0-temp4*cos((temp7))+temp5)*(1.0-temp4*cos((temp8))+temp5)*(1.0-temp4*cos((temp9))+temp5));
-	
-	return (result);
-}
-
-// scattering from a uniform sphere with a Gaussian size distribution
-//
-double
-FuzzySpheres(double dp[], double q)
-{
-	double pi,x;
-	double scale,rad,pd,sig,rho,rhos,bkg,delrho,sig_surf,f2,bes,vol,f;		//my local names
-	double va,vb,zi,yy,summ,inten;
-	int nord=20,ii;
-	
-	pi = 4.0*atan(1.0);
-	x= q;
-	
-	scale=dp[0];
-	rad=dp[1];
-	pd=dp[2];
-	sig=pd*rad;
-	sig_surf = dp[3];
-	rho=dp[4];
-	rhos=dp[5];
-	delrho=rho-rhos;
-	bkg=dp[6];
-	
-			
-	va = -4.0*sig + rad;
-	if (va<0) {
-		va=0;		//to avoid numerical error when  va<0 (-ve q-value)
-	}
-	vb = 4.0*sig +rad;
-	
-	summ = 0.0;		// initialize integral
-	for(ii=0;ii<nord;ii+=1) {
-		// calculate Gauss points on integration interval (r-value for evaluation)
-		zi = ( Gauss20Z[ii]*(vb-va) + vb + va )/2.0;
-		// calculate sphere scattering
-		//
-		//handle q==0 separately
-		if (x==0.0) {
-			f2 = 4.0/3.0*pi*zi*zi*zi*delrho*delrho*1.0e8;
-			f2 *= exp(-0.5*sig_surf*sig_surf*x*x);
-			f2 *= exp(-0.5*sig_surf*sig_surf*x*x);
-		} else {
-			bes = 3.0*(sin(x*zi)-x*zi*cos(x*zi))/(x*x*x)/(zi*zi*zi);
-			vol = 4.0*pi/3.0*zi*zi*zi;
-			f = vol*bes*delrho;		// [=] A
-			f *= exp(-0.5*sig_surf*sig_surf*x*x);
-			// normalize to single particle volume, convert to 1/cm
-			f2 = f * f / vol * 1.0e8;		// [=] 1/cm
-		}
-	
-		yy = Gauss20Wt[ii] *  Gauss_distr(sig,rad,zi) * f2;
-		yy *= 4.0*pi/3.0*zi*zi*zi;		//un-normalize by current sphere volume
-		
-		summ += yy;		//add to the running total of the quadrature
-		
-		
-   	}
-	// calculate value of integral to return
-	inten = (vb-va)/2.0*summ;
-	
-	//re-normalize by polydisperse sphere volume
-	inten /= (4.0*pi/3.0*rad*rad*rad)*(1.0+3.0*pd*pd);
-	
-	inten *= scale;
-	inten += bkg;
-	
-    return(inten);	//scale, and add in the background
-}
-
-
Index: c/sans/models/src/libigor/libSphere.h
===================================================================
--- src/sans/models/src/libigor/libSphere.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,50 +1,0 @@
-// header for SphereFit.c
-#if defined(_MSC_VER)
-#include "winFuncs.h"
-#endif
-
-/* IGOR Fit Functions */
-double MultiShell(double dp[], double q);
-double PolyMultiShell(double dp[], double q);
-double SphereForm(double dp[], double q);
-double CoreShellForm(double dp[], double q);
-double PolyCoreForm(double dp[], double q);
-double PolyCoreShellRatio(double dp[], double q);
-double VesicleForm(double dp[], double q);
-double SchulzSpheres(double dp[], double q);
-double PolyRectSpheres(double dp[], double q);
-double PolyHardSphereIntensity(double dp[], double q);
-double BimodalSchulzSpheres(double dp[], double q);
-double GaussPolySphere(double dp[], double q);
-double LogNormalPolySphere(double dp[], double q);
-double BinaryHS(double dp[], double q);
-double BinaryHS_PSF11(double dp[], double q);
-double BinaryHS_PSF12(double dp[], double q);
-double BinaryHS_PSF22(double dp[], double q);
-double OneShell(double dp[], double q);
-double TwoShell(double dp[], double q);
-double ThreeShell(double dp[], double q);
-double FourShell(double dp[], double q);
-double PolyOneShell(double dp[], double q);
-double PolyTwoShell(double dp[], double q);
-double PolyThreeShell(double dp[], double q);
-double PolyFourShell(double dp[], double q);
-double BCC_ParaCrystal(double dp[], double q);
-double FCC_ParaCrystal(double dp[], double q);
-double SC_ParaCrystal(double dp[], double q);
-double FuzzySpheres(double dp[], double q);
-
-//function prototypes
-double F_func(double qr);
-double MultiShellGuts(double q,double rcore,double ts,double tw,double rhocore,double rhoshel,int num);
-double fnt2(double yy, double zz);
-double fnt3(double yy, double pp, double zz);
-double SchulzSphere_Fn(double scale, double ravg, double pd, double rho, double rhos, double x);
-int ashcroft(double qval, double r2, double nf2, double aa, double phi, double *s11, double *s22, double *s12);
-double BCC_Integrand(double w[], double qq, double xx, double yy);
-double BCCeval(double Theta, double Phi, double temp1, double temp3);
-double SphereForm_Paracrystal(double radius, double delrho, double x);
-double FCC_Integrand(double w[], double qq, double xx, double yy);
-double FCCeval(double Theta, double Phi, double temp1, double temp3);
-double SC_Integrand(double w[], double qq, double xx, double yy);
-double SCeval(double Theta, double Phi, double temp3, double temp4, double temp5);
Index: c/sans/models/src/libigor/libStructureFactor.c
===================================================================
--- src/sans/models/src/libigor/libStructureFactor.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,758 +1,0 @@
-/*	SimpleFit.c
-
-A simplified project designed to act as a template for your curve fitting function.
-The fitting function is a simple polynomial. It works but is of no practical use.
-*/
-
-#include "StandardHeaders.h"			// Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h
-#include "libStructureFactor.h"
-
-//Hard Sphere Structure Factor
-//
-double
-HardSphereStruct(double dp[], double q)
-{
-	double denom,dnum,alpha,beta,gamm,a,asq,ath,afor,rca,rsa;
-	double calp,cbeta,cgam,prefac,c,vstruc;
-	double r,phi,struc;
-	
-	r = dp[0];
-	phi = dp[1];
-	//  compute constants
-	denom = pow((1.0-phi),4);
-	dnum = pow((1.0 + 2.0*phi),2);
-	alpha = dnum/denom;
-	beta = -6.0*phi*pow((1.0 + phi/2.0),2)/denom;
-	gamm = 0.50*phi*dnum/denom;
-	//
-	//  calculate the structure factor
-	//     
-	a = 2.0*q*r;
-	asq = a*a;
-	ath = asq*a;
-	afor = ath*a;
-	rca = cos(a);
-	rsa = sin(a);
-	calp = alpha*(rsa/asq - rca/a);
-	cbeta = beta*(2.0*rsa/asq - (asq - 2.0)*rca/ath - 2.0/ath);
-	cgam = gamm*(-rca/a + (4.0/a)*((3.0*asq - 6.0)*rca/afor + (asq - 6.0)*rsa/ath + 6.0/afor));
-	prefac = -24.0*phi/a;
-	c = prefac*(calp + cbeta + cgam);
-	vstruc = 1.0/(1.0-c);
-	struc = vstruc;
-	
-	return(struc);
-}
-
-//Sticky Hard Sphere Structure Factor
-//
-double
-StickyHS_Struct(double dp[], double q)
-{
-	double qv;
-	double rad,phi,eps,tau,eta;
-	double sig,aa,etam1,qa,qb,qc,radic;
-	double lam,lam2,test,mu,alpha,beta;
-	double kk,k2,k3,ds,dc,aq1,aq2,aq3,aq,bq1,bq2,bq3,bq,sq;
-	
-	qv= q;
-	rad = dp[0];
-	phi = dp[1];
-	eps = dp[2];
-	tau = dp[3];
-	
-	eta = phi/(1.0-eps)/(1.0-eps)/(1.0-eps);
-	
-	sig = 2.0 * rad;
-	aa = sig/(1.0 - eps);
-	etam1 = 1.0 - eta;
-	//C
-	//C  SOLVE QUADRATIC FOR LAMBDA
-	//C
-	qa = eta/12.0;
-	qb = -1.0*(tau + eta/(etam1));
-	qc = (1.0 + eta/2.0)/(etam1*etam1);
-	radic = qb*qb - 4.0*qa*qc;
-	if(radic<0) {
-		//if(x>0.01 && x<0.015)
-	 	//	Print "Lambda unphysical - both roots imaginary"
-	 	//endif
-		return(-1.0);
-	}
-	//C   KEEP THE SMALLER ROOT, THE LARGER ONE IS UNPHYSICAL
-	lam = (-1.0*qb-sqrt(radic))/(2.0*qa);
-	lam2 = (-1.0*qb+sqrt(radic))/(2.0*qa);
-	if(lam2<lam) {
-		lam = lam2;
-	}
-	test = 1.0 + 2.0*eta;
-	mu = lam*eta*etam1;
-	if(mu>test) {
-		//if(x>0.01 && x<0.015)
-		// Print "Lambda unphysical mu>test"
-		//endif
-		return(-1.0);
-	}
-	alpha = (1.0 + 2.0*eta - mu)/(etam1*etam1);
-	beta = (mu - 3.0*eta)/(2.0*etam1*etam1);
-	//C
-	//C   CALCULATE THE STRUCTURE FACTOR
-	//C
-	kk = qv*aa;
-	k2 = kk*kk;
-	k3 = kk*k2;
-	ds = sin(kk);
-	dc = cos(kk);
-	aq1 = ((ds - kk*dc)*alpha)/k3;
-	aq2 = (beta*(1.0-dc))/k2;
-	aq3 = (lam*ds)/(12.0*kk);
-	aq = 1.0 + 12.0*eta*(aq1+aq2-aq3);
-	//
-	bq1 = alpha*(0.5/kk - ds/k2 + (1.0 - dc)/k3);
-	bq2 = beta*(1.0/kk - ds/k2);
-	bq3 = (lam/12.0)*((1.0 - dc)/kk);
-	bq = 12.0*eta*(bq1+bq2-bq3);
-	//
-	sq = 1.0/(aq*aq +bq*bq);
-	
-	return(sq);
-}
-
-
-
-//     SUBROUTINE SQWELL: CALCULATES THE STRUCTURE FACTOR FOR A
-//                        DISPERSION OF MONODISPERSE HARD SPHERES
-//     IN THE Mean Spherical APPROXIMATION ASSUMING THE SPHERES
-//     INTERACT THROUGH A SQUARE WELL POTENTIAL.
-//** not the best choice of closure ** see note below
-//     REFS:  SHARMA,SHARMA, PHYSICA 89A,(1977),212
-double
-SquareWellStruct(double dp[], double q)
-{
-	double req,phis,edibkb,lambda,struc;
-	double sigma,eta,eta2,eta3,eta4,etam1,etam14,alpha,beta,gamm;
-	double x,sk,sk2,sk3,sk4,t1,t2,t3,t4,ck;
-	
-	x= q;
-	
-	req = dp[0];
-	phis = dp[1];
-	edibkb = dp[2];
-	lambda = dp[3];
-	
-	sigma = req*2.;
-	eta = phis;
-	eta2 = eta*eta;
-	eta3 = eta*eta2;
-	eta4 = eta*eta3;
-	etam1 = 1. - eta;
-	etam14 = etam1*etam1*etam1*etam1;
-	alpha = (  pow((1. + 2.*eta),2) + eta3*( eta-4.0 )  )/etam14;
-	beta = -(eta/3.0) * ( 18. + 20.*eta - 12.*eta2 + eta4 )/etam14;
-	gamm = 0.5*eta*( pow((1. + 2.*eta),2) + eta3*(eta-4.) )/etam14;
-	//
-	//  calculate the structure factor
-	
-	sk = x*sigma;
-	sk2 = sk*sk;
-	sk3 = sk*sk2;
-	sk4 = sk3*sk;
-	t1 = alpha * sk3 * ( sin(sk) - sk * cos(sk) );
-	t2 = beta * sk2 * ( 2.*sk*sin(sk) - (sk2-2.)*cos(sk) - 2.0 );
-	t3 =   ( 4.0*sk3 - 24.*sk ) * sin(sk);
-	t3 = t3 - ( sk4 - 12.0*sk2 + 24.0 )*cos(sk) + 24.0;
-	t3 = gamm*t3;
-	t4 = -edibkb*sk3*(sin(lambda*sk) - lambda*sk*cos(lambda*sk)+ sk*cos(sk) - sin(sk) );
-	ck =  -24.0*eta*( t1 + t2 + t3 + t4 )/sk3/sk3;
-	struc  = 1./(1.-ck);
-	
-	return(struc);
-}
-
-// Hayter-Penfold (rescaled) MSA structure factor for screened Coulomb interactions 
-//
-double
-HayterPenfoldMSA(double dp[], double q)
-{
-  double gMSAWave[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
-	double Elcharge=1.602189e-19;		// electron charge in Coulombs (C)
-	double kB=1.380662e-23;				// Boltzman constant in J/K
-	double FrSpPerm=8.85418782E-12;	//Permittivity of free space in C^2/(N m^2)
-	double SofQ, QQ, Qdiam, Vp, csalt, ss;
-	double VolFrac, SIdiam, diam, Kappa, cs, IonSt;
-	double dialec, Perm, Beta, Temp, zz, charge;
-	double pi;
-	int ierr;
-	
-	pi = 4.0*atan(1.);
-	QQ= q;
-
-	diam=dp[0];		//in A
-	zz = dp[1];		//# of charges
-	VolFrac=dp[2];
-	Temp=dp[3];		//in degrees Kelvin
-	csalt=dp[4];		//in molarity
-	dialec=dp[5];		// unitless
-						////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-						//////////////////////////// convert to USEFUL inputs in SI units                                                //
-						////////////////////////////    NOTE: easiest to do EVERYTHING in SI units                               //
-						////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-	Beta=1.0/(kB*Temp);		// in Joules^-1
-	Perm=dialec*FrSpPerm;	//in C^2/(N  m^2)
-	charge=zz*Elcharge;		//in Coulomb (C)
-	SIdiam = diam*1E-10;		//in m
-	Vp=4.0*pi/3.0*(SIdiam/2.0)*(SIdiam/2.0)*(SIdiam/2.0);	//in m^3
-	cs=csalt*6.022E23*1E3;	//# salt molecules/m^3
-	
-	//         Compute the derived values of :
-	//			 Ionic strength IonSt (in C^2/m^3)  
-	// 			Kappa (Debye-Huckel screening length in m)
-	//	and		gamma Exp(-k)
-	IonSt=0.5 * Elcharge*Elcharge*(zz*VolFrac/Vp+2.0*cs);
-	Kappa=sqrt(2*Beta*IonSt/Perm);     //Kappa calc from Ionic strength
-									   //	Kappa=2/SIdiam					// Use to compare with HP paper
-	gMSAWave[5]=Beta*charge*charge/(pi*Perm*SIdiam*pow((2.0+Kappa*SIdiam),2));
-	
-	//         Finally set up dimensionless parameters 
-	Qdiam=QQ*diam;
-	gMSAWave[6] = Kappa*SIdiam;
-	gMSAWave[4] = VolFrac;
-	
-	//Function sqhpa(qq)  {this is where Hayter-Penfold program began}
-	
-	//       FIRST CALCULATE COUPLING
-	
-	ss=pow(gMSAWave[4],(1.0/3.0));
-	gMSAWave[9] = 2.0*ss*gMSAWave[5]*exp(gMSAWave[6]-gMSAWave[6]/ss);
-	
-	//        CALCULATE COEFFICIENTS, CHECK ALL IS WELL
-	//        AND IF SO CALCULATE S(Q*SIG)
-	
-	ierr=0;
-	ierr=sqcoef(ierr, gMSAWave);
-	if (ierr>=0) {
-		SofQ=sqhcal(Qdiam, gMSAWave);
-	}else{
-       	//SofQ=NaN;
-		SofQ=-1.0;
-		//	print "Error Level = ",ierr
-		//      print "Please report HPMSA problem with above error code"
-	}
-	
-	return(SofQ);
-}
-
-
-
-/////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////
-//
-//
-//      CALCULATES RESCALED VOLUME FRACTION AND CORRESPONDING
-//      COEFFICIENTS FOR "SQHPA"
-//
-//      JOHN B. HAYTER   (I.L.L.)    14-SEP-81
-//
-//      ON EXIT:
-//
-//      SETA IS THE RESCALED VOLUME FRACTION
-//      SGEK IS THE RESCALED CONTACT POTENTIAL
-//      SAK IS THE RESCALED SCREENING CONSTANT
-//      A,B,C,F,U,V ARE THE MSA COEFFICIENTS
-//      G1= G(1+) IS THE CONTACT VALUE OF G(R/SIG):
-//      FOR THE GILLAN CONDITION, THE DIFFERENCE FROM
-//      ZERO INDICATES THE COMPUTATIONAL ACCURACY.
-//
-//      IR > 0:    NORMAL EXIT,  IR IS THE NUMBER OF ITERATIONS.
-//         < 0:    FAILED TO CONVERGE
-//
-int
-sqcoef(int ir, double gMSAWave[])
-{	
-	int itm=40,ix,ig,ii;
-	double acc=5.0E-6,del,e1,e2,f1,f2;
-
-	//      WAVE gMSAWave = $"root:HayPenMSA:gMSAWave"
-	f1=0;		//these were never properly initialized...
-	f2=0;
-	
-	ig=1;
-	if (gMSAWave[6]>=(1.0+8.0*gMSAWave[4])) {
-		ig=0;
-		gMSAWave[15]=gMSAWave[14];
-		gMSAWave[16]=gMSAWave[4];
-		ix=1;
-		ir = sqfun(ix,ir,gMSAWave);
-		gMSAWave[14]=gMSAWave[15];
-		gMSAWave[4]=gMSAWave[16];
-		if((ir<0.0) || (gMSAWave[14]>=0.0)) {
-			return ir;
-		}
-	}
-	gMSAWave[10]=fmin(gMSAWave[4],0.20);
-	if ((ig!=1) || ( gMSAWave[9]>=0.15)) {
-		ii=0;                             
-		do {
-			ii=ii+1;
-			if(ii>itm) {
-				ir=-1;
-				return ir;		
-			}
-			if (gMSAWave[10]<=0.0) {
-			    gMSAWave[10]=gMSAWave[4]/ii;
-			}
-			if(gMSAWave[10]>0.6) {
-			    gMSAWave[10] = 0.35/ii;
-			}
-			e1=gMSAWave[10];
-			gMSAWave[15]=f1;
-			gMSAWave[16]=e1;
-			ix=2;
-			ir = sqfun(ix,ir,gMSAWave);
-			f1=gMSAWave[15];
-			e1=gMSAWave[16];
-			e2=gMSAWave[10]*1.01;
-			gMSAWave[15]=f2;
-			gMSAWave[16]=e2;
-			ix=2;
-			ir = sqfun(ix,ir,gMSAWave);
-			f2=gMSAWave[15];
-			e2=gMSAWave[16];
-			e2=e1-(e2-e1)*f1/(f2-f1);
-			gMSAWave[10] = e2;
-			del = fabs((e2-e1)/e1);
-		} while (del>acc);
-		gMSAWave[15]=gMSAWave[14];
-		gMSAWave[16]=e2;
-		ix=4;
-		ir = sqfun(ix,ir,gMSAWave);
-		gMSAWave[14]=gMSAWave[15];
-		e2=gMSAWave[16];
-		ir=ii;
-		if ((ig!=1) || (gMSAWave[10]>=gMSAWave[4])) {
-		    return ir;
-		}
-	}
-	gMSAWave[15]=gMSAWave[14];
-	gMSAWave[16]=gMSAWave[4];
-	ix=3;
-	ir = sqfun(ix,ir,gMSAWave);
-	gMSAWave[14]=gMSAWave[15];
-	gMSAWave[4]=gMSAWave[16];
-	if ((ir>=0) && (gMSAWave[14]<0.0)) {
-		ir=-3;
-	}
-	return ir;
-}
-
-
-int
-sqfun(int ix, int ir, double gMSAWave[])
-{	
-	double acc=1.0e-6;
-	double reta,eta2,eta21,eta22,eta3,eta32,eta2d,eta2d2,eta3d,eta6d,e12,e24,rgek;
-	double rak,ak1,ak2,dak,dak2,dak4,d,d2,dd2,dd4,dd45,ex1,ex2,sk,ck,ckma,skma;
-	double al1,al2,al3,al4,al5,al6,be1,be2,be3,vu1,vu2,vu3,vu4,vu5,ph1,ph2,ta1,ta2,ta3,ta4,ta5;
-	double a1,a2,a3,b1,b2,b3,v1,v2,v3,p1,p2,p3,pp,pp1,pp2,p1p2,t1,t2,t3,um1,um2,um3,um4,um5,um6;
-	double w0,w1,w2,w3,w4,w12,w13,w14,w15,w16,w24,w25,w26,w32,w34,w3425,w35,w3526,w36,w46,w56;
-	double fa,fap,ca,e24g,pwk,qpw,pg,del,fun,fund,g24;
-	int ii,ibig,itm=40;
-	//      WAVE gMSAWave = $"root:HayPenMSA:gMSAWave"
-	a2=0;
-	a3=0;
-	b2=0;
-	b3=0;
-	v2=0;
-	v3=0;
-	p2=0;
-	p3=0;
-	
-	//     CALCULATE CONSTANTS; NOTATION IS HAYTER PENFOLD (1981)
-	
-	reta = gMSAWave[16];                                                
-	eta2 = reta*reta;
-	eta3 = eta2*reta;
-	e12 = 12.0*reta;
-	e24 = e12+e12;
-	gMSAWave[13] = pow( (gMSAWave[4]/gMSAWave[16]),(1.0/3.0));
-	gMSAWave[12]=gMSAWave[6]/gMSAWave[13];
-	ibig=0;
-	if (( gMSAWave[12]>15.0) && (ix==1)) {
-		ibig=1;
-	}
-    
-	gMSAWave[11] = gMSAWave[5]*gMSAWave[13]*exp(gMSAWave[6]- gMSAWave[12]);
-	rgek =  gMSAWave[11];
-	rak =  gMSAWave[12];
-	ak2 = rak*rak;
-	ak1 = 1.0+rak;
-	dak2 = 1.0/ak2;
-	dak4 = dak2*dak2;
-	d = 1.0-reta;
-	d2 = d*d;
-	dak = d/rak;
-	dd2 = 1.0/d2;
-	dd4 = dd2*dd2;
-	dd45 = dd4*2.0e-1;
-	eta3d=3.0*reta;
-	eta6d = eta3d+eta3d;
-	eta32 = eta3+ eta3;
-	eta2d = reta+2.0;
-	eta2d2 = eta2d*eta2d;
-	eta21 = 2.0*reta+1.0;
-	eta22 = eta21*eta21;
-	
-	//     ALPHA(I)
-	
-	al1 = -eta21*dak;
-	al2 = (14.0*eta2-4.0*reta-1.0)*dak2;
-	al3 = 36.0*eta2*dak4;
-	
-	//      BETA(I)
-	
-	be1 = -(eta2+7.0*reta+1.0)*dak;
-	be2 = 9.0*reta*(eta2+4.0*reta-2.0)*dak2;
-	be3 = 12.0*reta*(2.0*eta2+8.0*reta-1.0)*dak4;
-	
-	//      NU(I)
-	
-	vu1 = -(eta3+3.0*eta2+45.0*reta+5.0)*dak;
-	vu2 = (eta32+3.0*eta2+42.0*reta-2.0e1)*dak2;
-	vu3 = (eta32+3.0e1*reta-5.0)*dak4;
-	vu4 = vu1+e24*rak*vu3;
-	vu5 = eta6d*(vu2+4.0*vu3);
-	
-	//      PHI(I)
-	
-	ph1 = eta6d/rak;
-	ph2 = d-e12*dak2;
-	
-	//      TAU(I)
-	
-	ta1 = (reta+5.0)/(5.0*rak);
-	ta2 = eta2d*dak2;
-	ta3 = -e12*rgek*(ta1+ta2);
-	ta4 = eta3d*ak2*(ta1*ta1-ta2*ta2);
-	ta5 = eta3d*(reta+8.0)*1.0e-1-2.0*eta22*dak2;
-	
-	//     double PRECISION SINH(K), COSH(K)
-	
-	ex1 = exp(rak);
-	ex2 = 0.0;
-	if ( gMSAWave[12]<20.0) {
-		ex2=exp(-rak);
-	}
-	sk=0.5*(ex1-ex2);
-	ck = 0.5*(ex1+ex2);
-	ckma = ck-1.0-rak*sk;
-	skma = sk-rak*ck;
-	
-	//      a(I)
-	
-	a1 = (e24*rgek*(al1+al2+ak1*al3)-eta22)*dd4;
-	if (ibig==0) {
-		a2 = e24*(al3*skma+al2*sk-al1*ck)*dd4;
-		a3 = e24*(eta22*dak2-0.5*d2+al3*ckma-al1*sk+al2*ck)*dd4;
-	}
-	
-	//      b(I)
-	
-	b1 = (1.5*reta*eta2d2-e12*rgek*(be1+be2+ak1*be3))*dd4;
-	if (ibig==0) {
-		b2 = e12*(-be3*skma-be2*sk+be1*ck)*dd4;
-		b3 = e12*(0.5*d2*eta2d-eta3d*eta2d2*dak2-be3*ckma+be1*sk-be2*ck)*dd4;
-	}
-	
-	//      V(I)
-	
-	v1 = (eta21*(eta2-2.0*reta+1.0e1)*2.5e-1-rgek*(vu4+vu5))*dd45;
-	if (ibig==0) {
-		v2 = (vu4*ck-vu5*sk)*dd45;
-		v3 = ((eta3-6.0*eta2+5.0)*d-eta6d*(2.0*eta3-3.0*eta2+18.0*reta+1.0e1)*dak2+e24*vu3+vu4*sk-vu5*ck)*dd45;
-	}
-	
-	
-	//       P(I)
-	
-	pp1 = ph1*ph1;
-	pp2 = ph2*ph2;
-	pp = pp1+pp2;
-	p1p2 = ph1*ph2*2.0;
-	p1 = (rgek*(pp1+pp2-p1p2)-0.5*eta2d)*dd2;
-	if (ibig==0) {
-		p2 = (pp*sk+p1p2*ck)*dd2;
-		p3 = (pp*ck+p1p2*sk+pp1-pp2)*dd2;
-	}
-	
-	//       T(I)
-	
-	t1 = ta3+ta4*a1+ta5*b1;
-	if (ibig!=0) {
-		
-		//		VERY LARGE SCREENING:  ASYMPTOTIC SOLUTION
-		
-  		v3 = ((eta3-6.0*eta2+5.0)*d-eta6d*(2.0*eta3-3.0*eta2+18.0*reta+1.0e1)*dak2+e24*vu3)*dd45;
-		t3 = ta4*a3+ta5*b3+e12*ta2 - 4.0e-1*reta*(reta+1.0e1)-1.0;
-		p3 = (pp1-pp2)*dd2;
-		b3 = e12*(0.5*d2*eta2d-eta3d*eta2d2*dak2+be3)*dd4;
-		a3 = e24*(eta22*dak2-0.5*d2-al3)*dd4;
-		um6 = t3*a3-e12*v3*v3;
-		um5 = t1*a3+a1*t3-e24*v1*v3;
-		um4 = t1*a1-e12*v1*v1;
-		al6 = e12*p3*p3;
-		al5 = e24*p1*p3-b3-b3-ak2;
-		al4 = e12*p1*p1-b1-b1;
-		w56 = um5*al6-al5*um6;
-		w46 = um4*al6-al4*um6;
-		fa = -w46/w56;
-		ca = -fa;
-		gMSAWave[3] = fa;
-		gMSAWave[2] = ca;
-		gMSAWave[1] = b1+b3*fa;
-		gMSAWave[0] = a1+a3*fa;
-		gMSAWave[8] = v1+v3*fa;
-		gMSAWave[14] = -(p1+p3*fa);
-		gMSAWave[15] = gMSAWave[14];
-		if (fabs(gMSAWave[15])<1.0e-3) {
-			gMSAWave[15] = 0.0;
-		}
-		gMSAWave[10] = gMSAWave[16];
-		
-	} else {
-        
-		t2 = ta4*a2+ta5*b2+e12*(ta1*ck-ta2*sk);
-		t3 = ta4*a3+ta5*b3+e12*(ta1*sk-ta2*(ck-1.0))-4.0e-1*reta*(reta+1.0e1)-1.0;
-		
-		//		MU(i)
-		
-		um1 = t2*a2-e12*v2*v2;
-		um2 = t1*a2+t2*a1-e24*v1*v2;
-		um3 = t2*a3+t3*a2-e24*v2*v3;
-		um4 = t1*a1-e12*v1*v1;
-		um5 = t1*a3+t3*a1-e24*v1*v3;
-		um6 = t3*a3-e12*v3*v3;
-		
-		//			GILLAN CONDITION ?
-		//
-		//			YES - G(X=1+) = 0
-		//
-		//			COEFFICIENTS AND FUNCTION VALUE
-		//
-		if ((ix==1) || (ix==3)) {
-			
-			//			NO - CALCULATE REMAINING COEFFICIENTS.
-			
-			//			LAMBDA(I)
-			
-			al1 = e12*p2*p2;
-			al2 = e24*p1*p2-b2-b2;
-			al3 = e24*p2*p3;
-			al4 = e12*p1*p1-b1-b1;
-			al5 = e24*p1*p3-b3-b3-ak2;
-			al6 = e12*p3*p3;
-			
-			//			OMEGA(I)
-			
-			w16 = um1*al6-al1*um6;
-			w15 = um1*al5-al1*um5;
-			w14 = um1*al4-al1*um4;
-			w13 = um1*al3-al1*um3;
-			w12 = um1*al2-al1*um2;
-			
-			w26 = um2*al6-al2*um6;
-			w25 = um2*al5-al2*um5;
-			w24 = um2*al4-al2*um4;
-			
-			w36 = um3*al6-al3*um6;
-			w35 = um3*al5-al3*um5;
-			w34 = um3*al4-al3*um4;
-			w32 = um3*al2-al3*um2;
-			//
-			w46 = um4*al6-al4*um6;
-			w56 = um5*al6-al5*um6;
-			w3526 = w35+w26;
-			w3425 = w34+w25;
-			
-			//			QUARTIC COEFFICIENTS
-			
-			w4 = w16*w16-w13*w36;
-			w3 = 2.0*w16*w15-w13*w3526-w12*w36;
-			w2 = w15*w15+2.0*w16*w14-w13*w3425-w12*w3526;
-			w1 = 2.0*w15*w14-w13*w24-w12*w3425;
-			w0 = w14*w14-w12*w24;
-			
-			//			ESTIMATE THE STARTING VALUE OF f
-			
-			if (ix==1) {
-				//				LARGE K
-				fap = (w14-w34-w46)/(w12-w15+w35-w26+w56-w32);
-			} else {
-				//				ASSUME NOT TOO FAR FROM GILLAN CONDITION.
-				//				IF BOTH RGEK AND RAK ARE SMALL, USE P-W ESTIMATE.
-				gMSAWave[14]=0.5*eta2d*dd2*exp(-rgek);
-				if (( gMSAWave[11]<=2.0) && ( gMSAWave[11]>=0.0) && ( gMSAWave[12]<=1.0)) {
-					e24g = e24*rgek*exp(rak);
-					pwk = sqrt(e24g);
-					qpw = (1.0-sqrt(1.0+2.0*d2*d*pwk/eta22))*eta21/d;
-					gMSAWave[14] = -qpw*qpw/e24+0.5*eta2d*dd2;
-				}
-  				pg = p1+gMSAWave[14];
-				ca = ak2*pg+2.0*(b3*pg-b1*p3)+e12*gMSAWave[14]*gMSAWave[14]*p3;
-				ca = -ca/(ak2*p2+2.0*(b3*p2-b2*p3));
-				fap = -(pg+p2*ca)/p3;
-			}
-			
-			//			AND REFINE IT ACCORDING TO NEWTON
-			ii=0;
-			do {
-				ii = ii+1;
-				if (ii>itm) {
-					//					FAILED TO CONVERGE IN ITM ITERATIONS
-					ir=-2;
-					return (ir);
-				}
-				fa = fap;
-				fun = w0+(w1+(w2+(w3+w4*fa)*fa)*fa)*fa;
-				fund = w1+(2.0*w2+(3.0*w3+4.0*w4*fa)*fa)*fa;
-				fap = fa-fun/fund;
-				del=fabs((fap-fa)/fa);
-			} while (del>acc);
-			
-			ir = ir+ii;
-			fa = fap;
-			ca = -(w16*fa*fa+w15*fa+w14)/(w13*fa+w12);
-			gMSAWave[14] = -(p1+p2*ca+p3*fa);
-			gMSAWave[15] = gMSAWave[14];
-			if (fabs(gMSAWave[15])<1.0e-3) {
-				gMSAWave[15] = 0.0;
-			}
-			gMSAWave[10] = gMSAWave[16];
-		} else {
-			ca = ak2*p1+2.0*(b3*p1-b1*p3);
-			ca = -ca/(ak2*p2+2.0*(b3*p2-b2*p3));
-			fa = -(p1+p2*ca)/p3;
-			if (ix==2) {
-				gMSAWave[15] = um1*ca*ca+(um2+um3*fa)*ca+um4+um5*fa+um6*fa*fa;
-			}
-			if (ix==4) {
-				gMSAWave[15] = -(p1+p2*ca+p3*fa);
-			}
-		}
-   		gMSAWave[3] = fa;
-		gMSAWave[2] = ca;
-		gMSAWave[1] = b1+b2*ca+b3*fa;
-		gMSAWave[0] = a1+a2*ca+a3*fa;
-		gMSAWave[8] = (v1+v2*ca+v3*fa)/gMSAWave[0];
-	}
-   	g24 = e24*rgek*ex1;
-	gMSAWave[7] = (rak*ak2*ca-g24)/(ak2*g24);
-	return (ir);
-}
-
-// called as DiamCyl(hcyl,rcyl)
-double
-DiamCyl(double hcyl, double rcyl)
-{
-	
-	double diam,a,b,t1,t2,ddd;
-	double pi;
-	
-	pi = 4.0*atan(1.0);
-	if (rcyl == 0 || hcyl == 0) {
-		return 0.0;
-	}
-	a = rcyl;
-	b = hcyl/2.0;
-	t1 = a*a*2.0*b/2.0;
-	t2 = 1.0 + (b/a)*(1.0+a/b/2.0)*(1.0+pi*a/b/2.0);
-	ddd = 3.0*t1*t2;
-	diam = pow(ddd,(1.0/3.0));
-	
-	return(diam);
-}
-
-//prolate OR oblate ellipsoids
-//aa is the axis of rotation
-//if aa>bb, then PROLATE
-//if aa<bb, then OBLATE
-// A. Isihara, J. Chem. Phys. 18, 1446 (1950)
-//returns DIAMETER
-// called as DiamEllip(aa,bb)
-double
-DiamEllip(double aa, double bb)
-{
-	
-	double ee,e1,bd,b1,bL,b2,del,ddd,diam;
-
-	if (aa == 0 || bb == 0) {
-		return 0.0;
-	}
-	if (aa == bb) {
-		return 2.0*aa;
-	}
-	if(aa>bb) {
-		ee = (aa*aa - bb*bb)/(aa*aa);
-	}else{
-		ee = (bb*bb - aa*aa)/(bb*bb);
-	}
-	
-	bd = 1.0-ee;
-	e1 = sqrt(ee);
-	b1 = 1.0 + asin(e1)/(e1*sqrt(bd));
-	bL = (1.0+e1)/(1.0-e1);
-	b2 = 1.0 + bd/2/e1*log(bL);
-	del = 0.75*b1*b2;
-	
-	ddd = 2.0*(del+1.0)*aa*bb*bb;		//volume is always calculated correctly
-	diam = pow(ddd,(1.0/3.0));
-	
-	return(diam);
-}
-
-double
-sqhcal(double qq, double gMSAWave[])
-{      	
-    double SofQ,etaz,akz,gekz,e24,x1,x2,ck,sk,ak2,qk,q2k,qk2,qk3,qqk,sink,cosk,asink,qcosk,aqk,inter; 		
-	//	WAVE gMSAWave = $"root:HayPenMSA:gMSAWave"
-
-	etaz = gMSAWave[10];
-	akz =  gMSAWave[12];
-	gekz =  gMSAWave[11];
-	e24 = 24.0*etaz;
-	x1 = exp(akz);
-	x2 = 0.0;
-	if ( gMSAWave[12]<20.0) {
-		x2 = exp(-akz);
-	}
-	ck = 0.5*(x1+x2);
-	sk = 0.5*(x1-x2);
-	ak2 = akz*akz;
-	
-	if (qq<=0.0) {
-		SofQ = -1.0/gMSAWave[0];
-	} else {
-		qk = qq/gMSAWave[13];
-		q2k = qk*qk;
-		qk2 = 1.0/q2k;
-		qk3 = qk2/qk;
-		qqk = 1.0/(qk*(q2k+ak2));
-		sink = sin(qk);
-		cosk = cos(qk);
-		asink = akz*sink;
-		qcosk = qk*cosk;
-		aqk = gMSAWave[0]*(sink-qcosk);
-		aqk=aqk+gMSAWave[1]*((2.0*qk2-1.0)*qcosk+2.0*sink-2.0/qk);
-		inter=24.0*qk3+4.0*(1.0-6.0*qk2)*sink;
-		aqk=(aqk+0.5*etaz*gMSAWave[0]*(inter-(1.0-12.0*qk2+24.0*qk2*qk2)*qcosk))*qk3;
-		aqk=aqk +gMSAWave[2]*(ck*asink-sk*qcosk)*qqk;
-		aqk=aqk +gMSAWave[3]*(sk*asink-qk*(ck*cosk-1.0))*qqk;
-		aqk=aqk +gMSAWave[3]*(cosk-1.0)*qk2;
-		aqk=aqk -gekz*(asink+qcosk)*qqk;
-		SofQ = 1.0/(1.0-e24*aqk);
-	}
-	return (SofQ);
-}
-
-///////////end of XOP
-
-
Index: c/sans/models/src/libigor/libStructureFactor.h
===================================================================
--- src/sans/models/src/libigor/libStructureFactor.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,14 +1,0 @@
-// header for SphereFit.c
-
-/* IGOR Fit Functions */
-double HardSphereStruct(double dp[], double q);
-double SquareWellStruct(double dp[], double q);
-double StickyHS_Struct(double dp[], double q);
-double HayterPenfoldMSA(double dp[], double q);
-double DiamCyl(double a, double b);
-double DiamEllip(double a, double b);
-
-//function prototypes
-double sqhcal(double qq, double gMSAWave[]);
-int sqfun(int ix, int ir, double gMSAWave[]);
-int sqcoef(int ir, double gMSAWave[]);
Index: c/sans/models/src/libigor/libTwoPhase.c
===================================================================
--- src/sans/models/src/libigor/libTwoPhase.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,555 +1,0 @@
-/*	TwoPhaseFit.c
-
-*/
-
-#include "StandardHeaders.h"			// Include ANSI headers, Mac headers
-#include "libTwoPhase.h"
-
-/* internal functions */
-static double
-gammln(double xx) {
-
-    double x,y,tmp,ser;
-    static double cof[6]={76.18009172947146,-86.50532032941677,
-    24.01409824083091,-1.231739572450155,
-    0.1208650973866179e-2,-0.5395239384953e-5};
-    int j;
-
-    y=x=xx;
-    tmp=x+5.5;
-    tmp -= (x+0.5)*log(tmp);
-    ser=1.000000000190015;
-    for (j=0;j<=5;j++) ser += cof[j]/++y;
-    return -tmp+log(2.5066282746310005*ser/x);
-}
-
-// scattering from the Teubner-Strey model for microemulsions - hardly needs to be an XOP...
-double
-TeubnerStreyModel(double dp[], double q)
-{
-	double inten,q2,q4;		//my local names
-	
-	q2 = q*q;
-	q4 = q2*q2;
-	
-	inten = 1.0/(dp[0]+dp[1]*q2+dp[2]*q4);
-	inten += dp[3];  
-	return(inten);
-}
-
-double
-Power_Law_Model(double dp[], double q)
-{
-	double qval;
-	double inten,A,m,bgd;		//my local names
-	
-	qval= q;
-	
-	A = dp[0];
-	m = dp[1];
-	bgd = dp[2];
-	inten = A*pow(qval,-m) + bgd;
-	return(inten);
-}
-
-
-double
-Peak_Lorentz_Model(double dp[], double q)
-{
-	double qval;
-	double inten,I0, qpk, dq,bgd;		//my local names
-	qval= q;
-	
-	I0 = dp[0];
-	qpk = dp[1];
-	dq = dp[2];
-	bgd = dp[3];
-	inten = I0/(1.0 + pow( (qval-qpk)/dq,2) ) + bgd;
-	
-	return(inten);
-}
-
-double
-Peak_Gauss_Model(double dp[], double q)
-{
-	double qval;
-	double inten,I0, qpk, dq,bgd;		//my local names
-	
-	qval= q;
-	
-	I0 = dp[0];
-	qpk = dp[1];
-	dq = dp[2];
-	bgd = dp[3];
-	inten = I0*exp(-0.5*pow((qval-qpk)/dq,2))+ bgd;
-	
-	return(inten);
-}
-
-double
-Lorentz_Model(double dp[], double q)
-{
-	double qval;
-	double inten,I0, L,bgd;		//my local names
-	
-	qval= q;
-	
-	I0 = dp[0];
-	L = dp[1];
-	bgd = dp[2];
-	inten = I0/(1.0 + (qval*L)*(qval*L)) + bgd;
-	
-	return(inten);
-}
-
-double
-Fractal(double dp[], double q)
-{
-	double x,pi;
-	double r0,Df,corr,phi,sldp,sldm,bkg;
-	double pq,sq,ans;
-	
-	pi = 4.0*atan(1.0);
-	x=q;
-	
-	phi = dp[0];		// volume fraction of building block spheres...
-	r0 = dp[1];		//  radius of building block
-	Df = dp[2];		//  fractal dimension
-	corr = dp[3];		//  correlation length of fractal-like aggregates
-	sldp = dp[4];		// SLD of building block
-	sldm = dp[5];		// SLD of matrix or solution
-	bkg = dp[6];		//  flat background 
-	
-	//calculate P(q) for the spherical subunits, units cm-1 sr-1
-	pq = 1.0e8*phi*4.0/3.0*pi*r0*r0*r0*(sldp-sldm)*(sldp-sldm)*pow((3*(sin(x*r0) - x*r0*cos(x*r0))/pow((x*r0),3)),2);
-	
-	//calculate S(q)
-	sq = Df*exp(gammln(Df-1.0))*sin((Df-1.0)*atan(x*corr));
-	sq /= pow((x*r0),Df) * pow((1.0 + 1.0/(x*corr)/(x*corr)),((Df-1.0)/2.0));
-	sq += 1.0;
-	//combine and return
-	ans = pq*sq + bkg;
-	
-	return(ans);
-}
-
-// 6 JUL 2009 SRK changed definition of Izero scale factor to be uncorrelated with range
-//
-double
-DAB_Model(double dp[], double q)
-{
-	double qval,inten;
-	double Izero, range, incoh;
-	
-	qval= q;
-	Izero = dp[0];
-	range = dp[1];
-	incoh = dp[2]; 
-	
-	inten = (Izero*range*range*range)/pow((1.0 + (qval*range)*(qval*range)),2) + incoh;
-	
-	return(inten);
-}
-
-// G. Beaucage's Unified Model (1-4 levels)
-//
-double
-OneLevel(double dp[], double q)
-{
-	double x,ans,erf1;
-	double G1,Rg1,B1,Pow1,bkg,scale;
-	
-	x=q;
-	scale = dp[0];
-	G1 = dp[1];
-	Rg1 = dp[2];
-	B1 = dp[3];
-	Pow1 = dp[4];
-	bkg = dp[5];
-	
-	erf1 = erf( (x*Rg1/sqrt(6.0)));
-	
-	ans = G1*exp(-x*x*Rg1*Rg1/3.0);
-	ans += B1*pow((erf1*erf1*erf1/x),Pow1);
-	
-	if(x == 0) {
-		ans = G1;
-	}
-	
-	ans *= scale;
-	ans += bkg;
-	return(ans);
-}
-
-// G. Beaucage's Unified Model (1-4 levels)
-//
-double
-TwoLevel(double dp[], double q)
-{
-	double x;
-	double ans,G1,Rg1,B1,G2,Rg2,B2,Pow1,Pow2,bkg;
-	double erf1,erf2,scale;
-	
-	x=q;
-	
-	scale = dp[0];
-	G1 = dp[1];	//equivalent to I(0)
-	Rg1 = dp[2];
-	B1 = dp[3];
-	Pow1 = dp[4];
-	G2 = dp[5];
-	Rg2 = dp[6];
-	B2 = dp[7];
-	Pow2 = dp[8];
-	bkg = dp[9];
-	
-	erf1 = erf( (x*Rg1/sqrt(6.0)) );
-	erf2 = erf( (x*Rg2/sqrt(6.0)) );
-	//Print erf1
-	
-	ans = G1*exp(-x*x*Rg1*Rg1/3.0);
-	ans += B1*exp(-x*x*Rg2*Rg2/3.0)*pow((erf1*erf1*erf1/x),Pow1);
-	ans += G2*exp(-x*x*Rg2*Rg2/3.0);
-	ans += B2*pow((erf2*erf2*erf2/x),Pow2);
-
-	if(x == 0) {
-		ans = G1+G2;
-	}
-	
-	ans *= scale;
-	ans += bkg;
-	
-	return(ans);
-}
-
-// G. Beaucage's Unified Model (1-4 levels)
-//
-double
-ThreeLevel(double dp[], double q)
-{
-	double x;
-	double ans,G1,Rg1,B1,G2,Rg2,B2,Pow1,Pow2,bkg;
-	double G3,Rg3,B3,Pow3,erf3;
-	double erf1,erf2,scale;
-	
-	x=q;
-	
-	scale = dp[0];
-	G1 = dp[1];	//equivalent to I(0)
-	Rg1 = dp[2];
-	B1 = dp[3];
-	Pow1 = dp[4];
-	G2 = dp[5];
-	Rg2 = dp[6];
-	B2 = dp[7];
-	Pow2 = dp[8];
-	G3 = dp[9];
-	Rg3 = dp[10];
-	B3 = dp[11];
-	Pow3 = dp[12];
-	bkg = dp[13];
-	
-	erf1 = erf( (x*Rg1/sqrt(6.0)) );
-	erf2 = erf( (x*Rg2/sqrt(6.0)) );
-	erf3 = erf( (x*Rg3/sqrt(6.0)) );
-	//Print erf1
-	
-	ans = G1*exp(-x*x*Rg1*Rg1/3.0) + B1*exp(-x*x*Rg2*Rg2/3.0)*pow((erf1*erf1*erf1/x),Pow1);
-	ans += G2*exp(-x*x*Rg2*Rg2/3.0) + B2*exp(-x*x*Rg3*Rg3/3.0)*pow((erf2*erf2*erf2/x),Pow2);
-	ans += G3*exp(-x*x*Rg3*Rg3/3.0) + B3*pow((erf3*erf3*erf3/x),Pow3);
-
-	if(x == 0) {
-		ans = G1+G2+G3;
-	}
-	
-	ans *= scale;
-	ans += bkg;
-	
-	return(ans);
-}
-
-// G. Beaucage's Unified Model (1-4 levels)
-//
-double
-FourLevel(double dp[], double q)
-{
-	double x;
-	double ans,G1,Rg1,B1,G2,Rg2,B2,Pow1,Pow2,bkg;
-	double G3,Rg3,B3,Pow3,erf3;
-	double G4,Rg4,B4,Pow4,erf4;
-	double erf1,erf2,scale;
-	
-	x=q;
-	
-	scale = dp[0];
-	G1 = dp[1];	//equivalent to I(0)
-	Rg1 = dp[2];
-	B1 = dp[3];
-	Pow1 = dp[4];
-	G2 = dp[5];
-	Rg2 = dp[6];
-	B2 = dp[7];
-	Pow2 = dp[8];
-	G3 = dp[9];
-	Rg3 = dp[10];
-	B3 = dp[11];
-	Pow3 = dp[12];
-	G4 = dp[13];
-	Rg4 = dp[14];
-	B4 = dp[15];
-	Pow4 = dp[16];
-	bkg = dp[17];
-	
-	erf1 = erf( (x*Rg1/sqrt(6.0)) );
-	erf2 = erf( (x*Rg2/sqrt(6.0)) );
-	erf3 = erf( (x*Rg3/sqrt(6.0)) );
-	erf4 = erf( (x*Rg4/sqrt(6.0)) );
-	
-	ans = G1*exp(-x*x*Rg1*Rg1/3.0) + B1*exp(-x*x*Rg2*Rg2/3.0)*pow((erf1*erf1*erf1/x),Pow1);
-	ans += G2*exp(-x*x*Rg2*Rg2/3.0) + B2*exp(-x*x*Rg3*Rg3/3.0)*pow((erf2*erf2*erf2/x),Pow2);
-	ans += G3*exp(-x*x*Rg3*Rg3/3.0) + B3*exp(-x*x*Rg4*Rg4/3.0)*pow((erf3*erf3*erf3/x),Pow3);
-	ans += G4*exp(-x*x*Rg4*Rg4/3.0) + B4*pow((erf4*erf4*erf4/x),Pow4);
-
-	if(x == 0) {
-		ans = G1+G2+G3+G4;
-	}
-	
-	ans *= scale;
-	ans += bkg;
-	
-    return(ans);
-}
-
-double
-BroadPeak(double dp[], double q)
-{
-	// variables are:							
-	//[0] Porod term scaling
-	//[1] Porod exponent
-	//[2] Lorentzian term scaling
-	//[3] Lorentzian screening length [A]
-	//[4] peak location [1/A]
-	//[5] Lorentzian exponent
-	//[6] background
-	
-	double aa,nn,cc,LL,Qzero,mm,bgd,inten,qval;
-	qval= q;
-	aa = dp[0];
-	nn = dp[1];
-	cc = dp[2]; 
-	LL = dp[3]; 
-	Qzero = dp[4]; 
-	mm = dp[5]; 
-	bgd = dp[6]; 
-	
-	inten = aa/pow(qval,nn);
-	inten += cc/(1.0 + pow((fabs(qval-Qzero)*LL),mm) );
-	inten += bgd;
-	
-	return(inten);
-}
-
-double
-CorrLength(double dp[], double q)
-{
-	// variables are:							
-	//[0] Porod term scaling
-	//[1] Porod exponent
-	//[2] Lorentzian term scaling
-	//[3] Lorentzian screening length [A]
-	//[4] Lorentzian exponent
-	//[5] background
-	
-	double aa,nn,cc,LL,mm,bgd,inten,qval;
-	qval= q;
-	aa = dp[0];
-	nn = dp[1];
-	cc = dp[2]; 
-	LL = dp[3]; 
-	mm = dp[4]; 
-	bgd = dp[5]; 
-	
-	inten = aa/pow(qval,nn);
-	inten += cc/(1.0 + pow((qval*LL),mm) );
-	inten += bgd;
-	
-	return(inten);
-}
-
-double
-TwoLorentzian(double dp[], double q)
-{
-	// variables are:							
-	//[0] Lorentzian term scaling
-	//[1] Lorentzian screening length [A]
-	//[2] Lorentzian exponent
-	//[3] Lorentzian #2 term scaling
-	//[4] Lorentzian #2 screening length [A]
-	//[5] Lorentzian #2 exponent
-	//[6] background
-		
-	double aa,LL1,nn,cc,LL2,mm,bgd,inten,qval;
-	qval= q;
-	aa = dp[0];
-	LL1 = dp[1];
-	nn = dp[2]; 
-	cc = dp[3]; 
-	LL2 = dp[4]; 
-	mm = dp[5]; 
-	bgd= dp[6];
-	
-	inten = aa/(1.0 + pow((qval*LL1),nn) );
-	inten += cc/(1.0 + pow((qval*LL2),mm) );
-	inten += bgd;
-	
-	return(inten);
-}
-
-double
-TwoPowerLaw(double dp[], double q)
-{
-	//[0] Coefficient
-	//[1] (-) Power @ low Q
-	//[2] (-) Power @ high Q
-	//[3] crossover Q-value
-	//[4] incoherent background
-		
-	double A, m1,m2,qc,bgd,scale,inten,qval;
-	qval= q;
-	A = dp[0];
-	m1 = dp[1];
-	m2 = dp[2]; 
-	qc = dp[3]; 
-	bgd = dp[4]; 
-	
-	if(qval<=qc){
-		inten = A*pow(qval,-1.0*m1);
-	} else {
-		scale = A*pow(qc,-1.0*m1) / pow(qc,-1.0*m2);
-		inten = scale*pow(qval,-1.0*m2);
-	}
-	
-	inten += bgd;
-	
-	return(inten);
-}
-
-double
-PolyGaussCoil(double dp[], double x)
-{
-	//w[0] = scale
-	//w[1] = radius of gyration [ï¿œ]
-	//w[2] = polydispersity, ratio of Mw/Mn
-	//w[3] = bkg [cm-1]
-		
-	double scale,bkg,Rg,uval,Mw_Mn,inten,xi;
-
-	scale = dp[0];
-	Rg = dp[1];
-	Mw_Mn = dp[2]; 
-	bkg = dp[3]; 
-	
-	uval = Mw_Mn - 1.0;
-	if(uval == 0.0) {
-		uval = 1e-6;		//avoid divide by zero error
-	}
-	
-	xi = Rg*Rg*x*x/(1.0+2.0*uval);
-	
-	if(xi < 1e-3) {
-		return(scale+bkg);		//limiting value
-	}
-	
-	inten = 2.0*(pow((1.0+uval*xi),(-1.0/uval))+xi-1.0);
-	inten /= (1.0+uval)*xi*xi;
-
-	inten *= scale;
-	//add in the background
-	inten += bkg;	
-	return(inten);
-}
-
-double
-GaussLorentzGel(double dp[], double x)
-{
-	//[0] Gaussian scale factor
-	//[1] Gaussian (static) screening length
-	//[2] Lorentzian (fluctuation) scale factor
-	//[3] Lorentzian screening length
-	//[4] incoherent background
-		
-	double Ig0,gg,Il0,ll,bgd,inten;
-
-	Ig0 = dp[0];
-	gg = dp[1];
-	Il0 = dp[2]; 
-	ll = dp[3];
-	bgd = dp[4]; 
-	
-	inten = Ig0*exp(-1.0*x*x*gg*gg/2.0) + Il0/(1.0 + (x*ll)*(x*ll)) + bgd;
-	
-	return(inten);
-}
-
-
-double
-GaussianShell(double w[], double x)
-{
-	// variables are:							
-	//[0] scale
-	//[1] radius (ï¿œ)
-	//[2] thick (ï¿œ) (thickness parameter - this is the std. dev. of the Gaussian width of the shell)
-	//[3] polydispersity of the radius
-	//[4] sld shell (ï¿œ-2)
-	//[5] sld solvent
-	//[6] background (cm-1)
-	
-	double scale,rad,delrho,bkg,del,thick,pd,sig,pi;
-	double t1,t2,t3,t4,retval,exfact,vshell,vexcl,sldShell,sldSolvent;
-	scale = w[0];
-	rad = w[1];
-	thick = w[2];
-	pd = w[3];
-	sldShell = w[4];
-	sldSolvent = w[5];
-	bkg = w[6];
-	
-	delrho = w[4] - w[5];
-	sig = pd*rad;
-	
-	pi = 4.0*atan(1.0);
-	
-	///APPROXIMATION (see eqn 4 - but not a bad approximation)
-	// del is the equivalent shell thickness with sharp boundaries, centered at mean radius
-	del = thick*sqrt(2.0*pi);
-	
-	// calculate the polydisperse shell volume and the excluded volume
-	vshell=4.0*pi/3.0*( pow((rad+del/2.0),3) - pow((rad-del/2.0),3) ) *(1.0+pd*pd);
-	vexcl=4.0*pi/3.0*( pow((rad+del/2.0),3) ) *(1.0+pd*pd);
-	
-	//intensity, eqn 9(a-d)
-	exfact = exp(-2.0*sig*sig*x*x);
-	
-	t1 = 0.5*x*x*thick*thick*thick*thick*(1.0+cos(2.0*x*rad)*exfact);
-	t2 = x*thick*thick*(rad*sin(2.0*x*rad) + 2.0*x*sig*sig*cos(2.0*x*rad))*exfact;
-	t3 = 0.5*rad*rad*(1.0-cos(2.0*x*rad)*exfact);
-	t4 = 0.5*sig*sig*(1.0+4.0*x*rad*sin(2.0*x*rad)*exfact+cos(2.0*x*rad)*(4.0*sig*sig*x*x-1.0)*exfact);
-	
-	retval = t1+t2+t3+t4;
-	retval *= exp(-1.0*x*x*thick*thick);
-	retval *= (del*del/x/x);
-	retval *= 16.0*pi*pi*delrho*delrho*scale;
-	retval *= 1.0e8;
-	
-	//NORMALIZED by the AVERAGE shell volume, since scale is the volume fraction of material
-//	retval /= vshell
-	retval /= vexcl;
-	//re-normalize by polydisperse sphere volume, Gaussian distribution
-	retval /= (1.0+3.0*pd*pd);
-	
-	retval += bkg;
-	
-	return(retval);
-}
-
-
Index: c/sans/models/src/libigor/libTwoPhase.h
===================================================================
--- src/sans/models/src/libigor/libTwoPhase.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,23 +1,0 @@
-// header for TwoPhaseFit.c
-
-//function prototypes
-/* IGOR Fit Functions */
-double TeubnerStreyModel(double dp[], double q);
-double Power_Law_Model(double dp[], double q);
-double Peak_Lorentz_Model(double dp[], double q);
-double Peak_Gauss_Model(double dp[], double q);
-double Lorentz_Model(double dp[], double q);
-double Fractal(double dp[], double q);
-double DAB_Model(double dp[], double q);
-double OneLevel(double dp[], double q);
-double TwoLevel(double dp[], double q);
-double ThreeLevel(double dp[], double q);
-double FourLevel(double dp[], double q);
-double BroadPeak(double dp[], double q);
-double CorrLength(double dp[], double q);
-double TwoLorentzian(double dp[], double q);
-double TwoPowerLaw(double dp[], double q);
-double PolyGaussCoil(double dp[], double q);
-double GaussLorentzGel(double dp[], double q);
-double GaussianShell(double dp[], double q);
-
Index: c/sans/models/src/libigor/local.def
===================================================================
--- src/sans/models/src/libigor/local.def	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,29 +1,0 @@
-# -*- Makefile -*-
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-#                               Michael A.G. Aivazis
-#                        California Institute of Technology
-#                        (C) 1998-2004  All Rights Reserved
-#
-# <LicenseText>
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-
-#
-# Local (project) definitions
-#
-
-# C++
-
-    PROJ_CXX_FLAGS += $(CXX_SOFLAGS)
-    PROJ_LCXX_FLAGS += $(LCXX_SARFLAGS)
-
-#PROJ_CXX_DEFINES += DEEPDEBUG
-#PROJ_CXX_DEFINES += DEBUG
-
-# version
-# $Id: local.def 1280 2007-06-25 07:01:00Z linjiao $
-
-# End of file
Index: c/sans/models/src/libigor/release_notes.txt
===================================================================
--- src/sans/models/src/libigor/release_notes.txt	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,8 +1,0 @@
-Release Notes for 'libigor'
-
-The C code in 'libigor' has been written as part of the SANS analysis package
-that uses IGOR. More information can be found here:
-
-	http://www.ncnr.nist.gov/programs/sans/data/red_anal.html
-	 
-    "Reduction and Analysis of SANS and USANS Data using Igor Pro", Kline, S. R. J Appl. Cryst. 39(6), 895 (2006).
Index: c/sans/models/src/libigor/winFuncs.c
===================================================================
--- src/sans/models/src/libigor/winFuncs.c	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,146 +1,0 @@
-/* winFuncs.c
-   Adding functions missing from windows math library
-   Andrew Jackson, October 2007
-   */
-
-#include <stdio.h>
-#include <math.h>
-
-#include "winFuncs.h"
-
-
-double fmax(double x, double y){
-	//Doesn't exactly match BSD as if one or other value is NaN behaviour is undefined
-	//BSD returns the other value if one is NaN and NaN if both are NaN
-	//probably wouldn't want to rely on that in any case.
-	if (x > y) {
-		//x is greater than y
-		return x;
-	} else if (y > x) {
-		//y is greater than x
-		return y;
-	} else {
-		//equal
-		return x;
-	}
-}
-
-double fmin(double x, double y){
-	//Doesn't exactly match BSD as if one or other value is NaN behaviour is undefined
-	//BSD returns the other value if one is NaN and NaN if both are NaN
-	//probably wouldn't want to rely on that in any case.
-	if (x < y) {
-		//x is less than y
-		return x;
-	} else if (y < x) {
-		//y is less than x
-		return y;
-	} else {
-		//equal
-		return x;
-	}
-}
-
-double trunc(double x){
-	//This is probably slow as hell
-	if (x > 0){
-		//positive - need floor
-		return floor(x);
-	} else if (x < 0) {
-		//negative - need ceiling
-		return ceil(x);
-	} else {
-		//x is zero or infinity, return x
-		return x;
-	}
-
-}
-
-
-/* erf.c  - public domain implementation of error function erf(3m)
-
-reference - Haruhiko Okumura: C-gengo niyoru saishin algorithm jiten
-            (New Algorithm handbook in C language) (Gijyutsu hyouron
-            sha, Tokyo, 1991) p.227 [in Japanese]                 */
-
-
-#ifdef _WIN32
-# include <float.h>
-# if !defined __MINGW32__ || defined __NO_ISOCEXT
-#  ifndef isnan
-#   define isnan(x) _isnan(x)
-#  endif
-#  ifndef isinf
-#   define isinf(x) (!_finite(x) && !_isnan(x))
-#  endif
-#  ifndef finite
-#   define finite(x) _finite(x)
-#  endif
-# endif
-#endif
-
-static double q_gamma(double, double, double);
-
-/* Incomplete gamma function
-   1 / Gamma(a) * Int_0^x exp(-t) t^(a-1) dt  */
-static double p_gamma(double a, double x, double loggamma_a)
-{
-    int k;
-    double result, term, previous;
-
-    if (x >= 1 + a) return 1 - q_gamma(a, x, loggamma_a);
-    if (x == 0)     return 0;
-    result = term = exp(a * log(x) - x - loggamma_a) / a;
-    for (k = 1; k < 1000; k++) {
-        term *= x / (a + k);
-        previous = result;  result += term;
-        if (result == previous) return result;
-    }
-    fprintf(stderr, "erf.c:%d:p_gamma() could not converge.", __LINE__);
-    return result;
-}
-
-/* Incomplete gamma function
-   1 / Gamma(a) * Int_x^inf exp(-t) t^(a-1) dt  */
-static double q_gamma(double a, double x, double loggamma_a)
-{
-    int k;
-    double result, w, temp, previous;
-    double la = 1, lb = 1 + x - a;  /* Laguerre polynomial */
-
-    if (x < 1 + a) return 1 - p_gamma(a, x, loggamma_a);
-    w = exp(a * log(x) - x - loggamma_a);
-    result = w / lb;
-    for (k = 2; k < 1000; k++) {
-        temp = ((k - 1 - a) * (lb - la) + (k + x) * lb) / k;
-        la = lb;  lb = temp;
-        w *= (k - 1 - a) / k;
-        temp = w / (la * lb);
-        previous = result;  result += temp;
-        if (result == previous) return result;
-    }
-    fprintf(stderr, "erf.c:%d:q_gamma() could not converge.", __LINE__);
-    return result;
-}
-
-#define LOG_PI_OVER_2 0.572364942924700087071713675675 /* log_e(PI)/2 */
-
-double erf(double x)
-{
-    if (!finite(x)) {
-        if (isnan(x)) return x;      /* erf(NaN)   = NaN   */
-        return (x>0 ? 1.0 : -1.0);   /* erf(+-inf) = +-1.0 */
-    }
-    if (x >= 0) return   p_gamma(0.5, x * x, LOG_PI_OVER_2);
-    else        return - p_gamma(0.5, x * x, LOG_PI_OVER_2);
-}
-
-double erfc(double x)
-{
-    if (!finite(x)) {
-        if (isnan(x)) return x;      /* erfc(NaN)   = NaN      */
-        return (x>0 ? 0.0 : 2.0);    /* erfc(+-inf) = 0.0, 2.0 */
-    }
-    if (x >= 0) return  q_gamma(0.5, x * x, LOG_PI_OVER_2);
-    else        return  1 + p_gamma(0.5, x * x, LOG_PI_OVER_2);
-}
Index: c/sans/models/src/libigor/winFuncs.h
===================================================================
--- src/sans/models/src/libigor/winFuncs.h	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,50 +1,0 @@
-#if !defined(WINFUNCS_H)
-#define WINFUNCS_H
-/* winFuncs.h
-   Definitions for missing math lib functions
-   Andrew Jackson, October 2007
-   */
-
-double fmax(double x, double y);
-//long double fmaxl (long double x, long double y);
-//float fmaxf (float x, float y);
-
-double fmin(double x, double y);
-
-double trunc(double x);
-//long double truncl(long double x);
-//float truncf(float x);
-
-double erf(double x);
-//long double erfl(long double x);
-//float erff (float x);
-//double erfc(double x);
-//long double erfcl(long double x);
-//float erfcf(float x;
-
-
-// Define INFINITY and NAN
-typedef union { unsigned char __c[4]; float __f; } __huge_valf_t;
-
-# if __BYTE_ORDER == __BIG_ENDIAN
-#  define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 }
-# endif
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f }
-# endif
-
-static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };
-# define INFINITY  (__huge_valf.__f)
-
-
-# if __BYTE_ORDER == __BIG_ENDIAN
-#  define __nan_bytes   { 0x7f, 0xc0, 0, 0 }
-# endif
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define __nan_bytes   { 0, 0, 0xc0, 0x7f }
-# endif
-
-static union { unsigned char __c[4]; float __d; } __nan_union;
-# define NAN  (__nan_union.__d)
-
-#endif
Index: c/sans/models/src/python_wrapper/WrapperGenerator.py
===================================================================
--- src/sans/models/src/python_wrapper/WrapperGenerator.py	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,596 +1,0 @@
-#!/usr/bin/env python
-""" WrapperGenerator class to generate model code automatically.
-"""
-
-import os, sys,re
-import lineparser
-
-class WrapperGenerator:
-    """ Python wrapper generator for C models
-    
-        The developer must provide a header file describing 
-        the new model.
-        
-        To provide the name of the Python class to be
-        generated, the .h file must contain the following 
-        string in the comments:
-        
-        // [PYTHONCLASS] = my_model
-        
-        where my_model must be replaced by the name of the
-        class that you want to import from sans.models.
-        (example: [PYTHONCLASS] = MyModel
-          will create a class MyModel in sans.models.MyModel.
-          It will also create a class CMyModel in 
-          sans_extension.c_models.)
-          
-        Also in comments, each parameter of the params 
-        dictionary must be declared with a default value
-        in the following way:
-        
-        // [DEFAULT]=param_name=default_value
-        
-        (example:
-            //  [DEFAULT]=radius=20.0
-        )
-          
-        See cylinder.h for an example.
-        
-        
-        A .c file corresponding to the .h file should also
-        be provided (example: my_model.h, my_model.c).
-    
-        The .h file should define two function definitions. For example,
-        cylinder.h defines the following:
-        
-        /// 1D scattering function
-        double cylinder_analytical_1D(CylinderParameters *pars, double q);
-            
-        /// 2D scattering function
-        double cylinder_analytical_2D(CylinderParameters *pars, double q, double phi);
-            
-        The .c file implements those functions.
-        
-        @author: Mathieu Doucet / UTK
-        @contact: mathieu.doucet@nist.gov
-    """
-    
-    def __init__(self, filename, output_dir='.', c_wrapper_dir='.'):
-        """ Initialization """
-        
-        ## Name of .h file to generate wrapper from
-        self.file = filename
-        
-        # Info read from file
-        
-        ## Name of python class to write
-        self.pythonClass = None
-        ## Parser in struct section
-        self.inStruct = False
-        self.foundCPP = False
-        self.inParDefs = False
-        ## Name of struct for the c object
-        self.structName = None
-        ## Dictionary of parameters
-        self.params = {}
-        ## ModelCalculation module flag
-        self.modelCalcFlag = False
-        ## List of default parameters (text)
-        self.default_list = ""
-        ## Dictionary of units
-        self.details = ""
-        ## List of dispersed parameters
-        self.disp_params = []
-        #model description
-        self.description=''
-        # paramaters for fittable
-        self.fixed= []
-        # paramaters for non-fittable
-        self.non_fittable= []
-        ## parameters with orientation
-        self.orientation_params =[]
-        ## parameter with magnetism
-        self.magentic_params = []
-        # Model category
-        self.category = None
-        # Whether model belongs to multifunc
-        self.is_multifunc = False
-        ## output directory for wrappers
-        self.output_dir = output_dir
-        self.c_wrapper_dir = c_wrapper_dir
-
-        
-        
-    def __repr__(self):
-        """ Simple output for printing """
-        
-        rep  = "\n Python class: %s\n\n" % self.pythonClass
-        rep += "  struc name: %s\n\n" % self.structName
-        rep += "  params:     %s\n\n" % self.params
-        rep += "  description:    %s\n\n" % self.description
-        rep += "  Fittable parameters:     %s\n\n"% self.fixed
-        rep += "  Non-Fittable parameters:     %s\n\n"% self.non_fittable
-        rep += "  Orientation parameters:  %s\n\n"% self.orientation_params
-        rep += "  Magnetic parameters:  %s\n\n"% self.magnetic_params
-        return rep
-        
-    def read(self):
-        """ Reads in the .h file to catch parameters of the wrapper """
-        
-        # Check if the file is there
-        if not os.path.isfile(self.file):
-            raise ValueError, "File %s is not a regular file" % self.file
-        
-        # Read file
-        f = open(self.file,'r')
-        buf = f.read()
-        
-        self.default_list = "List of default parameters:\n"
-        #lines = string.split(buf,'\n')
-        lines = buf.split('\n')
-        self.details  = "## Parameter details [units, min, max]\n"
-        self.details += "        self.details = {}\n"
-        
-        #open item in this case Fixed
-        text='text'
-        key2="<%s>"%text.lower()
-        # close an item in this case fixed
-        text='TexT'
-        key3="</%s>"%text.lower()
-        
-        ## Catch fixed parameters
-        key = "[FIXED]"
-        try:
-            self.fixed= lineparser.readhelper(lines, key, 
-                                              key2, key3, file=self.file)
-        except:
-           raise   
-        ## Catch non-fittable parameters parameters
-        key = "[NON_FITTABLE_PARAMS]"
-        try:
-            self.non_fittable= lineparser.readhelper(lines, key, key2,
-                                                     key3, file=self.file)
-        except:
-           raise   
-
-        ## Catch parameters with orientation
-        key = "[ORIENTATION_PARAMS]"    
-        try:
-            self.orientation_params = lineparser.readhelper(lines, key, 
-                                                    key2, key3, file=self.file)
-        except:
-           raise 
-       
-        ## Catch parameters with orientation
-        key = "[MAGNETIC_PARAMS]"    
-        try:
-            self.magnetic_params = lineparser.readhelper( lines,key, 
-                                                    key2,key3, file= self.file)
-        except:
-           raise 
-       
-        ## Catch Description
-        key = "[DESCRIPTION]"
-        
-        find_description = False
-        temp=""
-        for line in lines:
-            if line.count(key)>0 :
-                
-                try:
-                    find_description= True
-                    index = line.index(key)
-                    toks = line[index:].split("=",1 )
-                    temp=toks[1].lstrip().rstrip()
-                    text='text'
-                    key2="<%s>"%text.lower()
-                    if re.match(key2,temp)!=None:
-    
-                        toks2=temp.split(key2,1)
-                        self.description=toks2[1]
-                        text='text'
-                        key2="</%s>"%text.lower()
-                        if re.search(key2,toks2[1])!=None:
-                            temp=toks2[1].split(key2,1)
-                            self.description=temp[0]
-                            break
-                      
-                    else:
-                        self.description=temp
-                        break
-                except:
-                     raise ValueError, "Could not parse file %s" % self.file
-            elif find_description:
-                text='text'
-                key2="</%s>"%text.lower()
-                if re.search(key2,line)!=None:
-                    tok=line.split(key2,1)
-                    temp=tok[0].split("//",1)
-                    self.description+=tok[1].lstrip().rstrip()
-                    break
-                else:
-                    if re.search("//",line)!=None:
-                        temp=line.split("//",1)
-                        self.description+='\n\t\t'+temp[1].lstrip().rstrip()
-                        
-                    else:
-                        self.description+='\n\t\t'+line.lstrip().rstrip()
-                    
-                
-     
-        for line in lines:
-            
-            # Catch class name
-            key = "[PYTHONCLASS]"
-            if line.count(key)>0:
-                try:
-                    index = line.index(key)
-                    toks = line[index:].split("=" )
-                    self.pythonClass = toks[1].lstrip().rstrip()
-
-                except:
-                    raise ValueError, "Could not parse file %s" % self.file
-                
-            key = "[CATEGORY]"
-            if line.count(key)>0:
-                try:
-                    index = line.index(key)
-                    toks = line[index:].split("=")
-                    self.category = toks[1].lstrip().rstrip()
-
-                except:
-                    raise ValueError, "Could not parse file %s" % self.file
-
-            # is_multifunc
-            key = "[MULTIPLICITY_INFO]"
-            if line.count(key) > 0:
-                self.is_multifunc = True
-                try:
-                    index = line.index(key)
-                    toks = line[index:].split("=")
-                    self.multiplicity_info = toks[1].lstrip().rstrip()
-                except:
-                    raise ValueError, "Could not parse file %s" % self.file
-
-            # Catch struct name
-            # C++ class definition
-            if line.count("class")>0:
-                # We are entering a class definition
-                self.inParDefs = True
-                self.foundCPP = True
-                
-            # Old-Style C struct definition
-            if line.count("typedef struct")>0:
-                # We are entering a struct block
-                self.inParDefs = True
-                self.inStruct = True
-            
-            if self.inParDefs and line.count("}")>0:
-                # We are exiting a struct block
-                self.inParDefs = False
-                
-                if self.inStruct:
-                    self.inStruct = False
-                    # Catch the name of the struct
-                    index = line.index("}")
-                    toks = line[index+1:].split(";")
-                    # Catch pointer definition
-                    toks2 = toks[0].split(',')
-                    self.structName = toks2[0].lstrip().rstrip()
-           
-            # Catch struct content
-            key = "[DEFAULT]"
-            if self.inParDefs and line.count(key)>0:
-                # Found a new parameter
-                try:
-                    index = line.index(key)
-                    toks = line[index:].split("=")
-                    toks2 = toks[2].split()
-                    val = float(toks2[0])
-                    self.params[toks[1]] = val
-                    #self.pythonClass = toks[1].lstrip().rstrip()
-                    units = ""
-                    if len(toks2) >= 2:
-                        units = toks2[1]
-                    self.default_list += "         %-15s = %s %s\n" % \
-                        (toks[1], val, units)
-                    
-                    # Check for min and max
-                    min = "None"
-                    max = "None"
-                    if len(toks2) == 4:
-                        min = toks2[2]
-                        max = toks2[3]
-                    
-                    self.details += "        self.details['%s'] = ['%s', %s, %s]\n" % \
-                        (toks[1].lstrip().rstrip(), units.lstrip().rstrip(), min, max)
-                except:
-                    raise ValueError, "Could not parse input file %s \n  %s" % \
-                        (self.file, sys.exc_value)
-                
-                
-            # Catch need for numerical calculations
-            key = "CalcParameters calcPars"
-            if line.count(key)>0:
-                self.modelCalcFlag = True
-                
-            # Catch list of dispersed parameters 
-            key = "[DISP_PARAMS]"
-            if line.count(key)>0:
-                try:
-                    index = line.index(key)
-                    toks = line[index:].split("=")
-                    list_str = toks[1].lstrip().rstrip()
-                    self.disp_params = list_str.split(',')
-                except:
-                    raise ValueError, "Could not parse file %s" % self.file
-
-    def write_c_wrapper(self):
-        """ Writes the C file to create the python extension class 
-            The file is written in C[PYTHONCLASS].c
-        """
-        file_path = os.path.join(self.c_wrapper_dir, 
-                                 "C"+self.pythonClass+'.cpp')
-        file = open(file_path, 'w')
-        
-        template = open(os.path.join(os.path.dirname(__file__), 
-                                     "classTemplate.txt"), 'r')
-        
-        tmp_buf = template.read()
-        #tmp_lines = string.split(tmp_buf,'\n')
-        tmp_lines = tmp_buf.split('\n')
-        
-        for tmp_line in tmp_lines:
-            
-            # Catch class name
-            newline = self.replaceToken(tmp_line, 
-                                        "[PYTHONCLASS]", 'C'+self.pythonClass)
-            #Catch model description
-            #newline = self.replaceToken(tmp_line, 
-            #                            "[DESCRIPTION]", self.description)
-            # Catch C model name
-            newline = self.replaceToken(newline, 
-                                        "[CMODEL]", self.pythonClass)
-            
-            # Catch class name
-            newline = self.replaceToken(newline, 
-                                        "[MODELSTRUCT]", self.structName)
-
-            # Sort model initialization based on multifunc
-            if(self.is_multifunc):
-                line = "int level = 1;\nPyArg_ParseTuple(args,\"i\",&level);\n"
-                line += "self->model = new " + self.pythonClass + "(level);"
-            else:
-                line = "self->model = new " + self.pythonClass + "();"
-    
-            newline = self.replaceToken(newline,"[INITIALIZE_MODEL]",
-                                            line)
-            
-            # Dictionary initialization
-            param_str = "// Initialize parameter dictionary\n"            
-            for par in self.params:
-                param_str += "        PyDict_SetItemString(self->params,\"%s\",Py_BuildValue(\"d\",%10.12f));\n" % \
-                    (par, self.params[par])
-
-            if len(self.disp_params)>0:
-                param_str += "        // Initialize dispersion / averaging parameter dict\n"
-                param_str += "        DispersionVisitor* visitor = new DispersionVisitor();\n"
-                param_str += "        PyObject * disp_dict;\n"
-                for par in self.disp_params:
-                    par = par.strip()
-                    if par == '':
-                        continue
-                    param_str += "        disp_dict = PyDict_New();\n"
-                    param_str += "        self->model->%s.dispersion->accept_as_source(visitor, self->model->%s.dispersion, disp_dict);\n" % (par, par)
-                    param_str += "        PyDict_SetItemString(self->dispersion, \"%s\", disp_dict);\n" % par
-                
-            # Initialize dispersion object dictionnary
-            param_str += "\n"
-            
-                
-            newline = self.replaceToken(newline,
-                                        "[INITDICTIONARY]", param_str)
-            
-            # Read dictionary
-            param_str = "    // Reader parameter dictionary\n"
-            for par in self.params:
-                param_str += "    self->model->%s = PyFloat_AsDouble( PyDict_GetItemString(self->params, \"%s\") );\n" % \
-                    (par, par)
-                    
-            if len(self.disp_params)>0:
-                param_str += "    // Read in dispersion parameters\n"
-                param_str += "    PyObject* disp_dict;\n"
-                param_str += "    DispersionVisitor* visitor = new DispersionVisitor();\n"
-                for par in self.disp_params:
-                    par = par.strip()
-                    if par == '':
-                        continue
-                    param_str += "    disp_dict = PyDict_GetItemString(self->dispersion, \"%s\");\n" % par
-                    param_str += "    self->model->%s.dispersion->accept_as_destination(visitor, self->model->%s.dispersion, disp_dict);\n" % (par, par)
-                
-            newline = self.replaceToken(newline, "[READDICTIONARY]", param_str)
-                
-            # Name of .c file
-            #toks = string.split(self.file,'.')
-            basename = os.path.basename(self.file)
-            toks = basename.split('.')
-            newline = self.replaceToken(newline, "[C_FILENAME]", toks[0])
-            
-            # Include file
-            basename = os.path.basename(self.file)
-            newline = self.replaceToken(newline, 
-                                        "[INCLUDE_FILE]", self.file)  
-            if self.foundCPP:
-                newline = self.replaceToken(newline, 
-                            "[C_INCLUDE_FILE]", "")  
-                newline = self.replaceToken(newline, 
-                            "[CPP_INCLUDE_FILE]", "#include \"%s\"" % basename)  
-            else:  
-                newline = self.replaceToken(newline, 
-                            "[C_INCLUDE_FILE]", "#include \"%s\"" % basename)   
-                newline = self.replaceToken(newline, 
-                            "[CPP_INCLUDE_FILE]", "#include \"models.hh\"")  
-                
-            # Numerical calcs dealloc
-            dealloc_str = "\n"
-            if self.modelCalcFlag:
-                dealloc_str = "    modelcalculations_dealloc(&(self->model_pars.calcPars));\n"
-            newline = self.replaceToken(newline, 
-                                        "[NUMERICAL_DEALLOC]", dealloc_str)     
-                
-            # Numerical calcs init
-            init_str = "\n"
-            if self.modelCalcFlag:
-                init_str = "        modelcalculations_init(&(self->model_pars.calcPars));\n"
-            newline = self.replaceToken(newline, 
-                                        "[NUMERICAL_INIT]", init_str)     
-                
-            # Numerical calcs reset
-            reset_str = "\n"
-            if self.modelCalcFlag:
-                reset_str = "modelcalculations_reset(&(self->model_pars.calcPars));\n"
-            newline = self.replaceToken(newline, 
-                                        "[NUMERICAL_RESET]", reset_str)     
-                
-            # Setting dispsertion weights
-            set_weights = "    // Ugliness necessary to go from python to C\n"
-            set_weights = "    // TODO: refactor this\n"
-            for par in self.disp_params:
-                par = par.strip()
-                if par == '':
-                        continue
-                set_weights += "    if (!strcmp(par_name, \"%s\")) {\n" % par
-                set_weights += "        self->model->%s.dispersion = dispersion;\n" % par
-                set_weights += "    } else"
-            newline = self.replaceToken(newline, 
-                                        "[SET_DISPERSION]", set_weights)     
-            
-            # Write new line to the wrapper .c file
-            file.write(newline+'\n')
-            
-            
-        file.close()
-        
-    def write_python_wrapper(self):
-        """ Writes the python file to create the python extension class 
-            The file is written in ../[PYTHONCLASS].py
-        """
-        file_path = os.path.join(self.output_dir, self.pythonClass+'.py')
-        file = open(file_path, 'w')
-        template = open(os.path.join(os.path.dirname(__file__), 
-                                     "modelTemplate.txt"), 'r')
-        
-        tmp_buf = template.read()
-        tmp_lines = tmp_buf.split('\n')
-        
-        for tmp_line in tmp_lines:
-            
-            # Catch class name
-            newline = self.replaceToken(tmp_line, 
-                                        "[CPYTHONCLASS]", 
-                                        'C' + self.pythonClass)
-            
-            # Catch class name
-            newline = self.replaceToken(newline, 
-                                        "[PYTHONCLASS]", self.pythonClass)
-            
-            # Include file
-            newline = self.replaceToken(newline, 
-                                        "[INCLUDE_FILE]", self.file)    
-                   
-            # Include file
-            newline = self.replaceToken(newline, 
-                                        "[DEFAULT_LIST]", self.default_list)
-            # model description
-            newline = self.replaceToken(newline, 
-                                        "[DESCRIPTION]", self.description)
-            # Parameter details
-            newline = self.replaceToken(newline, 
-                                        "[PAR_DETAILS]", self.details)
-            
-            # Call base constructor
-            if self.is_multifunc:
-                newline = self.replaceToken(newline,"[CALL_CPYTHON_INIT]",
-                    'C' + self.pythonClass + \
-                    ".__init__(self,multfactor)\n\tself.is_multifunc = True")
-                newline = self.replaceToken(newline,"[MULTIPLICITY_INFO]", 
-                                            self.multiplicity_info)
-            else:
-                newline = self.replaceToken(newline,"[CALL_CPYTHON_INIT]",
-                    'C' + self.pythonClass + \
-                    ".__init__(self)\n        self.is_multifunc = False")
-                newline = self.replaceToken(newline, 
-                                            "[MULTIPLICITY_INFO]", "None")
-
-           
-            # fixed list  details
-            fixed_str = str(self.fixed)
-            fixed_str = fixed_str.replace(', ', ',\n                      ')
-            newline = self.replaceToken(newline, "[FIXED]", fixed_str)
-            
-            # non-fittable list details
-            pars_str = str(self.non_fittable)
-            pars_str = pars_str.replace(', ', 
-                                        ',\n                             ')
-            newline = self.replaceToken(newline, 
-                                        "[NON_FITTABLE_PARAMS]", pars_str)
-            
-            ## parameters with orientation
-            oriented_str = str(self.orientation_params)
-            formatted_endl = ',\n                                   '
-            oriented_str = oriented_str.replace(', ', formatted_endl)
-            newline = self.replaceToken(newline, 
-                               "[ORIENTATION_PARAMS]", oriented_str)
-           ## parameters with magnetism
-            newline = self.replaceToken(newline, 
-                               "[MAGNETIC_PARAMS]", str(self.magnetic_params))
-
-            if self.category:
-                newline = self.replaceToken(newline, "[CATEGORY]", 
-                                            '"' + self.category + '"')
-            else:
-                newline = self.replaceToken(newline, "[CATEGORY]",
-                                            "None")
-            
-
-
-            # Write new line to the wrapper .c file
-            file.write(newline+'\n')
-               
-        file.close()
-        
-        
-    def replaceToken(self, line, key, value): #pylint: disable-msg=R0201
-        """ Replace a token in the template file 
-            @param line: line of text to inspect
-            @param key: token to look for
-            @param value: string value to replace the token with
-            @return: new string value
-        """
-        lenkey = len(key)
-        newline = line
-       
-        while newline.count(key)>0:
-            index = newline.index(key)
-            newline = newline[:index]+value+newline[index+lenkey:]
-        
-        return newline
-        
-    def getModelName(self):
-        return self.pythonClass
-        
-
-
-# main
-if __name__ == '__main__':
-    if len(sys.argv)>1:
-        print "Will look for file %s" % sys.argv[1]
-        app = WrapperGenerator(sys.argv[1])
-    else:
-        app = WrapperGenerator("test.h")
-    app.read()
-    app.write_c_wrapper()
-    app.write_python_wrapper()
-    print app
-   
-# End of file        
Index: c/sans/models/src/python_wrapper/classTemplate.txt
===================================================================
--- src/sans/models/src/python_wrapper/classTemplate.txt	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,507 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** [PYTHONCLASS]
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY [INCLUDE_FILE]
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-[C_INCLUDE_FILE]
-}
-
-[CPP_INCLUDE_FILE]
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * [PYTHONCLASS]Error = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    [CMODEL] * model;
-    /// Log for unit testing
-    PyObject * log;
-} [PYTHONCLASS];
-
-
-static void
-[PYTHONCLASS]_dealloc([PYTHONCLASS]* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    [NUMERICAL_DEALLOC]
-}
-
-static PyObject *
-[PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    [PYTHONCLASS] *self;
-    
-    self = ([PYTHONCLASS] *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-[PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-
-	[INITIALIZE_MODEL]
-
-        [INITDICTIONARY]
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        [NUMERICAL_INIT]
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef [PYTHONCLASS]_members[] = {
-    {name_params, T_OBJECT, offsetof([PYTHONCLASS], params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof([PYTHONCLASS], dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof([PYTHONCLASS], log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double [PYTHONCLASS]_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim([CMODEL]* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( [CMODEL]* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString([PYTHONCLASS]Error, 
-                   "[PYTHONCLASS].evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution([PYTHONCLASS] *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	[READDICTIONARY]
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString([PYTHONCLASS]Error, 
-	    	"[PYTHONCLASS].evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString([PYTHONCLASS]Error, 
-                   "[PYTHONCLASS].evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString([PYTHONCLASS]Error, 
-	    		"[PYTHONCLASS].evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString([PYTHONCLASS]Error, 
-                   "[PYTHONCLASS].evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString([PYTHONCLASS]Error, 
-                   "[PYTHONCLASS].evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run([PYTHONCLASS] *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	[READDICTIONARY]
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString([PYTHONCLASS]Error, 
-	    	"[PYTHONCLASS].run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString([PYTHONCLASS]Error, 
-	    		"[PYTHONCLASS].run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = [PYTHONCLASS]_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER([PYTHONCLASS] *self) {
-
-	// Get parameters
-	
-	[READDICTIONARY]
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to cal the ratio shell volume/ total volume
- * @return: the ratio shell volume/ total volume 
- */
-static PyObject * calculate_VR([PYTHONCLASS] *self) {
-
-	// Get parameters
-	
-	[READDICTIONARY]
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_VR());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	[READDICTIONARY]
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString([PYTHONCLASS]Error, 
-	    	"[PYTHONCLASS].run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString([PYTHONCLASS]Error, 
-	    		"[PYTHONCLASS].run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = [PYTHONCLASS]_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset([PYTHONCLASS] *self, PyObject *args) {
-    [NUMERICAL_RESET]
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion([PYTHONCLASS] *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString([PYTHONCLASS]Error,
-	    	"[PYTHONCLASS].set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	[SET_DISPERSION] {
-	    PyErr_SetString([PYTHONCLASS]Error,
-	    	"[PYTHONCLASS].set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef [PYTHONCLASS]_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"calculate_VR",      (PyCFunction)calculate_VR     , METH_VARARGS,
-      "Evaluate VR"},    
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject [PYTHONCLASS]Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "[PYTHONCLASS]",             /*tp_name*/
-    sizeof([PYTHONCLASS]),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "[PYTHONCLASS] objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    [PYTHONCLASS]_methods,             /* tp_methods */
-    [PYTHONCLASS]_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)[PYTHONCLASS]_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    [PYTHONCLASS]_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void add[PYTHONCLASS](PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&[PYTHONCLASS]Type) < 0)
-        return;
-
-    Py_INCREF(&[PYTHONCLASS]Type);
-    PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "[PYTHONCLASS].error";
-    [PYTHONCLASS]Error = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error);
-}
Index: c/sans/models/src/python_wrapper/lineparser.py
===================================================================
--- src/sans/models/src/python_wrapper/lineparser.py	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,215 +1,0 @@
-#!/usr/bin/env python
-""" WrapperGenerator class to generate model code automatically.
-"""
-
-import os, sys,re
-def split_list(separator, mylist, n=0):
-    """
-        @return a list of string without white space of separator
-        @param separator: the string to remove
-    """
-    list=[]
-    for item in mylist:
-        if re.search( separator,item)!=None:
-            if n >0:
-                word =re.split(separator,item,int(n))
-            else:
-                word =re.split( separator,item)
-            for new_item in word: 
-                if new_item.lstrip().rstrip() !='':
-                    list.append(new_item.lstrip().rstrip())
-    return list
-def split_text(separator, string1, n=0):
-    """
-        @return a list of string without white space of separator
-        @param separator: the string to remove
-    """
-    list=[]
-    if re.search( separator,string1)!=None:
-        if n >0:
-            word =re.split(separator,string1,int(n))
-        else:
-            word =re.split(separator,string1)
-        for item in word: 
-            if item.lstrip().rstrip() !='':
-                list.append(item.lstrip().rstrip())
-    return list
-def look_for_tag( string1,begin, end=None ):
-    """
-        @note: this method  remove the begin and end tags given by the user
-        from the string .
-        @param begin: the initial tag
-        @param end: the final tag
-        @param string: the string to check
-        @return: begin_flag==True if begin was found,
-         end_flag==if end was found else return false, false
-         
-    """
-    begin_flag= False
-    end_flag= False
-    if  re.search( begin,string1)!=None:
-        begin_flag= True
-    if end !=None:
-        if  re.search(end,string1)!=None:
-            end_flag= True
-    return begin_flag, end_flag
-
-
-  
-def readhelper(lines, key, key2, key3 , file):
-  
-    temp=""
-    # flag to found key
-    find_fixed= False
-    find_key2=False
-    find_key3=False
-    listtofill=[]
-    for line in lines:
-        if line.count(key.lstrip().rstrip())>0 :#[FIXED]= .....
-            try:
-                find_fixed= True
-                index = line.index(key)
-                toks  = line[index:].split("=",1 )
-                temp  = toks[1].lstrip().rstrip()
-                find_key2, find_key3=look_for_tag( string1=temp,
-                                                   begin=key2, end=key3 )
-                if find_key2 and find_key3:
-                    temp1=[]
-                    temp2=[]
-                    temp3=[]
-                    temp4=[]
-                    temp1=split_text(separator=key2, string1=temp)
-                    temp2=split_list(separator=key3, mylist=temp1)
-                    temp3=split_list(separator=';', mylist=temp2)
-                    temp4=split_list(separator=',', mylist=temp3)
-                    listtofill= temp3 + temp4
-                    return listtofill
-                    
-                    
-                elif find_key2 and not find_key3:
-                    ## [key]= key2(<text>)
-                    ##        ....
-                    ##        key3(<text>)
-                    temp1=[]
-                    temp2=[]
-                    temp3=[]
-                    temp4=[]
-                    ## remove key2= <text>
-                    temp1=split_text(separator=key2, string1=temp)
-                    
-                    ## split ";" first
-                    temp3=split_list(separator=';', mylist=temp1)
-                    temp4=split_list(separator=',', mylist=temp3)
-            
-                    if len(temp3 + temp4)==0:
-                        # [FIXED]=  only one param
-                        listtofill+= temp1
-                    listtofill += temp3+temp4 
-               
-                elif not find_key2 and not find_key3 :
-                    ## [key]= param done looking
-                    temp3=[]
-                    temp4=[]
-                    if look_for_tag( string1=temp,begin=";")[0]:
-                        ## split ";" first
-                        temp3=split_text(separator=';',string1=temp)
-                        temp4=split_list(separator=',', mylist=temp3)
-                    else:
-                        ## slip "," first
-                        temp3=split_text(separator=',',string1=temp)
-                        temp4=split_list(separator=';', mylist=temp3)
-                    if len(temp3+ temp4)==0:
-                        ## [FIXED]=  only one param
-                        if temp.lstrip().rstrip()!="":
-                            listtofill= [temp.lstrip().rstrip()]
-                        
-                    listtofill += temp3+temp4
-                    return listtofill
-            except:
-                raise ValueError, "Could not parse file %s" % file
-        
-        elif find_fixed :
-            if not find_key2:
-                raise ValueError, "Could not parse file %s" % file
-            if find_key3:
-                temp1=[]
-                temp2=[]
-                temp3=[]
-                temp4=[]
-                temp5=[]
-               
-                temp1=split_text(separator=key3, string1=line)
-                temp2=split_list(separator='//',mylist=temp1)
-                temp5=split_list(separator="\*",mylist=temp1)
-                
-                if len(temp5)>0:
-                    temp3=split_list(separator=';',mylist=temp5)
-                    temp4=split_list(separator=',', mylist=temp5)
-                elif len(temp2)>0:
-                    temp3=split_list(separator=';',mylist=temp2)
-                    temp4=split_list(separator=',', mylist=temp2)
-                else:
-                    temp3=split_list(separator=';',mylist=temp1)
-                    temp4=split_list(separator=',', mylist=temp1)
-                
-                if len(temp3 + temp4)==0:# [FIXED]=  only one param
-                    listtofill += temp1
-                listtofill+=temp3+temp4 #   
-                break
-            
-            else:
-                temp2=split_text(separator='//', string1=line)
-                temp5=split_text(separator="\*", string1=line)
-                if len(temp5)>0:
-                    temp3=split_list(separator=';', mylist=temp5)
-                    temp4=split_list(separator=',', mylist=temp5)
-                elif len(temp2)>0:
-                    temp3=split_list(separator=';', mylist=temp2)
-                    temp4=split_list(separator=',', mylist=temp2)
-                else:
-                    if look_for_tag( string1=line,begin=";")[0]:# split ";" first
-                        temp3=split_text(separator=';', string1=line)
-                        temp4=split_list(separator=',', mylist=temp3)
-                    else:
-                        temp3=split_text(separator=',', string1=line)# slip "," first
-                        temp4=split_list(separator=';', mylist=temp3)
-                if len(temp3+ temp4)==0:# [FIXED]=  only one param
-                    if line.lstrip().rstrip()!="":
-                        listtofill=[line.lstrip().rstrip()]
-                listtofill+=temp3+temp4 #
-                break
-    return listtofill
-   
-# main
-if __name__ == '__main__':
-    
-    # Read file
-    name= "sphere.h"
-    f = open("..\include\core_shell.h",'r')
-    buf = f.read()
-  
-    lines = buf.split('\n')
-  
-    ## Catch Fixed parameters
-    key = "[FIXED]"
-    #open item in this case Fixed
-    text='text'
-    key2="<%s>"%text.lower()
-    # close an item in this case fixed
-    text='TexT'
-    key3="</%s>"%text.lower()
-    listto=[]
-   
-    listto= readhelper(lines, key, key2,key3, file=name)
-    print "fixed parameters\n ",listto
-    print 
-    
-   
-    key0="[ORIENTATION_PARAMS]"
-   
-    listto=[]
-    listto= readhelper(lines,key0, key2,key3, file=name)
-    print "orientation parameters\n ",listto
-    print 
-    f.close()
-# End of file        
Index: c/sans/models/src/python_wrapper/modelTemplate.txt
===================================================================
--- src/sans/models/src/python_wrapper/modelTemplate.txt	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,159 +1,0 @@
-##############################################################################
-# This software was developed by the University of Tennessee as part of the
-# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-# project funded by the US National Science Foundation.
-#
-# If you use DANSE applications to do scientific research that leads to
-# publication, we ask that you acknowledge the use of the software with the
-# following sentence:
-#
-# This work benefited from DANSE software developed under NSF award DMR-0520547
-#
-# Copyright 2008-2011, University of Tennessee
-##############################################################################
-
-""" 
-Provide functionality for a C extension model
-
-:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
-         DO NOT MODIFY THIS FILE, MODIFY
-            [INCLUDE_FILE]
-         AND RE-RUN THE GENERATOR SCRIPT
-"""
-
-from sans.models.BaseComponent import BaseComponent
-from sans.models.sans_extension.c_models import [CPYTHONCLASS]
-
-def create_[PYTHONCLASS]():
-    """
-       Create a model instance
-    """
-    obj = [PYTHONCLASS]()
-    # [CPYTHONCLASS].__init__(obj) is called by
-    # the [PYTHONCLASS] constructor
-    return obj
-
-class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent):
-    """ 
-    Class that evaluates a [PYTHONCLASS] model. 
-    This file was auto-generated from [INCLUDE_FILE].
-    Refer to that file and the structure it contains
-    for details of the model.
-    [DEFAULT_LIST]
-    """
-        
-    def __init__(self, multfactor=1):
-        """ Initialization """
-        self.__dict__ = {}
-        
-        # Initialize BaseComponent first, then sphere
-        BaseComponent.__init__(self)
-        #apply([CPYTHONCLASS].__init__, (self,)) 
-
-        [CALL_CPYTHON_INIT]
-		        
-        ## Name of the model
-        self.name = "[PYTHONCLASS]"
-        ## Model description
-        self.description = """
-        [DESCRIPTION]
-        """
-       
-        [PAR_DETAILS]
-        ## fittable parameters
-        self.fixed = [FIXED]
-        
-        ## non-fittable parameters
-        self.non_fittable = [NON_FITTABLE_PARAMS]
-        
-        ## parameters with orientation
-        self.orientation_params = [ORIENTATION_PARAMS]
-
-        ## parameters with magnetism
-        self.magnetic_params = [MAGNETIC_PARAMS]
-
-        self.category = [CATEGORY]
-        self.multiplicity_info = [MULTIPLICITY_INFO]
-        
-    def __setstate__(self, state):
-        """
-        restore the state of a model from pickle
-        """
-        self.__dict__, self.params, self.dispersion = state
-        
-    def __reduce_ex__(self, proto):
-        """
-        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of 
-        c model.
-        """
-        state = (self.__dict__, self.params, self.dispersion)
-        return (create_[PYTHONCLASS], tuple(), state, None, None)
-        
-    def clone(self):
-        """ Return a identical copy of self """
-        return self._clone([PYTHONCLASS]())   
-       	
-    def run(self, x=0.0):
-        """ 
-        Evaluate the model
-        
-        :param x: input q, or [q,phi]
-        
-        :return: scattering function P(q)
-        
-        """
-        return [CPYTHONCLASS].run(self, x)
-   
-    def runXY(self, x=0.0):
-        """ 
-        Evaluate the model in cartesian coordinates
-        
-        :param x: input q, or [qx, qy]
-        
-        :return: scattering function P(q)
-        
-        """
-        return [CPYTHONCLASS].runXY(self, x)
-        
-    def evalDistribution(self, x):
-        """ 
-        Evaluate the model in cartesian coordinates
-        
-        :param x: input q[], or [qx[], qy[]]
-        
-        :return: scattering function P(q[])
-        
-        """
-        return [CPYTHONCLASS].evalDistribution(self, x)
-        
-    def calculate_ER(self):
-        """ 
-        Calculate the effective radius for P(q)*S(q)
-        
-        :return: the value of the effective radius
-        
-        """       
-        return [CPYTHONCLASS].calculate_ER(self)
-        
-    def calculate_VR(self):
-        """ 
-        Calculate the volf ratio for P(q)*S(q)
-        
-        :return: the value of the volf ratio
-        
-        """       
-        return [CPYTHONCLASS].calculate_VR(self)
-              
-    def set_dispersion(self, parameter, dispersion):
-        """
-        Set the dispersion object for a model parameter
-        
-        :param parameter: name of the parameter [string]
-        :param dispersion: dispersion object of type DispersionModel
-        
-        """
-        return [CPYTHONCLASS].set_dispersion(self,
-               parameter, dispersion.cdisp)
-        
-   
-# End of file
Index: c/sans/models/src/python_wrapper/wrapping.py
===================================================================
--- src/sans/models/src/python_wrapper/wrapping.py	(revision 3d244899f2298f4e741b8e2c0d6c07c6eba8e4ea)
+++ 	(revision )
@@ -1,69 +1,0 @@
-import sys
-import os
-import os.path
-from WrapperGenerator import WrapperGenerator
-
-def generate_wrappers(header_dir, output_dir='.', c_wrapper_dir='.'):
-    nModels=0
-    model_list = list()
-
-    for item in os.listdir(header_dir):
-        toks = os.path.splitext(os.path.basename(item))
-        if toks[1]=='.h':
-            nModels += 1
-            name = toks[0]
-            app = WrapperGenerator(os.path.join(header_dir, name+".h"), 
-                                   output_dir=output_dir,
-                                   c_wrapper_dir=c_wrapper_dir)
-            app.read()
-            app.write_c_wrapper()
-            app.write_python_wrapper()
-            model_list.append(app.getModelName())
-    write_c_models(model_list)
-    print "Total number of model  wrappers created is %s" % nModels
-
-def write_c_models(model_list):
-    # simultaneously generates 'sansmodels/installed_models.txt'
-    # and 'sansmodels/src/c_models/c_models.cpp'
-    
-
-    template_file = open(os.path.join("src", "sans", "models","src","c_models","c_models.cpp.template"),"r")
-    write_file = open(os.path.join("src", "sans",  "models","src","c_models","c_models.cpp"),"w")
-    buf = template_file.read()
-    lines = buf.split('\n')
-    
-    tag1 = "[TAG_1]"
-    tag2 = "[TAG_2]"
-    
-    for line in lines:
-        
-        if line.count(tag1) > 0:
-            write_file.write("\n // adding generated code \n")
-            for pyclass in model_list:
-                write_file.write("void addC" + pyclass
-                                 + "(PyObject *module); \n")
-            write_file.write(" // end generated code \n")
-                
-
-        elif line.count(tag2) > 0:
-            write_file.write("\n // adding generated code \n")
-
-            for pyclass in model_list:
-                write_file.write("addC" + pyclass + "(m); \n")
-
-            write_file.write("addDisperser(m); \n")
-            write_file.write("\n // end generated code \n")
-                
-                
-        else:
-            write_file.write(line + "\n")
-
-
-
-if __name__ == '__main__':
-    header_dir = os.path.join('..', 'include')
-    generate_wrappers(header_dir, output_dir="../sans/models/", c_wrapper_dir='.')
-
-
-
-
Index: c/sans/models/src/release_notes.txt
===================================================================
--- src/sans/models/src/release_notes.txt	(revision b8a8e4e983fdaf932bc8c355fc18731031e85366)
+++ 	(revision )
@@ -1,105 +1,0 @@
-Release Notes
-=============
-
-SANS Models version 0.4.3
-
-Package name: sans.models 
-
-1- What's New in Version 0.4.3
-    - Release date: April 21, 2009
-    - C extension models now use new C++ classes that incorporate dispersity and averaging
-      functionality. See utest_dispersity.py for examples of how to use the new dispersion
-      classes.
-      
-      # Create a model
-      model= CylinderModel()
-      
-      # Create a dispersion model
-      disp = GaussianDispersion()
-      
-	  # Set the dispersion for a chosen parameter
-	  model.set_dispersion('radius', disp)
-	  
-	  # Set the parameters of the dispersion model
-      model.dispersion['radius']['width'] = 5.0
-      model.dispersion['radius']['npts'] = 100
-
-
-    Version 0.4.3
-    -P(Q)*S(Q) added for P(Q)=cylinder, sphere, ellipsoid
-    -Array dispersion (user defined) added
-
-    Version 0.4.2
-    -4 Structure factors added
-    
-    Version 0.4.1
-    - Release date: 6/9/2008
-    - Modified non-shape models so that the 2D output is the 1D output for the length of Q
-
-    Version 0.4.0
-	- Release date: 4/15/2008
-	- Added shape-independent models.
-	
-	Version 0.3.2:
-	- Release date: 2/14/2008
-	- Added models to be used in magnetic analysis.
-
-
-2- Downloading and Installing
-
-	2.1- System Requirements:
-		- Python version >= 2.5 and < 3.0 should be running on the system
-
-
-	2.2- Installing:
-		- Get the code from svn://danse.us/sans/releases/sansmodels-0.4.3
-		- Execute the following: 
-			python setup.py install
-
-3- Known Issues
-
-	3.1- All systems:
-		- Q range validity of I(q) calculations.
-			Our 1D models of I(q) use the function of the NCNR library 
-			for their IGOR package (Klein, 2006). That library uses a
-			fast integration technique in some of its models (cylinders
-			and ellipsoids). Integration is done using 76 points in the
-			angle between the axis of the object and the q-vector, which
-			translates in a larger inaccuracy at high q. Integratiing
-			the 2D model I(q,phi) over all orientations of the object
-			will not yield the exact same result as the NCNR calculation
-			for q > 0.3 A-1.
-		- Refactoring needs to be done to update the model base class.
-		  We should get rid of the useless arithmetics and store the parameters
-		  as class objects rather than values. This would eliminate the multitude
-		  of dictionaries needed to store all the various aspects of a parameter
-		  (limits, units, dispersity information). The C++ design it relies
-		  on is much cleaner in that respect, but it still depends on the old
-		  C computation. Those should be incorporated in the C++ classes.
-
-	3.2- Windows:
-		- None
-
-	3.3- Linux:
-		- None
-
-4- Troubleshooting
-
-	- None
-
-5- Frequently Asked Questions
-
-	- None
-
-6- Other Resources
-
-	- See: http://danse.us/trac/sans/wiki/8_2_2_1DModelFitting
-	- See: http://danse.us/trac/sans/wiki/8_2_3_2DModeling
-	- See: http://danse.us/trac/sans/wiki/8_2_6_model_extensions
-	- See: http://danse.us/trac/sans/wiki/8_2_1Nonshape_models
-
-	
-
-	
-
-
