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