Debian Codegraph @

src/dr/geo/MultiRegionGeoSpatialDistribution.java

raw symbols SCIP
1 /*
2 * MultiRegionGeoSpatialDistribution.java
3 *
4 * Copyright (c) 2002-2017 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.geo;
27
28 import java.util.ArrayList;
29 import java.util.List;
30
31 /**
32 * @author Marc A. Suchard
33 */
34 public class MultiRegionGeoSpatialDistribution extends GeoSpatialDistribution {
35
36 public MultiRegionGeoSpatialDistribution(String label) {
37 super(label);
38 regions = new ArrayList<GeoSpatialDistribution>();
39 union = false;
40 fillValue = false;
41 }
42
43 public MultiRegionGeoSpatialDistribution(String label, List<GeoSpatialDistribution> regions, boolean union, boolean fillValue) {
44 super(label);
45 this.regions = regions;
46 this.union = union;
47 this.fillValue = fillValue;
48 }
49
50 public double logPdf(double[] x) {
51
52 if (fillValue) {
53 //System.err.println("fillValue set to true");
54 //int test = 0;
55 for (GeoSpatialDistribution region : regions) {
56 //System.err.println(test);
57 //test++;
58 if (!Double.isInfinite(region.logPdf(x))) {
59 return region.logPdf(x);
60 }
61 }
62 return Double.NEGATIVE_INFINITY;
63 }
64
65 if (union) {
66 for (GeoSpatialDistribution region : regions) {
67 if (region.logPdf(x) == 0.0) { // matches
68 return 0.0;
69 }
70 }
71 return Double.NEGATIVE_INFINITY;
72 } // else is intersection
73
74 for (GeoSpatialDistribution region : regions) {
75 if (region.logPdf(x) == Double.NEGATIVE_INFINITY) {
76 return Double.NEGATIVE_INFINITY;
77 }
78 }
79 return 0.0;
80 }
81
82 public double[][] getScaleMatrix() {
83 return null;
84 }
85
86 public double[] getMean() {
87 return null;
88 }
89
90 public String getType() {
91 return TYPE;
92 }
93
94 public String getLabel() {
95 return label;
96 }
97
98 public boolean getUnion() {
99 return union;
100 }
101
102 public List<GeoSpatialDistribution> getRegions() {
103 return regions;
104 }
105
106 private final List<GeoSpatialDistribution> regions;
107 private final boolean union;
108 private final boolean fillValue;
109
110 }