| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.oldevomodel.treelikelihood; |
| 27 |
|
| 28 |
@Deprecated |
| 29 |
public class NativeGeneralLikelihoodCore extends AbstractLikelihoodCore { |
| 30 |
|
| 31 |
public NativeGeneralLikelihoodCore(int stateCount) { |
| 32 |
super(stateCount); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
protected void calculateIntegratePartials(double[] inPartials, |
| 37 |
double[] proportions, double[] outPartials) { |
| 38 |
nativeIntegratePartials(inPartials, proportions, patternCount, matrixCount, outPartials, stateCount); |
| 39 |
} |
| 40 |
|
| 41 |
protected void calculatePartialsPartialsPruning(double[] partials1, |
| 42 |
double[] matrices1, double[] partials2, double[] matrices2, |
| 43 |
double[] partials3) { |
| 44 |
nativePartialsPartialsPruning(partials1, matrices1, partials2, matrices2, patternCount, matrixCount, partials3, stateCount); |
| 45 |
} |
| 46 |
|
| 47 |
protected void calculateStatesPartialsPruning(int[] states1, |
| 48 |
double[] matrices1, double[] partials2, double[] matrices2, |
| 49 |
double[] partials3) { |
| 50 |
nativeStatesPartialsPruning(states1, matrices1, partials2, matrices2, patternCount, matrixCount, partials3, stateCount); |
| 51 |
} |
| 52 |
|
| 53 |
protected void calculateStatesStatesPruning(int[] states1, |
| 54 |
double[] matrices1, int[] states2, double[] matrices2, |
| 55 |
double[] partials3) { |
| 56 |
|
| 57 |
|
| 58 |
nativeStatesStatesPruning(states1, matrices1, states2, matrices2, patternCount, matrixCount, partials3, stateCount); |
| 59 |
} |
| 60 |
|
| 61 |
protected void calculatePartialsPartialsPruning(double[] partials1, |
| 62 |
double[] matrices1, double[] partials2, double[] matrices2, |
| 63 |
double[] partials3, int[] matrixMap) { |
| 64 |
throw new RuntimeException("not implemented using matrixMap"); |
| 65 |
} |
| 66 |
|
| 67 |
protected void calculateStatesStatesPruning(int[] states1, |
| 68 |
double[] matrices1, int[] states2, double[] matrices2, |
| 69 |
double[] partials3, int[] matrixMap) { |
| 70 |
throw new RuntimeException("not implemented using matrixMap"); |
| 71 |
} |
| 72 |
|
| 73 |
protected void calculateStatesPartialsPruning(int[] states1, |
| 74 |
double[] matrices1, double[] partials2, double[] matrices2, |
| 75 |
double[] partials3, int[] matrixMap) { |
| 76 |
throw new RuntimeException("not implemented using matrixMap"); |
| 77 |
} |
| 78 |
|
| 79 |
public void calculateLogLikelihoods(double[] partials, |
| 80 |
double[] frequencies, double[] outLogLikelihoods) { |
| 81 |
int v = 0; |
| 82 |
for (int k = 0; k < patternCount; k++) { |
| 83 |
|
| 84 |
double sum = 0.0; |
| 85 |
for (int i = 0; i < stateCount; i++) { |
| 86 |
|
| 87 |
sum += frequencies[i] * partials[v]; |
| 88 |
v++; |
| 89 |
} |
| 90 |
outLogLikelihoods[k] = Math.log(sum) + getLogScalingFactor(k); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
public native void nativeIntegratePartials(double[] partials, double[] proportions, |
| 95 |
int patternCount, int matrixCount, |
| 96 |
double[] outPartials, |
| 97 |
int stateCount); |
| 98 |
|
| 99 |
protected native void nativePartialsPartialsPruning(double[] partials1, double[] matrices1, |
| 100 |
double[] partials2, double[] matrices2, |
| 101 |
int patternCount, int matrixCount, |
| 102 |
double[] partials3, |
| 103 |
int stateCount); |
| 104 |
|
| 105 |
protected native void nativeStatesPartialsPruning(int[] states1, double[] matrices1, |
| 106 |
double[] partials2, double[] matrices2, |
| 107 |
int patternCount, int matrixCount, |
| 108 |
double[] partials3, |
| 109 |
int stateCount); |
| 110 |
|
| 111 |
protected native void nativeStatesStatesPruning(int[] states1, double[] matrices1, |
| 112 |
int[] states2, double[] matrices2, |
| 113 |
int patternCount, int matrixCount, |
| 114 |
double[] partials3, |
| 115 |
int stateCount); |
| 116 |
|
| 117 |
protected native void setMode(int mode); |
| 118 |
|
| 119 |
public static boolean isAvailable() { |
| 120 |
return isNativeAvailable; |
| 121 |
} |
| 122 |
|
| 123 |
private static boolean isNativeAvailable = false; |
| 124 |
|
| 125 |
static { |
| 126 |
try { |
| 127 |
System.loadLibrary("GeneralLikelihoodCore"); |
| 128 |
isNativeAvailable = true; |
| 129 |
} catch (UnsatisfiedLinkError e) { |
| 130 |
System.err.println("Unable to load general core"); |
| 131 |
} |
| 132 |
} |
| 133 |
} |