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

org.lsmp.djep.groupJep.PolynomialVisitor Maven / Gradle / Ivy

Go to download

JEP is a Java library for parsing and evaluating mathematical expressions. Use groupId org.fudaa to deploy it in maven central

The newest version!
/* @author rich
 * Created on 05-Oct-2004
 */
package org.lsmp.djep.groupJep;

import org.nfunk.jep.*;
import org.lsmp.djep.groupJep.values.*;
import org.lsmp.djep.groupJep.groups.*;
import org.lsmp.djep.xjep.*;
/**
 * Constructs a polynomial from a JEP equation.
 * 
 * @author Rich Morris
 * Created on 05-Oct-2004
 */
public class PolynomialVisitor extends DoNothingVisitor {
	private OperatorSet opSet;
	private FreeGroup fg;
	/**
	 * 
	 */
	public PolynomialVisitor(JEP j) {
		super();
		opSet = j.getOperatorSet();
	}

	/**
	 * calculates a polynomial representing the node.
	 * @param node The top node of the expression
	 * @param fg The group the polynomial is an element of.
	 * @return the polynomial representing the equation
	 * @throws ParseException if the node cannot be converted to a Polynomial
	 */
	public Polynomial calcPolynomial(Node node,FreeGroup fg) throws ParseException
	{
		this.fg = fg;
		return (Polynomial) node.jjtAccept(this,null);
	}

	public Object visit(ASTFunNode node, Object data) throws ParseException {
		int nchild = node.jjtGetNumChildren();
		Polynomial children[] = new Polynomial[nchild];
		for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy