ptolemy.actor.lib.comm
Class HadamardCode
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.Source
ptolemy.actor.lib.comm.HadamardCode
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class HadamardCode
- extends Source
Produce a Hadamard codeword by selecting a row from a Hadamard matrix.
The log base 2 of the matrix dimension is given by the log2Length
parameter, which should be a non-negative integer smaller than 32.
The row index is given by the index parameter or by the associated
index port, which should be a non-negative integer smaller
than the matrix dimension. If the index changes value when the actor is
in the middle of producing a sequence of Hadamard codeword, the actor
will take on the new index value, and start to produce the new codeword
from the beginning.
A Hadamard matrix is defined in the following way:
H1 = [1, 1; 1, -1]
Hn+1 = [Hn,
Hn;
Hn, -Hn]
where n is a positive integer.
Therefore, Hn is a 2n by
2n square matrix.
The codeword length is 2n.
The actor produces Hadamard codeword in booleans. Therefore, 1 is treated
as "true" and -1 is treated as "false".
- Since:
- Ptolemy II 3.0
- Version:
- $Id: HadamardCode.java,v 1.20 2004/04/13 03:01:35 cxh Exp $
- Author:
- Edward A. Lee and Rachel Zhou
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Constructor Summary |
HadamardCode(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
|
Method Summary |
void |
attributeChanged(Attribute attribute)
If the attribute being changed is log2Length, then
calculate the new Hadamard sequence; if it is index,
then verify that is non-negative and check if it is different
from the previous value. |
void |
fire()
Read from the associated index port if there is any input.
|
void |
initialize()
Initialize the actor by resetting the index counter to begin
at the beginning of the Hadamard sequence. |
boolean |
postfire()
This method should be invoked once per iteration, after the last
invocation of fire() in that iteration. |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
index
public PortParameter index
- Index of the code to generate. Codes with different indexes
are orthogonal. This is an int with default 0. It should
not exceed length-1, where length = 2^log2Length.
log2Length
public Parameter log2Length
- Log base 2 of the length of the code. This is an integer with
default 5. It is required to be greater than 0.
HadamardCode
public HadamardCode(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
The output and trigger ports are also constructed.
- Parameters:
container - The container.name - The name of this actor.
- Throws:
IllegalActionException - If the entity 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
- If the attribute being changed is log2Length, then
calculate the new Hadamard sequence; if it is index,
then verify that is non-negative and check if it is different
from the previous value.
- Overrides:
attributeChanged in class NamedObj
- Parameters:
attribute - The attribute that changed.
- Throws:
IllegalActionException - If index is negative
or log2Length is not strictly positive.
fire
public void fire()
throws IllegalActionException
- Read from the associated index port if there is any input.
The actor compares the new index value with the old one.
If the value changes, the actor will interrupt the current
output sequence, compute the new Hadamard codeword, and send it
to the output in sequence.
If the index remains constant when it reaches the end of a
Hadamard codeword sequence, the next iteration will restart
from the beginning of that codeword.
- Specified by:
fire in interface Executable- Overrides:
fire in class Source
- Throws:
IllegalActionException - If index is out of range.
initialize
public void initialize()
throws IllegalActionException
- Initialize the actor by resetting the index counter to begin
at the beginning of the Hadamard sequence.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
- Throws:
IllegalActionException - If there is no director.
postfire
public boolean postfire()
throws IllegalActionException
- Description copied from interface:
Executable
- This method should be invoked once per iteration, after the last
invocation of fire() in that iteration. It may produce output data.
It returns true if the execution can proceed into the next iteration,
false if the actor does not wish to be fired again.
This method typically wraps up an iteration, which may involve
updating local state. In an opaque, non-atomic entity, it may also
transfer output data. The execution of this method is bounded.
- Specified by:
postfire in interface Executable- Overrides:
postfire in class AtomicActor
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException - Not thrown in this base class.