source: sans/Analysis/branches/ajj_23APR07/XOPs/SANSAnalysis/XOP/TwoPhase.c @ 102

Last change on this file since 102 was 102, checked in by ajj, 16 years ago

Switched to generic library header so that the XOP code doesn't have redundant defines for internal library functions.

File size: 8.8 KB
Line 
1/*      TwoPhaseFit.c
2
3*/
4
5#pragma XOP_SET_STRUCT_PACKING                  // All structures are 2-byte-aligned.
6
7#include "XOPStandardHeaders.h"                 // Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h
8#include "SANSAnalysis.h"
9#include "libSANSAnalysis.h"
10#include "TwoPhase.h"
11
12// scattering from the Teubner-Strey model for microemulsions - hardly needs to be an XOP...
13int
14TeubnerStreyModelX(FitParamsPtr p)
15{
16        double *dp;                             // Pointer to double precision wave data.
17        float *fp;                              // Pointer to single precision wave data.
18        double q;
19       
20        if (p->waveHandle == NIL) {
21                SetNaN64(&p->result);
22                return NON_EXISTENT_WAVE;
23        }
24   
25        q = p->x;
26       
27        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
28                case NT_FP32:
29                        fp= WaveData(p->waveHandle);
30            SetNaN64(&p->result);
31                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07           
32                case NT_FP64:
33                        dp= WaveData(p->waveHandle);
34                        p->result = TeubnerStreyModel(dp,q);                                                                                                                           
35                        return 0;
36                default:                                                                // We can't handle this wave data type.
37                        SetNaN64(&p->result);
38                        return REQUIRES_SP_OR_DP_WAVE;
39        }
40       
41        return 0;
42}
43
44int
45Power_Law_ModelX(FitParamsPtr p)
46{
47        double *dp;                             // Pointer to double precision wave data.
48        float *fp;                              // Pointer to single precision wave data.
49        double q;
50       
51        if (p->waveHandle == NIL) {
52                SetNaN64(&p->result);
53                return NON_EXISTENT_WAVE;
54        }
55       
56        q= p->x;
57       
58        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
59                case NT_FP32:
60                        fp= WaveData(p->waveHandle);
61                        SetNaN64(&p->result);
62                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
63                case NT_FP64:
64                        dp= WaveData(p->waveHandle);
65                        p->result = Power_Law_Model(dp,q);
66                        return 0;
67                default:                                                                // We can't handle this wave data type.
68                        SetNaN64(&p->result);
69                        return REQUIRES_SP_OR_DP_WAVE;
70        }
71       
72        return 0;
73}
74
75
76int
77Peak_Lorentz_ModelX(FitParamsPtr p)
78{
79        double *dp;                             // Pointer to double precision wave data.
80        float *fp;                              // Pointer to single precision wave data.
81        double q;
82       
83        if (p->waveHandle == NIL) {
84                SetNaN64(&p->result);
85                return NON_EXISTENT_WAVE;
86        }
87       
88        q= p->x;
89       
90        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
91                case NT_FP32:
92                        fp= WaveData(p->waveHandle);
93                        SetNaN64(&p->result);
94                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
95                case NT_FP64:
96                        dp= WaveData(p->waveHandle);
97                        p->result = Peak_Lorentz_Model(dp,q);
98                        return 0;
99                default:                                                                // We can't handle this wave data type.
100                        SetNaN64(&p->result);
101                        return REQUIRES_SP_OR_DP_WAVE;
102        }
103       
104        return 0;
105}
106
107int
108Peak_Gauss_ModelX(FitParamsPtr p)
109{
110        double *dp;                             // Pointer to double precision wave data.
111        float *fp;                              // Pointer to single precision wave data.
112        double q;
113       
114        if (p->waveHandle == NIL) {
115                SetNaN64(&p->result);
116                return NON_EXISTENT_WAVE;
117        }
118       
119        q= p->x;
120       
121        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
122                case NT_FP32:
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                        p->result = Peak_Gauss_Model(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
138int
139Lorentz_ModelX(FitParamsPtr p)
140{
141        double *dp;                             // Pointer to double precision wave data.
142        float *fp;                              // Pointer to single precision wave data.
143        double q;
144       
145        if (p->waveHandle == NIL) {
146                SetNaN64(&p->result);
147                return NON_EXISTENT_WAVE;
148        }
149       
150        q= p->x;
151       
152        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
153                case NT_FP32:
154                        fp= WaveData(p->waveHandle);
155                        SetNaN64(&p->result);
156                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
157                case NT_FP64:
158                        dp= WaveData(p->waveHandle);
159                        p->result=Lorentz_Model(dp,q);
160                        return 0;
161                default:                                                                // We can't handle this wave data type.
162                        SetNaN64(&p->result);
163                        return REQUIRES_SP_OR_DP_WAVE;
164        }
165       
166        return 0;
167}
168
169int
170FractalX(FitParamsPtr p)
171{
172        double *dp;                             // Pointer to double precision wave data.
173        float *fp;                              // Pointer to single precision wave data.
174        double q;
175       
176        if (p->waveHandle == NIL) {
177                SetNaN64(&p->result);
178                return NON_EXISTENT_WAVE;
179        }
180       
181        q= p->x;
182       
183        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
184                case NT_FP32:
185                        fp= WaveData(p->waveHandle);           
186                        SetNaN64(&p->result);
187                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
188                case NT_FP64:
189                        dp= WaveData(p->waveHandle);
190            p->result = Fractal(dp,q);
191                        return 0;
192                default:                                                                // We can't handle this wave data type.
193                        SetNaN64(&p->result);
194                        return REQUIRES_SP_OR_DP_WAVE;
195        }
196       
197        return 0;
198}
199
200int
201DAB_ModelX(FitParamsPtr p)
202{
203        double *dp;                             // Pointer to double precision wave data.
204        float *fp;                              // Pointer to single precision wave data.
205        double q;
206       
207        if (p->waveHandle == NIL) {
208                SetNaN64(&p->result);
209                return NON_EXISTENT_WAVE;
210        }
211       
212        q= p->x;
213       
214        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
215                case NT_FP32:
216                        fp= WaveData(p->waveHandle);
217                        SetNaN64(&p->result);
218                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
219                case NT_FP64:
220                        dp= WaveData(p->waveHandle);
221                        p->result = DAB_Model(dp,q);
222                        return 0;
223                default:                                                                // We can't handle this wave data type.
224                        SetNaN64(&p->result);
225                        return REQUIRES_SP_OR_DP_WAVE;
226        }
227       
228        return 0;
229}
230
231// G. Beaucage's Unified Model (1-4 levels)
232//
233int
234OneLevelX(FitParamsPtr p)
235{
236        double *dp;                             // Pointer to double precision wave data.
237        float *fp;                              // Pointer to single precision wave data.
238        double q;
239       
240        if (p->waveHandle == NIL) {
241                SetNaN64(&p->result);
242                return NON_EXISTENT_WAVE;
243        }
244       
245        q= p->x;
246       
247        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
248                case NT_FP32:
249                        fp= WaveData(p->waveHandle);
250                        SetNaN64(&p->result);
251                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
252                case NT_FP64:
253                        dp= WaveData(p->waveHandle);
254                        p-> result = OneLevel(dp,q);
255                        return 0;
256                default:                                                                // We can't handle this wave data type.
257                        SetNaN64(&p->result);
258                        return REQUIRES_SP_OR_DP_WAVE;
259        }
260       
261        return 0;
262}
263
264// G. Beaucage's Unified Model (1-4 levels)
265//
266int
267TwoLevelX(FitParamsPtr p)
268{
269        double *dp;                             // Pointer to double precision wave data.
270        float *fp;                              // Pointer to single precision wave data.
271        double q;
272       
273        if (p->waveHandle == NIL) {
274                SetNaN64(&p->result);
275                return NON_EXISTENT_WAVE;
276        }
277       
278        q= p->x;
279       
280        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
281                case NT_FP32:
282                        fp= WaveData(p->waveHandle);
283                        SetNaN64(&p->result);
284                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
285                case NT_FP64:
286                        dp= WaveData(p->waveHandle);
287                        p->result = TwoLevel(dp, q);
288                        return 0;
289                default:                                                                // We can't handle this wave data type.
290                        SetNaN64(&p->result);
291                        return REQUIRES_SP_OR_DP_WAVE;
292        }
293       
294        return 0;
295}
296
297// G. Beaucage's Unified Model (1-4 levels)
298//
299int
300ThreeLevelX(FitParamsPtr p)
301{
302        double *dp;                             // Pointer to double precision wave data.
303        float *fp;                              // Pointer to single precision wave data.
304        double q;
305       
306        if (p->waveHandle == NIL) {
307                SetNaN64(&p->result);
308                return NON_EXISTENT_WAVE;
309        }
310       
311        q= p->x;
312       
313        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
314                case NT_FP32:
315                        fp= WaveData(p->waveHandle);
316                        SetNaN64(&p->result);
317                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07 
318                case NT_FP64:
319                        dp= WaveData(p->waveHandle);
320                        p->result = ThreeLevel(dp, q);
321                        return 0;
322                default:                                                                // We can't handle this wave data type.
323                        SetNaN64(&p->result);
324                        return REQUIRES_SP_OR_DP_WAVE;
325        }
326       
327        return 0;
328}
329
330// G. Beaucage's Unified Model (1-4 levels)
331//
332int
333FourLevelX(FitParamsPtr p)
334{
335        double *dp;                             // Pointer to double precision wave data.
336        float *fp;                              // Pointer to single precision wave data.
337        double q;
338       
339        if (p->waveHandle == NIL) {
340                SetNaN64(&p->result);
341                return NON_EXISTENT_WAVE;
342        }
343       
344        q= p->x;
345       
346        switch(WaveType(p->waveHandle)){                        // We can handle single and double precision coefficient waves.
347                case NT_FP32:
348                        fp= WaveData(p->waveHandle);
349                        SetNaN64(&p->result);
350                        return REQUIRES_SP_OR_DP_WAVE; //not quite true, but good enough for now AJJ 4/23/07                   
351                case NT_FP64:
352                        dp= WaveData(p->waveHandle);
353                        p->result = FourLevel(dp,q);
354                        return 0;
355                default:                                                                // We can't handle this wave data type.
356                        SetNaN64(&p->result);
357                        return REQUIRES_SP_OR_DP_WAVE;
358        }
359       
360        return 0;
361}
362
363#pragma XOP_RESET_STRUCT_PACKING                        // All structures are 2-byte-aligned.
364
365///////////end of XOP
366
367
Note: See TracBrowser for help on using the repository browser.