Hi guys,
fun int[] discreteHaarWaveletTransform( int input[]){
int sum, difference,length,i;
int output[input.cap()];
for ( (input.cap() >> 1) => length ; true ; (length >> 1) => length) {
for (0 => i; i < length; ++i) {
input[i * 2] + input[i * 2 + 1] => sum;
input[i * 2] - input[i * 2 + 1] => difference;
sum => output[i] ;
difference => output[length + i];
}
if (length == 1) {
return output;
}
//Swap arrays to do next iteration
for (0=>i; i < (length<<1); i++){
output[i] => input[i];
}
}
}