/** * @param astNode */ private void compileRational(ASTNode astNode) { try { writer.writeCharacters(indent); writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "cn"); writer.writeAttribute("type", "rational"); writer.writeCharacters(" "); if (astNode.isSetUnits()) { writer.writeAttribute("sbml:units", astNode.getUnits()); } writer.writeCharacters(Integer.toString(astNode.getNumerator())); writer.writeCharacters(" "); writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "sep"); writer.writeCharacters(" "); writer.writeCharacters(Integer.toString(astNode.getDenominator())); writer.writeCharacters(" "); writer.writeEndElement(); writer.writeCharacters("\n"); } catch (XMLStreamException e) { e.printStackTrace(); } }
return ((double) getNumerator()) / getDenominator(); case CONSTANT_E: return Math.E;
buffer.append(" (").append(getNumerator()).append(" / ").append(getDenominator());
hashCode += prime * getName().hashCode(); } else if (isRational()) { hashCode += prime * getNumerator() + prime * getDenominator(); } else if (isReal()) { hashCode += prime * getReal();
&& ast.getDenominator() == getDenominator();
child.setValue(-child.getNumerator(), child.getDenominator()); minus.addChild(child);
compiled.setValue(-value.getInteger()); } else if (compiled.isRational()) { compiled.setValue(-value.getNumerator(), value.getDenominator()); } else if (compiled.getType().equals(Type.REAL_E)) { compiled.setValue(-value.getMantissa(), value.getExponent());
/** * @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(); } } }
break; case RATIONAL: value = compiler.frac(getNumerator(), getDenominator()); break; case NAME_TIME: