1 | /* |
---|
2 | * MonteCarlo.h |
---|
3 | * SANSAnalysis |
---|
4 | * |
---|
5 | * Created by Steve Kline on 10/16/08. |
---|
6 | * Copyright 2008 __MyCompanyName__. All rights reserved. |
---|
7 | * |
---|
8 | */ |
---|
9 | |
---|
10 | #include <math.h> |
---|
11 | #include <ctype.h> |
---|
12 | |
---|
13 | #include <stdlib.h> |
---|
14 | #include <stdio.h> |
---|
15 | |
---|
16 | #ifdef _WIN32 |
---|
17 | #include <float.h> |
---|
18 | #include "winFuncs.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | /* Prototypes */ |
---|
22 | // for TK6 |
---|
23 | HOST_IMPORT int main(IORecHandle ioRecHandle); |
---|
24 | |
---|
25 | |
---|
26 | //#define OLD_IGOR 1 + FIRST_XOP_ERR |
---|
27 | #define NON_EXISTENT_WAVE 2 + FIRST_XOP_ERR |
---|
28 | #define NEEDS_2D_WAVE 3 + FIRST_XOP_ERR |
---|
29 | |
---|
30 | |
---|
31 | // All structures passed to Igor are two-byte aligned. |
---|
32 | #pragma pack(2) |
---|
33 | |
---|
34 | struct MC_Params { // This structure must be 2-byte-aligned because it receives parameters from Igor. |
---|
35 | waveHndl resultsH; // results of MC |
---|
36 | waveHndl MC_linear_dataH; //this is a 2D WAVE |
---|
37 | waveHndl nnH; |
---|
38 | waveHndl j2H; |
---|
39 | waveHndl j1H; |
---|
40 | waveHndl ntH; |
---|
41 | waveHndl ran_devH; |
---|
42 | waveHndl inputWaveH; |
---|
43 | void* tp; //unused void for ThreadSafe functions |
---|
44 | double retVal; // return value is unused, save for error if needed |
---|
45 | }; |
---|
46 | typedef struct MC_Params MC_Params; |
---|
47 | typedef struct MC_Params *MC_ParamsPtr; |
---|
48 | |
---|
49 | #pragma pack() // return to default structure packing |
---|
50 | |
---|
51 | // function prototypes |
---|
52 | int Monte_SANSX(MC_ParamsPtr p); |
---|
53 | int Monte_SANSX2(MC_ParamsPtr p); |
---|
54 | int Monte_SANSX3(MC_ParamsPtr p); |
---|
55 | int Monte_SANSX4(MC_ParamsPtr p); |
---|
56 | |
---|
57 | long MC_round(double x); |
---|
58 | int FindPixel(double testQ, double testPhi, double lam, double yg_d, double sdd, double pixSize, double xCtr, double yCtr, long *xPixel, long *yPixel); |
---|
59 | int NewDirection(double *vx, double *vy, double *vz, double theta, double phi); |
---|
60 | double path_len(double aval, double sig_tot); |
---|
61 | float ran1(long *idum); |
---|
62 | float ran3(long *idum); |
---|
63 | float ran1a(long *idum); |
---|
64 | float ran3a(long *idum); |
---|
65 | double locate_interp(double xx[], long n, double x); |
---|