la.h 4.2 KB

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