ptolemy.actor.lib

## Class Lattice

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

```public class Lattice
extends Transformer```
An FIR filter with a lattice structure. The coefficients of such a filter are called "reflection coefficients." Lattice filters are typically used as linear predictors because it is easy to ensure that they are minimum phase, and hence that their inverse is stable. A lattice filter is (strictly) minimum phase if its reflection coefficients are all less than unity in magnitude. To get the reflection coefficients for a linear predictor for a particular random process, you can use the LevinsonDurbin actor. The inputs and outputs are of type double.

The default reflection coefficients correspond to the optimal linear predictor for an AR process generated by filtering white noise with the following filter:

```                            1
H(z) =  --------------------------------------
1 - 2z-1 + 1.91z-2 - 0.91z-3 + 0.205z-4
```

Since this filter is minimum phase, the transfer function of the lattice filter is H -1(z).

Note that the definition of reflection coefficients is not quite universal in the literature. The reflection coefficients in reference [2] are the negative of the ones used by this actor, which correspond to the definition in most other texts, and to the definition of partial-correlation (PARCOR) coefficients in the statistics literature.

The signs of the coefficients used in this actor are appropriate for values given by the LevinsonDurbin actor. The structure of the filter is as follows:

```      y[0]              y[1]               y[n-1]           y[n]
X(n) -------o-->-(+)-->----o-->-(+)-->-- ... ->---o-->-(+)------>  Y(n)
|       \   /          \   /                  \   /
|      +K1 /          +K2 /                  +Kn /
|         X              X                      X
V      -K1 \          -K2 \                  -Kn \
|       /   \          /   \                  /   \
\-[z]--o-->-(+)-[z]---o-->-(+)-[z]- ... ->---o-->-(+)
w[0]         w[1]               w[n-1]           w[n]
```

References

[1] J. Makhoul, "Linear Prediction: A Tutorial Review", Proc. IEEE, Vol. 63, pp. 561-580, Apr. 1975.

[2] S. M. Kay, Modern Spectral Estimation: Theory & Application, Prentice-Hall, Englewood Cliffs, NJ, 1988.

Since:
Ptolemy II 1.0
Version:
\$Id: Lattice.java 70402 2014-10-23 00:52:20Z cxh \$
Author:
Edward A. Lee, Christopher Hylands, Steve Neuendorffer
`FIR`, `LevinsonDurbin`, `RecursiveLattice`, `VariableLattice`
Accepted Rating:
 Yellow (cxh)
Proposed Rating:
 Yellow (eal)

• ### Nested classes/interfaces inherited from class ptolemy.kernel.Entity

`Entity.ContainedObjectsIterator`
• ### Field Summary

Fields
Modifier and Type Field and Description
`protected double[]` `_backward`
Backward prediction errors.
`protected double[]` `_backwardCache`
Cache of backward prediction errors.
`protected double[]` `_forward`
Forward prediction errors.
`protected double[]` `_forwardCache`
Cache of forward prediction errors.
`protected int` `_order`
The order of the filter (i.e. the number of reflection coefficients)
`protected double[]` `_reflectionCoefficients`
Cache of reflection coefficients.
`Parameter` `reflectionCoefficients`
The reflection coefficients.
• ### Fields inherited from class ptolemy.actor.lib.Transformer

`input, output`
• ### Fields inherited from class ptolemy.actor.TypedAtomicActor

`_typesValid`
• ### Fields inherited from class ptolemy.actor.AtomicActor

`_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested`
• ### Fields inherited from class ptolemy.kernel.util.NamedObj

`_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS`
• ### Fields inherited from interface ptolemy.actor.Executable

`COMPLETED, NOT_READY, STOP_ITERATING`
• ### Constructor Summary

Constructors
Constructor and Description
```Lattice(CompositeEntity container, java.lang.String name)```
Construct an actor with the given container and name.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`protected void` `_doFilter()`
Compute the filter, updating the caches, based on the current values.
`protected void` `_reallocate()`
Reallocate the internal arrays.
`void` `attributeChanged(Attribute attribute)`
If the argument is the reflectionCoefficients parameter, then reallocate the arrays to use.
`java.lang.Object` `clone(Workspace workspace)`
Clone the actor into the specified workspace.
`void` `fire()`
Consume one input token, if there is one, and produce one output token.
`void` `initialize()`
Initialize the state of the filter.
`boolean` `postfire()`
Update the backward and forward prediction errors that were generated in fire() method.
`boolean` `prefire()`
Check to see if this actor is ready to fire.
• ### Methods inherited from class ptolemy.actor.TypedAtomicActor

`_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints`
• ### Methods inherited from class ptolemy.actor.AtomicActor

`_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, 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

`_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName`
• ### Methods inherited from class ptolemy.kernel.InstantiableNamedObj

`_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition`
• ### Methods inherited from class ptolemy.kernel.util.NamedObj

`_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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`
• ### Methods inherited from interface ptolemy.actor.Actor

`createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList`
• ### Methods inherited from interface ptolemy.actor.Executable

`isFireFunctional, isStrict, iterate, stop, stopFire, terminate`
• ### Methods inherited from interface ptolemy.actor.Initializable

`addInitializable, preinitialize, removeInitializable, wrapup`
• ### Methods inherited from interface ptolemy.kernel.util.Nameable

`description, getContainer, getDisplayName, getFullName, getName, getName, setName`
• ### Methods inherited from interface ptolemy.kernel.util.Derivable

`getDerivedLevel, getDerivedList, propagateValue`
• ### Field Detail

• #### reflectionCoefficients

`public Parameter reflectionCoefficients`
The reflection coefficients. This is an array of doubles with default value {0.804534, -0.820577, 0.521934, -0.205}. These are the reflection coefficients for the linear predictor of a particular random process.
• #### _order

`protected int _order`
The order of the filter (i.e. the number of reflection coefficients)
• #### _backward

`protected double[] _backward`
Backward prediction errors. The length is _order.
• #### _backwardCache

`protected double[] _backwardCache`
Cache of backward prediction errors. The fire() method updates _forwardCache and postfire() copies _forwardCache to _forward so this actor will work in domains like SR. The length is _order.
• #### _forward

`protected double[] _forward`
Forward prediction errors. The length is _order + 1.
• #### _forwardCache

`protected double[] _forwardCache`
Cache of forward prediction errors. The fire() method updates _forwardCache and postfire() copies _forwardCache to _forward so this actor will work in domains like SR. The length is _order + 1.
• #### _reflectionCoefficients

`protected double[] _reflectionCoefficients`
Cache of reflection coefficients. The length is _order.
• ### Constructor Detail

• #### Lattice

```public Lattice(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.
• ### Method Detail

• #### attributeChanged

```public void attributeChanged(Attribute attribute)
throws IllegalActionException```
If the argument is the reflectionCoefficients parameter, then reallocate the arrays to use.
Overrides:
`attributeChanged` in class `NamedObj`
Parameters:
`attribute` - The attribute that changed.
Throws:
`IllegalActionException` - If the base class throws it.
• #### clone

```public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException```
Clone the actor into the specified workspace.
Overrides:
`clone` in class `TypedAtomicActor`
Parameters:
`workspace` - The workspace for the new object.
Returns:
A new actor.
Throws:
`java.lang.CloneNotSupportedException` - If a derived class contains an attribute that cannot be cloned.
`NamedObj.exportMoML(Writer, int, String)`, `NamedObj.setDeferringChangeRequests(boolean)`
• #### fire

```public void fire()
throws IllegalActionException```
Consume one input token, if there is one, and produce one output token. If there is no input, the produce no output.
Specified by:
`fire` in interface `Executable`
Overrides:
`fire` in class `AtomicActor<TypedIOPort>`
Throws:
`IllegalActionException` - If there is no director.
• #### initialize

```public void initialize()
throws IllegalActionException```
Initialize the state of the filter.
Specified by:
`initialize` in interface `Initializable`
Overrides:
`initialize` in class `AtomicActor<TypedIOPort>`
Throws:
`IllegalActionException` - If a derived class throws it.
• #### postfire

```public boolean postfire()
throws IllegalActionException```
Update the backward and forward prediction errors that were generated in fire() method.
Specified by:
`postfire` in interface `Executable`
Overrides:
`postfire` in class `AtomicActor<TypedIOPort>`
Returns:
False if the number of iterations matches the number requested.
Throws:
`IllegalActionException` - If there is no director.
• #### prefire

```public boolean prefire()
throws IllegalActionException```
Check to see if this actor is ready to fire.
Specified by:
`prefire` in interface `Executable`
Overrides:
`prefire` in class `AtomicActor<TypedIOPort>`
Returns:
True if this actor is ready for firing, false otherwise.
Throws:
`IllegalActionException` - If there is no director.
• #### _doFilter

```protected void _doFilter()
throws IllegalActionException```
Compute the filter, updating the caches, based on the current values.
Throws:
`IllegalActionException` - Not thrown in this base class.
• #### _reallocate

`protected void _reallocate()`
Reallocate the internal arrays.