use of dr.util.Transform in project beast-mcmc by beast-dev.
the class TransformedMultivariateParameterParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
final Parameter parameter = (Parameter) xo.getChild(Parameter.class);
Transform.MultivariableTransform transform = (Transform.MultivariableTransform) xo.getChild(Transform.MultivariableTransform.class);
final boolean inverse = xo.getAttribute(INVERSE, false);
TransformedMultivariateParameter transformedParameter = new TransformedMultivariateParameter(parameter, transform, inverse);
if (xo.hasChildNamed(BOUNDS)) {
Bounds<Double> bounds = ((Parameter) xo.getElementFirstChild(BOUNDS)).getBounds();
transformedParameter.addBounds(bounds);
} else {
transformedParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, parameter.getDimension()));
}
return transformedParameter;
}
use of dr.util.Transform 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);
}
use of dr.util.Transform in project beast-mcmc by beast-dev.
the class LoadingsTransformParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
MatrixParameterInterface matrix = (MatrixParameterInterface) xo.getChild(MatrixParameterInterface.class);
int nRows = matrix.getRowDimension();
int nCols = matrix.getColumnDimension();
List<Transform> transforms = new ArrayList<Transform>();
List<Integer> indices = null;
if (xo.hasAttribute(INDICES)) {
int[] tmp = xo.getIntegerArrayAttribute(INDICES);
indices = new ArrayList<Integer>();
for (int i : tmp) {
indices.add(i - 1);
}
}
for (int col = 0; col < nCols; ++col) {
for (int row = 0; row < nRows; ++row) {
if (noTransform(row, col, indices, nRows)) {
transforms.add(Transform.NONE);
} else {
transforms.add(Transform.LOG);
}
}
}
return new Transform.Array(transforms, matrix);
}
Aggregations