at.dms.kjc.sir.linear
Class LinearForm

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

public class LinearForm
extends Object

A LinearForm is the representation of a variable inside the linear dataflow analysis. It is comprised of a vector v and a value c. The vector corresponds to the combinations of inputs used to compute the value, and the value corresponds to a constant that is added 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.8 2006/01/25 17:01:57 thies Exp $


Constructor Summary
LinearForm(int size)
          Construct a new LinearForm with vector size size with all elements zero.
 
Method Summary
 void copyToColumn(FilterMatrix fm, int col)
          Add all of the weights in this linear form to the specified column in the passed FilterMatrix.
 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.
 int getIntegerOffset()
          Get the constant offset of this linear form.
 ComplexNumber getOffset()
          Get the constant offset of this linear form.
 ComplexNumber getWeight(int index)
          Gets a speficied weight.
 int getWeightsSize()
          Gets the internal size of the vecotr of this linear form (i.e.
 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 and a vector of all zeros.
 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 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 setWeight(int index, ComplexNumber weight)
          Sets the weight of a particular item in the linear form.
 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 size)
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 and a vector of all zeros.


setWeight

public void setWeight(int index,
                      ComplexNumber weight)
Sets the weight of a particular item in the linear form.


getWeight

public ComplexNumber getWeight(int index)
Gets a speficied weight.


getWeightsSize

public int getWeightsSize()
Gets the internal size of the vecotr of this linear form (i.e. the peek amount).


negate

public LinearForm negate()
Negate the LinearForm. To do this, we reverse the sign of the offset reverse the sign of each element in the array. 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 the weights vector element-wise, and you add the offset. 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 as well as the constant 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.


copyToColumn

public void copyToColumn(FilterMatrix fm,
                         int col)
Add all of the weights in this linear form to the specified column in the passed FilterMatrix. Weights are copied from index 0 to index n of the linear form, and from index (0,col) to index (n,col) of the filter matrix. eg from left to right in linear form becomes top to bottom in filter matrix. One more way -- copy the row vector in this linear form into the col column of the filter matrix.
Note that the offset of the linear form is not copied anywhere.


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