la.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /**
  2. * \file la.h
  3. *
  4. * \brief Wrapper headers for BLAS/LAPACK.
  5. *
  6. * This program is free software under the GNU General Public License
  7. * (>=v2). Read the file COPYING that comes with GRASS for details.
  8. *
  9. * \author David D. Gray, ddgray@armacde.demon co uk
  10. * \author GRASS GIS Development Team
  11. *
  12. * \date 2000-2007
  13. */
  14. #ifndef HAVE_LIBBLAS
  15. #error GRASS GIS is not configured with BLAS (la.h cannot be included)
  16. #endif
  17. #ifndef HAVE_LIBLAPACK
  18. #error GRASS GIS is not configured with LAPACK (la.h cannot be included)
  19. #endif
  20. #ifndef GRASS_LA_H
  21. #define GRASS_LA_H
  22. /* QUESTION: On some systems there appears to be no default link
  23. to this. Do we create a symlink to
  24. /usr/lib/gcc-lib/<platform>/<vers_num>/include/g2c.h
  25. or link to any old f2c.h that happens to hanging around?
  26. A job for autoconf
  27. [Also a consideration for -lg2c]
  28. */
  29. #include <grass/config.h>
  30. #include <stdio.h>
  31. #ifdef HAVE_G2C_H
  32. typedef int __g77_integer;
  33. typedef unsigned int __g77_uinteger;
  34. typedef long int __g77_longint;
  35. typedef unsigned long int __g77_ulongint;
  36. #include <g2c.h>
  37. #else /* for gcc4+ */
  38. typedef int integer;
  39. typedef unsigned int uinteger;
  40. typedef char *address;
  41. typedef short shortint;
  42. typedef float real;
  43. typedef double doublereal;
  44. typedef struct
  45. {
  46. real r, i;
  47. } complex;
  48. typedef struct
  49. {
  50. doublereal r, i;
  51. } doublecomplex;
  52. typedef int logical;
  53. typedef short shortlogical;
  54. typedef char logical1;
  55. typedef char integer1;
  56. typedef long longint;
  57. typedef unsigned long ulongint;
  58. /* IO stuff */
  59. typedef int ftnlen;
  60. /* procedure parameter types for -A */
  61. typedef int (*U_fp) ();
  62. typedef shortint(*J_fp) ();
  63. typedef integer(*I_fp) ();
  64. typedef real(*R_fp) ();
  65. typedef doublereal(*D_fp) (), (*E_fp) ();
  66. typedef void (*C_fp) ();
  67. typedef void (*Z_fp) ();
  68. typedef logical(*L_fp) ();
  69. typedef shortlogical(*K_fp) ();
  70. typedef void (*H_fp) ();
  71. typedef int (*S_fp) ();
  72. /* E_fp is for real functions when -R is not specified */
  73. typedef void C_f; /* complex function */
  74. typedef void H_f; /* character function */
  75. typedef void Z_f; /* double complex function */
  76. typedef doublereal E_f; /* real function with -R not specified */
  77. #endif /* HAVE_G2C_H */
  78. /* The following may have to be selectively installed according
  79. to platform, at least partly
  80. */
  81. #if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK)
  82. #include <grass/blas.h>
  83. #include <grass/lapack.h>
  84. #endif
  85. /* Useful defines */
  86. #define MAX_POS 1 /* Indicates maximum value */
  87. #define MAX_NEG -1 /* Indicates minimum value */
  88. #define MAX_ABS 0 /* Indicates absolute value */
  89. #define DO_COMPACT 0 /* Eliminate unnecessary rows (cols) in matrix */
  90. #define NO_COMPACT 1 /* ... or not */
  91. /* define macros for fortran symbols (called directly). Needed because
  92. of platform invariance on fortran->C symbol translations
  93. */
  94. #if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK)
  95. #define f77_dgesv dgesv_
  96. #define f77_dgemm dgemm_
  97. #define f77_dnrm2 dnrm2_
  98. #endif
  99. /* Operations should know type of coefficient matrix, so that
  100. they can call the right driver
  101. */
  102. typedef enum
  103. { NONSYM, SYM, HERMITIAN } mat_type;
  104. typedef enum
  105. { MATRIX_, ROWVEC_, COLVEC_ } mat_spec;
  106. typedef enum
  107. { RVEC, CVEC } vtype;
  108. /************************************************************
  109. * *
  110. * A general matrix wrapper for use with BLAS / LAPACK *
  111. * routines, and perhaps elsewhere *
  112. * *
  113. ************************************************************/
  114. typedef struct matrix_
  115. {
  116. mat_spec type; /* matrix, row vector or column vector? */
  117. int v_indx; /* If a vector, which row(column) is active?
  118. * If a matrix this is ignored. If value is < 0,
  119. * the first row(column) is assumed, ie. index 0. */
  120. int rows, cols; /* Rows and columns of matrix */
  121. int ldim; /* Lead dimension of matrix. How many `rows' are
  122. * alloc'ed? May exceed real number of rows `rows' */
  123. doublereal *vals; /* The values (should be dimensioned to lda * cols */
  124. int is_init; /* Is matrix initialised: values array
  125. * is allocated and parameters set ? */
  126. } mat_struct;
  127. typedef mat_struct vec_struct;
  128. #include <grass/defs/la.h>
  129. #endif /* GRASS_LA_H */