Package org.jamesii.core.math.parsetree

Examples of org.jamesii.core.math.parsetree.INode


  /** The Constant serialVersionUID. */
  private static final long serialVersionUID = -4130229097689040777L;

  @Override
  public IVariableModifier<?> create(ParameterBlock parameter, Context context) {
    INode mathExpression =
        ParameterBlocks.getSubBlockValue(parameter, EXPRESSION);
    return createModifier(mathExpression);
  }
View Full Code Here


*/
public class TestAbsNode extends TestValueNodeAbstract<AbsNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));

    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(1.) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(1.) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(0.) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(1.) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(1.) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(0.) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(4.) == 0);
  }
View Full Code Here

*/
public class TestExpNode extends TestValueNodeAbstract<ExpNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.exp(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.exp(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.exp(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.exp(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.exp(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.exp(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.exp(-4.)) == 0);
  }
View Full Code Here

*/
public class TestSinhNode extends TestValueNodeAbstract<SinhNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.sinh(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.sinh(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.sinh(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.sinh(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.sinh(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.sinh(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.sinh(-4.)) == 0);
  }
View Full Code Here

*/
public class TestTanhNode extends TestValueNodeAbstract<TanhNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.tanh(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.tanh(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.tanh(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.tanh(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.tanh(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.tanh(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.tanh(-4.)) == 0);
  }
View Full Code Here

*/
public class TestLog10Node extends TestValueNodeAbstract<Log10Node, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.log10(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.log10(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.log10(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log10(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log10(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log10(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log10(-4.)) == 0);
  }
View Full Code Here

*/
public class TestCosNode extends TestValueNodeAbstract<CosNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.cos(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.cos(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.cos(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.cos(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.cos(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.cos(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.cos(-4.)) == 0);
  }
View Full Code Here

*/
public class TestLogNode extends TestValueNodeAbstract<LogNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.log(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.log(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.log(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.log(-4.)) == 0);
  }
View Full Code Here

public class TestTailNode extends TestValueNodeAbstract<TailNode, INode> {

  @SuppressWarnings("unchecked")
  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ListNode res = node.calc(null);
    List<INode> resList = res.getValue();
    assertTrue(resList.size() == 0);

    node = getInstance(getA(3));
    res = node.calc(null);
    resList = res.getValue();
    assertTrue(resList.size() == 1);
    assertTrue(((ValueNode<Double>) resList.get(0)).getValue().compareTo(2.0) == 0);

    node =
        getInstance(new ListNode(toList(new MultNode(new ValueNode<>(2),
            new ValueNode<>(-2.)))));
    res = node.calc(null);
    resList = res.getValue();
    assertTrue(resList.size() == 0);

    node =
        getInstance(new ListNode(toList(new MultNode(new ValueNode<>(2),
            new ValueNode<>(-2.)), new MultNode(new ValueNode<>(2),
            new ValueNode<>(-3.)))));
    res = node.calc(null);
    resList = res.getValue();
    assertTrue(resList.size() == 1);
    assertTrue(((ValueNode<Double>) resList.get(0)).getValue().compareTo(-6.0) == 0);
  }
View Full Code Here

*/
public class TestArcCosNode extends TestValueNodeAbstract<ArcCosNode, INode> {

  @Override
  public void testCalc() {
    INode node = getInstance(getA(0));
    ValueNode<Double> res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.acos(1)) == 0);

    node = getInstance(getA(1));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.acos(-1)) == 0);

    node = getInstance(getA(2));
    res = node.calc(null);
    assertTrue(res.getValue().compareTo(Math.acos(0)) == 0);

    node = getInstance(getA(3));
    ValueNode<Double> res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.acos(1.)) == 0);

    node = getInstance(getA(4));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.acos(-1.)) == 0);

    node = getInstance(getA(5));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.acos(0.)) == 0);

    node =
        getInstance((new MultNode(new ValueNode<>(2), new ValueNode<>(-2.))));
    res2 = node.calc(null);
    assertTrue(res2.getValue().compareTo(Math.acos(-4.)) == 0);
  }
View Full Code Here

TOP

Related Classes of org.jamesii.core.math.parsetree.INode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.