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