/** * Gets the value of the denominator of this node. This function should be * called only when getType() == RATIONAL, otherwise an Exception is thrown. * * @return the value of the denominator of this ASTNode. * @throws IllegalArgumentException * if the method is called on a node that is not of type * rational. */ public int getDenominator() { if (isRational()) { return denominator; } throw new IllegalArgumentException(resourceBundle.getString("ASTNode.getDenominator")); }
/** * Gets the value of the numerator of this node. This method should be * called only when getType() == RATIONAL, otherwise an Exception is thrown. * * * @return the value of the numerator of this ASTNode. * @throws IllegalArgumentException * if this method is called on a node type other than rational. */ public int getNumerator() { if (isRational()) { return numerator; } throw new IllegalArgumentException(resourceBundle.getString("ASTNode.getNumerator")); }
@Override public boolean getAllowsChildren() { return !(isConstant() || isInfinity() || isNumber() || isNegInfinity() || isNaN() || isRational()); }
} else if (astNode.isInteger()) { astNode.setValue(StringTools.parseSBMLInt(characters.trim())); } else if (astNode.isRational()) { if (elementName == null) { astNode.setValue(astNode.getNumerator(), StringTools.parseSBMLInt(characters.trim()));
@Override public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) throws SBMLException { ASTNodeValue rootExponentValue = rootExponent.compile(this); if (rootExponent.isSetUnits() || !(rootExponent.isInteger() || rootExponent.isRational())) { checkForDimensionlessOrInvalidUnits(rootExponentValue.getUnits()); } if (rootExponentValue.isNumber()) { return root(rootExponentValue.toDouble(), radiant); } return new ASTNodeValue(this); }
} else if (!isNumber() && !isOperator() && (isSetName() || (variable != null))) { hashCode += prime * getName().hashCode(); } else if (isRational()) { hashCode += prime * getNumerator() + prime * getDenominator(); } else if (isReal()) {
@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(); }
if (isRational() && ast.isRational()) { equal &= ast.getNumerator() == getNumerator() && ast.getDenominator() == getDenominator();
if ((isNumber() || isRational() || isUnknown()) && (!isSetUnits() || (isSetParentSBMLObject() && (-1 < getParentSBMLObject().getLevel()) &&
if (compiled.isInteger()) { compiled.setValue(-value.getInteger()); } else if (compiled.isRational()) { compiled.setValue(-value.getNumerator(), value.getDenominator()); } else if (compiled.getType().equals(Type.REAL_E)) {
/** * @param value */ private void uMinusRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { uMinusRecursive(value.getChild(i)); } else if (useId) { value.replaceChild(i, ASTNode.uMinus(child)); } else if (child.isNumber()) { if (child.isInteger()) { value.getChild(i).setValue(-child.getInteger()); } else if (child.isRational()) { value.getChild(i).setValue(-child.getNumerator(), child.getDenominator()); } else if (child.getType().equals(Type.REAL_E)) { value.getChild(i).setValue(-child.getMantissa(), child.getExponent()); } else { value.getChild(i).setValue(-child.getReal()); } } else { throw new SBMLException(); } } }