Path: blob/devel/elmergrid/src/metis-5.1.0/GKlib/gk_struct.h
3206 views
/*!1\file gk_struct.h2\brief This file contains various datastructures used/provided by GKlib34\date Started 3/27/20075\author George6\version\verbatim $Id: gk_struct.h 13005 2012-10-23 22:34:36Z karypis $ \endverbatim7*/89#ifndef _GK_STRUCT_H_10#define _GK_STRUCT_H_111213/********************************************************************/14/*! Generator for gk_??KeyVal_t data structure */15/********************************************************************/16#define GK_MKKEYVALUE_T(NAME, KEYTYPE, VALTYPE) \17typedef struct {\18KEYTYPE key;\19VALTYPE val;\20} NAME;\2122/* The actual KeyVal data structures */23GK_MKKEYVALUE_T(gk_ckv_t, char, ssize_t)24GK_MKKEYVALUE_T(gk_ikv_t, int, ssize_t)25GK_MKKEYVALUE_T(gk_i32kv_t, int32_t, ssize_t)26GK_MKKEYVALUE_T(gk_i64kv_t, int64_t, ssize_t)27GK_MKKEYVALUE_T(gk_zkv_t, ssize_t, ssize_t)28GK_MKKEYVALUE_T(gk_fkv_t, float, ssize_t)29GK_MKKEYVALUE_T(gk_dkv_t, double, ssize_t)30GK_MKKEYVALUE_T(gk_skv_t, char *, ssize_t)31GK_MKKEYVALUE_T(gk_idxkv_t, gk_idx_t, gk_idx_t)32333435/********************************************************************/36/*! Generator for gk_?pq_t data structure */37/********************************************************************/38#define GK_MKPQUEUE_T(NAME, KVTYPE)\39typedef struct {\40gk_idx_t nnodes;\41gk_idx_t maxnodes;\42\43/* Heap version of the data structure */ \44KVTYPE *heap;\45gk_idx_t *locator;\46} NAME;\4748GK_MKPQUEUE_T(gk_ipq_t, gk_ikv_t)49GK_MKPQUEUE_T(gk_i32pq_t, gk_i32kv_t)50GK_MKPQUEUE_T(gk_i64pq_t, gk_i64kv_t)51GK_MKPQUEUE_T(gk_fpq_t, gk_fkv_t)52GK_MKPQUEUE_T(gk_dpq_t, gk_dkv_t)53GK_MKPQUEUE_T(gk_idxpq_t, gk_idxkv_t)545556#define GK_MKPQUEUE2_T(NAME, KTYPE, VTYPE)\57typedef struct {\58ssize_t nnodes;\59ssize_t maxnodes;\60\61/* Heap version of the data structure */ \62KTYPE *keys;\63VTYPE *vals;\64} NAME;\65666768/*-------------------------------------------------------------69* The following data structure stores a sparse CSR format70*-------------------------------------------------------------*/71typedef struct gk_csr_t {72int32_t nrows, ncols;73ssize_t *rowptr, *colptr;74int32_t *rowind, *colind;75int32_t *rowids, *colids;76float *rowval, *colval;77float *rnorms, *cnorms;78float *rsums, *csums;79float *rsizes, *csizes;80float *rvols, *cvols;81float *rwgts, *cwgts;82} gk_csr_t;838485/*-------------------------------------------------------------86* The following data structure stores a sparse graph87*-------------------------------------------------------------*/88typedef struct gk_graph_t {89int32_t nvtxs; /*!< The number of vertices in the graph */90ssize_t *xadj; /*!< The ptr-structure of the adjncy list */91int32_t *adjncy; /*!< The adjacency list of the graph */92int32_t *iadjwgt; /*!< The integer edge weights */93float *fadjwgt; /*!< The floating point edge weights */94int32_t *ivwgts; /*!< The integer vertex weights */95float *fvwgts; /*!< The floating point vertex weights */96int32_t *ivsizes; /*!< The integer vertex sizes */97float *fvsizes; /*!< The floating point vertex sizes */98int32_t *vlabels; /*!< The labels of the vertices */99} gk_graph_t;100101102/*-------------------------------------------------------------103* The following data structure stores stores a string as a104* pair of its allocated buffer and the buffer itself.105*-------------------------------------------------------------*/106typedef struct gk_str_t {107size_t len;108char *buf;109} gk_str_t;110111112113114/*-------------------------------------------------------------115* The following data structure implements a string-2-int mapping116* table used for parsing command-line options117*-------------------------------------------------------------*/118typedef struct gk_StringMap_t {119char *name;120int id;121} gk_StringMap_t;122123124/*------------------------------------------------------------125* This structure implements a simple hash table126*------------------------------------------------------------*/127typedef struct gk_HTable_t {128int nelements; /* The overall size of the hash-table */129int htsize; /* The current size of the hash-table */130gk_ikv_t *harray; /* The actual hash-table */131} gk_HTable_t;132133134/*------------------------------------------------------------135* This structure implements a gk_Tokens_t list returned by the136* string tokenizer137*------------------------------------------------------------*/138typedef struct gk_Tokens_t {139int ntoks; /* The number of tokens in the input string */140char *strbuf; /* The memory that stores all the entries */141char **list; /* Pointers to the strbuf for each element */142} gk_Tokens_t;143144/*------------------------------------------------------------145* This structure implements storage for an atom in a pdb file146*------------------------------------------------------------*/147typedef struct atom {148int serial;149char *name;150char altLoc;151char *resname;152char chainid;153int rserial;154char icode;155char element;156double x;157double y;158double z;159double opcy;160double tmpt;161} atom;162163164/*------------------------------------------------------------165* This structure implements storage for a center of mass for166* a single residue.167*------------------------------------------------------------*/168typedef struct center_of_mass {169char name;170double x;171double y;172double z;173} center_of_mass;174175176/*------------------------------------------------------------177* This structure implements storage for a pdb protein178*------------------------------------------------------------*/179typedef struct pdbf {180int natoms; /* Number of atoms */181int nresidues; /* Number of residues based on coordinates */182int ncas;183int nbbs;184int corruption;185char *resSeq; /* Residue sequence based on coordinates */186char **threeresSeq; /* three-letter residue sequence */187atom *atoms;188atom **bbs;189atom **cas;190center_of_mass *cm;191} pdbf;192193194195/*************************************************************196* Localization Structures for converting characters to integers197**************************************************************/198typedef struct gk_i2cc2i_t {199int n;200char *i2c;201int *c2i;202} gk_i2cc2i_t;203204205/*******************************************************************206*This structure implements storage of a protein sequence207* *****************************************************************/208typedef struct gk_seq_t {209210int len; /*Number of Residues */211int *sequence; /* Stores the sequence*/212213214int **pssm; /* Stores the pssm matrix */215int **psfm; /* Stores the psfm matrix */216char *name; /* Stores the name of the sequence */217218int nsymbols;219220221} gk_seq_t;222223224225226/*************************************************************************/227/*! The following data structure stores information about a memory228allocation operation that can either be served from gk_mcore_t or by229a gk_malloc if not sufficient workspace memory is available. */230/*************************************************************************/231typedef struct gk_mop_t {232int type;233ssize_t nbytes;234void *ptr;235} gk_mop_t;236237238/*************************************************************************/239/*! The following structure stores information used by Metis */240/*************************************************************************/241typedef struct gk_mcore_t {242/* Workspace information */243size_t coresize; /*!< The amount of core memory that has been allocated */244size_t corecpos; /*!< Index of the first free location in core */245void *core; /*!< Pointer to the core itself */246247/* These are for implementing a stack-based allocation scheme using both248core and also dynamically allocated memory */249size_t nmops; /*!< The number of maop_t entries that have been allocated */250size_t cmop; /*!< Index of the first free location in maops */251gk_mop_t *mops; /*!< The array recording the maop_t operations */252253/* These are for keeping various statistics for wspacemalloc */254size_t num_callocs; /*!< The number of core mallocs */255size_t num_hallocs; /*!< The number of heap mallocs */256size_t size_callocs; /*!< The total # of bytes in core mallocs */257size_t size_hallocs; /*!< The total # of bytes in heap mallocs */258size_t cur_callocs; /*!< The current # of bytes in core mallocs */259size_t cur_hallocs; /*!< The current # of bytes in heap mallocs */260size_t max_callocs; /*!< The maximum # of bytes in core mallocs at any given time */261size_t max_hallocs; /*!< The maximum # of bytes in heap mallocs at any given time */262263} gk_mcore_t;264265266267#endif268269270