Search in sources :

Example 1 with MarkovRandomFieldMatrix

use of dr.inference.model.MarkovRandomFieldMatrix in project beast-mcmc by beast-dev.

the class MarkovRandomFieldMatrixParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name = xo.getId();
    final int dim = xo.getIntegerAttribute(DIM);
    XMLObject cxo = xo.getChild(DIAGONAL);
    Parameter diagonalParameter = (Parameter) cxo.getChild(Parameter.class);
    Transform.ParsedTransform tmp = (Transform.ParsedTransform) cxo.getChild(Transform.ParsedTransform.class);
    Transform diagonalTransform = (tmp != null) ? tmp.transform : null;
    cxo = xo.getChild(OFF_DIAGONAL);
    Parameter offDiagonalParameter = (Parameter) cxo.getChild(Parameter.class);
    tmp = (Transform.ParsedTransform) cxo.getChild(Transform.ParsedTransform.class);
    Transform offDiagonalTransform = (tmp != null) ? tmp.transform : null;
    boolean asCorrelation = xo.getAttribute(AS_CORRELATION, false);
    if (diagonalParameter.getDimension() != 1 || offDiagonalParameter.getDimension() != 1) {
        throw new XMLParseException("Wrong parameter dimensions for GMRF");
    }
    cxo = xo.getChild(NUGGET);
    Parameter nuggetParameter = (Parameter) cxo.getChild(Parameter.class);
    return new MarkovRandomFieldMatrix(name, dim, diagonalParameter, offDiagonalParameter, nuggetParameter, asCorrelation, diagonalTransform, offDiagonalTransform);
}
Also used : Parameter(dr.inference.model.Parameter) Transform(dr.util.Transform) MarkovRandomFieldMatrix(dr.inference.model.MarkovRandomFieldMatrix)

Aggregations

MarkovRandomFieldMatrix (dr.inference.model.MarkovRandomFieldMatrix)1 Parameter (dr.inference.model.Parameter)1 Transform (dr.util.Transform)1