| 1 |
package dr.inferencexml.model; |
| 2 |
|
| 3 |
|
| 4 |
import dr.inference.model.ElementWiseMatrixMultiplicationParameter; |
| 5 |
import dr.inference.model.MatrixParameter; |
| 6 |
import dr.inference.model.MatrixParameterInterface; |
| 7 |
import dr.xml.AbstractXMLObjectParser; |
| 8 |
import dr.xml.XMLObject; |
| 9 |
import dr.xml.XMLParseException; |
| 10 |
import dr.xml.XMLSyntaxRule; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
public class ElementWiseMatrixMultiplicationParser extends AbstractXMLObjectParser { |
| 16 |
public final static String ELEMENT_WISE_MATRIX_MULTIPLICATION_PARAMETER="elementWiseMatrixMultiplicationParameter"; |
| 17 |
public final static String NAME="name"; |
| 18 |
|
| 19 |
@Override |
| 20 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 21 |
final String name = xo.hasId() ? xo.getId() : null; |
| 22 |
MatrixParameterInterface[] matList=new MatrixParameterInterface[xo.getChildCount()]; |
| 23 |
for (int i = 0; i <xo.getChildCount(); i++) { |
| 24 |
matList[i]=(MatrixParameterInterface) xo.getChild(i); |
| 25 |
} |
| 26 |
|
| 27 |
return new ElementWiseMatrixMultiplicationParameter(name, matList); |
| 28 |
} |
| 29 |
|
| 30 |
@Override |
| 31 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 32 |
return new XMLSyntaxRule[0]; |
| 33 |
} |
| 34 |
|
| 35 |
@Override |
| 36 |
public String getParserDescription() { |
| 37 |
return "Returns element wise matrix multiplication of a series of matrices"; |
| 38 |
} |
| 39 |
|
| 40 |
@Override |
| 41 |
public Class getReturnType() { |
| 42 |
return ElementWiseMatrixMultiplicationParameter.class; |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
public String getParserName() { |
| 47 |
return ELEMENT_WISE_MATRIX_MULTIPLICATION_PARAMETER; |
| 48 |
} |
| 49 |
} |