Debian Codegraph @

src/dr/oldevomodel/treelikelihood/LikelihoodCore.java

raw symbols SCIP
1 /*
2 * LikelihoodCore.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.oldevomodel.treelikelihood;
27
28 import dr.evomodel.treelikelihood.LikelihoodPartialsProvider;
29
30 /**
31 * LikelihoodCore - An interface describing the core likelihood functions.
32 *
33 * @author Andrew Rambaut
34 * @version $Id: LikelihoodCore.java,v 1.15 2006/08/29 18:07:23 rambaut Exp $
35 */
36
37 @Deprecated // Switching to BEAGLE
38 public interface LikelihoodCore extends LikelihoodPartialsProvider {
39
40 /**
41 * initializes partial likelihood arrays.
42 */
43 void initialize(int nodeCount, int patternCount, int matrixCount, boolean integrateCategories);
44
45 /**
46 * cleans up and deallocates arrays.
47 */
48 void finalize() throws java.lang.Throwable;
49
50 /**
51 * Allocates partials for a node
52 */
53 void createNodePartials(int nodeIndex);
54
55 /**
56 * Sets partials for a node
57 */
58 void setNodePartials(int nodeIndex, double[] partials);
59
60 /**
61 * Sets states for a node
62 */
63 void setNodeStates(int nodeIndex, int[] states);
64
65 /**
66 * Sets states for a node and a pattern
67 * Allocates states for a node
68 */
69 void createNodeStates(int nodeIndex);
70
71 /**
72 * Specify that the matrices for the given node are about to be updated
73 *
74 * @param nodeIndex
75 */
76 void setNodeMatrixForUpdate(int nodeIndex);
77
78 /**
79 * Sets probability matrix for a node
80 */
81 void setNodeMatrix(int nodeIndex, int matrixIndex, double[] matrix);
82
83 /**
84 * Specify that the partials for the given node are about to be updated
85 *
86 * @param nodeIndex
87 */
88 void setNodePartialsForUpdate(int nodeIndex);
89
90 /**
91 * Set the currently updating node partials from the array...
92 *
93 * @param nodeIndex
94 */
95 void setCurrentNodePartials(int nodeIndex, double[] partials);
96
97 /**
98 * Calculates partial likelihoods at a node using a matrixMap.
99 *
100 * @param nodeIndex1 the 'child 1' node
101 * @param nodeIndex2 the 'child 2' node
102 * @param nodeIndex3 the 'parent' node
103 */
104 void calculatePartials(int nodeIndex1, int nodeIndex2, int nodeIndex3);
105
106 /**
107 * Calculates partial likelihoods at a node using a matrixMap.
108 *
109 * @param nodeIndex1 the 'child 1' node
110 * @param nodeIndex2 the 'child 2' node
111 * @param nodeIndex3 the 'parent' node
112 * @param matrixMap a map of which matrix to use for each pattern
113 */
114 void calculatePartials(int nodeIndex1, int nodeIndex2, int nodeIndex3, int[] matrixMap);
115
116 /**
117 * Gets the partials for a particular node.
118 *
119 * @param nodeIndex the node
120 * @param outPartials an array into which the partials will go
121 */
122 public void getPartials(int nodeIndex, double[] outPartials);
123
124 /**
125 * Integrates partials across categories.
126 *
127 * @param nodeIndex the node at which to calculate the likelihoods
128 * @param proportions the proportions of sites in each category
129 * @param outPartials an array into which the partials will go
130 */
131 void integratePartials(int nodeIndex, double[] proportions, double[] outPartials);
132
133 /**
134 * Calculates pattern log likelihoods at a node.
135 *
136 * @param partials the partials used to calculate the likelihoods
137 * @param frequencies an array of state frequencies
138 * @param outLogLikelihoods an array into which the log likelihoods will go
139 */
140 void calculateLogLikelihoods(double[] partials, double[] frequencies, double[] outLogLikelihoods);
141
142 void setUseScaling(boolean useScaling);
143
144 double getLogScalingFactor(int pattern);
145
146 boolean arePartialsRescaled();
147
148 void getLogScalingFactors(int nodeIndex, double[] buffer);
149
150 /**
151 * Store current state
152 */
153 void storeState();
154
155 /**
156 * Restore the stored state
157 */
158 void restoreState();
159 }