source: sans/XOP_Dev/SANSAnalysis/XOP/Cylinder.c @ 357

Last change on this file since 357 was 357, checked in by srkline, 15 years ago

made Lamellar_PS and Lamellar_PS_HG resolution independent, to allow normal resolution smearing

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