la.h 4.0 KB

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