// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   NegativeNode.java

package lt.monarch.function.node;

import lt.monarch.function.Node;
import lt.monarch.function.Variable;

// Referenced classes of package lt.monarch.function.node:
//			MinusNode, TermNode, OperatorNode, ConstantNode

public class NegativeNode extends MinusNode
	implements TermNode
{

	public Node cloneNode()
	{
		return (Node)new NegativeNode(super.r.cloneNode());
	}

	public Node positive()
	{
		return super.r;
	}

	public String toString()
	{
		return "-" + super.r;
	}

	public double evaluate()
	{
		return -super.r.evaluate();
	}

	public Node simplifyOperation()
	{
		if(super.r instanceof NegativeNode)
			return ((OperatorNode) ((NegativeNode)super.r)).r;
		else
			return super.simplifyOperation();
	}

	public double multiplier()
	{
		if(super.r instanceof TermNode)
			return -((TermNode)super.r).multiplier();
		else
			return (double)-1;
	}

	public Node termNode()
	{
		if(super.r instanceof TermNode)
			return ((TermNode)super.r).termNode();
		else
			return super.r;
	}

	public Node derivative(Variable variable)
	{
		return (Node)new NegativeNode(super.r.derivative(variable));
	}

	public NegativeNode(Node node)
	{
		super(new ConstantNode(0.0D), node);
	}
}
