Debian Codegraph @

src/dr/inferencexml/model/FastBlockUpperTriangularMatrixParameterParser.java

raw symbols SCIP
1 /*
2 * BlockUpperTriangularMatrixParameterParser.java
3 *
4 * Copyright (c) 2002-2015 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.inferencexml.model;
27
28 import dr.inference.model.*;
29 import dr.xml.*;
30
31 /**
32 @author Max Tolkoff
33 */
34
35 // Block Upper Triangular Matrix Parameter
36 public class FastBlockUpperTriangularMatrixParameterParser extends AbstractXMLObjectParser {
37 private static final String FAST_BUTMP ="fastBlockUpperTriangularMatrixParameterParser";
38 private static final String ROWS="rows";
39 private static final String COLUMNS="columns";
40 private static final String TRANSPOSE="transpose";
41 private static final String DIAGONAL_RESTRICTION="diagonalRestriction";
42
43 @Override
44 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
45
46 final String name = xo.hasId() ? xo.getId() : null;
47 final boolean transpose= xo.getAttribute(TRANSPOSE, false);
48 // int rowDim=xo.getChildCount();
49 // int colDim;
50 final boolean diagonalRestriction=xo.getAttribute(DIAGONAL_RESTRICTION, false);
51 Parameter temp=null;
52 // if(xo.hasAttribute(COLUMN_DIMENSION)) {
53 // colDim = xo.getAttribute(COLUMN_DIMENSION, 1);
54 // }
55 // else
56 // {
57 // temp=(Parameter) xo.getChild(xo.getChildCount()-1);
58 // colDim=temp.getDimension();
59 // }
60 int rows=xo.getAttribute(ROWS,1);
61 int cols=xo.getAttribute(COLUMNS,1) ;
62
63 // Parameter[] params=new Parameter[xo.getChildCount()];
64
65
66
67 // for (int i = 0; i < xo.getChildCount(); i++) {
68 // temp = (Parameter) xo.getChild(i);
69 // params[i]=temp;}
70
71 // BlockUpperTriangularMatrixParameter ltmp=new BlockUpperTriangularMatrixParameter(name, params, diagonalRestriction);
72 if(transpose){
73 return new FastTransposedBlockUpperTriangularMatrixParameter(name, rows, cols);
74 }
75 else {
76 return new FastBlockUpperTriangularMatrixParameter(name, rows, cols); //To change body of implemented methods use File | Settings | File Templates.
77 }
78 }
79
80 @Override
81 public XMLSyntaxRule[] getSyntaxRules() {
82 return rules;
83 }
84
85 private final XMLSyntaxRule[] rules = {
86 // new ElementRule(Parameter.class, 0, Integer.MAX_VALUE),
87 AttributeRule.newBooleanRule(TRANSPOSE, true),
88 AttributeRule.newIntegerRule(COLUMNS, true),
89 AttributeRule.newIntegerRule(ROWS, true),
90
91 };
92
93
94 @Override
95 public String getParserDescription() {
96 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.
97 }
98
99 @Override
100 public Class getReturnType() {
101 return FastBlockUpperTriangularMatrixParameter.class; //To change body of implemented methods use File | Settings | File Templates.
102 }
103
104 @Override
105 public String getParserName() {
106 return FAST_BUTMP; //To change body of implemented methods use File | Settings | File Templates.
107 }
108 }