

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object  +wavelets.wavelet_base  +wavelets.simple_haar
Class simple_haar
This object calcalculates the "ordered fast Haar wavelet transform". The algorithm used is the a simple Haar wavelet algorithm that does not calculate the wavelet transform inplace. The function works on Java double values.
The wavelet_calc function is passed an array of doubles from which it calculates the Haar wavelet transform. The transform is not calculated in place. The result consists of a single value and a Vector of coefficients arrays, ordered by increasing frequency. The number of data points in the data used to calculate the wavelet must be a power of two.
The Haar wavelet transform is based on calculating the Haar step function and the Haar wavelet from two adjacent values. For an array of values S0, S1, S2 .. Sn, the step function and wavelet are calculated as follows for two adjacent points, S0 and S1:
HaarStep = (S0 + S1)/2 // average of S0 and S1 HaarWave = (S0  S1)/2 // average difference of S0 and S1
This yields two vectors: a, which contains the HaarStep values and c, which contains the HaarWave values.
The result of the wavelet_calc is the single Haar value and a set of coefficients. There will be ceil( log_{2}( values.length() )) coefficients.
You may use this source code without limitation and without fee as long as you include:
This software was written and is copyrighted by Ian Kaplan, Bear Products International, www.bearcave.com, 2001.
This software is provided "as is", without any warrenty or claim as to its usefulness. Anyone who uses this source code uses it at their own risk. Nor is any support provided by Ian Kaplan and Bear Products International.
Please send any bug fixes or suggested source changes to:
iank@bearcave.com
Field Summary  
private java.util.Vector 
coef

private double[] 
data

private double 
haar_value

Constructor Summary  
simple_haar()

Method Summary  
private double 
haar_calc(double[] values)
Recursively calculate the Haar transform. 
void 
inverse()
Calculate the inverse haar transform from the coefficients and the Haar value. 
void 
pr_values()
Print the data values. 
void 
pr()
Print the simple Haar object (e.g, the final Haar step value and the coefficients. 
private void 
reverseCoef()
The Haar transform coefficients are generated from the longest coefficient vector (highest frequency) to the shortest (lowest frequency). 
void 
wavelet_calc(double[] values)
Calculate the Haar wavelet transform (the ordered fast Haar wavelet tranform). 
Methods inherited from class java.lang.Object 

Field Detail 
private double haar_value
private java.util.Vector coef
private double[] data
Constructor Detail 
public simple_haar()
Method Detail 
public void wavelet_calc(double[] values)
Calculate the Haar wavelet transform (the ordered fast Haar wavelet tranform). This calculation is not done in place.
values
 a values: an array of double
values on which the Haar transform is
applied.private void reverseCoef()
private double haar_calc(double[] values)
The number of elements in values must be a power of two.
public void inverse()
Calculate the inverse haar transform from the coefficients and the Haar value.
The inverse function will overwrite the original data that was used to calculate the Haar transform. Since this data is initialized by the caller, the caller should make a copy if the data should not be overwritten.
The coefficients are stored in in a Java Vector container. The length of the coefficient arrays is ordered in powers of two (e.g., 1, 2, 4, 8...). The inverse Haar function is calculated using a butterfly pattern to write into the data array. An initial step writes the Haar value into data[0]. In the case of the example below this would be
data[0] = 5.0;
Then a butterfly pattern is shown below. Arrays indices start at 0, so in this example c[1,1] is the second element of the second coefficient vector.
wavelet: {[5.0]; 3.0; 0.0, 1.0; 1.0, 2.0, 1.0, 0.0} tmp = d[0]; d[0] = tmp + c[0, 0] d[4] = tmp  c[0, 0] tmp = d[0]; d[0] = tmp + c[1, 0] d[2] = tmp  c[1, 0] tmp = d[4]; d[4] = tmp + c[1, 1] d[6] = tmp  c[1, 1] tmp = d[0]; d[0] = tmp + c[2, 0] d[1] = tmp  c[2, 0] tmp = d[2]; d[2] = tmp + c[2, 1] d[3] = tmp  c[2, 1] tmp = d[4]; d[4] = tmp + c[2, 2] d[5] = tmp  c[2, 2] tmp = d[6]; d[6] = tmp + c[2, 3] d[7] = tmp  c[2, 3]
public void pr()
public void pr_values()
Print the data values.
The pr() method prints the coefficients in increasing frequency. This function prints the data values which were used to generate the Haar transform.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 