org.lsmp.djep.matrixJep.function
Class MIf

java.lang.Object
  extended by org.nfunk.jep.function.PostfixMathCommand
      extended by org.lsmp.djep.matrixJep.function.MIf
All Implemented Interfaces:
MatrixSpecialEvaluationI, NaryOperatorI, PostfixMathCommandI

public class MIf
extends PostfixMathCommand
implements NaryOperatorI, MatrixSpecialEvaluationI

The if(condExpr,posExpr,negExpr) function. The value of trueExpr will be returned if condExpr is >0 (true) and value of negExpr will be returned if condExpr is <= 0 (false).

This function performs lazy evaluation so that only posExpr or negExpr will be evaluated. For Complex numbers only the real part is used.

An alternate form if(condExpr,posExpr,negExpr,zeroExpr) is also available. Note most computations are carried out over floating point doubles so testing for zero can be dangerous.

This function implements the SpecialEvaluationI interface so that it handles setting the value of a variable.

Author:
Rich Morris Created on 18-Nov-2003

Field Summary
 
Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
curNumberOfParameters, numberOfParameters
 
Constructor Summary
MIf()
           
 
Method Summary
 Dimensions calcDim(Dimensions[] dims)
          Find the dimension of this node.
 MatrixValueI calcValue(MatrixValueI res, MatrixValueI[] inputs)
          This method should not be called.
 boolean checkNumberOfParameters(int n)
          Checks the number of parameters of the function.
 MatrixValueI evaluate(MatrixNodeI node, MatrixEvaluator visitor, MatrixJep j)
          Evaluate the node, uses lazy evaluation.
 
Methods inherited from class org.nfunk.jep.function.PostfixMathCommand
checkStack, getNumberOfParameters, run, setCurNumberOfParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nfunk.jep.function.PostfixMathCommandI
getNumberOfParameters, run, setCurNumberOfParameters
 

Constructor Detail

MIf

public MIf()
Method Detail

calcDim

public Dimensions calcDim(Dimensions[] dims)
                   throws ParseException
Find the dimension of this node.

Specified by:
calcDim in interface NaryOperatorI
Throws:
ParseException

calcValue

public MatrixValueI calcValue(MatrixValueI res,
                              MatrixValueI[] inputs)
                       throws ParseException
This method should not be called. Use evaluate(org.lsmp.djep.matrixJep.nodeTypes.MatrixNodeI, org.lsmp.djep.matrixJep.MatrixEvaluator, org.lsmp.djep.matrixJep.MatrixJep) instead.

Specified by:
calcValue in interface NaryOperatorI
Throws:
ParseException

evaluate

public MatrixValueI evaluate(MatrixNodeI node,
                             MatrixEvaluator visitor,
                             MatrixJep j)
                      throws ParseException
Evaluate the node, uses lazy evaluation.

Specified by:
evaluate in interface MatrixSpecialEvaluationI
Parameters:
node - The top node.
visitor - The parser visitor
j - The current MatrixJep instance.
Returns:
Value after evaluation.
Throws:
ParseException

checkNumberOfParameters

public boolean checkNumberOfParameters(int n)
Description copied from class: PostfixMathCommand
Checks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method

Specified by:
checkNumberOfParameters in interface PostfixMathCommandI
Overrides:
checkNumberOfParameters in class PostfixMathCommand
Parameters:
n - number of parameters function will be called with.
Returns:
False if an illegal number of parameters is supplied, true otherwise.


http://www.singularsys.com/jep Copyright © 2007 Singular Systems