UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
matrix.h
1 #ifndef __matrix_h
2 #define __matrix_h
3 
4 #include <stdio.h>
5 
6 /*
7 *-----------------------------------------------------------------------------
8 * file: matrix.h
9 * desc: matrix mathematics header file
10 * by: ko shu pui, patrick
11 * date: 24 nov 91 v0.1b
12 * revi:
13 * ref:
14 * [1] Mary L.Boas, "Mathematical Methods in the Physical Sciene,"
15 * John Wiley & Sons, 2nd Ed., 1983. Chap 3.
16 *
17 *-----------------------------------------------------------------------------
18 */
19 
20 /*
21 *-----------------------------------------------------------------------------
22 * internal matrix structure
23 *-----------------------------------------------------------------------------
24 */
25 typedef struct {
26  int row;
27  int col;
28  } MATHEAD;
29 
30 typedef struct {
31  MATHEAD head;
32  /*
33  * only the starting address of the following will be
34  * returned to the C programmer, like malloc() concept
35  */
36  double *matrix;
37  } MATBODY;
38 
39 typedef double **MATRIX;
40 
41 #define Mathead(a) ((MATHEAD *)((MATHEAD *)(a) - 1))
42 #define MatRow(a) (Mathead(a)->row)
43 #define MatCol(a) (Mathead(a)->col)
44 
45 /*
46 *----------------------------------------------------------------------------
47 * mat_errors definitions
48 *----------------------------------------------------------------------------
49 */
50 #define MAT_MALLOC 1
51 #define MAT_FNOTOPEN 2
52 #define MAT_FNOTGETMAT 3
53 
54 /*
55 *----------------------------------------------------------------------------
56 * matrice types
57 *----------------------------------------------------------------------------
58 */
59 #define UNDEFINED -1
60 #define ZERO_MATRIX 0
61 #define UNIT_MATRIX 1
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif /* __cplusplus */
66 
67 /* prototypes of matrix package */
68 MATRIX mat_error (int);
69 MATRIX _mat_creat (int, int);
70 MATRIX mat_creat (int, int, int);
71 MATRIX mat_fill (MATRIX, int);
72 int mat_free (MATRIX);
73 MATRIX mat_copy (MATRIX);
74 MATRIX mat_colcopy1 (MATRIX, MATRIX, int, int);
75 int fgetmat (MATRIX, FILE *);
76 MATRIX mat_dump (MATRIX);
77 MATRIX mat_dumpf (MATRIX, char *);
78 MATRIX mat_fdump (MATRIX, FILE *);
79 MATRIX mat_fdumpf (MATRIX, char *, FILE *);
80 
81 MATRIX mat_add (MATRIX, MATRIX);
82 MATRIX mat_sub (MATRIX, MATRIX);
83 MATRIX mat_mul (MATRIX, MATRIX);
84 double mat_diagmul (MATRIX);
85 MATRIX mat_tran (MATRIX);
86 MATRIX mat_inv (MATRIX);
87 MATRIX mat_SymToeplz (MATRIX);
88 
89 int mat_lu (MATRIX, MATRIX);
90 MATRIX mat_backsubs1 (MATRIX, MATRIX, MATRIX, MATRIX, int);
91 MATRIX mat_lsolve (MATRIX, MATRIX);
92 
93 MATRIX mat_submat (MATRIX, int, int);
94 double mat_cofact (MATRIX, int, int);
95 double mat_det (MATRIX);
96 double mat_minor (MATRIX, int, int);
97 
98 MATRIX mat_durbin (MATRIX);
99 MATRIX mat_lsolve_durbin (MATRIX, MATRIX);
100 
101 #ifdef __cplusplus
102 };
103 #endif /* __cplusplus */
104 
105 #endif /* __matrix_h */
106 
Definition: matrix.h:25
Definition: matrix.h:30