at.dms.kjc.sir.statespace
Class LinearForm

java.lang.Object
  extended by at.dms.kjc.sir.statespace.LinearForm

public class LinearForm
extends Object

A LinearForm is the representation of a variable inside the linear dataflow analysis. It is comprised of vectors v and w. The vector v corresponds to the combinations of inputs used to compute the value, and the vector w corresponds to the combinations of state variables that are used to compute the value.
The basic gist of the dataflow analysis is to determine for all variables what the corresponding LinearForm is. Armed with this knowledge, we can propage LinearForm information throughout the body of the filter and construct a LinearFilterRepresentation from the filter.
$Id: LinearForm.java,v 1.3 2006/01/25 17:02:30 thies Exp $ Modified to state space form by Sitij Agrawal 2/9/04


Constructor Summary
LinearForm(int inputs, int states)
          Construct a new LinearForm with vector size size with all elements zero.
 
Method Summary
 void copyInputsToRow(FilterMatrix fm, int row)
          Add all of the weights in this linear form to the specified row in the passed FilterMatrix.
 void copyStatesToRow(FilterMatrix fm, int row)
           
 LinearForm divideByConstant(ComplexNumber divideFactor)
          Divide all weights and the offset of this linear form by a constant.
 boolean equals(Object o)
          Returns true if this object is equal in value to this linear form.
 ComplexNumber getInputWeight(int index)
          Gets a specified input weight.
 int getInputWeightsSize()
          Gets the internal size of the input vector of this linear form
 int getIntegerOffset()
          Get the constant offset of this linear form.
 ComplexNumber getOffset()
          Get the constant offset of this linear form.
 ComplexNumber getStateWeight(int index)
          Gets a specified state weight.
 int getStateWeightsSize()
          Gets the internal size of the state vector of this linear form
 int hashCode()
          Preserve equals() semantics.
 boolean isIntegerOffset()
          returns true if this linear form's offset is an integer
 boolean isOnlyOffset()
          Returns true if this LinearForm contains only a constant offset This means the inputs vector is all zeros, and the states vector is all zeros except for the last weight
 LinearForm multiplyByConstant(ComplexNumber scaleFactor)
          Scale a linear form by a constant.
 LinearForm negate()
          Negate the LinearForm.
 LinearForm plus(LinearForm other)
          Add two linear forms together.
 void setInputWeight(int index, ComplexNumber weight)
          Sets the weight of a particular item in the inputs vector.
 void setOffset(ComplexNumber val)
          Set the offset with a ComplexNumber.
 void setOffset(double val)
          Set the offset with a double.
 void setOffset(int val)
          Set the offset with an integer.
 void setStateWeight(int index, ComplexNumber weight)
          Sets the weight of a particular item in the states vector.
 String toString()
          Pretty print this linear form.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearForm

public LinearForm(int inputs,
                  int states)
Construct a new LinearForm with vector size size with all elements zero.

Method Detail

isIntegerOffset

public boolean isIntegerOffset()
returns true if this linear form's offset is an integer


getIntegerOffset

public int getIntegerOffset()
Get the constant offset of this linear form.


getOffset

public ComplexNumber getOffset()
Get the constant offset of this linear form.


setOffset

public void setOffset(int val)
Set the offset with an integer.


setOffset

public void setOffset(double val)
Set the offset with a double.


setOffset

public void setOffset(ComplexNumber val)
Set the offset with a ComplexNumber.


isOnlyOffset

public boolean isOnlyOffset()
Returns true if this LinearForm contains only a constant offset This means the inputs vector is all zeros, and the states vector is all zeros except for the last weight


setInputWeight

public void setInputWeight(int index,
                           ComplexNumber weight)
Sets the weight of a particular item in the inputs vector.


setStateWeight

public void setStateWeight(int index,
                           ComplexNumber weight)
Sets the weight of a particular item in the states vector.


getInputWeight

public ComplexNumber getInputWeight(int index)
Gets a specified input weight.


getStateWeight

public ComplexNumber getStateWeight(int index)
Gets a specified state weight.


getInputWeightsSize

public int getInputWeightsSize()
Gets the internal size of the input vector of this linear form


getStateWeightsSize

public int getStateWeightsSize()
Gets the internal size of the state vector of this linear form


negate

public LinearForm negate()
Negate the LinearForm. To do this, we reverse the sign of each element each vector. This method creates a new LinearForm, and returns that as the the result.


plus

public LinearForm plus(LinearForm other)
Add two linear forms together. To add two forms, you add each element in each vector element-wise. Returns a new linear form.


multiplyByConstant

public LinearForm multiplyByConstant(ComplexNumber scaleFactor)
Scale a linear form by a constant. This is used for multiplications in the code by a constant factor. All of the vector entries of the linear form are scaled by this constant.


divideByConstant

public LinearForm divideByConstant(ComplexNumber divideFactor)
Divide all weights and the offset of this linear form by a constant.


copyInputsToRow

public void copyInputsToRow(FilterMatrix fm,
                            int row)
Add all of the weights in this linear form to the specified row in the passed FilterMatrix. Weights are copied from index 0 to index n of the linear form, and from index (row,0) to index (row,n) of the filter matrix. eg from left to right in linear form becomes left to right in filter matrix. One more way -- copy the row vector in this linear form into the row row of the filter matrix.


copyStatesToRow

public void copyStatesToRow(FilterMatrix fm,
                            int row)

equals

public boolean equals(Object o)
Returns true if this object is equal in value to this linear form.

Overrides:
equals in class Object

hashCode

public int hashCode()
Preserve equals() semantics.

Overrides:
hashCode in class Object

toString

public String toString()
Pretty print this linear form.

Overrides:
toString in class Object