1 | /* CylinderFit.c |
---|
2 | |
---|
3 | A simplified project designed to act as a template for your curve fitting function. |
---|
4 | The fitting function is a Cylinder form factor. No resolution effects are included (yet) |
---|
5 | */ |
---|
6 | |
---|
7 | #pragma XOP_SET_STRUCT_PACKING // All structures are 2-byte-aligned. |
---|
8 | |
---|
9 | #include "XOPStandardHeaders.h" // Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h |
---|
10 | #include "SANSAnalysis.h" |
---|
11 | #include "libSANSAnalysis.h" |
---|
12 | #include "Cylinder.h" |
---|
13 | |
---|
14 | |
---|
15 | /* CylinderFormX : calculates the form factor of a cylinder at the give x-value p->x |
---|
16 | |
---|
17 | Warning: |
---|
18 | The call to WaveData() below returns a pointer to the middle |
---|
19 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
20 | calculations could cause memory to move, you should copy the coefficient |
---|
21 | values to local variables or an array before such operations. |
---|
22 | */ |
---|
23 | int |
---|
24 | CylinderFormX(FitParamsPtr p) |
---|
25 | { |
---|
26 | double *dp; // Pointer to double precision wave data. |
---|
27 | float *fp; // Pointer to single precision wave data. |
---|
28 | double q; |
---|
29 | |
---|
30 | if (p->waveHandle == NIL) { |
---|
31 | SetNaN64(&p->result); |
---|
32 | return NON_EXISTENT_WAVE; |
---|
33 | } |
---|
34 | |
---|
35 | q= p->x; |
---|
36 | |
---|
37 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
38 | case NT_FP32: |
---|
39 | fp= WaveData(p->waveHandle); |
---|
40 | SetNaN64(&p->result); |
---|
41 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
42 | case NT_FP64: |
---|
43 | dp= WaveData(p->waveHandle); |
---|
44 | p->result = CylinderForm(dp,q); |
---|
45 | return 0; |
---|
46 | default: // We can't handle this wave data type. |
---|
47 | SetNaN64(&p->result); |
---|
48 | return REQUIRES_SP_OR_DP_WAVE; |
---|
49 | } |
---|
50 | |
---|
51 | return 0; |
---|
52 | } |
---|
53 | |
---|
54 | /* EllipCyl76X : calculates the form factor of a elliptical cylinder at the given x-value p->x |
---|
55 | |
---|
56 | Uses 76 pt Gaussian quadrature for both integrals |
---|
57 | |
---|
58 | Warning: |
---|
59 | The call to WaveData() below returns a pointer to the middle |
---|
60 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
61 | calculations could cause memory to move, you should copy the coefficient |
---|
62 | values to local variables or an array before such operations. |
---|
63 | */ |
---|
64 | int |
---|
65 | EllipCyl76X(FitParamsPtr p) |
---|
66 | { |
---|
67 | double *dp; // Pointer to double precision wave data. |
---|
68 | float *fp; // Pointer to single precision wave data. |
---|
69 | double q; |
---|
70 | |
---|
71 | if (p->waveHandle == NIL) { |
---|
72 | SetNaN64(&p->result); |
---|
73 | return NON_EXISTENT_WAVE; |
---|
74 | } |
---|
75 | |
---|
76 | q= p->x; |
---|
77 | |
---|
78 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
79 | case NT_FP32: |
---|
80 | fp= WaveData(p->waveHandle); |
---|
81 | SetNaN64(&p->result); |
---|
82 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
83 | case NT_FP64: |
---|
84 | dp= WaveData(p->waveHandle); |
---|
85 | p->result = EllipCyl76(dp,q); |
---|
86 | return 0; |
---|
87 | default: // We can't handle this wave data type. |
---|
88 | SetNaN64(&p->result); |
---|
89 | return REQUIRES_SP_OR_DP_WAVE; |
---|
90 | } |
---|
91 | |
---|
92 | return 0; |
---|
93 | } |
---|
94 | |
---|
95 | /* EllipCyl20X : calculates the form factor of a elliptical cylinder at the given x-value p->x |
---|
96 | |
---|
97 | Uses 76 pt Gaussian quadrature for orientational integral |
---|
98 | Uses 20 pt quadrature for the inner integral over the elliptical cross-section |
---|
99 | |
---|
100 | Warning: |
---|
101 | The call to WaveData() below returns a pointer to the middle |
---|
102 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
103 | calculations could cause memory to move, you should copy the coefficient |
---|
104 | values to local variables or an array before such operations. |
---|
105 | */ |
---|
106 | int |
---|
107 | EllipCyl20X(FitParamsPtr p) |
---|
108 | { |
---|
109 | double *dp; // Pointer to double precision wave data. |
---|
110 | float *fp; // Pointer to single precision wave data. |
---|
111 | double q; |
---|
112 | |
---|
113 | if (p->waveHandle == NIL) { |
---|
114 | SetNaN64(&p->result); |
---|
115 | return NON_EXISTENT_WAVE; |
---|
116 | } |
---|
117 | |
---|
118 | q= p->x; |
---|
119 | |
---|
120 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
121 | case NT_FP32: |
---|
122 | fp= WaveData(p->waveHandle); |
---|
123 | fp= WaveData(p->waveHandle); |
---|
124 | SetNaN64(&p->result); |
---|
125 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
126 | case NT_FP64: |
---|
127 | dp= WaveData(p->waveHandle); |
---|
128 | |
---|
129 | p->result = EllipCyl20(dp,q); |
---|
130 | return 0; |
---|
131 | default: // We can't handle this wave data type. |
---|
132 | SetNaN64(&p->result); |
---|
133 | return REQUIRES_SP_OR_DP_WAVE; |
---|
134 | } |
---|
135 | |
---|
136 | return 0; |
---|
137 | } |
---|
138 | |
---|
139 | /* TriaxialEllipsoidX : calculates the form factor of a Triaxial Ellipsoid at the given x-value p->x |
---|
140 | |
---|
141 | Uses 76 pt Gaussian quadrature for both integrals |
---|
142 | |
---|
143 | Warning: |
---|
144 | The call to WaveData() below returns a pointer to the middle |
---|
145 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
146 | calculations could cause memory to move, you should copy the coefficient |
---|
147 | values to local variables or an array before such operations. |
---|
148 | */ |
---|
149 | int |
---|
150 | TriaxialEllipsoidX(FitParamsPtr p) |
---|
151 | { |
---|
152 | double *dp; // Pointer to double precision wave data. |
---|
153 | float *fp; // Pointer to single precision wave data. |
---|
154 | double q; |
---|
155 | |
---|
156 | if (p->waveHandle == NIL) { |
---|
157 | SetNaN64(&p->result); |
---|
158 | return NON_EXISTENT_WAVE; |
---|
159 | } |
---|
160 | |
---|
161 | q= p->x; |
---|
162 | |
---|
163 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
164 | case NT_FP32: |
---|
165 | fp= WaveData(p->waveHandle); |
---|
166 | SetNaN64(&p->result); |
---|
167 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
168 | case NT_FP64: |
---|
169 | dp= WaveData(p->waveHandle); |
---|
170 | |
---|
171 | p->result = TriaxialEllipsoid(dp,q); |
---|
172 | return 0; |
---|
173 | default: // We can't handle this wave data type. |
---|
174 | SetNaN64(&p->result); |
---|
175 | return REQUIRES_SP_OR_DP_WAVE; |
---|
176 | } |
---|
177 | |
---|
178 | return 0; |
---|
179 | } |
---|
180 | |
---|
181 | /* ParallelepipedX : calculates the form factor of a Parallelepiped (a rectangular solid) |
---|
182 | at the given x-value p->x |
---|
183 | |
---|
184 | Uses 76 pt Gaussian quadrature for both integrals |
---|
185 | |
---|
186 | Warning: |
---|
187 | The call to WaveData() below returns a pointer to the middle |
---|
188 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
189 | calculations could cause memory to move, you should copy the coefficient |
---|
190 | values to local variables or an array before such operations. |
---|
191 | */ |
---|
192 | int |
---|
193 | ParallelepipedX(FitParamsPtr p) |
---|
194 | { |
---|
195 | double *dp; // Pointer to double precision wave data. |
---|
196 | float *fp; // Pointer to single precision wave data. |
---|
197 | double q; |
---|
198 | |
---|
199 | if (p->waveHandle == NIL) { |
---|
200 | SetNaN64(&p->result); |
---|
201 | return NON_EXISTENT_WAVE; |
---|
202 | } |
---|
203 | |
---|
204 | q= p->x; |
---|
205 | |
---|
206 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
207 | case NT_FP32: |
---|
208 | fp= WaveData(p->waveHandle); |
---|
209 | SetNaN64(&p->result); |
---|
210 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
211 | case NT_FP64: |
---|
212 | dp= WaveData(p->waveHandle); |
---|
213 | |
---|
214 | p->result = Parallelepiped(dp,q); |
---|
215 | return 0; |
---|
216 | default: // We can't handle this wave data type. |
---|
217 | SetNaN64(&p->result); |
---|
218 | return REQUIRES_SP_OR_DP_WAVE; |
---|
219 | } |
---|
220 | |
---|
221 | return 0; |
---|
222 | } |
---|
223 | |
---|
224 | /* HollowCylinderX : calculates the form factor of a Hollow Cylinder |
---|
225 | at the given x-value p->x |
---|
226 | |
---|
227 | Uses 76 pt Gaussian quadrature for the single integral |
---|
228 | |
---|
229 | Warning: |
---|
230 | The call to WaveData() below returns a pointer to the middle |
---|
231 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
232 | calculations could cause memory to move, you should copy the coefficient |
---|
233 | values to local variables or an array before such operations. |
---|
234 | */ |
---|
235 | int |
---|
236 | HollowCylinderX(FitParamsPtr p) |
---|
237 | { |
---|
238 | double *dp; // Pointer to double precision wave data. |
---|
239 | float *fp; // Pointer to single precision wave data. |
---|
240 | double q; |
---|
241 | |
---|
242 | if (p->waveHandle == NIL) { |
---|
243 | SetNaN64(&p->result); |
---|
244 | return NON_EXISTENT_WAVE; |
---|
245 | } |
---|
246 | |
---|
247 | q= p->x; |
---|
248 | |
---|
249 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
250 | case NT_FP32: |
---|
251 | fp= WaveData(p->waveHandle); |
---|
252 | SetNaN64(&p->result); |
---|
253 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
254 | case NT_FP64: |
---|
255 | dp= WaveData(p->waveHandle); |
---|
256 | |
---|
257 | p->result = HollowCylinder(dp,q); |
---|
258 | return 0; |
---|
259 | default: // We can't handle this wave data type. |
---|
260 | SetNaN64(&p->result); |
---|
261 | return REQUIRES_SP_OR_DP_WAVE; |
---|
262 | } |
---|
263 | |
---|
264 | return 0; |
---|
265 | } |
---|
266 | |
---|
267 | /* EllipsoidFormX : calculates the form factor of an ellipsoid of revolution with semiaxes a:a:nua |
---|
268 | at the given x-value p->x |
---|
269 | |
---|
270 | Uses 76 pt Gaussian quadrature for the single integral |
---|
271 | |
---|
272 | Warning: |
---|
273 | The call to WaveData() below returns a pointer to the middle |
---|
274 | of an unlocked Macintosh handle. In the unlikely event that your |
---|
275 | calculations could cause memory to move, you should copy the coefficient |
---|
276 | values to local variables or an array before such operations. |
---|
277 | */ |
---|
278 | int |
---|
279 | EllipsoidFormX(FitParamsPtr p) |
---|
280 | { |
---|
281 | double *dp; // Pointer to double precision wave data. |
---|
282 | float *fp; // Pointer to single precision wave data. |
---|
283 | double q; |
---|
284 | |
---|
285 | if (p->waveHandle == NIL) { |
---|
286 | SetNaN64(&p->result); |
---|
287 | return NON_EXISTENT_WAVE; |
---|
288 | } |
---|
289 | |
---|
290 | q= p->x; |
---|
291 | |
---|
292 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
293 | case NT_FP32: |
---|
294 | fp= WaveData(p->waveHandle); |
---|
295 | SetNaN64(&p->result); |
---|
296 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
297 | case NT_FP64: |
---|
298 | dp= WaveData(p->waveHandle); |
---|
299 | |
---|
300 | p->result = EllipsoidForm(dp,q); |
---|
301 | return 0; |
---|
302 | default: // We can't handle this wave data type. |
---|
303 | SetNaN64(&p->result); |
---|
304 | return REQUIRES_SP_OR_DP_WAVE; |
---|
305 | } |
---|
306 | |
---|
307 | return 0; |
---|
308 | } |
---|
309 | |
---|
310 | |
---|
311 | /* Cyl_PolyRadiusX : calculates the form factor of a cylinder at the given x-value p->x |
---|
312 | the cylinder has a polydisperse cross section |
---|
313 | |
---|
314 | */ |
---|
315 | int |
---|
316 | Cyl_PolyRadiusX(FitParamsPtr p) |
---|
317 | { |
---|
318 | double *dp; // Pointer to double precision wave data. |
---|
319 | float *fp; // Pointer to single precision wave data. |
---|
320 | double q; |
---|
321 | |
---|
322 | if (p->waveHandle == NIL) { |
---|
323 | SetNaN64(&p->result); |
---|
324 | return NON_EXISTENT_WAVE; |
---|
325 | } |
---|
326 | |
---|
327 | |
---|
328 | q= p->x; |
---|
329 | |
---|
330 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
331 | case NT_FP32: |
---|
332 | fp= WaveData(p->waveHandle); |
---|
333 | SetNaN64(&p->result); |
---|
334 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
335 | case NT_FP64: |
---|
336 | dp= WaveData(p->waveHandle); |
---|
337 | |
---|
338 | p->result = Cyl_PolyRadius(dp,q); |
---|
339 | return 0; |
---|
340 | default: // We can't handle this wave data type. |
---|
341 | SetNaN64(&p->result); |
---|
342 | return REQUIRES_SP_OR_DP_WAVE; |
---|
343 | } |
---|
344 | |
---|
345 | return 0; |
---|
346 | } |
---|
347 | |
---|
348 | /* Cyl_PolyLengthX : calculates the form factor of a cylinder at the given x-value p->x |
---|
349 | the cylinder has a polydisperse Length |
---|
350 | |
---|
351 | */ |
---|
352 | int |
---|
353 | Cyl_PolyLengthX(FitParamsPtr p) |
---|
354 | { |
---|
355 | double *dp; // Pointer to double precision wave data. |
---|
356 | float *fp; // Pointer to single precision wave data. |
---|
357 | double q; |
---|
358 | |
---|
359 | if (p->waveHandle == NIL) { |
---|
360 | SetNaN64(&p->result); |
---|
361 | return NON_EXISTENT_WAVE; |
---|
362 | } |
---|
363 | |
---|
364 | q= p->x; |
---|
365 | |
---|
366 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
367 | case NT_FP32: |
---|
368 | fp= WaveData(p->waveHandle); |
---|
369 | SetNaN64(&p->result); |
---|
370 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
371 | case NT_FP64: |
---|
372 | dp= WaveData(p->waveHandle); |
---|
373 | |
---|
374 | p->result = Cyl_PolyLength(dp,q); |
---|
375 | return 0; |
---|
376 | default: // We can't handle this wave data type. |
---|
377 | SetNaN64(&p->result); |
---|
378 | return REQUIRES_SP_OR_DP_WAVE; |
---|
379 | } |
---|
380 | |
---|
381 | |
---|
382 | return 0; |
---|
383 | } |
---|
384 | |
---|
385 | /* CoreShellCylinderX : calculates the form factor of a cylinder at the given x-value p->x |
---|
386 | the cylinder has a core-shell structure |
---|
387 | |
---|
388 | */ |
---|
389 | int |
---|
390 | CoreShellCylinderX(FitParamsPtr p) |
---|
391 | { |
---|
392 | double *dp; // Pointer to double precision wave data. |
---|
393 | float *fp; // Pointer to single precision wave data. |
---|
394 | double q; |
---|
395 | |
---|
396 | if (p->waveHandle == NIL) { |
---|
397 | SetNaN64(&p->result); |
---|
398 | return NON_EXISTENT_WAVE; |
---|
399 | } |
---|
400 | |
---|
401 | |
---|
402 | q= p->x; |
---|
403 | |
---|
404 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
405 | case NT_FP32: |
---|
406 | fp= WaveData(p->waveHandle); |
---|
407 | SetNaN64(&p->result); |
---|
408 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
409 | case NT_FP64: |
---|
410 | dp= WaveData(p->waveHandle); |
---|
411 | |
---|
412 | p->result = CoreShellCylinder(dp,q); |
---|
413 | return 0; |
---|
414 | default: // We can't handle this wave data type. |
---|
415 | SetNaN64(&p->result); |
---|
416 | return REQUIRES_SP_OR_DP_WAVE; |
---|
417 | } |
---|
418 | |
---|
419 | |
---|
420 | return 0; |
---|
421 | } |
---|
422 | |
---|
423 | |
---|
424 | /* PolyCoShCylinderX : calculates the form factor of a core-shell cylinder at the given x-value p->x |
---|
425 | the cylinder has a polydisperse CORE radius |
---|
426 | |
---|
427 | */ |
---|
428 | int |
---|
429 | PolyCoShCylinderX(FitParamsPtr p) |
---|
430 | { |
---|
431 | double *dp; // Pointer to double precision wave data. |
---|
432 | float *fp; // Pointer to single precision wave data. |
---|
433 | double q; |
---|
434 | |
---|
435 | if (p->waveHandle == NIL) { |
---|
436 | SetNaN64(&p->result); |
---|
437 | return NON_EXISTENT_WAVE; |
---|
438 | } |
---|
439 | q= p->x; |
---|
440 | |
---|
441 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
442 | case NT_FP32: |
---|
443 | fp= WaveData(p->waveHandle); |
---|
444 | SetNaN64(&p->result); |
---|
445 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
446 | case NT_FP64: |
---|
447 | dp= WaveData(p->waveHandle); |
---|
448 | |
---|
449 | p->result = PolyCoShCylinder(dp,q); |
---|
450 | return 0; |
---|
451 | default: // We can't handle this wave data type. |
---|
452 | SetNaN64(&p->result); |
---|
453 | return REQUIRES_SP_OR_DP_WAVE; |
---|
454 | } |
---|
455 | |
---|
456 | return 0; |
---|
457 | } |
---|
458 | |
---|
459 | /* OblateFormX : calculates the form factor of a core-shell Oblate ellipsoid at the given x-value p->x |
---|
460 | the ellipsoid has a core-shell structure |
---|
461 | |
---|
462 | */ |
---|
463 | int |
---|
464 | OblateFormX(FitParamsPtr p) |
---|
465 | { |
---|
466 | double *dp; // Pointer to double precision wave data. |
---|
467 | float *fp; // Pointer to single precision wave data. |
---|
468 | double q; //local variables of coefficient wave |
---|
469 | |
---|
470 | if (p->waveHandle == NIL) { |
---|
471 | SetNaN64(&p->result); |
---|
472 | return NON_EXISTENT_WAVE; |
---|
473 | } |
---|
474 | q= p->x; |
---|
475 | |
---|
476 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
477 | case NT_FP32: |
---|
478 | fp= WaveData(p->waveHandle); |
---|
479 | SetNaN64(&p->result); |
---|
480 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
481 | case NT_FP64: |
---|
482 | dp= WaveData(p->waveHandle); |
---|
483 | |
---|
484 | p->result = OblateForm(dp,q); |
---|
485 | return 0; |
---|
486 | default: // We can't handle this wave data type. |
---|
487 | SetNaN64(&p->result); |
---|
488 | return REQUIRES_SP_OR_DP_WAVE; |
---|
489 | } |
---|
490 | |
---|
491 | return 0; |
---|
492 | } |
---|
493 | |
---|
494 | /* ProlateFormX : calculates the form factor of a core-shell Prolate ellipsoid at the given x-value p->x |
---|
495 | the ellipsoid has a core-shell structure |
---|
496 | |
---|
497 | */ |
---|
498 | int |
---|
499 | ProlateFormX(FitParamsPtr p) |
---|
500 | { |
---|
501 | double *dp; // Pointer to double precision wave data. |
---|
502 | float *fp; // Pointer to single precision wave data. |
---|
503 | double q; //local variables of coefficient wave |
---|
504 | |
---|
505 | if (p->waveHandle == NIL) { |
---|
506 | SetNaN64(&p->result); |
---|
507 | return NON_EXISTENT_WAVE; |
---|
508 | } |
---|
509 | |
---|
510 | q= p->x; |
---|
511 | |
---|
512 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
513 | case NT_FP32: |
---|
514 | fp= WaveData(p->waveHandle); |
---|
515 | SetNaN64(&p->result); |
---|
516 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
517 | case NT_FP64: |
---|
518 | dp= WaveData(p->waveHandle); |
---|
519 | |
---|
520 | p->result = ProlateForm(dp,q); |
---|
521 | return 0; |
---|
522 | default: // We can't handle this wave data type. |
---|
523 | SetNaN64(&p->result); |
---|
524 | return REQUIRES_SP_OR_DP_WAVE; |
---|
525 | } |
---|
526 | return 0; |
---|
527 | } |
---|
528 | |
---|
529 | |
---|
530 | /* StackedDiscsX : calculates the form factor of a stacked "tactoid" of core shell disks |
---|
531 | like clay platelets that are not exfoliated |
---|
532 | |
---|
533 | */ |
---|
534 | int |
---|
535 | StackedDiscsX(FitParamsPtr p) |
---|
536 | { |
---|
537 | double *dp; // Pointer to double precision wave data. |
---|
538 | float *fp; // Pointer to single precision wave data. |
---|
539 | double q; //local variables of coefficient wave |
---|
540 | |
---|
541 | if (p->waveHandle == NIL) { |
---|
542 | SetNaN64(&p->result); |
---|
543 | return NON_EXISTENT_WAVE; |
---|
544 | } |
---|
545 | |
---|
546 | q= p->x; |
---|
547 | |
---|
548 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
549 | case NT_FP32: |
---|
550 | fp= WaveData(p->waveHandle); |
---|
551 | SetNaN64(&p->result); |
---|
552 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
553 | case NT_FP64: |
---|
554 | dp= WaveData(p->waveHandle); |
---|
555 | p->result = StackedDiscs(dp,q); |
---|
556 | return 0; |
---|
557 | default: // We can't handle this wave data type. |
---|
558 | SetNaN64(&p->result); |
---|
559 | return REQUIRES_SP_OR_DP_WAVE; |
---|
560 | } |
---|
561 | return 0; |
---|
562 | } |
---|
563 | |
---|
564 | |
---|
565 | /* LamellarFFX : calculates the form factor of a lamellar structure - no S(q) effects included |
---|
566 | |
---|
567 | */ |
---|
568 | int |
---|
569 | LamellarFFX(FitParamsPtr p) |
---|
570 | { |
---|
571 | double *dp; // Pointer to double precision wave data. |
---|
572 | float *fp; // Pointer to single precision wave data. |
---|
573 | double q; //local variables of coefficient wave |
---|
574 | |
---|
575 | if (p->waveHandle == NIL) { |
---|
576 | SetNaN64(&p->result); |
---|
577 | return NON_EXISTENT_WAVE; |
---|
578 | } |
---|
579 | |
---|
580 | q= p->x; |
---|
581 | |
---|
582 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
583 | case NT_FP32: |
---|
584 | fp= WaveData(p->waveHandle); |
---|
585 | SetNaN64(&p->result); |
---|
586 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
587 | case NT_FP64: |
---|
588 | dp= WaveData(p->waveHandle); |
---|
589 | p->result = LamellarFF(dp,q); |
---|
590 | return 0; |
---|
591 | default: // We can't handle this wave data type. |
---|
592 | SetNaN64(&p->result); |
---|
593 | return REQUIRES_SP_OR_DP_WAVE; |
---|
594 | } |
---|
595 | return 0; |
---|
596 | } |
---|
597 | |
---|
598 | /* LamellarPSX : calculates the form factor of a lamellar structure - with S(q) effects included |
---|
599 | ------- |
---|
600 | ------- resolution effects ARE included, but only a CONSTANT default value, not the real q-dependent resolution!! |
---|
601 | |
---|
602 | */ |
---|
603 | int |
---|
604 | LamellarPSX(FitParamsPtr p) |
---|
605 | { |
---|
606 | double *dp; // Pointer to double precision wave data. |
---|
607 | float *fp; // Pointer to single precision wave data. |
---|
608 | double q; //local variables of coefficient wave |
---|
609 | |
---|
610 | if (p->waveHandle == NIL) { |
---|
611 | SetNaN64(&p->result); |
---|
612 | return NON_EXISTENT_WAVE; |
---|
613 | } |
---|
614 | |
---|
615 | q= p->x; |
---|
616 | |
---|
617 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
618 | case NT_FP32: |
---|
619 | fp= WaveData(p->waveHandle); |
---|
620 | SetNaN64(&p->result); |
---|
621 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
622 | case NT_FP64: |
---|
623 | dp= WaveData(p->waveHandle); |
---|
624 | p->result = LamellarPS(dp,q); |
---|
625 | return 0; |
---|
626 | default: // We can't handle this wave data type. |
---|
627 | SetNaN64(&p->result); |
---|
628 | return REQUIRES_SP_OR_DP_WAVE; |
---|
629 | } |
---|
630 | return 0; |
---|
631 | } |
---|
632 | |
---|
633 | |
---|
634 | /* LamellarPS_HGX : calculates the form factor of a lamellar structure - with S(q) effects included |
---|
635 | ------- |
---|
636 | ------- resolution effects ARE included, but only a CONSTANT default value, not the real q-dependent resolution!! |
---|
637 | |
---|
638 | */ |
---|
639 | int |
---|
640 | LamellarPS_HGX(FitParamsPtr p) |
---|
641 | { |
---|
642 | double *dp; // Pointer to double precision wave data. |
---|
643 | float *fp; // Pointer to single precision wave data. |
---|
644 | double q; //local variables of coefficient wave |
---|
645 | |
---|
646 | if (p->waveHandle == NIL) { |
---|
647 | SetNaN64(&p->result); |
---|
648 | return NON_EXISTENT_WAVE; |
---|
649 | } |
---|
650 | |
---|
651 | q= p->x; |
---|
652 | |
---|
653 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
654 | case NT_FP32: |
---|
655 | fp= WaveData(p->waveHandle); |
---|
656 | SetNaN64(&p->result); |
---|
657 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
658 | case NT_FP64: |
---|
659 | dp= WaveData(p->waveHandle); |
---|
660 | p->result = LamellarPS_HG(dp,q); |
---|
661 | return 0; |
---|
662 | default: // We can't handle this wave data type. |
---|
663 | SetNaN64(&p->result); |
---|
664 | return REQUIRES_SP_OR_DP_WAVE; |
---|
665 | } |
---|
666 | return 0; |
---|
667 | } |
---|
668 | |
---|
669 | /* LamellarFF_HGX : calculates the form factor of a lamellar structure - no S(q) effects included |
---|
670 | but extra SLD for head groups is included |
---|
671 | |
---|
672 | */ |
---|
673 | int |
---|
674 | LamellarFF_HGX(FitParamsPtr p) |
---|
675 | { |
---|
676 | double *dp; // Pointer to double precision wave data. |
---|
677 | float *fp; // Pointer to single precision wave data. |
---|
678 | double q; //local variables of coefficient wave |
---|
679 | |
---|
680 | if (p->waveHandle == NIL) { |
---|
681 | SetNaN64(&p->result); |
---|
682 | return NON_EXISTENT_WAVE; |
---|
683 | } |
---|
684 | |
---|
685 | q= p->x; |
---|
686 | |
---|
687 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
688 | case NT_FP32: |
---|
689 | fp= WaveData(p->waveHandle); |
---|
690 | SetNaN64(&p->result); |
---|
691 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
692 | case NT_FP64: |
---|
693 | dp= WaveData(p->waveHandle); |
---|
694 | p->result = LamellarFF_HG(dp,q); |
---|
695 | return 0; |
---|
696 | default: // We can't handle this wave data type. |
---|
697 | SetNaN64(&p->result); |
---|
698 | return REQUIRES_SP_OR_DP_WAVE; |
---|
699 | } |
---|
700 | return 0; |
---|
701 | } |
---|
702 | |
---|
703 | /* FlexExclVolCylX : calculates the form factor of a flexible cylinder with a circular cross section |
---|
704 | -- incorporates Wei-Ren Chen's fixes - 2006 |
---|
705 | |
---|
706 | */ |
---|
707 | int |
---|
708 | FlexExclVolCylX(FitParamsPtr p) |
---|
709 | { |
---|
710 | double *dp; // Pointer to double precision wave data. |
---|
711 | float *fp; // Pointer to single precision wave data. |
---|
712 | double q; //local variables of coefficient wave |
---|
713 | |
---|
714 | if (p->waveHandle == NIL) { |
---|
715 | SetNaN64(&p->result); |
---|
716 | return NON_EXISTENT_WAVE; |
---|
717 | } |
---|
718 | |
---|
719 | q= p->x; |
---|
720 | |
---|
721 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
722 | case NT_FP32: |
---|
723 | fp= WaveData(p->waveHandle); |
---|
724 | SetNaN64(&p->result); |
---|
725 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
726 | case NT_FP64: |
---|
727 | dp= WaveData(p->waveHandle); |
---|
728 | p->result = FlexExclVolCyl(dp,q); |
---|
729 | return 0; |
---|
730 | default: // We can't handle this wave data type. |
---|
731 | SetNaN64(&p->result); |
---|
732 | return REQUIRES_SP_OR_DP_WAVE; |
---|
733 | } |
---|
734 | return 0; |
---|
735 | } |
---|
736 | |
---|
737 | /* FlexCyl_EllipX : calculates the form factor of a flexible cylinder with an elliptical cross section |
---|
738 | -- incorporates Wei-Ren Chen's fixes - 2006 |
---|
739 | |
---|
740 | */ |
---|
741 | int |
---|
742 | FlexCyl_EllipX(FitParamsPtr p) |
---|
743 | { |
---|
744 | double *dp; // Pointer to double precision wave data. |
---|
745 | float *fp; // Pointer to single precision wave data. |
---|
746 | double q; //local variables of coefficient wave |
---|
747 | |
---|
748 | if (p->waveHandle == NIL) { |
---|
749 | SetNaN64(&p->result); |
---|
750 | return NON_EXISTENT_WAVE; |
---|
751 | } |
---|
752 | |
---|
753 | q= p->x; |
---|
754 | |
---|
755 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
756 | case NT_FP32: |
---|
757 | fp= WaveData(p->waveHandle); |
---|
758 | SetNaN64(&p->result); |
---|
759 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
760 | case NT_FP64: |
---|
761 | dp= WaveData(p->waveHandle); |
---|
762 | p->result = FlexCyl_Ellip(dp,q); |
---|
763 | return 0; |
---|
764 | default: // We can't handle this wave data type. |
---|
765 | SetNaN64(&p->result); |
---|
766 | return REQUIRES_SP_OR_DP_WAVE; |
---|
767 | } |
---|
768 | return 0; |
---|
769 | } |
---|
770 | |
---|
771 | /* FlexCyl_PolyLenX : calculates the form factor of a flecible cylinder at the given x-value p->x |
---|
772 | the cylinder has a polydisperse Length |
---|
773 | |
---|
774 | */ |
---|
775 | int |
---|
776 | FlexCyl_PolyLenX(FitParamsPtr p) |
---|
777 | { |
---|
778 | double *dp; // Pointer to double precision wave data. |
---|
779 | float *fp; // Pointer to single precision wave data. |
---|
780 | double q; //local variables of coefficient wave |
---|
781 | |
---|
782 | if (p->waveHandle == NIL) { |
---|
783 | SetNaN64(&p->result); |
---|
784 | return NON_EXISTENT_WAVE; |
---|
785 | } |
---|
786 | |
---|
787 | q= p->x; |
---|
788 | |
---|
789 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
790 | case NT_FP32: |
---|
791 | fp= WaveData(p->waveHandle); |
---|
792 | SetNaN64(&p->result); |
---|
793 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
794 | case NT_FP64: |
---|
795 | dp= WaveData(p->waveHandle); |
---|
796 | p->result = FlexCyl_PolyLen(dp,q); |
---|
797 | return 0; |
---|
798 | default: // We can't handle this wave data type. |
---|
799 | SetNaN64(&p->result); |
---|
800 | return REQUIRES_SP_OR_DP_WAVE; |
---|
801 | } |
---|
802 | return 0; |
---|
803 | } |
---|
804 | |
---|
805 | /* FlexCyl_PolyLenX : calculates the form factor of a flexible cylinder at the given x-value p->x |
---|
806 | the cylinder has a polydisperse cross sectional radius |
---|
807 | |
---|
808 | */ |
---|
809 | int |
---|
810 | FlexCyl_PolyRadX(FitParamsPtr p) |
---|
811 | { |
---|
812 | double *dp; // Pointer to double precision wave data. |
---|
813 | float *fp; // Pointer to single precision wave data. |
---|
814 | double q; //local variables of coefficient wave |
---|
815 | |
---|
816 | if (p->waveHandle == NIL) { |
---|
817 | SetNaN64(&p->result); |
---|
818 | return NON_EXISTENT_WAVE; |
---|
819 | } |
---|
820 | |
---|
821 | q= p->x; |
---|
822 | |
---|
823 | switch(WaveType(p->waveHandle)){ // We can handle single and double precision coefficient waves. |
---|
824 | case NT_FP32: |
---|
825 | fp= WaveData(p->waveHandle); |
---|
826 | SetNaN64(&p->result); |
---|
827 | return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 |
---|
828 | case NT_FP64: |
---|
829 | dp= WaveData(p->waveHandle); |
---|
830 | p->result = FlexCyl_PolyRad(dp,q); |
---|
831 | return 0; |
---|
832 | default: // We can't handle this wave data type. |
---|
833 | SetNaN64(&p->result); |
---|
834 | return REQUIRES_SP_OR_DP_WAVE; |
---|
835 | } |
---|
836 | return 0; |
---|
837 | } |
---|
838 | |
---|
839 | #pragma XOP_RESET_STRUCT_PACKING // All structures are 2-byte-aligned. |
---|
840 | // All structures are 2-byte-aligned. |
---|