Changeset 3080527 in sasview for sansmodels/src/sans/models/c_models/CLamellarPSModel.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/CLamellarPSModel.cpp
r71e2de7 r3080527 183 183 { 184 184 PyArrayObject *result; 185 int i,j, x_len, y_len, dims[ 2];185 int i,j, x_len, y_len, dims[1]; 186 186 //check validity of input vectors 187 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE188 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE189 || y->dimensions[ 1] != x->dimensions[0]){187 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 188 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 189 || y->dimensions[0] != x->dimensions[0]){ 190 190 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 191 191 PyErr_SetString(PyExc_ValueError , message); … … 195 195 if (PyArray_Check(x) && PyArray_Check(y)) { 196 196 197 x_len = dims[ 1]= x->dimensions[1];197 x_len = dims[0]= x->dimensions[0]; 198 198 y_len = dims[0]= y->dimensions[0]; 199 199 200 200 // Make a new double matrix of same dims 201 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);201 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 202 202 if (result == NULL){ 203 203 const char * message= "Could not create result "; … … 207 207 208 208 /* Do the calculation. */ 209 for ( j=0; j< y_len; j++) { 210 for ( i=0; i< x_len; i++) { 211 double x_value = *(double *)(x->data + i*x->strides[1]); 212 double y_value = *(double *)(y->data + j*y->strides[0]); 213 double *result_value = (double *)(result->data + 214 j*result->strides[0] + i*result->strides[1]); 215 *result_value = (*model)(x_value, y_value); 216 } 217 } 209 for ( i=0; i< x_len; i++) { 210 double x_value = *(double *)(x->data + i*x->strides[0]); 211 double y_value = *(double *)(y->data + i*y->strides[0]); 212 double *result_value = (double *)(result->data + 213 i*result->strides[0]); 214 *result_value = (*model)(x_value, y_value); 215 } 218 216 return PyArray_Return(result); 219 217
Note: See TracChangeset
for help on using the changeset viewer.