| 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.inference.model; |
| 27 |
|
| 28 |
import java.util.ArrayList; |
| 29 |
import java.util.List; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class TransposedBlockUpperTriangularMatrixParameter extends BlockUpperTriangularMatrixParameter{ |
| 35 |
public TransposedBlockUpperTriangularMatrixParameter(String name, Parameter[] params) { |
| 36 |
super(name, params, false); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
int colDim=params[params.length-1].getSize(); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
this.colDim=colDim; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
public static TransposedBlockUpperTriangularMatrixParameter recast(String name, CompoundParameter compoundParameter) { |
| 59 |
final int count = compoundParameter.getParameterCount(); |
| 60 |
Parameter[] parameters = new Parameter[count]; |
| 61 |
for (int i = 0; i < count; ++i) { |
| 62 |
parameters[i] = compoundParameter.getParameter(i); |
| 63 |
} |
| 64 |
return new TransposedBlockUpperTriangularMatrixParameter(name, parameters); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
protected int getRow(int PID){ |
| 77 |
return PID%getRowDimension(); |
| 78 |
} |
| 79 |
|
| 80 |
protected int getColumn(int PID){ |
| 81 |
return PID/getRowDimension(); |
| 82 |
} |
| 83 |
|
| 84 |
@Override |
| 85 |
boolean matrixCondition(int row, int col) { |
| 86 |
return row>=col; |
| 87 |
} |
| 88 |
|
| 89 |
public void setParameterValue(int row, int col, double value){ |
| 90 |
if(matrixCondition(row, col)){ |
| 91 |
getParameter(col).setParameterValueQuietly(row - col, value); |
| 92 |
fireParameterChangedEvent(col*getRowDimension()+row, ChangeType.VALUE_CHANGED); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
public Parameter getParameter(int index) { |
| 97 |
if (slices == null) { |
| 98 |
|
| 99 |
slices = new ArrayList<Parameter>(); |
| 100 |
for (int i = 0; i < getColumnDimension(); ++i) { |
| 101 |
VectorSliceParameter thisSlice = new VectorSliceParameter(getParameterName() + "." + i, i); |
| 102 |
for (int j = i; j < getRowDimension(); ++j) { |
| 103 |
thisSlice.addParameter(super.getParameter(j)); |
| 104 |
} |
| 105 |
slices.add(thisSlice); |
| 106 |
} |
| 107 |
} |
| 108 |
return slices.get(index); |
| 109 |
} |
| 110 |
|
| 111 |
protected int getInnerDimension(int row, int col){ |
| 112 |
return row-col; |
| 113 |
} |
| 114 |
|
| 115 |
public int getRowDimension(){ |
| 116 |
return getParameterCount(); |
| 117 |
} |
| 118 |
|
| 119 |
public int getColumnDimension(){ |
| 120 |
return colDim; |
| 121 |
} |
| 122 |
|
| 123 |
int colDim; |
| 124 |
private List<Parameter> slices = null; |
| 125 |
} |