CAFE
Computational Analysis of gene Family Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
birthdeath.h
Go to the documentation of this file.
1 #ifndef __BIRTHDEATH_H__
2 #define __BIRTHDEATH_H__
3 
4 #include <assert.h>
5 #include "hashtable.h"
6 #include "chooseln_cache.h"
7 
8 struct square_matrix {
9  double *values;
10  int size;
11 };
12 void square_matrix_init(struct square_matrix* matrix, int sz);
13 void square_matrix_set(struct square_matrix* matrix, int x, int y, double val);
14 void square_matrix_resize(struct square_matrix* matrix, int new_size);
15 void square_matrix_multiply(struct square_matrix* matrix, double *vector, int row_start, int row_end, int col_start, int col_end, double *result);
16 
17 static inline double square_matrix_get(struct square_matrix *matrix, int x, int y)
18 {
19  assert(x < matrix->size);
20  assert(y < matrix->size);
21  return matrix->values[x*matrix->size+y];
22 }
23 
24 
25 
27 {
29  double lambda;
30  double mu;
31 };
32 
39 typedef struct
40 {
46 
48 extern double birthdeath_likelihood_with_s_c(int s, int c, double branchlength, double lambda, double mu, struct chooseln_cache *cache);
49 extern struct square_matrix* compute_birthdeath_rates( double branchlength, double lambda, double mu, int maxFamilysize );
50 struct square_matrix* birthdeath_cache_get_matrix(pBirthDeathCacheArray pbdc_array, double branchlength, double lambda, double mu );
51 extern void thread_run(int numthreads, void* (*run)(void*), void* param, int size );
52 double birthdeath_rate_with_log_alpha(int s, int c, double log_alpha, double coeff, struct chooseln_cache *cache);
53 extern void birthdeath_cache_resize(pBirthDeathCacheArray pbdc_array, int remaxFamilysize);
55 #endif
struct square_matrix * compute_birthdeath_rates(double branchlength, double lambda, double mu, int maxFamilysize)
Definition: birthdeath.c:238
int maxFamilysize
Definition: birthdeath.h:43
void birthdeath_cache_array_free(pBirthDeathCacheArray pbdc_array)
Definition: birthdeath.c:345
int size
Definition: birthdeath.h:10
void birthdeath_cache_resize(pBirthDeathCacheArray pbdc_array, int remaxFamilysize)
Definition: birthdeath.c:316
Definition: birthdeath.h:8
Definition: birthdeath.h:26
double * values
Definition: birthdeath.h:9
pBirthDeathCacheArray birthdeath_cache_init(int size, struct chooseln_cache *ln_cache)
Definition: birthdeath.c:331
void square_matrix_init(struct square_matrix *matrix, int sz)
Definition: birthdeath.c:121
hash_table_t * table
Definition: birthdeath.h:42
void square_matrix_resize(struct square_matrix *matrix, int new_size)
Definition: birthdeath.c:139
double lambda
Definition: birthdeath.h:29
struct chooseln_cache cache
A cache of values of chooseln.
Definition: birthdeath.c:32
A cache of values of chooseln.
Definition: chooseln_cache.h:16
BirthDeathCacheArray * pBirthDeathCacheArray
Definition: birthdeath.h:45
void square_matrix_set(struct square_matrix *matrix, int x, int y, double val)
Definition: birthdeath.c:127
int branchlength
Definition: birthdeath.h:28
void thread_run(int numthreads, void *(*run)(void *), void *param, int size)
Definition: cafe_main.c:62
struct square_matrix * birthdeath_cache_get_matrix(pBirthDeathCacheArray pbdc_array, double branchlength, double lambda, double mu)
Definition: birthdeath.c:363
A cache of values of family size transition probabilities.
Definition: birthdeath.h:39
std::vector< std::vector< double > > matrix
Definition: branch_cutting.h:11
double birthdeath_rate_with_log_alpha(int s, int c, double log_alpha, double coeff, struct chooseln_cache *cache)
Definition: birthdeath.c:52
a simple hash table implementation
identifies the hashtable for which operations are to be performed
Definition: hashtable.h:64
double birthdeath_likelihood_with_s_c(int s, int c, double branchlength, double lambda, double mu, struct chooseln_cache *cache)
Calculates the probability of transitioning from root_family_size to family_size. ...
Definition: birthdeath.c:79
void square_matrix_multiply(struct square_matrix *matrix, double *vector, int row_start, int row_end, int col_start, int col_end, double *result)
Definition: birthdeath.c:163
double mu
Definition: birthdeath.h:30