@Override public boolean check(ValidationContext ctx, ASTNode node) { if (node.isSetUnits()) { String units = node.getUnits(); if (units != null && !units.isEmpty()) { // Checks if the unit is predefined or defined in the model if (!(Unit.isUnitKind(units, ctx.getLevel(), ctx.getVersion())) && node.getUnitsInstance() == null) { return false; } } } return true; }
@Override public ASTNodeValue pow(ASTNode base, ASTNode exponent) throws SBMLException { if (exponent.isSetUnits()) { checkForDimensionlessOrInvalidUnits(exponent.getUnitsInstance()); } return pow(base.compile(this), exponent.compile(this)); }
@Override public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) throws SBMLException { if (rootExponent.isSetUnits()) { checkForDimensionlessOrInvalidUnits(rootExponent.getUnitsInstance()); } if (rootExponent.isNumber()) { if (!(rootExponent.isInteger() || rootExponent.isRational())) { checkForDimensionlessOrInvalidUnits(rootExponent .getUnitsInstance()); } return root(rootExponent.compile(this).toDouble(), radiant); } return invalid(); }
@Override public ASTNodeValue factorial(ASTNode value) throws SBMLException { ASTNodeValue v = new ASTNodeValue(Maths.factorial((int) Math .round(value.compile(this).toDouble())), this); if (value.isSetUnits()) { v.setUnits(value.getUnitsInstance()); } else { v.setLevel(level); v.setVersion(version); } checkForDimensionlessOrInvalidUnits(v.getUnits()); return v; }
ASTNode right = node.getRightChild(); UnitDefinition ud = right.getUnitsInstance();