Class MathFunction

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    @Deprecated
    public class MathFunction
    extends TypedAtomicActor
    Deprecated.
    This breaks the class mechanism. Generally, it is awkward to have the ports of an actor depend on parameter values. Use UnaryMathFunction instead.
    Produce an output token on each firing with a value that is equal to the specified math function of the input. The input and output types are DoubleToken. The functions are a subset of those in the java.lang.Math class. They are:
    • exp: The exponential function. This is the default function for this actor If the argument is NaN, then the result is NaN.
    • log: The natural logarithm function. If the argument is NaN, then the result is NaN.
    • modulo: The modulo after division. If the second operand is zero, then the result is NaN.
    • sign: If the argument is greater than 0, return 1.0, if it is less than 0, return -1.0, otherwise return 0.0.
    • square: The square function If the argument is NaN, then the result is NaN.
    • sqrt: The square root function. If the argument is NaN, then the result is NaN.

    NOTES:

    1. Some functions like exp, log, square, and sqrt act on a single operand only. Other functions like modulo act on two operands. The actor acquires a second input when the function is changed to modulo, and loses the input when the function is changed back.

    2. There is an alternative to using the MathFunction.modulo() method If you want to use the IEEE remainder standard, use the Remainder actor.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    C. Fong
    See Also:
    AbsoluteValue, Remainder, Scale, TrigFunction
    Pt.AcceptedRating:
    Yellow (janneck)
    Pt.ProposedRating:
    Yellow (chf)
    • Field Detail

      • function

        public StringParameter function
        Deprecated.
        The function to compute. This is a string-valued attribute that defaults to "exp".
      • firstOperand

        public TypedIOPort firstOperand
        Deprecated.
        The port for the first operand. The port has type BaseType.DOUBLE
      • secondOperand

        public TypedIOPort secondOperand
        Deprecated.
        The port for the second operand, if it is needed. The port has type BaseType.DOUBLE
      • output

        public TypedIOPort output
        Deprecated.
        Output port. The port has type BaseType.DOUBLE
    • Method Detail

      • iterate

        public int iterate​(int count)
                    throws IllegalActionException
        Deprecated.
        Invoke a specified number of iterations of this actor. Each iteration computes the math function specified by the function parameter on a single token. An invocation of this method therefore applies the function to count successive input tokens.

        This method should be called instead of the usual prefire(), fire(), postfire() methods when this actor is used in a domain that supports vectorized actors. This leads to more efficient execution.

        Specified by:
        iterate in interface Executable
        Overrides:
        iterate in class AtomicActor<TypedIOPort>
        Parameters:
        count - The number of iterations to perform.
        Returns:
        COMPLETED if the actor was successfully iterated the specified number of times. Otherwise, return NOT_READY, and do not consume any input tokens.
        Throws:
        IllegalActionException - Not thrown in this base class