com.codetaco.algebrain.function.FuncLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algebrain Show documentation
Show all versions of algebrain Show documentation
Equation processing for Java
The newest version!
package com.codetaco.algebrain.function;
import java.text.ParseException;
import com.codetaco.algebrain.Function;
import com.codetaco.algebrain.ValueStack;
import com.codetaco.algebrain.token.TokVariable;
/**
*
* FuncLog class.
*
*
* @author Chris DeGreef [email protected]
* @since 1.3.9
*/
public class FuncLog extends Function
{
/**
*
* Constructor for FuncLog.
*
*/
public FuncLog()
{
super();
}
/**
*
* Constructor for FuncLog.
*
*
* @param var a {@link com.codetaco.algebrain.token.TokVariable} object.
*/
public FuncLog(final TokVariable var)
{
super(var);
}
/** {@inheritDoc} */
@Override
public void resolve(final ValueStack values) throws Exception
{
if (values.size() < 1)
throw new Exception("missing operands for " + toString());
try
{
values.push(new Double(Math.log(values.popDouble())));
} catch (final ParseException e)
{
e.fillInStackTrace();
throw new Exception(toString() + "; " + e.getMessage(), e);
}
}
/** {@inheritDoc} */
@Override
public String toString()
{
return "function(log)";
}
}