-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathforward_wavelet_transform.m
More file actions
65 lines (41 loc) · 1.53 KB
/
forward_wavelet_transform.m
File metadata and controls
65 lines (41 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [f] = forward_wavelet_transform(deg,lev,Lmin,Lmax,foo,dV,params,blocks,t)
%% Decompose a 1D function into the multiwavelet basis
% Get the Legendre-Gauss nodes (quad_x) and weights (quad_w) on the domain
% [-1,+1] for performing quadrature.
[quad_x,quad_w] = lgwt(default_quad_number(deg),-1,1);
% Get grid spacing.
n=2^(lev);
h=(Lmax-Lmin)/n;
dof_1D=deg*n;
f=zeros(dof_1D,1);
% Get the Legendre basis function evaluated at the Legendre-Gauss nodes up
% to order k.
p_val = transpose( lin_legendre(quad_x,deg) * 1/sqrt(h) ); % TODO : this call happens in lots of places. We should consolidate if possible.
for i=0:n-1
% Map quad_x from [-1,+1] to [LMin,LMax] physical domain.
x = h*(quad_x/2+1/2+i) + Lmin;
% Get the function foo(x) at the quadrature points.
fxHere = foo(x, params, t) .* dV(x);
this_quad = (quad_w .* fxHere);
% Generate the coefficients for DG basis
% Method 1: Unroll the rows in the GEMM
%for thisk=1:Deg
%
% this_k_legendre = p_val(thisk,:);
% f(Deg*i+thisk) = mtimes(this_k_legendre,this_quad);
%
%end
% Method 2: Do the GEMM directly
f(i*deg+1:i*deg+deg) = mtimes(p_val,this_quad);
end
f = f * h / 2;
% Transfer to multi-DG bases
%f = mtimes( FMWT, f );
left_notrans = 'LN';
f = apply_FMWT_blocks(lev, blocks, f, left_notrans);
%%
% After the transformation to wavelet space there may be very tiny coefficient values.
% Here we zero them out.
tol = 1e-12;
f = f .* (abs(f) > tol );
end