/** * Creates and returns a new {@link ASTNode}. * * @param mantissa * @param exponent * @param parent */ public ASTNode(double mantissa, int exponent, MathContainer parent) { this(Type.REAL_E, parent); setValue(mantissa, exponent); }
/** * Creates and returns a new {@link ASTNode}. * * @param real * @param parent */ public ASTNode(double real, MathContainer parent) { this(Type.REAL, parent); setValue(real); }
/** * Creates and returns a new {@link ASTNode}. * * @param mantissa * @param exponent */ public ASTNode(double mantissa, int exponent) { this(Type.REAL_E); setValue(mantissa, exponent); }
/** * Creates and returns a new {@link ASTNode}. * * @param real */ public ASTNode(double real) { this(Type.REAL); setValue(real); }
/** * Creates and returns a new {@link ASTNode} with the given integer value with * the given associated {@link #unitId} for the * given {@link MathContainer} as its parent SBML object. * * @param integer * @param unitsID * @param parent */ public ASTNode(int integer, String unitsID, MathContainer parent) { this(Type.INTEGER, parent); setValue(integer); if (unitsID != null) { setUnits(unitsID); } }
@Override public ASTNodeValue getConstantAvogadro(String name) { ASTNode avogNode = new ASTNode(ASTNode.Type.REAL); avogNode.setValue(Math.pow(6.02214179, Math.pow(10, 23))); setNode(avogNode); return dummy; }
@Override public ASTNodeValue compile(double mantissa, int exponent, String units) { ASTNode node = new ASTNode(); node.setValue(mantissa, exponent); setNode(node); return dummy; }
/** * Replaces dimension id with the appropriate integer value. * * @param math * @param id * @param index */ private static void recursiveReplaceDimensionId(ASTNode math, String id, int index) { if (math.getChildCount() == 0) { if (math.isString() && math.getName().equals(id)) { math.setValue(index); } return; } for (int i = 0; i < math.getChildCount(); ++i) { recursiveReplaceDimensionId(math.getChild(i), id, index); } }
/** * @param value */ private void ceilingRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { ceilingRecursive(value.getChild(i)); } else if (useId){ ASTNode ceilValue = new ASTNode(ASTNode.Type.FUNCTION_CEILING, child.getParentSBMLObject()); ceilValue.addChild(child.clone()); value.replaceChild(i, ceilValue); } else if (child.isNumber()) { value.getChild(i).setValue(Math.ceil(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void logRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { logRecursive(value.getChild(i)); } else if (useId){ ASTNode logValue = new ASTNode(ASTNode.Type.FUNCTION_LOG, child.getParentSBMLObject()); logValue.addChild(child.clone()); value.replaceChild(i, logValue); } else if (child.isNumber()) { value.getChild(i).setValue(Math.log10(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void arcsinRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { arcsinRecursive(value.getChild(i)); } else if (useId){ ASTNode arcsinValue = new ASTNode(ASTNode.Type.FUNCTION_ARCSIN, child.getParentSBMLObject()); arcsinValue.addChild(child.clone()); value.replaceChild(i, arcsinValue); } else if (child.isNumber()) { value.getChild(i).setValue(Math.asin(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void floorRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { floorRecursive(value.getChild(i)); } else if (useId){ ASTNode floorValue = new ASTNode(ASTNode.Type.FUNCTION_FLOOR, child.getParentSBMLObject()); floorValue.addChild(child.clone()); value.replaceChild(i, floorValue); } else if (child.isNumber()) { value.getChild(i).setValue(Math.floor(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void lnRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { lnRecursive(value.getChild(i)); } else if (useId){ ASTNode lnValue = new ASTNode(ASTNode.Type.FUNCTION_LN, child.getParentSBMLObject()); lnValue.addChild(child.clone()); value.replaceChild(i, lnValue); } else if (child.isNumber()) { value.getChild(i).setValue(Math.log(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void arccothRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { arccothRecursive(value.getChild(i)); } else if (useId){ ASTNode arccothValue = new ASTNode(ASTNode.Type.FUNCTION_ARCCOTH, child.getParentSBMLObject()); arccothValue.addChild(child.clone()); value.replaceChild(i, arccothValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.arccoth(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void arccscRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { arccscRecursive(value.getChild(i)); } else if (useId){ ASTNode arccscValue = new ASTNode(ASTNode.Type.FUNCTION_ARCCSC, child.getParentSBMLObject()); arccscValue.addChild(child.clone()); value.replaceChild(i, arccscValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.arccsc(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void arcsecRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { arcsecRecursive(value.getChild(i)); } else if (useId){ ASTNode arcsecValue = new ASTNode(ASTNode.Type.FUNCTION_ARCSEC, child.getParentSBMLObject()); arcsecValue.addChild(child.clone()); value.replaceChild(i, arcsecValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.arcsec(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void coshRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isNumber()) { value.getChild(i).setValue(Math.cosh(child.getReal())); } else if (child.isVector()) { coshRecursive(value.getChild(i)); } else if (useId){ ASTNode coshValue = new ASTNode(ASTNode.Type.FUNCTION_COSH, child.getParentSBMLObject()); coshValue.addChild(child.clone()); value.replaceChild(i, coshValue); } else { throw new SBMLException(); } } }
/** * @param value */ private void cschRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { cschRecursive(value.getChild(i)); } else if (useId){ ASTNode cschValue = new ASTNode(ASTNode.Type.FUNCTION_CSCH, child.getParentSBMLObject()); cschValue.addChild(child.clone()); value.replaceChild(i, cschValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.csch(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void cotRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isNumber()) { value.getChild(i).setValue(Maths.cot(child.getReal())); } else if (child.isVector()) { cotRecursive(value.getChild(i)); } else if (useId){ ASTNode cotValue = new ASTNode(ASTNode.Type.FUNCTION_COT, child.getParentSBMLObject()); cotValue.addChild(child.clone()); value.replaceChild(i, cotValue); } else { throw new SBMLException(); } } }
/** * @param value */ private void sechRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { sechRecursive(value.getChild(i)); } else if (useId){ ASTNode sechValue = new ASTNode(ASTNode.Type.FUNCTION_SECH, child.getParentSBMLObject()); sechValue.addChild(child.clone()); value.replaceChild(i, sechValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.sech(child.getReal())); } else { throw new SBMLException(); } } }