Debian Codegraph @

src/dr/inference/model/ElementWiseMatrixMultiplicationParameter.java

raw symbols SCIP
1 package dr.inference.model;
2
3 /**
4 * Created by max on 11/30/15.
5 */
6 public class ElementWiseMatrixMultiplicationParameter extends MatrixParameter {
7 private MatrixParameterInterface[] paramList;
8
9 public ElementWiseMatrixMultiplicationParameter(String name) {
10 super(name);
11 }
12
13 public ElementWiseMatrixMultiplicationParameter(String name, MatrixParameterInterface[] matList) {
14 super(name);
15 this.paramList =matList;
16 for (MatrixParameterInterface mat : matList) {
17 mat.addVariableListener(this);
18 }
19 }
20
21 @Override
22 public double getParameterValue(int dim) {
23 double prod = 1;
24 for (int i = 0; i < paramList.length ; i++) {
25 prod = prod * paramList[i].getParameterValue(dim);
26 }
27 return prod;
28 }
29
30 public double getParameterValue(int row, int col){
31 double prod=1;
32 for (int i = 0; i < paramList.length ; i++) {
33 prod=prod * paramList[i].getParameterValue(row, col);
34 }
35 return prod;
36 }
37
38
39 protected void storeValues() {
40 for (Parameter p : paramList) {
41 p.storeParameterValues();
42 }
43 }
44
45 protected void restoreValues() {
46 for (Parameter p : paramList) {
47 p.restoreParameterValues();
48 }
49 }
50
51 protected void acceptValues() {
52 for (Parameter p : paramList) {
53 p.acceptParameterValues();
54 }
55 }
56
57 @Override
58 public void variableChangedEvent(Variable variable, int index, ChangeType type) {
59 fireParameterChangedEvent(index, type);
60 }
61
62 // @Override
63 // public void fireParameterChangedEvent(){
64 // for (int i = 0; i < paramList.length ; i++) {
65 // paramList[i].fireParameterChangedEvent();
66 // }
67 // }
68 //
69 // @Override
70 // public void fireParameterChangedEvent(int index, ChangeType type){
71 // for (int i = 0; i < paramList.length; i++) {
72 // paramList[i].fireParameterChangedEvent(index, type);
73 // }
74 // }
75
76 @Override
77 public int getDimension() {
78 return paramList[0].getDimension();
79 }
80
81 @Override
82 public int getColumnDimension() {
83 return paramList[0].getColumnDimension();
84 }
85
86 public int getRowDimension(){
87 return paramList[0].getRowDimension();
88 }
89 }