ptolemy.actor.lib
Class UnaryMathFunction
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Transformer
ptolemy.actor.lib.UnaryMathFunction
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class UnaryMathFunction
- extends Transformer
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.
- 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.
- Since:
- Ptolemy II 4.1
- Version:
- $Id: UnaryMathFunction.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- C. Fong, Steve Neuendorffer
- See Also:
AbsoluteValue
,
Remainder
,
Scale
,
TrigFunction
,
Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Method Summary |
private double |
_doFunction(double input)
Calculate the function on the given argument. |
void |
attributeChanged(Attribute attribute)
Override the base class to determine which function is being
specified. |
void |
fire()
Consume at most one input token from each input channel, and
compute the specified math function of the input. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup |
Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
function
public StringParameter function
- The function to compute. This is a string-valued attribute
that defaults to "exp".
_function
private int _function
_EXP
private static final int _EXP
- See Also:
- Constant Field Values
_LOG
private static final int _LOG
- See Also:
- Constant Field Values
_SIGN
private static final int _SIGN
- See Also:
- Constant Field Values
_SQUARE
private static final int _SQUARE
- See Also:
- Constant Field Values
_SQRT
private static final int _SQRT
- See Also:
- Constant Field Values
UnaryMathFunction
public UnaryMathFunction(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
- Parameters:
container
- The container.name
- The name of this actor.
- Throws:
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.
attributeChanged
public void attributeChanged(Attribute attribute)
throws IllegalActionException
- Override the base class to determine which function is being
specified.
- Overrides:
attributeChanged
in class NamedObj
- Parameters:
attribute
- The attribute that changed.
- Throws:
IllegalActionException
- If the function is not recognized.
fire
public void fire()
throws IllegalActionException
- Consume at most one input token from each input channel, and
compute the specified math function of the input.
If there is no input, then produce no output.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class AtomicActor
- Throws:
IllegalActionException
- If there is no director.
_doFunction
private double _doFunction(double input)
- Calculate the function on the given argument.
- Parameters:
input
- The input value.
- Returns:
- The result of applying the function.