void wavelet::partial_inverse(const vector<double>& in, vector<double>& out, const int n) const { assert(in.size() == out.size()); assert(n <= in.size()); // trap calls where n is too small if (n < 4) return; // initialise workspace (since out & in may be the same vector) vector<double> b(n); b = 0; // set up some constants that we need const int nh = n >> 1; const int mask = n - 1; const int ncof = g.size(); // do the transform for (int i = 0; i < nh; i++) for (int j = 0; j < ncof; j++) { const int k = ((i << 1) + j) & mask; b(k) += g(j) * in(i) + h(j) * in(i + nh); } // copy the result back from workspace out.copyfrom(b); }