Index: sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp	(revision 50686972861f70ebff2c64a50118cfb6b905253a)
+++ sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
@@ -22,7 +22,10 @@
  *
  */
+#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>
@@ -137,5 +140,196 @@
     }
 }
-
+/**
+ * Function to call to evaluate model
+ * @param args: input numpy array q[] 
+ * @return: numpy array object 
+ */
+ 
+static PyObject *evaluateOneDim(TriaxialEllipsoidModel* 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;
+	}
+	 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  [q[],phi[]]
+ * @return: numpy array object 
+ */
+static PyObject * evaluateTwoDim( TriaxialEllipsoidModel* model, 
+                              PyArrayObject *q, PyArrayObject *phi)
+ {
+    PyArrayObject *result;
+    //check validity of input vectors
+    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
+        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
+        || phi->dimensions[0] != q->dimensions[0]){
+     
+        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
+        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
+        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;
+	}
+	
+    for (int i = 0; i < q->dimensions[0]; i++) {
+      double q_value = *(double *)(q->data + i*q->strides[0]);
+      double phi_value = *(double *)(phi->data + i*phi->strides[0]);
+      double *result_value = (double *)(result->data + i*result->strides[0]);
+      if (q_value == 0)
+          *result_value = 0.0;
+      else
+          *result_value = model->evaluate_rphi(q_value, phi_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( TriaxialEllipsoidModel* model, 
+                              PyArrayObject *x, PyArrayObject *y)
+ {
+    PyArrayObject *result;
+    int i,j, x_len, y_len, dims[2];
+    //check validity of input vectors
+    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
+        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
+        || y->dimensions[1] != 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[1]= y->dimensions[1];
+	    
+	    // Make a new double matrix of same dims
+        result=(PyArrayObject *) PyArray_FromDims(2,dims,NPY_DOUBLE);
+        if (result == NULL){
+	    const char * message= "Could not create result ";
+        PyErr_SetString(PyExc_RuntimeError , message);
+	    return NULL;
+	    }
+       
+        /* Do the calculation. */
+        for ( i=0; i< x_len; i++) {
+            for ( j=0; j< y_len; j++) {
+                double x_value = *(double *)(x->data + i*x->strides[0]);
+      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+      			double *result_value = (double *)(result->data +
+      			      i*result->strides[0] + j*result->strides[1]);
+      			*result_value = (*model)(x_value, y_value);
+            }           
+        }
+        return PyArray_Return(result); 
+        
+        }else{
+		    PyErr_SetString(CTriaxialEllipsoidModelError, 
+                   "CTriaxialEllipsoidModel.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(CTriaxialEllipsoidModel *self, PyObject *args){
+	PyObject *qx, *qy;
+	PyArrayObject * pars;
+	int npars ,mpars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
+    self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") );
+    self->model->semi_axisB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisB") );
+    self->model->semi_axisC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisC") );
+    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
+    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
+    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CTriaxialEllipsoidModelError, 
+	    	"CTriaxialEllipsoidModel.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(CTriaxialEllipsoidModelError, 
+                   "CTriaxialEllipsoidModel.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(CTriaxialEllipsoidModelError, 
+	    		"CTriaxialEllipsoidModel.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(CTriaxialEllipsoidModelError, 
+                   "CTriaxialEllipsoidModel.evalDistribution expect 2 numpy arrays in list.");
+	        return NULL;
+	     }
+	}else{
+	    PyErr_SetString(CTriaxialEllipsoidModelError, 
+                   "CTriaxialEllipsoidModel.evalDistribution couln't be run.");
+	    return NULL;
+	}
+}
 
 /**
@@ -311,4 +505,7 @@
     {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
       "Evaluate the model at a given Q or Qx, Qy"},
+      
+    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy vector "},
     {"reset",    (PyCFunction)reset   , METH_VARARGS,
       "Reset pair correlation"},
@@ -361,7 +558,7 @@
 
 
-static PyMethodDef module_methods[] = {
-    {NULL} 
-};
+//static PyMethodDef module_methods[] = {
+//    {NULL} 
+//};
 
 /**
