refactor WaveletMatrix.cpp