/*
This program will perform Mallat's algorithm in V_3
which is isomorphic to R^8
Here an orthogonal basis is used that is not normalized.  Mallat's algorithm
does not use a orthonormal basis in R^8.
*/

#include <iostream>   
#include <string>
#include <cmath>

using namespace std;

void Mallat(double x[], double y[]);

int main()
{
  int count;
  double input_signal[8];
  double filtered[8];

  cout << "Please enter the eight coefficients from the original signal separated by spaces: " << endl;

  for(count = 0; count <= 7; count++){
  cin >> input_signal[count];
  }
  Mallat(input_signal, filtered);

  cout << "Your wavelet coeficients are:\n"
       << "[ ";
  for(count = 0; count <= 7; count++){
  cout << filtered[count]
       << " ";
  }
  cout << " ]\n";

  return 0;
}

void Mallat(double x[], double y[])
{
  y[0]=(x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7])*(1.0/8.0);
  y[1]=(x[0]+x[1]+x[2]+x[3]-x[4]-x[5]-x[6]-x[7])*(1.0/8.0);  
  y[2]=(x[0]+x[1]-x[2]-x[3])*(1.0/4.0);
  y[3]=(x[4]+x[5]-x[6]-x[7])*(1.0/4.0);
  y[4]=(x[0]-x[1])*(1.0/2.0);
  y[5]=(x[2]-x[3])*(1.0/2.0);
  y[6]=(x[4]-x[5])*(1.0/2.0);
  y[7]=(x[6]-x[7])*(1.0/2.0);

}
