| 1 | /* |
|---|
| 2 | * util.h |
|---|
| 3 | * |
|---|
| 4 | * |
|---|
| 5 | * Part of TREE-PUZZLE 5.0 (June 2000) |
|---|
| 6 | * |
|---|
| 7 | * (c) 1999-2000 by Heiko A. Schmidt, Korbinian Strimmer, |
|---|
| 8 | * M. Vingron, and Arndt von Haeseler |
|---|
| 9 | * (c) 1995-1999 by Korbinian Strimmer and Arndt von Haeseler |
|---|
| 10 | * |
|---|
| 11 | * All parts of the source except where indicated are distributed under |
|---|
| 12 | * the GNU public licence. See http://www.opensource.org for details. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #ifndef _UTIL_ |
|---|
| 17 | #define _UTIL_ |
|---|
| 18 | |
|---|
| 19 | #include <stdio.h> |
|---|
| 20 | #include <stdlib.h> |
|---|
| 21 | #include <math.h> |
|---|
| 22 | #include <time.h> |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | /* |
|---|
| 26 | * general definitions |
|---|
| 27 | */ |
|---|
| 28 | |
|---|
| 29 | #define TRUE 1 |
|---|
| 30 | #define FALSE 0 |
|---|
| 31 | |
|---|
| 32 | #ifdef PARALLEL |
|---|
| 33 | extern long int PP_randn; |
|---|
| 34 | extern long int PP_rand; |
|---|
| 35 | #endif |
|---|
| 36 | |
|---|
| 37 | /* |
|---|
| 38 | * type definitions |
|---|
| 39 | */ |
|---|
| 40 | |
|---|
| 41 | typedef unsigned long int uli; |
|---|
| 42 | |
|---|
| 43 | typedef double *dvector, **dmatrix, ***dcube; |
|---|
| 44 | typedef char *cvector, **cmatrix, ***ccube; |
|---|
| 45 | typedef int *ivector, **imatrix, ***icube; |
|---|
| 46 | typedef uli *ulivector, **ulimatrix, ***ulicube; |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | /* |
|---|
| 50 | * prototypes of functions defined in util.c |
|---|
| 51 | */ |
|---|
| 52 | |
|---|
| 53 | void maerror(const char *message); |
|---|
| 54 | |
|---|
| 55 | dvector new_dvector(int n); |
|---|
| 56 | dmatrix new_dmatrix(int nrow, int ncol); |
|---|
| 57 | dcube new_dcube(int ntri, int nrow, int ncol); |
|---|
| 58 | void free_dvector(dvector v); |
|---|
| 59 | void free_dmatrix(dmatrix m); |
|---|
| 60 | void free_dcube(dcube c); |
|---|
| 61 | |
|---|
| 62 | cvector new_cvector(int n); |
|---|
| 63 | cmatrix new_cmatrix(int nrow, int ncol); |
|---|
| 64 | ccube new_ccube(int ntri, int nrow, int ncol); |
|---|
| 65 | void free_cvector(cvector v); |
|---|
| 66 | void free_cmatrix(cmatrix m); |
|---|
| 67 | void free_ccube(ccube c); |
|---|
| 68 | |
|---|
| 69 | ivector new_ivector(int n); |
|---|
| 70 | imatrix new_imatrix(int nrow, int ncol); |
|---|
| 71 | icube new_icube(int ntri, int nrow, int ncol); |
|---|
| 72 | void free_ivector(ivector v); |
|---|
| 73 | void free_imatrix(imatrix m); |
|---|
| 74 | void free_icube(icube c); |
|---|
| 75 | |
|---|
| 76 | ulivector new_ulivector(int n); |
|---|
| 77 | ulimatrix new_ulimatrix(int nrow, int ncol); |
|---|
| 78 | ulicube new_ulicube(int ntri, int nrow, int ncol); |
|---|
| 79 | void free_ulivector(ulivector v); |
|---|
| 80 | void free_ulimatrix(ulimatrix m); |
|---|
| 81 | void free_ulicube(ulicube c); |
|---|
| 82 | |
|---|
| 83 | double randomunitinterval(void); |
|---|
| 84 | int initrandom(int seed); |
|---|
| 85 | int randominteger(int n); |
|---|
| 86 | void chooser(int t, int s, ivector slist); |
|---|
| 87 | void *myrealloc(void *, size_t); |
|---|
| 88 | cvector mygets(void); |
|---|
| 89 | |
|---|
| 90 | #define MAXITS 10 /* maximum number of iterations in twoedimenmin */ |
|---|
| 91 | double onedimenmin(double, double, double, double (*f )(double ), double, double *, double *); |
|---|
| 92 | void twodimenmin(double, int, double, double *, double, double (*func1 )(double ), double *, int, double, double *, double, double (*func2 )(double ), double *); |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | #endif |
|---|