1 #ifndef __UEP__
2 #define __UEP__
3 /* unique event polymorphism UEP
4  (c) Peter Beerli 2013
5  Permission is hereby granted, free of charge, to any person obtaining
6  a copy of this software and associated documentation files (the
7  "Software"), to deal in the Software without restriction, including
8  without limitation the rights to use, copy, modify, merge, publish,
9  distribute, sublicense, and/or sell copies of the Software, and to
10  permit persons to whom the Software is furnished to do so, subject
11  to the following conditions:
12 
13  The above copyright notice and this permission notice shall be
14  included in all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
20  ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 
24 */
25 #ifdef UEP
26 
27 #include "migration.h"
28 #include "tree.h"
29 
30 extern void alloc_ueplike (MYREAL ***ueplike, long size,
31                                MYREAL *****ueplikestore, long storesize,
32                                long ****ueprootstore, long numpop, long loci);
33 extern void alloc_ueptime (ueptime_fmt ** ueptime, long size,
34                                ueptime_fmt **** ueptimestore, long storesize,
35                                long numpop, long loci);
36 
37 extern void allocate_uep (node * p, world_fmt * world, char datatype,
38                               boolean withtips);
39 
40 extern void destroy_uep(world_fmt * world, long storesize);
41 
42 
43 extern void constrain_distance_uep (int **uep, long uepsites, MYREAL **distm,
44                                         long tips);
45 extern void make_uep_values (world_fmt * world, data_fmt * data, long locus);
46 extern void update_uep (node * p, world_fmt * world);
47 extern void check_uep_root (node * p, world_fmt * world);
48 extern boolean is_success_pseudo_uep (proposal_fmt * proposal);
49 extern boolean uep_compare (int *target, int *origin, long uepsites);
50 extern void store_uep (world_fmt * world);
51 extern MYREAL pseudo_ueplikelihood (world_fmt * world,
52                                         proposal_fmt * proposal);
53 extern MYREAL ueplikelihood (world_fmt * world);
54 extern void calc_ueplike (node * p, world_fmt * world, MYREAL **ueplike);
55 extern MYREAL collect_pseudo_ueplike (proposal_fmt * proposal,
56                                           MYREAL **ueplike);
57 extern void collect_ueplike (node * p, node * d1, node * d2, long uepsite,
58                                  world_fmt * world, MYREAL *ueplike);
59 extern void show_uep_store (world_fmt * world);
60 extern node *first_uep (node * p, node * nop, long uepsites);
61 extern node *first_uep2 (node * p, node * root, long uepsites);
62 extern void analyze_uep (world_fmt * world);
63 extern void alloc_uepanc (long ***uepanc, long size, long numpop, long loci);
64 extern void update_uepanc (world_fmt * world);
65 extern void setup_uep (world_fmt * world, option_fmt * options);
66 extern void pseudonu_twostate (proposal_fmt * proposal, ueparray_fmt * xx1,
67                                    MYREAL *lx1, MYREAL v1, ueparray_fmt * xx2,
68                                    MYREAL *lx2, MYREAL v2);
69 extern MYREAL pseudo_tl_uep (ueparray_fmt * xx1, ueparray_fmt * xx2,
70                                  MYREAL v1, MYREAL v2, proposal_fmt * proposal,
71                                  world_fmt * world);
72 extern void twostate_nuview (node * mother, world_fmt * world, const long locus);
73 
74 extern void copy_uepx (proposal_fmt * proposal, ueparray_fmt xx1, ueparray_fmt xx2);
75 
76 #endif
77 
78 
79 #endif /* __UEP__ */
80