1 /****************************************************************************/
2 /*                                 matrix.h                                 */
3 /****************************************************************************/
4 /*                                                                          */
5 /* type MATRIX                                                              */
6 /*                                                                          */
7 /* Copyright (C) 1992-1996 Tomas Skalicky. All rights reserved.             */
8 /*                                                                          */
9 /****************************************************************************/
10 /*                                                                          */
11 /*        ANY USE OF THIS CODE CONSTITUTES ACCEPTANCE OF THE TERMS          */
12 /*              OF THE COPYRIGHT NOTICE (SEE FILE COPYRGHT.H)               */
13 /*                                                                          */
14 /****************************************************************************/
15 
16 #ifndef MATRIX_H
17 #define MATRIX_H
18 
19 #include "laspack_config.h"
20 #ifdef _LP_INCLUDED_FROM_CPLUSPLUS
21 extern "C" {
22 #endif
23 
24 
25 #include <stdlib.h>
26 
27 #include "lastypes.h"
28 #include "elcmp.h"
29 #include "copyrght.h"
30 
31 typedef struct {
32     char *Name;
33     size_t RowDim;
34     size_t ClmDim;
35     ElOrderType ElOrder;
36     InstanceType Instance;
37     int LockLevel;
38     _LPDouble Multipl;
39     _LPBoolean OwnData;
40     size_t *Len;
41     ElType **El;
42     _LPBoolean *ElSorted;
43 } Matrix;
44 
45 void M_Constr(Matrix *M, const char *Name, size_t RowDim, size_t ClmDim,
46               ElOrderType ElOrder, InstanceType Instance, _LPBoolean OwnData);
47 void M_Destr(Matrix *M);
48 void M_SetName(Matrix *M, const char *Name);
49 const char *M_GetName(const Matrix *M);
50 size_t M_GetRowDim(const Matrix *M);
51 size_t M_GetClmDim(const Matrix *M);
52 ElOrderType M_GetElOrder(const Matrix *M);
53 void M_SetLen(Matrix *M, size_t RoC, size_t Len);
54 size_t M_GetLen(const Matrix *M, size_t RoC);
55 void M_SetEntry(Matrix *M, size_t RoC, size_t Entry, size_t Pos, _LPNumber Val);
56 size_t M_GetPos(const Matrix *M, size_t RoC, size_t Entry);
57 _LPNumber M_GetVal(const Matrix *M, size_t RoC, size_t Entry);
58 void M_AddVal(Matrix *M, size_t RoC, size_t Entry, _LPNumber Val);
59 
60 /* macros for fast access */
61 #define     M__GetLen(PtrM, RoC)               (PtrM)->Len[RoC]
62 #define     M__SetEntry(PtrM, RoC, Entry, Pos_, Val_) { \
63                 (PtrM)->El[RoC][Entry].Pos = (Pos_); \
64                 (PtrM)->El[RoC][Entry].Val = (Val_); \
65             }
66 #define     M__GetPos(PtrM, RoC, Entry)        (PtrM)->El[RoC][Entry].Pos
67 #define     M__GetVal(PtrM, RoC, Entry)        (PtrM)->El[RoC][Entry].Val
68 #define     M__AddVal(PtrM, RoC, Entry, Val_) { \
69                 (PtrM)->El[RoC][Entry].Val += (Val_); \
70             }
71 
72 _LPNumber M_GetEl(Matrix *M, size_t Row, size_t Clm);
73 
74 void M_SortEl(Matrix *M);
75 
76 void M_Lock(Matrix *M);
77 void M_Unlock(Matrix *M);
78 
79 #ifdef _LP_INCLUDED_FROM_CPLUSPLUS
80 }
81 #endif
82 
83 #endif /* MATRIX_H */
84