/** * Creates a new {@link ASTNode} that has exactly one child and which is of type * minus, i.e., this negates what is encoded in ast. * * @param ast * @return a new {@link ASTNode} that has exactly one child and which is of type * minus, i.e., this negates what is encoded in ast. */ public static ASTNode uMinus(ASTNode ast) { ASTNode um = new ASTNode(Type.MINUS, ast.getParentSBMLObject()); um.addChild(ast); return um; }
/** * Creates and returns an {@link ASTNode} that computes the absolute value * of the given integer value. * * @param integer an integer value * @param parent the parent {@link ASTNode} * @return an {@link ASTNode} that computes the absolute value * of the given integer value. */ public static ASTNode abs(int integer, MathContainer parent) { ASTNode abs = new ASTNode(Type.FUNCTION_ABS, parent); abs.addChild(new ASTNode(integer, parent)); return abs; }
/** * Creates and returns an {@link ASTNode} that computes the absolute value * of the given double value. * * @param d a double value * @param parent the parent {@link ASTNode} * @return an {@link ASTNode} that computes the absolute value * of the given double value. */ public static ASTNode abs(double d, MathContainer parent) { ASTNode abs = new ASTNode(Type.FUNCTION_ABS, parent); abs.addChild(new ASTNode(d, parent)); return abs; }
/** * Creates a root {@link ASTNode}. * * @param radicand the radicand * @param rootExponent the exponent of the root element. * @return a root {@link ASTNode}. */ public static ASTNode root(ASTNode rootExponent, ASTNode radicand) { ASTNode root = new ASTNode(Type.FUNCTION_ROOT, radicand .getParentSBMLObject()); root.addChild(rootExponent); root.addChild(radicand); setParentSBMLObject(rootExponent, radicand.getParentSBMLObject(), 0); return root; }
@Override public ASTNodeValue lambda(List<ASTNode> values) throws SBMLException { if (useId) { ASTNode value = new ASTNode(ASTNode.Type.LAMBDA); for (ASTNode node : values) { node.compile(this); value.addChild(getNode()); } setNode(value); } else { values.get(values.size() - 1).compile(this); } return dummy; }
@Override public ASTNodeValue vector(List<ASTNode> nodes) throws SBMLException { ASTNode vector = new ASTNode(); vector.setType(ASTNode.Type.VECTOR); for (int i = 0; i < nodes.size(); ++i) { nodes.get(i).compile(this); ASTNode node = getNode(); if (node.equals(new ASTNode("unknown"))) { unknownValue(); return dummy; } vector.addChild(getNode()); } setNode(vector); return dummy; }
/** * @param value */ private void sinRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { sinRecursive(value.getChild(i)); } else if (useId){ ASTNode sinValue = new ASTNode(ASTNode.Type.FUNCTION_SIN, child.getParentSBMLObject()); sinValue.addChild(child.clone()); value.replaceChild(i, sinValue); } else if (child.isNumber()) { value.getChild(i).setValue(Math.sin(child.getReal())); } else { throw new SBMLException(); } } }
/** * @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 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 arctanhRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { arctanhRecursive(value.getChild(i)); } else if (useId){ ASTNode arctanhValue = new ASTNode(ASTNode.Type.FUNCTION_ARCTANH, child.getParentSBMLObject()); arctanhValue.addChild(child.clone()); value.replaceChild(i, arctanhValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.arctanh(child.getReal())); } else { throw new SBMLException(); } } }
/** * @param value */ private void cothRecursive(ASTNode value) { for (int i = 0; i < value.getChildCount(); i++) { value.getChild(i).compile(this); ASTNode child = getNode(); if (child.isVector()) { cothRecursive(value.getChild(i)); } else if (useId){ ASTNode cothValue = new ASTNode(ASTNode.Type.FUNCTION_COTH, child.getParentSBMLObject()); cothValue.addChild(child.clone()); value.replaceChild(i, cothValue); } else if (child.isNumber()) { value.getChild(i).setValue(Maths.coth(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(); } } }