annotate rDiff/src/locfit/Source/local.h @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 /*
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 * Most of the changes formerly needed here are handled through
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 * the Makefiles and #ifdef's.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 #ifndef I_LF_H
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 #define I_LF_H
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 /*
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 * DIRSEP: '/' for unix; '\\' for DOS
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 #ifdef DOS
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 #define DIRSEP '\\'
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 #else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 #define DIRSEP '/'
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 /*
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 * Some older math libraries have no lgamma() function, and gamma(arg)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 * actually returns log(gamma(arg)). If so, you need to change
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 * LGAMMA macro below.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 #define LGAMMA(arg) lgamma(arg)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 /******** NOTHING BELOW HERE NEEDS CHANGING **********/
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 #include <stdlib.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 #include <stdio.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 #include <string.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 #include <math.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 /*RVERSION*/
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 #ifdef SWINVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 #define SVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 #include "newredef.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 #ifdef RVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 /* #typedef int Sint is defined in R.h */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 #include <R.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 #include <Rdefines.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 #include <Rinternals.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 #define list_elt(ev,i) VECTOR_PTR(ev)[i]
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 #define dval2(ev,i,j) NUMERIC_POINTER(list_elt(ev,i))[j]
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 #define dvec2(ev,i) NUMERIC_POINTER(list_elt(ev,i))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48 #define ivec2(ev,i) INTEGER_POINTER(list_elt(ev,i))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 #undef pmatch
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 #else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 #ifdef SVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 #include <S.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 typedef long int Sint;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 typedef s_object * SEXP;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 #define list_elt(ev,i) LIST_POINTER(ev)[i]
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 #define dval2(ev,i,j) NUMERIC_POINTER(list_elt(ev,i))[j]
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 #define dvec2(ev,i) NUMERIC_POINTER(list_elt(ev,i))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 #define ivec2(ev,i) INTEGER_POINTER(list_elt(ev,i))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 #define ALLOW_MODULES
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 #else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 typedef int Sint;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 #ifdef MATLAB_MEX_FILE
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 #include "mex.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 #define printf mexPrintf
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 #ifdef RVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 #undef LGAMMA
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75 #define LGAMMA(arg) Rf_lgammafn(arg)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 extern double Rf_lgammafn();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 #define SVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 #include "mutil.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 #include "tube.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
83 #include "lfcons.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
84
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
85 typedef char varname[15];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
86
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
87 #ifdef CVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
88 #include "cversion.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
89 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
90
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
91 #include "lfstruc.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
92 #include "design.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
93 #include "lffuns.h"
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
94
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
95 #ifdef CVERSION
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
96 #undef printf
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
97 #define printf lfprintf
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
98 extern int lfprintf(const char *format, ...);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
99 extern int printe(const char *format, ...);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
100 #else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
101 #define printe printf
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
102 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
103
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
104 #ifdef ERROR
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
105 #undef ERROR
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
106 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
107
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
108 #ifdef WARN
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
109 #undef WARN
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
110 #endif
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
111
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
112 #define ERROR(args) {printe("Error: "); printe args; printe("\n"); lf_error=1;}
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
113 #define WARN(args) {printe("Warning: "); printe args; printe("\n"); }
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
114
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
115 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
116 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
117 #define SGN(x) (((x)>0) ? 1 : -1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
118 #define SQR(x) ((x)*(x))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
119 #define NOSLN 0.1278433
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
120 #define GFACT 2.5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
121 #define EFACT 3.0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
122
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
123 #define MAXCOLOR 20
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
124 #define MAXWIN 5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
125
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
126 #define ISWAP(a,b) { int zz; zz = a; a = b; b = zz; }
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
127 extern int lf_error;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
128
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
129 #endif /* I_LF_H */