Changeset 3080527 in sasview for sansmodels
- Timestamp:
- Mar 12, 2010 1:08:42 PM (15 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
- Location:
- sansmodels/src/sans/models
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/BaseComponent.py
rf9bf661 r3080527 68 68 69 69 70 * For 2D, a list of numpy arrays are expected: [qx_prime,qy_prime]. 71 72 For the following matrix of q_values [qx,qy], we will have: 73 +--------+--------+--------+ 74 qy[2] | | | | 75 +--------+--------+--------+ 76 qy[1] | | | | 77 +--------+--------+--------+ 78 qy[0] | | | | 79 +--------+--------+--------+ 80 qx[0] qx[1] qx[2] 81 82 83 The q-values must be stored in numpy arrays. 84 The qxprime and qyprime are 2D arrays. From the two lists of q-values 85 above, numpy arrays must be created the following way: 86 87 qx_prime = numpy.reshape(qx, [1,3]) 88 qy_prime = numpy.reshape(qy, [3,1]) 70 * For 2D, a list of numpy arrays are expected: [qx_prime,qy_prime], 71 where 1D arrays, 72 73 qx_prime = [ qx[0], qx[1], qx[2], ....] 74 and 75 qy_prime = [ qy[0], qy[1], qy[2], ....] 89 76 90 77 The method is then called the following way: … … 92 79 evalDistribution([qx_prime, qy_prime]) 93 80 94 @param qdist: ndarray of scalar q-values or list [qx,qy] where qx,qy are 2D ndarrays81 @param qdist: ndarray of scalar q-values or list [qx,qy] where qx,qy are 1D ndarrays 95 82 """ 96 83 if qdist.__class__.__name__ == 'list': … … 106 93 107 94 # Create output array 108 iq_array = numpy.zeros([qx.shape[1], qy.shape[0]]) 109 110 for j in range(qy.shape[0]): 111 for i in range(qx.shape[1]): 112 iq_array[j][i] = self.runXY([qx[0][i],qy[j][0]]) 95 iq_array = numpy.zeros((len(qx))) 96 97 for i in range(len(qx)): 98 iq_array[i] = self.runXY([qx[i],qy[i]]) 113 99 return iq_array 114 100 -
sansmodels/src/sans/models/c_models/CBinaryHSModel.cpp
r4cbaf35 r3080527 184 184 { 185 185 PyArrayObject *result; 186 int i,j, x_len, y_len, dims[ 2];186 int i,j, x_len, y_len, dims[1]; 187 187 //check validity of input vectors 188 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE189 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE190 || y->dimensions[ 1] != x->dimensions[0]){188 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 189 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 190 || y->dimensions[0] != x->dimensions[0]){ 191 191 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 192 192 PyErr_SetString(PyExc_ValueError , message); … … 196 196 if (PyArray_Check(x) && PyArray_Check(y)) { 197 197 198 x_len = dims[ 1]= x->dimensions[1];198 x_len = dims[0]= x->dimensions[0]; 199 199 y_len = dims[0]= y->dimensions[0]; 200 200 201 201 // Make a new double matrix of same dims 202 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);202 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 203 203 if (result == NULL){ 204 204 const char * message= "Could not create result "; … … 208 208 209 209 /* Do the calculation. */ 210 for ( j=0; j< y_len; j++) { 211 for ( i=0; i< x_len; i++) { 212 double x_value = *(double *)(x->data + i*x->strides[1]); 213 double y_value = *(double *)(y->data + j*y->strides[0]); 214 double *result_value = (double *)(result->data + 215 j*result->strides[0] + i*result->strides[1]); 216 *result_value = (*model)(x_value, y_value); 217 } 218 } 210 for ( i=0; i< x_len; i++) { 211 double x_value = *(double *)(x->data + i*x->strides[0]); 212 double y_value = *(double *)(y->data + i*y->strides[0]); 213 double *result_value = (double *)(result->data + 214 i*result->strides[0]); 215 *result_value = (*model)(x_value, y_value); 216 } 219 217 return PyArray_Return(result); 220 218 -
sansmodels/src/sans/models/c_models/CBinaryHSPSF11Model.cpp
r71e2de7 r3080527 184 184 { 185 185 PyArrayObject *result; 186 int i,j, x_len, y_len, dims[ 2];186 int i,j, x_len, y_len, dims[1]; 187 187 //check validity of input vectors 188 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE189 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE190 || y->dimensions[ 1] != x->dimensions[0]){188 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 189 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 190 || y->dimensions[0] != x->dimensions[0]){ 191 191 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 192 192 PyErr_SetString(PyExc_ValueError , message); … … 196 196 if (PyArray_Check(x) && PyArray_Check(y)) { 197 197 198 x_len = dims[ 1]= x->dimensions[1];198 x_len = dims[0]= x->dimensions[0]; 199 199 y_len = dims[0]= y->dimensions[0]; 200 200 201 201 // Make a new double matrix of same dims 202 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);202 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 203 203 if (result == NULL){ 204 204 const char * message= "Could not create result "; … … 208 208 209 209 /* Do the calculation. */ 210 for ( j=0; j< y_len; j++) { 211 for ( i=0; i< x_len; i++) { 212 double x_value = *(double *)(x->data + i*x->strides[1]); 213 double y_value = *(double *)(y->data + j*y->strides[0]); 214 double *result_value = (double *)(result->data + 215 j*result->strides[0] + i*result->strides[1]); 216 *result_value = (*model)(x_value, y_value); 217 } 218 } 210 for ( i=0; i< x_len; i++) { 211 double x_value = *(double *)(x->data + i*x->strides[0]); 212 double y_value = *(double *)(y->data + i*y->strides[0]); 213 double *result_value = (double *)(result->data + 214 i*result->strides[0]); 215 *result_value = (*model)(x_value, y_value); 216 } 219 217 return PyArray_Return(result); 220 218 -
sansmodels/src/sans/models/c_models/CCoreShellCylinderModel.cpp
r71e2de7 r3080527 195 195 { 196 196 PyArrayObject *result; 197 int i,j, x_len, y_len, dims[ 2];197 int i,j, x_len, y_len, dims[1]; 198 198 //check validity of input vectors 199 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE200 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE201 || y->dimensions[ 1] != x->dimensions[0]){199 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 200 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 201 || y->dimensions[0] != x->dimensions[0]){ 202 202 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 203 203 PyErr_SetString(PyExc_ValueError , message); … … 207 207 if (PyArray_Check(x) && PyArray_Check(y)) { 208 208 209 x_len = dims[ 1]= x->dimensions[1];209 x_len = dims[0]= x->dimensions[0]; 210 210 y_len = dims[0]= y->dimensions[0]; 211 211 212 212 // Make a new double matrix of same dims 213 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);213 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 214 214 if (result == NULL){ 215 215 const char * message= "Could not create result "; … … 219 219 220 220 /* Do the calculation. */ 221 for ( j=0; j< y_len; j++) { 222 for ( i=0; i< x_len; i++) { 223 double x_value = *(double *)(x->data + i*x->strides[1]); 224 double y_value = *(double *)(y->data + j*y->strides[0]); 225 double *result_value = (double *)(result->data + 226 j*result->strides[0] + i*result->strides[1]); 227 *result_value = (*model)(x_value, y_value); 228 } 229 } 221 for ( i=0; i< x_len; i++) { 222 double x_value = *(double *)(x->data + i*x->strides[0]); 223 double y_value = *(double *)(y->data + i*y->strides[0]); 224 double *result_value = (double *)(result->data + 225 i*result->strides[0]); 226 *result_value = (*model)(x_value, y_value); 227 } 230 228 return PyArray_Return(result); 231 229 -
sansmodels/src/sans/models/c_models/CCoreShellEllipsoidModel.cpp
r71e2de7 r3080527 198 198 { 199 199 PyArrayObject *result; 200 int i,j, x_len, y_len, dims[ 2];200 int i,j, x_len, y_len, dims[1]; 201 201 //check validity of input vectors 202 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE203 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE204 || y->dimensions[ 1] != x->dimensions[0]){202 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 203 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 204 || y->dimensions[0] != x->dimensions[0]){ 205 205 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 206 206 PyErr_SetString(PyExc_ValueError , message); … … 210 210 if (PyArray_Check(x) && PyArray_Check(y)) { 211 211 212 x_len = dims[ 1]= x->dimensions[1];212 x_len = dims[0]= x->dimensions[0]; 213 213 y_len = dims[0]= y->dimensions[0]; 214 214 215 215 // Make a new double matrix of same dims 216 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);216 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 217 217 if (result == NULL){ 218 218 const char * message= "Could not create result "; … … 222 222 223 223 /* Do the calculation. */ 224 for ( j=0; j< y_len; j++) { 225 for ( i=0; i< x_len; i++) { 226 double x_value = *(double *)(x->data + i*x->strides[1]); 227 double y_value = *(double *)(y->data + j*y->strides[0]); 228 double *result_value = (double *)(result->data + 229 j*result->strides[0] + i*result->strides[1]); 230 *result_value = (*model)(x_value, y_value); 231 } 232 } 224 for ( i=0; i< x_len; i++) { 225 double x_value = *(double *)(x->data + i*x->strides[0]); 226 double y_value = *(double *)(y->data + i*y->strides[0]); 227 double *result_value = (double *)(result->data + 228 i*result->strides[0]); 229 *result_value = (*model)(x_value, y_value); 230 } 233 231 return PyArray_Return(result); 234 232 -
sansmodels/src/sans/models/c_models/CCoreShellModel.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 -
sansmodels/src/sans/models/c_models/CCylinderModel.cpp
r71e2de7 r3080527 189 189 { 190 190 PyArrayObject *result; 191 int i,j, x_len, y_len, dims[ 2];191 int i,j, x_len, y_len, dims[1]; 192 192 //check validity of input vectors 193 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE194 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE195 || y->dimensions[ 1] != x->dimensions[0]){193 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 194 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 195 || y->dimensions[0] != x->dimensions[0]){ 196 196 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 197 197 PyErr_SetString(PyExc_ValueError , message); … … 201 201 if (PyArray_Check(x) && PyArray_Check(y)) { 202 202 203 x_len = dims[ 1]= x->dimensions[1];203 x_len = dims[0]= x->dimensions[0]; 204 204 y_len = dims[0]= y->dimensions[0]; 205 205 206 206 // Make a new double matrix of same dims 207 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);207 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 208 208 if (result == NULL){ 209 209 const char * message= "Could not create result "; … … 213 213 214 214 /* Do the calculation. */ 215 for ( j=0; j< y_len; j++) { 216 for ( i=0; i< x_len; i++) { 217 double x_value = *(double *)(x->data + i*x->strides[1]); 218 double y_value = *(double *)(y->data + j*y->strides[0]); 219 double *result_value = (double *)(result->data + 220 j*result->strides[0] + i*result->strides[1]); 221 *result_value = (*model)(x_value, y_value); 222 } 223 } 215 for ( i=0; i< x_len; i++) { 216 double x_value = *(double *)(x->data + i*x->strides[0]); 217 double y_value = *(double *)(y->data + i*y->strides[0]); 218 double *result_value = (double *)(result->data + 219 i*result->strides[0]); 220 *result_value = (*model)(x_value, y_value); 221 } 224 222 return PyArray_Return(result); 225 223 -
sansmodels/src/sans/models/c_models/CDiamCylFunc.cpp
r71e2de7 r3080527 178 178 { 179 179 PyArrayObject *result; 180 int i,j, x_len, y_len, dims[ 2];180 int i,j, x_len, y_len, dims[1]; 181 181 //check validity of input vectors 182 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE183 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE184 || y->dimensions[ 1] != x->dimensions[0]){182 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 183 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 184 || y->dimensions[0] != x->dimensions[0]){ 185 185 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 186 186 PyErr_SetString(PyExc_ValueError , message); … … 190 190 if (PyArray_Check(x) && PyArray_Check(y)) { 191 191 192 x_len = dims[ 1]= x->dimensions[1];192 x_len = dims[0]= x->dimensions[0]; 193 193 y_len = dims[0]= y->dimensions[0]; 194 194 195 195 // Make a new double matrix of same dims 196 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);196 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 197 197 if (result == NULL){ 198 198 const char * message= "Could not create result "; … … 202 202 203 203 /* Do the calculation. */ 204 for ( j=0; j< y_len; j++) { 205 for ( i=0; i< x_len; i++) { 206 double x_value = *(double *)(x->data + i*x->strides[1]); 207 double y_value = *(double *)(y->data + j*y->strides[0]); 208 double *result_value = (double *)(result->data + 209 j*result->strides[0] + i*result->strides[1]); 210 *result_value = (*model)(x_value, y_value); 211 } 212 } 204 for ( i=0; i< x_len; i++) { 205 double x_value = *(double *)(x->data + i*x->strides[0]); 206 double y_value = *(double *)(y->data + i*y->strides[0]); 207 double *result_value = (double *)(result->data + 208 i*result->strides[0]); 209 *result_value = (*model)(x_value, y_value); 210 } 213 211 return PyArray_Return(result); 214 212 -
sansmodels/src/sans/models/c_models/CDiamEllipFunc.cpp
r71e2de7 r3080527 178 178 { 179 179 PyArrayObject *result; 180 int i,j, x_len, y_len, dims[ 2];180 int i,j, x_len, y_len, dims[1]; 181 181 //check validity of input vectors 182 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE183 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE184 || y->dimensions[ 1] != x->dimensions[0]){182 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 183 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 184 || y->dimensions[0] != x->dimensions[0]){ 185 185 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 186 186 PyErr_SetString(PyExc_ValueError , message); … … 190 190 if (PyArray_Check(x) && PyArray_Check(y)) { 191 191 192 x_len = dims[ 1]= x->dimensions[1];192 x_len = dims[0]= x->dimensions[0]; 193 193 y_len = dims[0]= y->dimensions[0]; 194 194 195 195 // Make a new double matrix of same dims 196 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);196 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 197 197 if (result == NULL){ 198 198 const char * message= "Could not create result "; … … 202 202 203 203 /* Do the calculation. */ 204 for ( j=0; j< y_len; j++) { 205 for ( i=0; i< x_len; i++) { 206 double x_value = *(double *)(x->data + i*x->strides[1]); 207 double y_value = *(double *)(y->data + j*y->strides[0]); 208 double *result_value = (double *)(result->data + 209 j*result->strides[0] + i*result->strides[1]); 210 *result_value = (*model)(x_value, y_value); 211 } 212 } 204 for ( i=0; i< x_len; i++) { 205 double x_value = *(double *)(x->data + i*x->strides[0]); 206 double y_value = *(double *)(y->data + i*y->strides[0]); 207 double *result_value = (double *)(result->data + 208 i*result->strides[0]); 209 *result_value = (*model)(x_value, y_value); 210 } 213 211 return PyArray_Return(result); 214 212 -
sansmodels/src/sans/models/c_models/CEllipsoidModel.cpp
r71e2de7 r3080527 189 189 { 190 190 PyArrayObject *result; 191 int i,j, x_len, y_len, dims[ 2];191 int i,j, x_len, y_len, dims[1]; 192 192 //check validity of input vectors 193 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE194 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE195 || y->dimensions[ 1] != x->dimensions[0]){193 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 194 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 195 || y->dimensions[0] != x->dimensions[0]){ 196 196 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 197 197 PyErr_SetString(PyExc_ValueError , message); … … 201 201 if (PyArray_Check(x) && PyArray_Check(y)) { 202 202 203 x_len = dims[ 1]= x->dimensions[1];203 x_len = dims[0]= x->dimensions[0]; 204 204 y_len = dims[0]= y->dimensions[0]; 205 205 206 206 // Make a new double matrix of same dims 207 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);207 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 208 208 if (result == NULL){ 209 209 const char * message= "Could not create result "; … … 213 213 214 214 /* Do the calculation. */ 215 for ( j=0; j< y_len; j++) { 216 for ( i=0; i< x_len; i++) { 217 double x_value = *(double *)(x->data + i*x->strides[1]); 218 double y_value = *(double *)(y->data + j*y->strides[0]); 219 double *result_value = (double *)(result->data + 220 j*result->strides[0] + i*result->strides[1]); 221 *result_value = (*model)(x_value, y_value); 222 } 223 } 215 for ( i=0; i< x_len; i++) { 216 double x_value = *(double *)(x->data + i*x->strides[0]); 217 double y_value = *(double *)(y->data + i*y->strides[0]); 218 double *result_value = (double *)(result->data + 219 i*result->strides[0]); 220 *result_value = (*model)(x_value, y_value); 221 } 224 222 return PyArray_Return(result); 225 223 -
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 -
sansmodels/src/sans/models/c_models/CFlexibleCylinderModel.cpp
r71e2de7 r3080527 185 185 { 186 186 PyArrayObject *result; 187 int i,j, x_len, y_len, dims[ 2];187 int i,j, x_len, y_len, dims[1]; 188 188 //check validity of input vectors 189 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE190 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE191 || y->dimensions[ 1] != x->dimensions[0]){189 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 190 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 191 || y->dimensions[0] != x->dimensions[0]){ 192 192 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 193 193 PyErr_SetString(PyExc_ValueError , message); … … 197 197 if (PyArray_Check(x) && PyArray_Check(y)) { 198 198 199 x_len = dims[ 1]= x->dimensions[1];199 x_len = dims[0]= x->dimensions[0]; 200 200 y_len = dims[0]= y->dimensions[0]; 201 201 202 202 // Make a new double matrix of same dims 203 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);203 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 204 204 if (result == NULL){ 205 205 const char * message= "Could not create result "; … … 209 209 210 210 /* Do the calculation. */ 211 for ( j=0; j< y_len; j++) { 212 for ( i=0; i< x_len; i++) { 213 double x_value = *(double *)(x->data + i*x->strides[1]); 214 double y_value = *(double *)(y->data + j*y->strides[0]); 215 double *result_value = (double *)(result->data + 216 j*result->strides[0] + i*result->strides[1]); 217 *result_value = (*model)(x_value, y_value); 218 } 219 } 211 for ( i=0; i< x_len; i++) { 212 double x_value = *(double *)(x->data + i*x->strides[0]); 213 double y_value = *(double *)(y->data + i*y->strides[0]); 214 double *result_value = (double *)(result->data + 215 i*result->strides[0]); 216 *result_value = (*model)(x_value, y_value); 217 } 220 218 return PyArray_Return(result); 221 219 -
sansmodels/src/sans/models/c_models/CGaussian.cpp
r71e2de7 r3080527 173 173 { 174 174 PyArrayObject *result; 175 int i,j, x_len, y_len, dims[ 2];175 int i,j, x_len, y_len, dims[1]; 176 176 //check validity of input vectors 177 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE178 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE179 || y->dimensions[ 1] != x->dimensions[0]){177 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 178 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 179 || y->dimensions[0] != x->dimensions[0]){ 180 180 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 181 181 PyErr_SetString(PyExc_ValueError , message); … … 185 185 if (PyArray_Check(x) && PyArray_Check(y)) { 186 186 187 x_len = dims[ 1]= x->dimensions[1];187 x_len = dims[0]= x->dimensions[0]; 188 188 y_len = dims[0]= y->dimensions[0]; 189 189 190 190 // Make a new double matrix of same dims 191 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);191 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 192 192 if (result == NULL){ 193 193 const char * message= "Could not create result "; … … 197 197 198 198 /* Do the calculation. */ 199 for ( j=0; j< y_len; j++) { 200 for ( i=0; i< x_len; i++) { 201 double x_value = *(double *)(x->data + i*x->strides[1]); 202 double y_value = *(double *)(y->data + j*y->strides[0]); 203 double *result_value = (double *)(result->data + 204 j*result->strides[0] + i*result->strides[1]); 205 *result_value = (*model)(x_value, y_value); 206 } 207 } 199 for ( i=0; i< x_len; i++) { 200 double x_value = *(double *)(x->data + i*x->strides[0]); 201 double y_value = *(double *)(y->data + i*y->strides[0]); 202 double *result_value = (double *)(result->data + 203 i*result->strides[0]); 204 *result_value = (*model)(x_value, y_value); 205 } 208 206 return PyArray_Return(result); 209 207 -
sansmodels/src/sans/models/c_models/CHardsphereStructure.cpp
r71e2de7 r3080527 175 175 { 176 176 PyArrayObject *result; 177 int i,j, x_len, y_len, dims[ 2];177 int i,j, x_len, y_len, dims[1]; 178 178 //check validity of input vectors 179 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE180 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE181 || y->dimensions[ 1] != x->dimensions[0]){179 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 180 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 181 || y->dimensions[0] != x->dimensions[0]){ 182 182 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 183 183 PyErr_SetString(PyExc_ValueError , message); … … 187 187 if (PyArray_Check(x) && PyArray_Check(y)) { 188 188 189 x_len = dims[ 1]= x->dimensions[1];189 x_len = dims[0]= x->dimensions[0]; 190 190 y_len = dims[0]= y->dimensions[0]; 191 191 192 192 // Make a new double matrix of same dims 193 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);193 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 194 194 if (result == NULL){ 195 195 const char * message= "Could not create result "; … … 199 199 200 200 /* Do the calculation. */ 201 for ( j=0; j< y_len; j++) { 202 for ( i=0; i< x_len; i++) { 203 double x_value = *(double *)(x->data + i*x->strides[1]); 204 double y_value = *(double *)(y->data + j*y->strides[0]); 205 double *result_value = (double *)(result->data + 206 j*result->strides[0] + i*result->strides[1]); 207 *result_value = (*model)(x_value, y_value); 208 } 209 } 201 for ( i=0; i< x_len; i++) { 202 double x_value = *(double *)(x->data + i*x->strides[0]); 203 double y_value = *(double *)(y->data + i*y->strides[0]); 204 double *result_value = (double *)(result->data + 205 i*result->strides[0]); 206 *result_value = (*model)(x_value, y_value); 207 } 210 208 return PyArray_Return(result); 211 209 -
sansmodels/src/sans/models/c_models/CHayterMSAStructure.cpp
r71e2de7 r3080527 179 179 { 180 180 PyArrayObject *result; 181 int i,j, x_len, y_len, dims[ 2];181 int i,j, x_len, y_len, dims[1]; 182 182 //check validity of input vectors 183 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE184 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE185 || y->dimensions[ 1] != x->dimensions[0]){183 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 184 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 185 || y->dimensions[0] != x->dimensions[0]){ 186 186 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 187 187 PyErr_SetString(PyExc_ValueError , message); … … 191 191 if (PyArray_Check(x) && PyArray_Check(y)) { 192 192 193 x_len = dims[ 1]= x->dimensions[1];193 x_len = dims[0]= x->dimensions[0]; 194 194 y_len = dims[0]= y->dimensions[0]; 195 195 196 196 // Make a new double matrix of same dims 197 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);197 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 198 198 if (result == NULL){ 199 199 const char * message= "Could not create result "; … … 203 203 204 204 /* Do the calculation. */ 205 for ( j=0; j< y_len; j++) { 206 for ( i=0; i< x_len; i++) { 207 double x_value = *(double *)(x->data + i*x->strides[1]); 208 double y_value = *(double *)(y->data + j*y->strides[0]); 209 double *result_value = (double *)(result->data + 210 j*result->strides[0] + i*result->strides[1]); 211 *result_value = (*model)(x_value, y_value); 212 } 213 } 205 for ( i=0; i< x_len; i++) { 206 double x_value = *(double *)(x->data + i*x->strides[0]); 207 double y_value = *(double *)(y->data + i*y->strides[0]); 208 double *result_value = (double *)(result->data + 209 i*result->strides[0]); 210 *result_value = (*model)(x_value, y_value); 211 } 214 212 return PyArray_Return(result); 215 213 -
sansmodels/src/sans/models/c_models/CHollowCylinderModel.cpp
r71e2de7 r3080527 193 193 { 194 194 PyArrayObject *result; 195 int i,j, x_len, y_len, dims[ 2];195 int i,j, x_len, y_len, dims[1]; 196 196 //check validity of input vectors 197 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE198 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE199 || y->dimensions[ 1] != x->dimensions[0]){197 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 198 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 199 || y->dimensions[0] != x->dimensions[0]){ 200 200 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 201 201 PyErr_SetString(PyExc_ValueError , message); … … 205 205 if (PyArray_Check(x) && PyArray_Check(y)) { 206 206 207 x_len = dims[ 1]= x->dimensions[1];207 x_len = dims[0]= x->dimensions[0]; 208 208 y_len = dims[0]= y->dimensions[0]; 209 209 210 210 // Make a new double matrix of same dims 211 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);211 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 212 212 if (result == NULL){ 213 213 const char * message= "Could not create result "; … … 217 217 218 218 /* Do the calculation. */ 219 for ( j=0; j< y_len; j++) { 220 for ( i=0; i< x_len; i++) { 221 double x_value = *(double *)(x->data + i*x->strides[1]); 222 double y_value = *(double *)(y->data + j*y->strides[0]); 223 double *result_value = (double *)(result->data + 224 j*result->strides[0] + i*result->strides[1]); 225 *result_value = (*model)(x_value, y_value); 226 } 227 } 219 for ( i=0; i< x_len; i++) { 220 double x_value = *(double *)(x->data + i*x->strides[0]); 221 double y_value = *(double *)(y->data + i*y->strides[0]); 222 double *result_value = (double *)(result->data + 223 i*result->strides[0]); 224 *result_value = (*model)(x_value, y_value); 225 } 228 226 return PyArray_Return(result); 229 227 -
sansmodels/src/sans/models/c_models/CLamellarFFHGModel.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 -
sansmodels/src/sans/models/c_models/CLamellarModel.cpp
r71e2de7 r3080527 178 178 { 179 179 PyArrayObject *result; 180 int i,j, x_len, y_len, dims[ 2];180 int i,j, x_len, y_len, dims[1]; 181 181 //check validity of input vectors 182 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE183 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE184 || y->dimensions[ 1] != x->dimensions[0]){182 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 183 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 184 || y->dimensions[0] != x->dimensions[0]){ 185 185 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 186 186 PyErr_SetString(PyExc_ValueError , message); … … 190 190 if (PyArray_Check(x) && PyArray_Check(y)) { 191 191 192 x_len = dims[ 1]= x->dimensions[1];192 x_len = dims[0]= x->dimensions[0]; 193 193 y_len = dims[0]= y->dimensions[0]; 194 194 195 195 // Make a new double matrix of same dims 196 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);196 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 197 197 if (result == NULL){ 198 198 const char * message= "Could not create result "; … … 202 202 203 203 /* Do the calculation. */ 204 for ( j=0; j< y_len; j++) { 205 for ( i=0; i< x_len; i++) { 206 double x_value = *(double *)(x->data + i*x->strides[1]); 207 double y_value = *(double *)(y->data + j*y->strides[0]); 208 double *result_value = (double *)(result->data + 209 j*result->strides[0] + i*result->strides[1]); 210 *result_value = (*model)(x_value, y_value); 211 } 212 } 204 for ( i=0; i< x_len; i++) { 205 double x_value = *(double *)(x->data + i*x->strides[0]); 206 double y_value = *(double *)(y->data + i*y->strides[0]); 207 double *result_value = (double *)(result->data + 208 i*result->strides[0]); 209 *result_value = (*model)(x_value, y_value); 210 } 213 211 return PyArray_Return(result); 214 212 -
sansmodels/src/sans/models/c_models/CLamellarPSHGModel.cpp
r71e2de7 r3080527 189 189 { 190 190 PyArrayObject *result; 191 int i,j, x_len, y_len, dims[ 2];191 int i,j, x_len, y_len, dims[1]; 192 192 //check validity of input vectors 193 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE194 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE195 || y->dimensions[ 1] != x->dimensions[0]){193 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 194 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 195 || y->dimensions[0] != x->dimensions[0]){ 196 196 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 197 197 PyErr_SetString(PyExc_ValueError , message); … … 201 201 if (PyArray_Check(x) && PyArray_Check(y)) { 202 202 203 x_len = dims[ 1]= x->dimensions[1];203 x_len = dims[0]= x->dimensions[0]; 204 204 y_len = dims[0]= y->dimensions[0]; 205 205 206 206 // Make a new double matrix of same dims 207 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);207 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 208 208 if (result == NULL){ 209 209 const char * message= "Could not create result "; … … 213 213 214 214 /* Do the calculation. */ 215 for ( j=0; j< y_len; j++) { 216 for ( i=0; i< x_len; i++) { 217 double x_value = *(double *)(x->data + i*x->strides[1]); 218 double y_value = *(double *)(y->data + j*y->strides[0]); 219 double *result_value = (double *)(result->data + 220 j*result->strides[0] + i*result->strides[1]); 221 *result_value = (*model)(x_value, y_value); 222 } 223 } 215 for ( i=0; i< x_len; i++) { 216 double x_value = *(double *)(x->data + i*x->strides[0]); 217 double y_value = *(double *)(y->data + i*y->strides[0]); 218 double *result_value = (double *)(result->data + 219 i*result->strides[0]); 220 *result_value = (*model)(x_value, y_value); 221 } 224 222 return PyArray_Return(result); 225 223 -
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 -
sansmodels/src/sans/models/c_models/CLogNormal.cpp
r71e2de7 r3080527 173 173 { 174 174 PyArrayObject *result; 175 int i,j, x_len, y_len, dims[ 2];175 int i,j, x_len, y_len, dims[1]; 176 176 //check validity of input vectors 177 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE178 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE179 || y->dimensions[ 1] != x->dimensions[0]){177 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 178 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 179 || y->dimensions[0] != x->dimensions[0]){ 180 180 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 181 181 PyErr_SetString(PyExc_ValueError , message); … … 185 185 if (PyArray_Check(x) && PyArray_Check(y)) { 186 186 187 x_len = dims[ 1]= x->dimensions[1];187 x_len = dims[0]= x->dimensions[0]; 188 188 y_len = dims[0]= y->dimensions[0]; 189 189 190 190 // Make a new double matrix of same dims 191 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);191 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 192 192 if (result == NULL){ 193 193 const char * message= "Could not create result "; … … 197 197 198 198 /* Do the calculation. */ 199 for ( j=0; j< y_len; j++) { 200 for ( i=0; i< x_len; i++) { 201 double x_value = *(double *)(x->data + i*x->strides[1]); 202 double y_value = *(double *)(y->data + j*y->strides[0]); 203 double *result_value = (double *)(result->data + 204 j*result->strides[0] + i*result->strides[1]); 205 *result_value = (*model)(x_value, y_value); 206 } 207 } 199 for ( i=0; i< x_len; i++) { 200 double x_value = *(double *)(x->data + i*x->strides[0]); 201 double y_value = *(double *)(y->data + i*y->strides[0]); 202 double *result_value = (double *)(result->data + 203 i*result->strides[0]); 204 *result_value = (*model)(x_value, y_value); 205 } 208 206 return PyArray_Return(result); 209 207 -
sansmodels/src/sans/models/c_models/CLorentzian.cpp
r71e2de7 r3080527 173 173 { 174 174 PyArrayObject *result; 175 int i,j, x_len, y_len, dims[ 2];175 int i,j, x_len, y_len, dims[1]; 176 176 //check validity of input vectors 177 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE178 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE179 || y->dimensions[ 1] != x->dimensions[0]){177 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 178 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 179 || y->dimensions[0] != x->dimensions[0]){ 180 180 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 181 181 PyErr_SetString(PyExc_ValueError , message); … … 185 185 if (PyArray_Check(x) && PyArray_Check(y)) { 186 186 187 x_len = dims[ 1]= x->dimensions[1];187 x_len = dims[0]= x->dimensions[0]; 188 188 y_len = dims[0]= y->dimensions[0]; 189 189 190 190 // Make a new double matrix of same dims 191 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);191 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 192 192 if (result == NULL){ 193 193 const char * message= "Could not create result "; … … 197 197 198 198 /* Do the calculation. */ 199 for ( j=0; j< y_len; j++) { 200 for ( i=0; i< x_len; i++) { 201 double x_value = *(double *)(x->data + i*x->strides[1]); 202 double y_value = *(double *)(y->data + j*y->strides[0]); 203 double *result_value = (double *)(result->data + 204 j*result->strides[0] + i*result->strides[1]); 205 *result_value = (*model)(x_value, y_value); 206 } 207 } 199 for ( i=0; i< x_len; i++) { 200 double x_value = *(double *)(x->data + i*x->strides[0]); 201 double y_value = *(double *)(y->data + i*y->strides[0]); 202 double *result_value = (double *)(result->data + 203 i*result->strides[0]); 204 *result_value = (*model)(x_value, y_value); 205 } 208 206 return PyArray_Return(result); 209 207 -
sansmodels/src/sans/models/c_models/CMultiShellModel.cpp
r71e2de7 r3080527 187 187 { 188 188 PyArrayObject *result; 189 int i,j, x_len, y_len, dims[ 2];189 int i,j, x_len, y_len, dims[1]; 190 190 //check validity of input vectors 191 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE192 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE193 || y->dimensions[ 1] != x->dimensions[0]){191 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 192 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 193 || y->dimensions[0] != x->dimensions[0]){ 194 194 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 195 195 PyErr_SetString(PyExc_ValueError , message); … … 199 199 if (PyArray_Check(x) && PyArray_Check(y)) { 200 200 201 x_len = dims[ 1]= x->dimensions[1];201 x_len = dims[0]= x->dimensions[0]; 202 202 y_len = dims[0]= y->dimensions[0]; 203 203 204 204 // Make a new double matrix of same dims 205 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);205 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 206 206 if (result == NULL){ 207 207 const char * message= "Could not create result "; … … 211 211 212 212 /* Do the calculation. */ 213 for ( j=0; j< y_len; j++) { 214 for ( i=0; i< x_len; i++) { 215 double x_value = *(double *)(x->data + i*x->strides[1]); 216 double y_value = *(double *)(y->data + j*y->strides[0]); 217 double *result_value = (double *)(result->data + 218 j*result->strides[0] + i*result->strides[1]); 219 *result_value = (*model)(x_value, y_value); 220 } 221 } 213 for ( i=0; i< x_len; i++) { 214 double x_value = *(double *)(x->data + i*x->strides[0]); 215 double y_value = *(double *)(y->data + i*y->strides[0]); 216 double *result_value = (double *)(result->data + 217 i*result->strides[0]); 218 *result_value = (*model)(x_value, y_value); 219 } 222 220 return PyArray_Return(result); 223 221 -
sansmodels/src/sans/models/c_models/COblateModel.cpp
r71e2de7 r3080527 192 192 { 193 193 PyArrayObject *result; 194 int i,j, x_len, y_len, dims[ 2];194 int i,j, x_len, y_len, dims[1]; 195 195 //check validity of input vectors 196 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE197 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE198 || y->dimensions[ 1] != x->dimensions[0]){196 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 197 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 198 || y->dimensions[0] != x->dimensions[0]){ 199 199 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 200 200 PyErr_SetString(PyExc_ValueError , message); … … 204 204 if (PyArray_Check(x) && PyArray_Check(y)) { 205 205 206 x_len = dims[ 1]= x->dimensions[1];206 x_len = dims[0]= x->dimensions[0]; 207 207 y_len = dims[0]= y->dimensions[0]; 208 208 209 209 // Make a new double matrix of same dims 210 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);210 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 211 211 if (result == NULL){ 212 212 const char * message= "Could not create result "; … … 216 216 217 217 /* Do the calculation. */ 218 for ( j=0; j< y_len; j++) { 219 for ( i=0; i< x_len; i++) { 220 double x_value = *(double *)(x->data + i*x->strides[1]); 221 double y_value = *(double *)(y->data + j*y->strides[0]); 222 double *result_value = (double *)(result->data + 223 j*result->strides[0] + i*result->strides[1]); 224 *result_value = (*model)(x_value, y_value); 225 } 226 } 218 for ( i=0; i< x_len; i++) { 219 double x_value = *(double *)(x->data + i*x->strides[0]); 220 double y_value = *(double *)(y->data + i*y->strides[0]); 221 double *result_value = (double *)(result->data + 222 i*result->strides[0]); 223 *result_value = (*model)(x_value, y_value); 224 } 227 225 return PyArray_Return(result); 228 226 -
sansmodels/src/sans/models/c_models/CParallelepipedModel.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 -
sansmodels/src/sans/models/c_models/CProlateModel.cpp
r71e2de7 r3080527 190 190 { 191 191 PyArrayObject *result; 192 int i,j, x_len, y_len, dims[ 2];192 int i,j, x_len, y_len, dims[1]; 193 193 //check validity of input vectors 194 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE195 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE196 || y->dimensions[ 1] != x->dimensions[0]){194 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 195 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 196 || y->dimensions[0] != x->dimensions[0]){ 197 197 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 198 198 PyErr_SetString(PyExc_ValueError , message); … … 202 202 if (PyArray_Check(x) && PyArray_Check(y)) { 203 203 204 x_len = dims[ 1]= x->dimensions[1];204 x_len = dims[0]= x->dimensions[0]; 205 205 y_len = dims[0]= y->dimensions[0]; 206 206 207 207 // Make a new double matrix of same dims 208 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);208 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 209 209 if (result == NULL){ 210 210 const char * message= "Could not create result "; … … 214 214 215 215 /* Do the calculation. */ 216 for ( j=0; j< y_len; j++) { 217 for ( i=0; i< x_len; i++) { 218 double x_value = *(double *)(x->data + i*x->strides[1]); 219 double y_value = *(double *)(y->data + j*y->strides[0]); 220 double *result_value = (double *)(result->data + 221 j*result->strides[0] + i*result->strides[1]); 222 *result_value = (*model)(x_value, y_value); 223 } 224 } 216 for ( i=0; i< x_len; i++) { 217 double x_value = *(double *)(x->data + i*x->strides[0]); 218 double y_value = *(double *)(y->data + i*y->strides[0]); 219 double *result_value = (double *)(result->data + 220 i*result->strides[0]); 221 *result_value = (*model)(x_value, y_value); 222 } 225 223 return PyArray_Return(result); 226 224 -
sansmodels/src/sans/models/c_models/CSchulz.cpp
r71e2de7 r3080527 173 173 { 174 174 PyArrayObject *result; 175 int i,j, x_len, y_len, dims[ 2];175 int i,j, x_len, y_len, dims[1]; 176 176 //check validity of input vectors 177 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE178 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE179 || y->dimensions[ 1] != x->dimensions[0]){177 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 178 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 179 || y->dimensions[0] != x->dimensions[0]){ 180 180 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 181 181 PyErr_SetString(PyExc_ValueError , message); … … 185 185 if (PyArray_Check(x) && PyArray_Check(y)) { 186 186 187 x_len = dims[ 1]= x->dimensions[1];187 x_len = dims[0]= x->dimensions[0]; 188 188 y_len = dims[0]= y->dimensions[0]; 189 189 190 190 // Make a new double matrix of same dims 191 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);191 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 192 192 if (result == NULL){ 193 193 const char * message= "Could not create result "; … … 197 197 198 198 /* Do the calculation. */ 199 for ( j=0; j< y_len; j++) { 200 for ( i=0; i< x_len; i++) { 201 double x_value = *(double *)(x->data + i*x->strides[1]); 202 double y_value = *(double *)(y->data + j*y->strides[0]); 203 double *result_value = (double *)(result->data + 204 j*result->strides[0] + i*result->strides[1]); 205 *result_value = (*model)(x_value, y_value); 206 } 207 } 199 for ( i=0; i< x_len; i++) { 200 double x_value = *(double *)(x->data + i*x->strides[0]); 201 double y_value = *(double *)(y->data + i*y->strides[0]); 202 double *result_value = (double *)(result->data + 203 i*result->strides[0]); 204 *result_value = (*model)(x_value, y_value); 205 } 208 206 return PyArray_Return(result); 209 207 -
sansmodels/src/sans/models/c_models/CSphereModel.cpp
r71e2de7 r3080527 177 177 { 178 178 PyArrayObject *result; 179 int i,j, x_len, y_len, dims[ 2];179 int i,j, x_len, y_len, dims[1]; 180 180 //check validity of input vectors 181 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE182 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE183 || y->dimensions[ 1] != x->dimensions[0]){181 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 182 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 183 || y->dimensions[0] != x->dimensions[0]){ 184 184 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 185 185 PyErr_SetString(PyExc_ValueError , message); … … 189 189 if (PyArray_Check(x) && PyArray_Check(y)) { 190 190 191 x_len = dims[ 1]= x->dimensions[1];191 x_len = dims[0]= x->dimensions[0]; 192 192 y_len = dims[0]= y->dimensions[0]; 193 193 194 194 // Make a new double matrix of same dims 195 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);195 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 196 196 if (result == NULL){ 197 197 const char * message= "Could not create result "; … … 201 201 202 202 /* Do the calculation. */ 203 for ( j=0; j< y_len; j++) { 204 for ( i=0; i< x_len; i++) { 205 double x_value = *(double *)(x->data + i*x->strides[1]); 206 double y_value = *(double *)(y->data + j*y->strides[0]); 207 double *result_value = (double *)(result->data + 208 j*result->strides[0] + i*result->strides[1]); 209 *result_value = (*model)(x_value, y_value); 210 } 211 } 203 for ( i=0; i< x_len; i++) { 204 double x_value = *(double *)(x->data + i*x->strides[0]); 205 double y_value = *(double *)(y->data + i*y->strides[0]); 206 double *result_value = (double *)(result->data + 207 i*result->strides[0]); 208 *result_value = (*model)(x_value, y_value); 209 } 212 210 return PyArray_Return(result); 213 211 -
sansmodels/src/sans/models/c_models/CSquareWellStructure.cpp
r71e2de7 r3080527 177 177 { 178 178 PyArrayObject *result; 179 int i,j, x_len, y_len, dims[ 2];179 int i,j, x_len, y_len, dims[1]; 180 180 //check validity of input vectors 181 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE182 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE183 || y->dimensions[ 1] != x->dimensions[0]){181 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 182 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 183 || y->dimensions[0] != x->dimensions[0]){ 184 184 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 185 185 PyErr_SetString(PyExc_ValueError , message); … … 189 189 if (PyArray_Check(x) && PyArray_Check(y)) { 190 190 191 x_len = dims[ 1]= x->dimensions[1];191 x_len = dims[0]= x->dimensions[0]; 192 192 y_len = dims[0]= y->dimensions[0]; 193 193 194 194 // Make a new double matrix of same dims 195 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);195 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 196 196 if (result == NULL){ 197 197 const char * message= "Could not create result "; … … 201 201 202 202 /* Do the calculation. */ 203 for ( j=0; j< y_len; j++) { 204 for ( i=0; i< x_len; i++) { 205 double x_value = *(double *)(x->data + i*x->strides[1]); 206 double y_value = *(double *)(y->data + j*y->strides[0]); 207 double *result_value = (double *)(result->data + 208 j*result->strides[0] + i*result->strides[1]); 209 *result_value = (*model)(x_value, y_value); 210 } 211 } 203 for ( i=0; i< x_len; i++) { 204 double x_value = *(double *)(x->data + i*x->strides[0]); 205 double y_value = *(double *)(y->data + i*y->strides[0]); 206 double *result_value = (double *)(result->data + 207 i*result->strides[0]); 208 *result_value = (*model)(x_value, y_value); 209 } 212 210 return PyArray_Return(result); 213 211 -
sansmodels/src/sans/models/c_models/CStackedDisksModel.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 -
sansmodels/src/sans/models/c_models/CStickyHSStructure.cpp
r71e2de7 r3080527 177 177 { 178 178 PyArrayObject *result; 179 int i,j, x_len, y_len, dims[ 2];179 int i,j, x_len, y_len, dims[1]; 180 180 //check validity of input vectors 181 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE182 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE183 || y->dimensions[ 1] != x->dimensions[0]){181 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 182 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 183 || y->dimensions[0] != x->dimensions[0]){ 184 184 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 185 185 PyErr_SetString(PyExc_ValueError , message); … … 189 189 if (PyArray_Check(x) && PyArray_Check(y)) { 190 190 191 x_len = dims[ 1]= x->dimensions[1];191 x_len = dims[0]= x->dimensions[0]; 192 192 y_len = dims[0]= y->dimensions[0]; 193 193 194 194 // Make a new double matrix of same dims 195 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);195 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 196 196 if (result == NULL){ 197 197 const char * message= "Could not create result "; … … 201 201 202 202 /* Do the calculation. */ 203 for ( j=0; j< y_len; j++) { 204 for ( i=0; i< x_len; i++) { 205 double x_value = *(double *)(x->data + i*x->strides[1]); 206 double y_value = *(double *)(y->data + j*y->strides[0]); 207 double *result_value = (double *)(result->data + 208 j*result->strides[0] + i*result->strides[1]); 209 *result_value = (*model)(x_value, y_value); 210 } 211 } 203 for ( i=0; i< x_len; i++) { 204 double x_value = *(double *)(x->data + i*x->strides[0]); 205 double y_value = *(double *)(y->data + i*y->strides[0]); 206 double *result_value = (double *)(result->data + 207 i*result->strides[0]); 208 *result_value = (*model)(x_value, y_value); 209 } 212 210 return PyArray_Return(result); 213 211 -
sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp
r71e2de7 r3080527 188 188 { 189 189 PyArrayObject *result; 190 int i,j, x_len, y_len, dims[ 2];190 int i,j, x_len, y_len, dims[1]; 191 191 //check validity of input vectors 192 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE193 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE194 || y->dimensions[ 1] != x->dimensions[0]){192 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 193 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 194 || y->dimensions[0] != x->dimensions[0]){ 195 195 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 196 196 PyErr_SetString(PyExc_ValueError , message); … … 200 200 if (PyArray_Check(x) && PyArray_Check(y)) { 201 201 202 x_len = dims[ 1]= x->dimensions[1];202 x_len = dims[0]= x->dimensions[0]; 203 203 y_len = dims[0]= y->dimensions[0]; 204 204 205 205 // Make a new double matrix of same dims 206 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);206 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 207 207 if (result == NULL){ 208 208 const char * message= "Could not create result "; … … 212 212 213 213 /* Do the calculation. */ 214 for ( j=0; j< y_len; j++) { 215 for ( i=0; i< x_len; i++) { 216 double x_value = *(double *)(x->data + i*x->strides[1]); 217 double y_value = *(double *)(y->data + j*y->strides[0]); 218 double *result_value = (double *)(result->data + 219 j*result->strides[0] + i*result->strides[1]); 220 *result_value = (*model)(x_value, y_value); 221 } 222 } 214 for ( i=0; i< x_len; i++) { 215 double x_value = *(double *)(x->data + i*x->strides[0]); 216 double y_value = *(double *)(y->data + i*y->strides[0]); 217 double *result_value = (double *)(result->data + 218 i*result->strides[0]); 219 *result_value = (*model)(x_value, y_value); 220 } 223 221 return PyArray_Return(result); 224 222 -
sansmodels/src/sans/models/c_models/CVesicleModel.cpp
r71e2de7 r3080527 182 182 { 183 183 PyArrayObject *result; 184 int i,j, x_len, y_len, dims[ 2];184 int i,j, x_len, y_len, dims[1]; 185 185 //check validity of input vectors 186 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE187 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE188 || y->dimensions[ 1] != x->dimensions[0]){186 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 187 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 188 || y->dimensions[0] != x->dimensions[0]){ 189 189 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 190 190 PyErr_SetString(PyExc_ValueError , message); … … 194 194 if (PyArray_Check(x) && PyArray_Check(y)) { 195 195 196 x_len = dims[ 1]= x->dimensions[1];196 x_len = dims[0]= x->dimensions[0]; 197 197 y_len = dims[0]= y->dimensions[0]; 198 198 199 199 // Make a new double matrix of same dims 200 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);200 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 201 201 if (result == NULL){ 202 202 const char * message= "Could not create result "; … … 206 206 207 207 /* Do the calculation. */ 208 for ( j=0; j< y_len; j++) { 209 for ( i=0; i< x_len; i++) { 210 double x_value = *(double *)(x->data + i*x->strides[1]); 211 double y_value = *(double *)(y->data + j*y->strides[0]); 212 double *result_value = (double *)(result->data + 213 j*result->strides[0] + i*result->strides[1]); 214 *result_value = (*model)(x_value, y_value); 215 } 216 } 208 for ( i=0; i< x_len; i++) { 209 double x_value = *(double *)(x->data + i*x->strides[0]); 210 double y_value = *(double *)(y->data + i*y->strides[0]); 211 double *result_value = (double *)(result->data + 212 i*result->strides[0]); 213 *result_value = (*model)(x_value, y_value); 214 } 217 215 return PyArray_Return(result); 218 216 -
sansmodels/src/sans/models/c_models/classTemplate.txt
r71e2de7 r3080527 163 163 { 164 164 PyArrayObject *result; 165 int i,j, x_len, y_len, dims[ 2];165 int i,j, x_len, y_len, dims[1]; 166 166 //check validity of input vectors 167 if (x->nd != 2|| x->descr->type_num != PyArray_DOUBLE168 || y->nd != 2|| y->descr->type_num != PyArray_DOUBLE169 || y->dimensions[ 1] != x->dimensions[0]){167 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 168 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 169 || y->dimensions[0] != x->dimensions[0]){ 170 170 const char * message= "evaluateTwoDimXY expect 2 numpy arrays"; 171 171 PyErr_SetString(PyExc_ValueError , message); … … 175 175 if (PyArray_Check(x) && PyArray_Check(y)) { 176 176 177 x_len = dims[ 1]= x->dimensions[1];177 x_len = dims[0]= x->dimensions[0]; 178 178 y_len = dims[0]= y->dimensions[0]; 179 179 180 180 // Make a new double matrix of same dims 181 result=(PyArrayObject *) PyArray_FromDims( 2,dims,NPY_DOUBLE);181 result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE); 182 182 if (result == NULL){ 183 183 const char * message= "Could not create result "; … … 187 187 188 188 /* Do the calculation. */ 189 for ( j=0; j< y_len; j++) { 190 for ( i=0; i< x_len; i++) { 191 double x_value = *(double *)(x->data + i*x->strides[1]); 192 double y_value = *(double *)(y->data + j*y->strides[0]); 193 double *result_value = (double *)(result->data + 194 j*result->strides[0] + i*result->strides[1]); 195 *result_value = (*model)(x_value, y_value); 196 } 197 } 189 for ( i=0; i< x_len; i++) { 190 double x_value = *(double *)(x->data + i*x->strides[0]); 191 double y_value = *(double *)(y->data + i*y->strides[0]); 192 double *result_value = (double *)(result->data + 193 i*result->strides[0]); 194 *result_value = (*model)(x_value, y_value); 195 } 198 196 return PyArray_Return(result); 199 197
Note: See TracChangeset
for help on using the changeset viewer.