Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmergrid/src/metis-5.1.0/GKlib/gk_struct.h
3206 views
1
/*!
2
\file gk_struct.h
3
\brief This file contains various datastructures used/provided by GKlib
4
5
\date Started 3/27/2007
6
\author George
7
\version\verbatim $Id: gk_struct.h 13005 2012-10-23 22:34:36Z karypis $ \endverbatim
8
*/
9
10
#ifndef _GK_STRUCT_H_
11
#define _GK_STRUCT_H_
12
13
14
/********************************************************************/
15
/*! Generator for gk_??KeyVal_t data structure */
16
/********************************************************************/
17
#define GK_MKKEYVALUE_T(NAME, KEYTYPE, VALTYPE) \
18
typedef struct {\
19
KEYTYPE key;\
20
VALTYPE val;\
21
} NAME;\
22
23
/* The actual KeyVal data structures */
24
GK_MKKEYVALUE_T(gk_ckv_t, char, ssize_t)
25
GK_MKKEYVALUE_T(gk_ikv_t, int, ssize_t)
26
GK_MKKEYVALUE_T(gk_i32kv_t, int32_t, ssize_t)
27
GK_MKKEYVALUE_T(gk_i64kv_t, int64_t, ssize_t)
28
GK_MKKEYVALUE_T(gk_zkv_t, ssize_t, ssize_t)
29
GK_MKKEYVALUE_T(gk_fkv_t, float, ssize_t)
30
GK_MKKEYVALUE_T(gk_dkv_t, double, ssize_t)
31
GK_MKKEYVALUE_T(gk_skv_t, char *, ssize_t)
32
GK_MKKEYVALUE_T(gk_idxkv_t, gk_idx_t, gk_idx_t)
33
34
35
36
/********************************************************************/
37
/*! Generator for gk_?pq_t data structure */
38
/********************************************************************/
39
#define GK_MKPQUEUE_T(NAME, KVTYPE)\
40
typedef struct {\
41
gk_idx_t nnodes;\
42
gk_idx_t maxnodes;\
43
\
44
/* Heap version of the data structure */ \
45
KVTYPE *heap;\
46
gk_idx_t *locator;\
47
} NAME;\
48
49
GK_MKPQUEUE_T(gk_ipq_t, gk_ikv_t)
50
GK_MKPQUEUE_T(gk_i32pq_t, gk_i32kv_t)
51
GK_MKPQUEUE_T(gk_i64pq_t, gk_i64kv_t)
52
GK_MKPQUEUE_T(gk_fpq_t, gk_fkv_t)
53
GK_MKPQUEUE_T(gk_dpq_t, gk_dkv_t)
54
GK_MKPQUEUE_T(gk_idxpq_t, gk_idxkv_t)
55
56
57
#define GK_MKPQUEUE2_T(NAME, KTYPE, VTYPE)\
58
typedef struct {\
59
ssize_t nnodes;\
60
ssize_t maxnodes;\
61
\
62
/* Heap version of the data structure */ \
63
KTYPE *keys;\
64
VTYPE *vals;\
65
} NAME;\
66
67
68
69
/*-------------------------------------------------------------
70
* The following data structure stores a sparse CSR format
71
*-------------------------------------------------------------*/
72
typedef struct gk_csr_t {
73
int32_t nrows, ncols;
74
ssize_t *rowptr, *colptr;
75
int32_t *rowind, *colind;
76
int32_t *rowids, *colids;
77
float *rowval, *colval;
78
float *rnorms, *cnorms;
79
float *rsums, *csums;
80
float *rsizes, *csizes;
81
float *rvols, *cvols;
82
float *rwgts, *cwgts;
83
} gk_csr_t;
84
85
86
/*-------------------------------------------------------------
87
* The following data structure stores a sparse graph
88
*-------------------------------------------------------------*/
89
typedef struct gk_graph_t {
90
int32_t nvtxs; /*!< The number of vertices in the graph */
91
ssize_t *xadj; /*!< The ptr-structure of the adjncy list */
92
int32_t *adjncy; /*!< The adjacency list of the graph */
93
int32_t *iadjwgt; /*!< The integer edge weights */
94
float *fadjwgt; /*!< The floating point edge weights */
95
int32_t *ivwgts; /*!< The integer vertex weights */
96
float *fvwgts; /*!< The floating point vertex weights */
97
int32_t *ivsizes; /*!< The integer vertex sizes */
98
float *fvsizes; /*!< The floating point vertex sizes */
99
int32_t *vlabels; /*!< The labels of the vertices */
100
} gk_graph_t;
101
102
103
/*-------------------------------------------------------------
104
* The following data structure stores stores a string as a
105
* pair of its allocated buffer and the buffer itself.
106
*-------------------------------------------------------------*/
107
typedef struct gk_str_t {
108
size_t len;
109
char *buf;
110
} gk_str_t;
111
112
113
114
115
/*-------------------------------------------------------------
116
* The following data structure implements a string-2-int mapping
117
* table used for parsing command-line options
118
*-------------------------------------------------------------*/
119
typedef struct gk_StringMap_t {
120
char *name;
121
int id;
122
} gk_StringMap_t;
123
124
125
/*------------------------------------------------------------
126
* This structure implements a simple hash table
127
*------------------------------------------------------------*/
128
typedef struct gk_HTable_t {
129
int nelements; /* The overall size of the hash-table */
130
int htsize; /* The current size of the hash-table */
131
gk_ikv_t *harray; /* The actual hash-table */
132
} gk_HTable_t;
133
134
135
/*------------------------------------------------------------
136
* This structure implements a gk_Tokens_t list returned by the
137
* string tokenizer
138
*------------------------------------------------------------*/
139
typedef struct gk_Tokens_t {
140
int ntoks; /* The number of tokens in the input string */
141
char *strbuf; /* The memory that stores all the entries */
142
char **list; /* Pointers to the strbuf for each element */
143
} gk_Tokens_t;
144
145
/*------------------------------------------------------------
146
* This structure implements storage for an atom in a pdb file
147
*------------------------------------------------------------*/
148
typedef struct atom {
149
int serial;
150
char *name;
151
char altLoc;
152
char *resname;
153
char chainid;
154
int rserial;
155
char icode;
156
char element;
157
double x;
158
double y;
159
double z;
160
double opcy;
161
double tmpt;
162
} atom;
163
164
165
/*------------------------------------------------------------
166
* This structure implements storage for a center of mass for
167
* a single residue.
168
*------------------------------------------------------------*/
169
typedef struct center_of_mass {
170
char name;
171
double x;
172
double y;
173
double z;
174
} center_of_mass;
175
176
177
/*------------------------------------------------------------
178
* This structure implements storage for a pdb protein
179
*------------------------------------------------------------*/
180
typedef struct pdbf {
181
int natoms; /* Number of atoms */
182
int nresidues; /* Number of residues based on coordinates */
183
int ncas;
184
int nbbs;
185
int corruption;
186
char *resSeq; /* Residue sequence based on coordinates */
187
char **threeresSeq; /* three-letter residue sequence */
188
atom *atoms;
189
atom **bbs;
190
atom **cas;
191
center_of_mass *cm;
192
} pdbf;
193
194
195
196
/*************************************************************
197
* Localization Structures for converting characters to integers
198
**************************************************************/
199
typedef struct gk_i2cc2i_t {
200
int n;
201
char *i2c;
202
int *c2i;
203
} gk_i2cc2i_t;
204
205
206
/*******************************************************************
207
*This structure implements storage of a protein sequence
208
* *****************************************************************/
209
typedef struct gk_seq_t {
210
211
int len; /*Number of Residues */
212
int *sequence; /* Stores the sequence*/
213
214
215
int **pssm; /* Stores the pssm matrix */
216
int **psfm; /* Stores the psfm matrix */
217
char *name; /* Stores the name of the sequence */
218
219
int nsymbols;
220
221
222
} gk_seq_t;
223
224
225
226
227
/*************************************************************************/
228
/*! The following data structure stores information about a memory
229
allocation operation that can either be served from gk_mcore_t or by
230
a gk_malloc if not sufficient workspace memory is available. */
231
/*************************************************************************/
232
typedef struct gk_mop_t {
233
int type;
234
ssize_t nbytes;
235
void *ptr;
236
} gk_mop_t;
237
238
239
/*************************************************************************/
240
/*! The following structure stores information used by Metis */
241
/*************************************************************************/
242
typedef struct gk_mcore_t {
243
/* Workspace information */
244
size_t coresize; /*!< The amount of core memory that has been allocated */
245
size_t corecpos; /*!< Index of the first free location in core */
246
void *core; /*!< Pointer to the core itself */
247
248
/* These are for implementing a stack-based allocation scheme using both
249
core and also dynamically allocated memory */
250
size_t nmops; /*!< The number of maop_t entries that have been allocated */
251
size_t cmop; /*!< Index of the first free location in maops */
252
gk_mop_t *mops; /*!< The array recording the maop_t operations */
253
254
/* These are for keeping various statistics for wspacemalloc */
255
size_t num_callocs; /*!< The number of core mallocs */
256
size_t num_hallocs; /*!< The number of heap mallocs */
257
size_t size_callocs; /*!< The total # of bytes in core mallocs */
258
size_t size_hallocs; /*!< The total # of bytes in heap mallocs */
259
size_t cur_callocs; /*!< The current # of bytes in core mallocs */
260
size_t cur_hallocs; /*!< The current # of bytes in heap mallocs */
261
size_t max_callocs; /*!< The maximum # of bytes in core mallocs at any given time */
262
size_t max_hallocs; /*!< The maximum # of bytes in heap mallocs at any given time */
263
264
} gk_mcore_t;
265
266
267
268
#endif
269
270