Changeset 3080527 in sasview for sansmodels/src/sans/models/c_models/CEllipticalCylinderModel.cpp
- Timestamp:
- Mar 12, 2010 1:08:42 PM (14 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- e575db9
- Parents:
- 7e99f5c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CEllipticalCylinderModel.cpp
r71e2de7 r3080527 197 197 { 198 198 PyArrayObject *result; 199 int i,j, x_len, y_len, dims[ 2];199 int i,j, x_len, y_len, dims[1]; 200 200 //check validity of input vectors 201 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE202 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE203 || y->dimensions[ 1] != x->dimensions[0]){201 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 202 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 203 || y->dimensions[0] != x->dimensions[0]){ 204 204 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 205 205 PyErr_SetString(PyExc_ValueError , message); … … 209 209 if (PyArray_Check(x) && PyArray_Check(y)) { 210 210 211 x_len = dims[ 1]= x->dimensions[1];211 x_len = dims[0]= x->dimensions[0]; 212 212 y_len = dims[0]= y->dimensions[0]; 213 213 214 214 // Make a new double matrix of same dims 215 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);215 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 216 216 if (result == NULL){ 217 217 const char * message= "Could not create result "; … … 221 221 222 222 /* Do the calculation. */ 223 for ( j=0; j< y_len; j++) { 224 for ( i=0; i< x_len; i++) { 225 double x_value = *(double *)(x->data + i*x->strides[1]); 226 double y_value = *(double *)(y->data + j*y->strides[0]); 227 double *result_value = (double *)(result->data + 228 j*result->strides[0] + i*result->strides[1]); 229 *result_value = (*model)(x_value, y_value); 230 } 231 } 223 for ( i=0; i< x_len; i++) { 224 double x_value = *(double *)(x->data + i*x->strides[0]); 225 double y_value = *(double *)(y->data + i*y->strides[0]); 226 double *result_value = (double *)(result->data + 227 i*result->strides[0]); 228 *result_value = (*model)(x_value, y_value); 229 } 232 230 return PyArray_Return(result); 233 231
Note: See TracChangeset
for help on using the changeset viewer.