All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lsmp.djep.sjep.PFunction Maven / Gradle / Ivy

Go to download

JEP is a Java library for parsing and evaluating mathematical expressions.

The newest version!
/* @author rich
 * Created on 15-Dec-2004
 */
package org.lsmp.djep.sjep;
import org.nfunk.jep.*;
import org.nfunk.jep.function.*;
import org.lsmp.djep.xjep.*;
/**
 * Represents a function.
 * 
 * @author Rich Morris
 * Created on 15-Dec-2004
 */
public class PFunction extends AbstractPNode {
	
	String name;
	PostfixMathCommandI pfmc;
	XOperator op=null;
	PNodeI args[];
	/**
	 * 
	 */
	public PFunction(PolynomialCreator pc,String name,PostfixMathCommandI pfmc,PNodeI args[]) {
		super(pc);
		this.name = name;
		this.pfmc = pfmc;
		this.args = args;
	}

	public boolean equals(PNodeI node)
	{
		if(!(node instanceof PFunction)) return false;
		PFunction fun = (PFunction) node;
		if(!name.equals(fun.name)) return false;
		if(args.length != fun.args.length)
			return false;
		for(int i=0;i -1
	this > arg ---> 1
	*/
	public int compareTo(PFunction fun)
	{
		int res = name.compareTo(fun.name);
		if(res != 0) return res;
		
		if(args.length < fun.args.length) return -1;
		if(args.length > fun.args.length) return 1;
		
		for(int i=0;i0) sb.append(',');
			sb.append(args[i].toString());
		}
		sb.append(')');
		return sb.toString();
	}
	
	public Node toNode() throws ParseException
	{
		Node funargs[] = new Node[args.length];
		for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy