00001
00010 #ifndef _GK_PROTO_H_
00011 #define _GK_PROTO_H_
00012
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016
00017
00018
00019
00020 GK_MKBLAS_PROTO(gk_c, char, int)
00021 GK_MKBLAS_PROTO(gk_i, int, int)
00022 GK_MKBLAS_PROTO(gk_i32, int32_t, int32_t)
00023 GK_MKBLAS_PROTO(gk_i64, int64_t, int64_t)
00024 GK_MKBLAS_PROTO(gk_z, ssize_t, ssize_t)
00025 GK_MKBLAS_PROTO(gk_f, float, float)
00026 GK_MKBLAS_PROTO(gk_d, double, double)
00027 GK_MKBLAS_PROTO(gk_idx, gk_idx_t, gk_idx_t)
00028
00029
00030
00031
00032
00033
00034
00035 FILE *gk_fopen(char *, char *, const char *);
00036 void gk_fclose(FILE *);
00037 gk_idx_t gk_getline(char **lineptr, size_t *n, FILE *stream);
00038 char **gk_readfile(char *fname, gk_idx_t *r_nlines);
00039 int32_t *gk_i32readfile(char *fname, gk_idx_t *r_nlines);
00040 int64_t *gk_i64readfile(char *fname, gk_idx_t *r_nlines);
00041 int32_t *gk_i32readfilebin(char *fname, ssize_t *r_nelmnts);
00042 int64_t *gk_i64readfilebin(char *fname, ssize_t *r_nelmnts);
00043 float *gk_freadfilebin(char *fname, ssize_t *r_nelmnts);
00044 size_t gk_fwritefilebin(char *fname, size_t n, float *a);
00045 double *gk_dreadfilebin(char *fname, ssize_t *r_nelmnts);
00046
00047
00048
00049
00050
00051
00052
00053 int gk_fexists(char *);
00054 int gk_dexists(char *);
00055 intmax_t gk_getfsize(char *);
00056 void gk_getfilestats(char *fname, size_t *r_nlines, size_t *r_ntokens,
00057 size_t *r_max_nlntokens, size_t *r_nbytes);
00058 char *gk_getbasename(char *path);
00059 char *gk_getextname(char *path);
00060 char *gk_getfilename(char *path);
00061 char *gk_getpathname(char *path);
00062 int gk_mkpath(char *);
00063 int gk_rmpath(char *);
00064
00065
00066
00067
00068
00069
00070 GK_MKALLOC_PROTO(gk_c, char)
00071 GK_MKALLOC_PROTO(gk_i, int)
00072 GK_MKALLOC_PROTO(gk_i32, int32_t)
00073 GK_MKALLOC_PROTO(gk_i64, int64_t)
00074 GK_MKALLOC_PROTO(gk_z, ssize_t)
00075 GK_MKALLOC_PROTO(gk_f, float)
00076 GK_MKALLOC_PROTO(gk_d, double)
00077 GK_MKALLOC_PROTO(gk_idx, gk_idx_t)
00078
00079 GK_MKALLOC_PROTO(gk_ckv, gk_ckv_t)
00080 GK_MKALLOC_PROTO(gk_ikv, gk_ikv_t)
00081 GK_MKALLOC_PROTO(gk_i32kv, gk_i32kv_t)
00082 GK_MKALLOC_PROTO(gk_i64kv, gk_i64kv_t)
00083 GK_MKALLOC_PROTO(gk_zkv, gk_zkv_t)
00084 GK_MKALLOC_PROTO(gk_fkv, gk_fkv_t)
00085 GK_MKALLOC_PROTO(gk_dkv, gk_dkv_t)
00086 GK_MKALLOC_PROTO(gk_skv, gk_skv_t)
00087 GK_MKALLOC_PROTO(gk_idxkv, gk_idxkv_t)
00088
00089 void gk_AllocMatrix(void ***, size_t, size_t , size_t);
00090 void gk_FreeMatrix(void ***, size_t, size_t);
00091 int gk_malloc_init();
00092 void gk_malloc_cleanup(int showstats);
00093 void *gk_malloc(size_t nbytes, char *msg);
00094 void *gk_realloc(void *oldptr, size_t nbytes, char *msg);
00095 void gk_free(void **ptr1,...);
00096 size_t gk_GetCurMemoryUsed();
00097 size_t gk_GetMaxMemoryUsed();
00098
00099
00100
00101
00102
00103
00104 gk_seq_t *gk_seq_ReadGKMODPSSM(char *file_name);
00105 gk_i2cc2i_t *gk_i2cc2i_create_common(char *alphabet);
00106 void gk_seq_init(gk_seq_t *seq);
00107
00108
00109
00110
00111
00112
00113
00114 char gk_threetoone(char *res);
00115 void gk_freepdbf(pdbf *p);
00116 pdbf *gk_readpdbfile(char *fname);
00117 void gk_writefullatom(pdbf *p, char *fname);
00118 void gk_writebackbone(pdbf *p, char *fname);
00119 void gk_writealphacarbons(pdbf *p, char *fname);
00120 void gk_showcorruption(pdbf *p);
00121
00122
00123
00124
00125
00126 void gk_set_exit_on_error(int value);
00127 void errexit(char *,...);
00128 void gk_errexit(int signum, char *,...);
00129 int gk_sigtrap();
00130 int gk_siguntrap();
00131 void gk_sigthrow(int signum);
00132 void gk_SetSignalHandlers();
00133 void gk_UnsetSignalHandlers();
00134 void gk_NonLocalExit_Handler(int signum);
00135 char *gk_strerror(int errnum);
00136 void PrintBackTrace();
00137
00138
00139
00140
00141
00142 void gk_RandomPermute(size_t, int *, int);
00143 void gk_array2csr(size_t n, size_t range, int *array, int *ptr, int *ind);
00144 int gk_log2(int);
00145 int gk_ispow2(int);
00146 float gk_flog2(float);
00147
00148
00149
00150
00151
00152 gk_wclock_t gk_WClockSeconds(void);
00153 double gk_CPUSeconds(void);
00154
00155
00156
00157
00158 char *gk_strchr_replace(char *str, char *fromlist, char *tolist);
00159 int gk_strstr_replace(char *str, char *pattern, char *replacement, char *options, char **new_str);
00160 char *gk_strtprune(char *, char *);
00161 char *gk_strhprune(char *, char *);
00162 char *gk_strtoupper(char *);
00163 char *gk_strtolower(char *);
00164 char *gk_strdup(char *orgstr);
00165 int gk_strcasecmp(char *s1, char *s2);
00166 int gk_strrcmp(char *s1, char *s2);
00167 char *gk_time2str(time_t time);
00168 time_t gk_str2time(char *str);
00169 int gk_GetStringID(gk_StringMap_t *strmap, char *key);
00170
00171
00172
00173
00174
00175
00176 void gk_csorti(size_t, char *);
00177 void gk_csortd(size_t, char *);
00178 void gk_isorti(size_t, int *);
00179 void gk_isortd(size_t, int *);
00180 void gk_fsorti(size_t, float *);
00181 void gk_fsortd(size_t, float *);
00182 void gk_dsorti(size_t, double *);
00183 void gk_dsortd(size_t, double *);
00184 void gk_idxsorti(size_t, gk_idx_t *);
00185 void gk_idxsortd(size_t, gk_idx_t *);
00186 void gk_ckvsorti(size_t, gk_ckv_t *);
00187 void gk_ckvsortd(size_t, gk_ckv_t *);
00188 void gk_ikvsorti(size_t, gk_ikv_t *);
00189 void gk_ikvsortd(size_t, gk_ikv_t *);
00190 void gk_i32kvsorti(size_t, gk_i32kv_t *);
00191 void gk_i32kvsortd(size_t, gk_i32kv_t *);
00192 void gk_i64kvsorti(size_t, gk_i64kv_t *);
00193 void gk_i64kvsortd(size_t, gk_i64kv_t *);
00194 void gk_zkvsorti(size_t, gk_zkv_t *);
00195 void gk_zkvsortd(size_t, gk_zkv_t *);
00196 void gk_fkvsorti(size_t, gk_fkv_t *);
00197 void gk_fkvsortd(size_t, gk_fkv_t *);
00198 void gk_dkvsorti(size_t, gk_dkv_t *);
00199 void gk_dkvsortd(size_t, gk_dkv_t *);
00200 void gk_skvsorti(size_t, gk_skv_t *);
00201 void gk_skvsortd(size_t, gk_skv_t *);
00202 void gk_idxkvsorti(size_t, gk_idxkv_t *);
00203 void gk_idxkvsortd(size_t, gk_idxkv_t *);
00204
00205
00206
00207
00208
00209 int gk_dfkvkselect(size_t, int, gk_fkv_t *);
00210 int gk_ifkvkselect(size_t, int, gk_fkv_t *);
00211
00212
00213
00214
00215
00216 GK_MKPQUEUE_PROTO(gk_ipq, gk_ipq_t, int, gk_idx_t)
00217 GK_MKPQUEUE_PROTO(gk_i32pq, gk_i32pq_t, int32_t, gk_idx_t)
00218 GK_MKPQUEUE_PROTO(gk_i64pq, gk_i64pq_t, int64_t, gk_idx_t)
00219 GK_MKPQUEUE_PROTO(gk_fpq, gk_fpq_t, float, gk_idx_t)
00220 GK_MKPQUEUE_PROTO(gk_dpq, gk_dpq_t, double, gk_idx_t)
00221 GK_MKPQUEUE_PROTO(gk_idxpq, gk_idxpq_t, gk_idx_t, gk_idx_t)
00222
00223
00224
00225
00226
00227 gk_HTable_t *HTable_Create(int nelements);
00228 void HTable_Reset(gk_HTable_t *htable);
00229 void HTable_Resize(gk_HTable_t *htable, int nelements);
00230 void HTable_Insert(gk_HTable_t *htable, int key, int val);
00231 void HTable_Delete(gk_HTable_t *htable, int key);
00232 int HTable_Search(gk_HTable_t *htable, int key);
00233 int HTable_GetNext(gk_HTable_t *htable, int key, int *val, int type);
00234 int HTable_SearchAndDelete(gk_HTable_t *htable, int key);
00235 void HTable_Destroy(gk_HTable_t *htable);
00236 int HTable_HFunction(int nelements, int key);
00237
00238
00239
00240
00241
00242 void gk_strtokenize(char *line, char *delim, gk_Tokens_t *tokens);
00243 void gk_freetokenslist(gk_Tokens_t *tokens);
00244
00245
00246
00247
00248 void encodeblock(unsigned char *in, unsigned char *out);
00249 void decodeblock(unsigned char *in, unsigned char *out);
00250 void GKEncodeBase64(int nbytes, unsigned char *inbuffer, unsigned char *outbuffer);
00251 void GKDecodeBase64(int nbytes, unsigned char *inbuffer, unsigned char *outbuffer);
00252
00253
00254
00255
00256
00257 GK_MKRANDOM_PROTO(gk_c, size_t, char)
00258 GK_MKRANDOM_PROTO(gk_i, size_t, int)
00259 GK_MKRANDOM_PROTO(gk_f, size_t, float)
00260 GK_MKRANDOM_PROTO(gk_d, size_t, double)
00261 GK_MKRANDOM_PROTO(gk_idx, size_t, gk_idx_t)
00262 GK_MKRANDOM_PROTO(gk_z, size_t, ssize_t)
00263 void gk_randinit(uint64_t);
00264 uint64_t gk_randint64(void);
00265 uint32_t gk_randint32(void);
00266
00267
00268
00269
00270
00271 #if !defined(__OPENMP__)
00272 void omp_set_num_threads(int num_threads);
00273 int omp_get_num_threads(void);
00274 int omp_get_max_threads(void);
00275 int omp_get_thread_num(void);
00276 int omp_get_num_procs(void);
00277 int omp_in_parallel(void);
00278 void omp_set_dynamic(int num_threads);
00279 int omp_get_dynamic(void);
00280 void omp_set_nested(int nested);
00281 int omp_get_nested(void);
00282 #endif
00283
00284
00285
00286
00287
00288 gk_csr_t *gk_csr_Create();
00289 void gk_csr_Init(gk_csr_t *mat);
00290 void gk_csr_Free(gk_csr_t **mat);
00291 void gk_csr_FreeContents(gk_csr_t *mat);
00292 gk_csr_t *gk_csr_Dup(gk_csr_t *mat);
00293 gk_csr_t *gk_csr_ExtractSubmatrix(gk_csr_t *mat, int rstart, int nrows);
00294 gk_csr_t *gk_csr_ExtractRows(gk_csr_t *mat, int nrows, int *rind);
00295 gk_csr_t *gk_csr_ExtractPartition(gk_csr_t *mat, int *part, int pid);
00296 gk_csr_t **gk_csr_Split(gk_csr_t *mat, int *color);
00297 gk_csr_t *gk_csr_Read(char *filename, int format, int readvals, int numbering);
00298 void gk_csr_Write(gk_csr_t *mat, char *filename, int format, int writevals, int numbering);
00299 gk_csr_t *gk_csr_Prune(gk_csr_t *mat, int what, int minf, int maxf);
00300 gk_csr_t *gk_csr_LowFilter(gk_csr_t *mat, int what, int norm, float fraction);
00301 gk_csr_t *gk_csr_TopKPlusFilter(gk_csr_t *mat, int what, int topk, float keepval);
00302 gk_csr_t *gk_csr_ZScoreFilter(gk_csr_t *mat, int what, float zscore);
00303 void gk_csr_CompactColumns(gk_csr_t *mat);
00304 void gk_csr_SortIndices(gk_csr_t *mat, int what);
00305 void gk_csr_CreateIndex(gk_csr_t *mat, int what);
00306 void gk_csr_Normalize(gk_csr_t *mat, int what, int norm);
00307 void gk_csr_Scale(gk_csr_t *mat, int type);
00308 void gk_csr_ComputeSums(gk_csr_t *mat, int what);
00309 void gk_csr_ComputeSquaredNorms(gk_csr_t *mat, int what);
00310 float gk_csr_ComputeSimilarity(gk_csr_t *mat, int i1, int i2, int what, int simtype);
00311 int gk_csr_GetSimilarRows(gk_csr_t *mat, int nqterms, int *qind, float *qval,
00312 int simtype, int nsim, float minsim, gk_fkv_t *hits, int *_imarker,
00313 gk_fkv_t *i_cand);
00314
00315
00316
00317
00318 void gk_find_frequent_itemsets(int ntrans, ssize_t *tranptr, int *tranind,
00319 int minfreq, int maxfreq, int minlen, int maxlen,
00320 void (*process_itemset)(void *stateptr, int nitems, int *itemind,
00321 int ntrans, int *tranind),
00322 void *stateptr);
00323
00324
00325
00326 float ComputeAccuracy(int n, gk_fkv_t *list);
00327 float ComputeROCn(int n, int maxN, gk_fkv_t *list);
00328 float ComputeMedianRFP(int n, gk_fkv_t *list);
00329 float ComputeMean (int n, float *values);
00330 float ComputeStdDev(int n, float *values);
00331
00332
00333
00334 gk_mcore_t *gk_mcoreCreate(size_t coresize);
00335 gk_mcore_t *gk_gkmcoreCreate();
00336 void gk_mcoreDestroy(gk_mcore_t **r_mcore, int showstats);
00337 void gk_gkmcoreDestroy(gk_mcore_t **r_mcore, int showstats);
00338 void *gk_mcoreMalloc(gk_mcore_t *mcore, size_t nbytes);
00339 void gk_mcorePush(gk_mcore_t *mcore);
00340 void gk_gkmcorePush(gk_mcore_t *mcore);
00341 void gk_mcorePop(gk_mcore_t *mcore);
00342 void gk_gkmcorePop(gk_mcore_t *mcore);
00343 void gk_mcoreAdd(gk_mcore_t *mcore, int type, size_t nbytes, void *ptr);
00344 void gk_gkmcoreAdd(gk_mcore_t *mcore, int type, size_t nbytes, void *ptr);
00345 void gk_mcoreDel(gk_mcore_t *mcore, void *ptr);
00346 void gk_gkmcoreDel(gk_mcore_t *mcore, void *ptr);
00347
00348
00349 int gk_rw_PageRank(gk_csr_t *mat, float lamda, float eps, int max_niter, float *pr);
00350
00351
00352
00353 gk_graph_t *gk_graph_Create();
00354 void gk_graph_Init(gk_graph_t *graph);
00355 void gk_graph_Free(gk_graph_t **graph);
00356 void gk_graph_FreeContents(gk_graph_t *graph);
00357 gk_graph_t *gk_graph_Read(char *filename, int format, int isfewgts,
00358 int isfvwgts, int isfvsizes);
00359 void gk_graph_Write(gk_graph_t *graph, char *filename, int format);
00360 gk_graph_t *gk_graph_Dup(gk_graph_t *graph);
00361 gk_graph_t *gk_graph_ExtractSubgraph(gk_graph_t *graph, int vstart, int nvtxs);
00362 gk_graph_t *gk_graph_Reorder(gk_graph_t *graph, int32_t *perm, int32_t *iperm);
00363 int gk_graph_FindComponents(gk_graph_t *graph, int32_t *cptr, int32_t *cind);
00364 void gk_graph_ComputeBFSOrdering(gk_graph_t *graph, int v, int32_t **r_perm,
00365 int32_t **r_iperm);
00366 void gk_graph_ComputeBestFOrdering0(gk_graph_t *graph, int v, int type,
00367 int32_t **r_perm, int32_t **r_iperm);
00368 void gk_graph_ComputeBestFOrdering(gk_graph_t *graph, int v, int type,
00369 int32_t **r_perm, int32_t **r_iperm);
00370 void gk_graph_SingleSourceShortestPaths(gk_graph_t *graph, int v, void **r_sps);
00371
00372
00373
00374
00375 #ifdef __cplusplus
00376 }
00377 #endif
00378
00379
00380 #endif
00381