local.h 2.4 KB

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