Debian Codegraph @

src/dr/inferencexml/model/AdaptableSizeFastMatrixParameterParser.java

raw symbols SCIP
1 package dr.inferencexml.model;
2
3
4 import dr.inference.model.AdaptableSizeFastMatrixParameter;
5 import dr.xml.*;
6
7 /**
8 * Created by max on 4/6/16.
9 */
10 public class AdaptableSizeFastMatrixParameterParser extends AbstractXMLObjectParser {
11
12
13 private static final String ADAPTABLE_SIZE_FAST_MATRIX_PARAMETER="adaptableSizeFastMatrixParameter";
14 private static final String ROWS="rows";
15 private static final String MAX_ROW_SIZE="maxRowSize";
16 private static final String MAX_COL_SIZE="maxColumnSize";
17 private static final String COLUMNS="columns";
18 private static final String TRANSPOSE="transpose";
19 private static final String STARTING_VALUE = "startingValue";
20 private static final String LOWER_TRIANGLE = "lowerTriangle";
21 @Override
22 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
23 int MaxRowSize = xo.getAttribute(MAX_ROW_SIZE, 1);
24 int MaxColumnSize = xo.getAttribute(MAX_COL_SIZE, 1);
25 int rowDimension = xo.getAttribute(ROWS, 1);
26 int columnDimension = xo.getAttribute(COLUMNS, 1);
27 String name = xo.getId();
28 double startingValue = 1;
29 if(xo.hasAttribute(STARTING_VALUE))
30 startingValue = xo.getDoubleAttribute(STARTING_VALUE);
31 boolean lowerTriangle = false;
32 if(xo.hasAttribute(LOWER_TRIANGLE))
33 lowerTriangle = xo.getBooleanAttribute(LOWER_TRIANGLE);
34
35 return new AdaptableSizeFastMatrixParameter(name, rowDimension, columnDimension, MaxRowSize, MaxColumnSize, startingValue, lowerTriangle);
36 }
37
38 @Override
39 public XMLSyntaxRule[] getSyntaxRules() {
40 return rules;
41 }
42
43 private final XMLSyntaxRule[] rules = {
44 // new ElementRule(Parameter.class, 0, Integer.MAX_VALUE),
45 AttributeRule.newIntegerRule(COLUMNS, true),
46 AttributeRule.newIntegerRule(ROWS, true),
47 AttributeRule.newIntegerRule(MAX_ROW_SIZE, true),
48 AttributeRule.newIntegerRule(MAX_COL_SIZE, true),
49 AttributeRule.newDoubleRule(STARTING_VALUE, true),
50 AttributeRule.newBooleanRule(LOWER_TRIANGLE, true),
51
52 };
53
54
55
56 @Override
57 public String getParserDescription() {
58 return "Returns a blockUpperTriangularMatrixParameter which is a compoundParameter which forces the last element to be of full length, the second to last element to be of full length-1, etc."; //To change body of implemented methods use File | Settings | File Templates.
59 }
60
61 @Override
62 public Class getReturnType() {
63 return AdaptableSizeFastMatrixParameter.class; //To change body of implemented methods use File | Settings | File Templates.
64 }
65
66 @Override
67 public String getParserName() {
68 return ADAPTABLE_SIZE_FAST_MATRIX_PARAMETER; //To change body of implemented methods use File | Settings | File Templates.
69 }
70 }