# Adjoint of the MATLAB $\tt dwt3$ (3D wavelet transform) operator

How do I compute the adjoint of MATLAB's dwt3 operator?

In other words, how do I compute the adjoint of the linear operator that takes a 3D complex array x as input and returns the quantity dwt3(x,'db4') as output.

This adjoint computation is an important step in many iterative reconstruction algorithms.

One might guess that idwt3 is the adjoint of dwt3, but the following code seems to show that this is not the case (unless my code contains an error):

sz = [384,300,144];

% Randomly generate a 3D complex array
x1 = randn(sz) + 1i*(randn(sz));

% Compute wavelet transform of x1
Wx1 = dwt3(x1,'db4');

% Randomly generate x2 which has the same size and shape as Wx1 (which is a Matlab structure)
x2 = Wx1;
for i1 = 1:2
for i2 = 1:2
for i3 = 1:2
arrSz = size(x2.dec{i1,i2,i3});
x2.dec{i1,i2,i3} = randn(arrSz) + 1i*randn(arrSz);
end
end
end

% Compute inverse wavelet transform of w2
WTransx2 = idwt3(x2);

% Check to see if the adjoint property <x1,WTransx2> = <Wx1,x2> is satisfied
prod1 = x1(:)'*conj(WTransx2(:));
prod2 = 0;
for i1 = 1:2
for i2 = 1:2
for i3 = 1:2

Wx1_arr = Wx1.dec{i1,i2,i3};
x2_arr = x2.dec{i1,i2,i3};
prod2 = prod2 + Wx1_arr(:)'*conj(x2_arr(:));

end
end
end

max(abs(prod1 - prod2))