Debian Codegraph @

src/dr/inference/operators/LoadingsSparsityOperator.java

raw symbols SCIP
1 package dr.inference.operators;
2
3 import dr.inference.model.MatrixParameterInterface;
4 import dr.math.MathUtils;
5
6 public class LoadingsSparsityOperator extends SimpleMCMCOperator{
7 public LoadingsSparsityOperator(double weight, LoadingsGibbsTruncatedOperator loadingsGibbs, MatrixParameterInterface sparse){
8
9 setWeight(weight);
10 this.loadingsGibbs = loadingsGibbs;
11 this.sparse = sparse;
12 }
13
14 @Override
15 public String getOperatorName() {
16 return "LoadingsSparsityOperator";
17 }
18
19 @Override
20 public double doOperation() {
21 int row = MathUtils.nextInt(sparse.getRowDimension());
22 int col = MathUtils.nextInt(sparse.getColumnDimension());
23
24 double hastings = 0;
25 hastings += loadingsGibbs.drawI(row, col, false);
26 if(sparse.getParameterValue(row, col) == 0)
27 sparse.setParameterValue(row, col, 1);
28 else
29 sparse.setParameterValue(row, col, 0);
30 hastings -= loadingsGibbs.drawI(row, col, true);
31
32 if(Double.isNaN(hastings)){
33 System.out.println("is NaN");
34 }
35 if(Double.isInfinite(hastings))
36 {
37 return Double.NEGATIVE_INFINITY;
38 }
39 return hastings;
40 }
41
42
43 LoadingsGibbsTruncatedOperator loadingsGibbs;
44 MatrixParameterInterface sparse;
45 }