/** * Creates a new {@link ASTNode} that of type DIVIDE with the given numerator and * denominator. * * @param numerator the numerator * @param denominator the denominator * @return a new {@link ASTNode} that of type DIVIDE with the given numerator and * denominator. */ public static ASTNode frac(int numerator, ASTNode denominator) { return frac(new ASTNode(numerator, denominator.getParentSBMLObject()), denominator); }
/** * Returns a new {@link ASTNode} that of type DIVIDE with the two entities as numerator and denominator. * * @param container the parent object * @param numeratorId the numerator * @param denominatorId the numerator * @return a new {@link ASTNode} that of type DIVIDE with the two entities as numerator and denominator. */ public static ASTNode frac(MathContainer container, String numeratorId, String denominatorId) { return frac(new ASTNode(numeratorId, container), new ASTNode( denominatorId, container)); }
/** * Creates a new {@link ASTNode} that divides two {@link CallableSBase} objects. * * @param container the parent object * @param numerator the numerator * @param denominator the denominator * @return a new {@link ASTNode} that divides two {@link CallableSBase} objects. */ public static ASTNode frac(MathContainer container, CallableSBase numerator, CallableSBase denominator) { return frac(new ASTNode(numerator, container), new ASTNode(denominator, container)); }
/** * @param vector * @param scalar */ private void vectorScalarFrac(ASTNode vector, ASTNode scalar) { for (int i = 0; i < vector.getChildCount(); ++i) { ASTNode child = vector.getChild(i); child.compile(this); ASTNode result = getNode(); if (result.isVector()) { vectorScalarGt(child, scalar); } else if (useId) { vector.replaceChild(i, ASTNode.frac(result, scalar)); } else if (result.isNumber() && scalar.isNumber()) { vector.getChild(i).setValue(result.getReal() / scalar.getReal()); } else { throw new SBMLException(); } } }
/** * @param scalar * @param vector */ private void scalarVectorFrac(ASTNode scalar, ASTNode vector) { for (int i = 0; i < vector.getChildCount(); ++i) { ASTNode child = vector.getChild(i); child.compile(this); ASTNode result = getNode(); if (result.isVector()) { scalarVectorGt(child, scalar); } else if (useId) { vector.replaceChild(i, ASTNode.frac(scalar, result)); } else if (result.isNumber() && scalar.isNumber() && result.getReal() != 0) { vector.getChild(i).setValue(scalar.getReal() / result.getReal()); } else { throw new SBMLException(); } } } /* (non-Javadoc)