Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_wav_3d_mxolap_multi_inv (c09fd)

## Purpose

nag_wav_3d_mxolap_multi_inv (c09fd) computes the inverse three-dimensional multi-level discrete wavelet transform (IDWT). This function reconstructs data from (possibly filtered or otherwise manipulated) wavelet transform coefficients calculated by nag_wav_3d_multi_fwd (c09fc) from an original input array. The initialization function nag_wav_3d_init (c09ac) must be called first to set up the IDWT options.

## Syntax

[b, ifail] = c09fd(nwl, c, m, n, fr, icomm, 'lenc', lenc)
[b, ifail] = nag_wav_3d_mxolap_multi_inv(nwl, c, m, n, fr, icomm, 'lenc', lenc)

## Description

nag_wav_3d_mxolap_multi_inv (c09fd) performs the inverse operation of nag_wav_3d_multi_fwd (c09fc). That is, given a set of wavelet coefficients, computed by nag_wav_3d_multi_fwd (c09fc) using a DWT as set up by the initialization function nag_wav_3d_init (c09ac), on a real three-dimensional array, A$A$, nag_wav_3d_mxolap_multi_inv (c09fd) will reconstruct A$A$. The reconstructed array is referred to as B$B$ in the following since it will not be identical to A$A$ when the DWT coefficients have been filtered or otherwise manipulated prior to reconstruction. If the original input array is level 0$0$, then it is possible to terminate reconstruction at a higher level by specifying fewer than the number of levels used in the call to nag_wav_3d_multi_fwd (c09fc). This results in a partial reconstruction.

None.

## Parameters

### Compulsory Input Parameters

1:     nwl – int64int32nag_int scalar
The number, nl${n}_{l}$, of levels to be used in the inverse multi-level transform.
Constraint: 1nwlnfwd$1\le {\mathbf{nwl}}\le {n}_{\mathrm{fwd}}$, where nfwd${n}_{\mathrm{fwd}}$ is the value used in a preceding call to nag_wav_3d_multi_fwd (c09fc).
2:     c(lenc) – double array
lenc, the dimension of the array, must satisfy the constraint lencnct${\mathbf{lenc}}\ge {n}_{\mathrm{ct}}$, where nct${n}_{\mathrm{ct}}$ is the total number of wavelet coefficients that correspond to a transform with nwl levels.
The coefficients of the multi-level discrete wavelet transform. This will normally be the result of some transformation on the coefficients computed by function nag_wav_3d_multi_fwd (c09fc).
3:     m – int64int32nag_int scalar
The number of elements, m$m$, in the first dimension of the reconstructed array B$B$. For a full reconstruction of nfwd${n}_{\mathrm{fwd}}$ levels this must be the same as parameter m used in a preceding call to nag_wav_3d_multi_fwd (c09fc). For reconstruction of nl < nfwd${n}_{l}<{n}_{\mathrm{fwd}}$ levels this must be equal to dwtlvm(nl + 1)${\mathbf{dwtlvm}}\left({n}_{l}+1\right)$ as returned from nag_wav_3d_multi_fwd (c09fc).
4:     n – int64int32nag_int scalar
The number of elements, n$n$, in the second dimension of the reconstructed array B$B$. For a full reconstruction of nfwd${n}_{\mathrm{fwd}}$ levels this must be the same as parameter n used in a preceding call to nag_wav_3d_multi_fwd (c09fc). For a partial reconstruction of nl < nfwd${n}_{l}<{n}_{\mathrm{fwd}}$ levels this must be equal to dwtlvn(nl + 1)${\mathbf{dwtlvn}}\left({n}_{l}+1\right)$ as returned from nag_wav_3d_multi_fwd (c09fc).
5:     fr – int64int32nag_int scalar
The number of elements, fr$\mathit{fr}$, in the third dimension of the reconstructed array B$B$. For a full reconstruction of nfwd${n}_{\mathrm{fwd}}$ levels this must be the same as parameter fr used in a preceding call to nag_wav_3d_multi_fwd (c09fc). For a partial reconstruction of nl < nfwd${n}_{l}<{n}_{\mathrm{fwd}}$ levels this must be equal to dwtlvfr(nl + 1)${\mathbf{dwtlvfr}}\left({n}_{l}+1\right)$ as returned from nag_wav_3d_multi_fwd (c09fc).
6:     icomm(260$260$) – int64int32nag_int array
Contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function nag_wav_3d_init (c09ac).

### Optional Input Parameters

1:     lenc – int64int32nag_int scalar
Default: The dimension of the array c.
The dimension of the array c as declared in the (sub)program from which nag_wav_3d_mxolap_multi_inv (c09fd) is called.
Constraint: lencnct${\mathbf{lenc}}\ge {n}_{\mathrm{ct}}$, where nct${n}_{\mathrm{ct}}$ is the total number of wavelet coefficients that correspond to a transform with nwl levels.

ldb sdb

### Output Parameters

1:     b(ldb,sdb,fr) – double array
ldbm$\mathit{ldb}\ge {\mathbf{m}}$.
sdbn$\mathit{sdb}\ge {\mathbf{n}}$.
The m$m$ by n$n$ by fr$\mathit{fr}$ reconstructed array, B$B$, based on the input multi-level wavelet transform coefficients and the transform options supplied to the initialization function nag_wav_3d_init (c09ac).
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
Constraint: nwlnfwd${\mathbf{nwl}}\le {n}_{\mathrm{fwd}}$.
Constraint: nwl1${\mathbf{nwl}}\ge 1$.
ifail = 2${\mathbf{ifail}}=2$
Constraint: ldbm$\mathit{ldb}\ge {\mathbf{m}}$.
Constraint: sdbn$\mathit{sdb}\ge {\mathbf{n}}$.
ifail = 3${\mathbf{ifail}}=3$
lenc is too small, the number of wavelet coefficients required for a transform operating on nwl levels. If nwl = lmax${\mathbf{nwl}}={l}_{\mathrm{max}}$, the maximum number of levels as returned in nwl by the initial call to nag_wav_3d_init (c09ac), then lenc must be at least nct${n}_{\mathrm{ct}}$, the value returned in nwct by the same call to nag_wav_3d_init (c09ac).
ifail = 4${\mathbf{ifail}}=4$
fr is too small, the number of coefficients in the third dimension at the required level of reconstruction.
m is too small, the number of coefficients in the first dimension at the required level of reconstruction.
n is too small, the number of coefficients in the second dimension at the required level of reconstruction.
ifail = 6${\mathbf{ifail}}=6$
Either the initialization function has not been called first or the communication array icomm has been corrupted.
The initialization function was called with wtrans = 'S'${\mathbf{wtrans}}=\text{'S'}$.
ifail = 999${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

The accuracy of the wavelet transform depends only on the floating point operations used in the convolution and downsampling and should thus be close to machine precision.

None.

## Example

function nag_wav_3d_mxolap_multi_inv
m  = int64(7);
n  = int64(6);
fr = int64(5);
wavnam = 'Bior1.1';
mode = 'period';
wtrans = 'Multilevel';
a = zeros(m, n, fr);
a(:, :, 1) = [3, 2, 2, 2, 1, 1;
2, 9, 1, 2, 1, 3;
2, 5, 1, 2, 1, 1;
1, 6, 2, 2, 7, 2;
5, 3, 2, 2, 4, 7;
2, 2, 1, 1, 2, 1;
6, 2, 1, 3, 6, 9];
a(:, :, 2) = [2, 1, 5, 1, 2, 3;
2, 9, 5, 2, 1, 2;
2, 3, 2, 7, 1, 1;
2, 1, 1, 2, 3, 1;
2, 1, 2, 8, 3, 3;
1, 4, 5, 1, 2, 7;
8, 1, 3, 9, 1, 2];
a(:, :, 3) = [3, 1, 4, 1, 1, 1;
1, 1, 2, 1, 2, 6;
4, 1, 7, 2, 5, 6;
3, 2, 1, 5, 9, 5;
1, 1, 2, 2, 2, 1;
2, 6, 3, 9, 5, 1;
1, 1, 8, 2, 1, 3];
a(:, :, 4) = [5, 8, 1, 2, 2, 1;
1, 2, 2, 9, 2, 9;
2, 2, 2, 1, 1, 3;
1, 1, 1, 5, 1, 2;
3, 2, 8, 1, 9, 2;
2, 1, 9, 1, 2, 2;
3, 6, 5, 3, 2, 2];
a(:, :, 5) = [5, 2, 1, 2, 1, 1;
3, 1, 9, 1, 2, 1;
2, 3, 1, 1, 7, 2;
7, 2, 2, 6, 1, 1;
5, 1, 7, 2, 1, 1;
2, 1, 3, 2, 2, 1;
5, 3, 9, 1, 4, 1];

% Query wavelet filter dimensions
[nwl, nf, nwct, nwcn, nwcfr, icomm, ifail] = ...
nag_wav_3d_init(wavnam, wtrans, mode, m, n, fr);

% Perform Discrete Wavelet transform
[c, dwtlvm, dwtlvn, dwtlvfr, icomm, ifail] = ...
nag_wav_3d_multi_fwd(n, fr, a, nwct, nwl, icomm);

fprintf(' Number of Levels : %d\n\n', nwl);
fprintf(' Number of coefficients in 1st dimension for each level:\n');
fprintf(' %8d', dwtlvm(1:nwl));
fprintf('\n');
fprintf(' Number of coefficients in 2nd dimension for each level:\n');
fprintf(' %8d', dwtlvn(1:nwl));
fprintf('\n');
fprintf(' Number of coefficients in 3rd dimension for each level:\n');
fprintf(' %8d', dwtlvfr(1:nwl));
fprintf('\n');

% Print the first level HLL coefficients
want_level = 1;

% Select the approximation coefficients.
want_coeffs = 4;

% Identify each set of coefficients in c
for ilevel = nwl:-1:1

if ilevel ~= want_level
continue
end

nwcm = dwtlvm(nwl-ilevel+1);
nwcn = dwtlvn(nwl-ilevel+1);
nwcfr = dwtlvfr(nwl-ilevel+1);

fprintf('\n--------------------------------\n');
fprintf(' Level %d output is %d by %d by %d.\n', ilevel, nwcm, nwcn, nwcfr);
fprintf('--------------------------------\n\n');

for itype_coeffs = 0:7

if itype_coeffs ~= want_coeffs
continue
end

% Unless we're looking at the deepest level of nesting, which contains
% approximation coefficients, advance the pointer on past the preceding
% levels
if ilevel == nwl
locc = 0;
else
locc = 8*dwtlvm(1)*dwtlvn(1)*dwtlvfr(1);
for i = ilevel + 1 : nwl - 1
locc = locc + 7*dwtlvm(nwl-i+1)*dwtlvn(nwl-i+1)*dwtlvfr(nwl-i+1);
end
end

% Now decide which coefficient type we are considering
switch (itype_coeffs)
case {0}
if (ilevel==nwl)
fprintf('Approximation coefficients (LLL)\n');
locc = locc + 1;
end
case {1}
fprintf('Detail coefficients (LLH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients
locc = locc + nwcm*nwcn*nwcfr + 1;
else
locc = locc + 1;
end
case {2}
fprintf('Detail coefficients (LHL)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 1 set of
% detail coefficients
locc = locc + 2*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 1 set of detail coefficients
locc = locc + nwcm*nwcn*nwcfr + 1;
end
case {3}
fprintf('Detail coefficients (LHH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 2 sets of
% detail coefficients
locc = locc + 3*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 2 sets of detail coefficients
locc = locc + 2*nwcm*nwcn*nwcfr + 1;
end
case {4}
fprintf('Detail coefficients (HLL)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 3 sets of
% detail coefficients
locc = locc + 4*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 3 sets of detail coefficients
locc = locc + 3*nwcm*nwcn*nwcfr + 1;
end
case {5}
fprintf('Detail coefficients (HLH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 4 sets of
% detail coefficients
locc = locc + 5*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 4 sets of detail coefficients
locc = locc + 4*nwcm*nwcn*nwcfr + 1;
end
case {6}
fprintf('Detail coefficients (HHL)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 5 sets of
% detail coefficients
locc = locc + 6*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 4 sets of detail coefficients
locc = locc + 5*nwcm*nwcn*nwcfr + 1;
end
case {7}
fprintf('Detail coefficients (HHH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 6 sets of
% detail coefficients
locc = locc + 7*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 5 sets of detail coefficients
locc = locc + 6*nwcm*nwcn*nwcfr + 1;
end
end

if itype_coeffs > 0 || ilevel == nwl

if (itype_coeffs==0)
% For a multi level transform approx coeffs stored as
% nwcm x nwcn x nwcfr
i1 = locc;
for k = 1:nwcfr
for j = 1:nwcn
for i = 1:nwcm
d(i,j,k) = c(i1);
i1 = i1 + 1;
end
end
end
else
% ... but detail coefficients are stored as ncwfr x nwcm x nwcn
for k = 1:nwcfr
for j = 1:nwcn
for i = 1:nwcm
i1 = locc - 1 + (j-1)*nwcfr*nwcm + (i-1)*nwcfr + k;
d(i,j,k) = c(i1);
end
end
end
end

% Print out the selected set of coefficients
fprintf('Level %d, Coefficients %d:\n', ilevel, itype_coeffs);
for k = 1:nwcfr
fprintf('Frame %d:\n', k);
for i = 1:nwcm
for j=1:nwcn
fprintf('%8.4f ', d(i, j, k));
end
fprintf('\n');
end
end

end

end
end

% Reconstruct original data
[b, ifail] = nag_wav_3d_mxolap_multi_inv(nwl, c, m, n, fr, icomm);

% Check reconstruction matches original
eps = 10*double(m*n*fr)*nag_machine_precision;
err = a-b;
frob = 0;
for i=1:fr
fnew = sqrt(sum(sum(err(:,:,i).^2)));
frob = max(frob,fnew);
end

if frob < eps
fprintf('\nSuccess: the reconstruction matches the original.\n');
else
fprintf('\nFail: Frobenius norm of b-a is too large.\n');
end

Number of Levels : 2

Number of coefficients in 1st dimension for each level:
2        4
Number of coefficients in 2nd dimension for each level:
2        3
Number of coefficients in 3rd dimension for each level:
2        3

--------------------------------
Level 1 output is 4 by 3 by 3.
--------------------------------

Detail coefficients (HLL)
Level 1, Coefficients 4:
Frame 1:
-4.9497   0.0000   0.0000
0.7071   1.7678  -3.1820
0.7071   2.1213   1.7678
0.0000   0.0000   0.0000
Frame 2:
4.2426  -2.1213  -4.9497
0.7071  -0.0000  -0.7071
-1.4142  -3.1820   1.4142
0.0000   0.0000   0.0000
Frame 3:
2.1213  -4.9497  -0.7071
-2.8284  -4.2426   4.9497
2.1213   2.8284  -0.7071
0.0000   0.0000   0.0000

Success: the reconstruction matches the original.

function c09fd_example
m  = int64(7);
n  = int64(6);
fr = int64(5);
wavnam = 'Bior1.1';
mode = 'period';
wtrans = 'Multilevel';
a = zeros(m, n, fr);
a(:, :, 1) = [3, 2, 2, 2, 1, 1;
2, 9, 1, 2, 1, 3;
2, 5, 1, 2, 1, 1;
1, 6, 2, 2, 7, 2;
5, 3, 2, 2, 4, 7;
2, 2, 1, 1, 2, 1;
6, 2, 1, 3, 6, 9];
a(:, :, 2) = [2, 1, 5, 1, 2, 3;
2, 9, 5, 2, 1, 2;
2, 3, 2, 7, 1, 1;
2, 1, 1, 2, 3, 1;
2, 1, 2, 8, 3, 3;
1, 4, 5, 1, 2, 7;
8, 1, 3, 9, 1, 2];
a(:, :, 3) = [3, 1, 4, 1, 1, 1;
1, 1, 2, 1, 2, 6;
4, 1, 7, 2, 5, 6;
3, 2, 1, 5, 9, 5;
1, 1, 2, 2, 2, 1;
2, 6, 3, 9, 5, 1;
1, 1, 8, 2, 1, 3];
a(:, :, 4) = [5, 8, 1, 2, 2, 1;
1, 2, 2, 9, 2, 9;
2, 2, 2, 1, 1, 3;
1, 1, 1, 5, 1, 2;
3, 2, 8, 1, 9, 2;
2, 1, 9, 1, 2, 2;
3, 6, 5, 3, 2, 2];
a(:, :, 5) = [5, 2, 1, 2, 1, 1;
3, 1, 9, 1, 2, 1;
2, 3, 1, 1, 7, 2;
7, 2, 2, 6, 1, 1;
5, 1, 7, 2, 1, 1;
2, 1, 3, 2, 2, 1;
5, 3, 9, 1, 4, 1];

% Query wavelet filter dimensions
[nwl, nf, nwct, nwcn, nwcfr, icomm, ifail] = ...
c09ac(wavnam, wtrans, mode, m, n, fr);

% Perform Discrete Wavelet transform
[c, dwtlvm, dwtlvn, dwtlvfr, icomm, ifail] = c09fc(n, fr, a, nwct, nwl, icomm);

fprintf(' Number of Levels : %d\n\n', nwl);
fprintf(' Number of coefficients in 1st dimension for each level:\n');
fprintf(' %8d', dwtlvm(1:nwl));
fprintf('\n');
fprintf(' Number of coefficients in 2nd dimension for each level:\n');
fprintf(' %8d', dwtlvn(1:nwl));
fprintf('\n');
fprintf(' Number of coefficients in 3rd dimension for each level:\n');
fprintf(' %8d', dwtlvfr(1:nwl));
fprintf('\n');

% Print the first level HLL coefficients
want_level = 1;

% Select the approximation coefficients.
want_coeffs = 4;

% Identify each set of coefficients in c
for ilevel = nwl:-1:1

if ilevel ~= want_level
continue
end

nwcm = dwtlvm(nwl-ilevel+1);
nwcn = dwtlvn(nwl-ilevel+1);
nwcfr = dwtlvfr(nwl-ilevel+1);

fprintf('\n--------------------------------\n');
fprintf(' Level %d output is %d by %d by %d.\n', ilevel, nwcm, nwcn, nwcfr);
fprintf('--------------------------------\n\n');

for itype_coeffs = 0:7

if itype_coeffs ~= want_coeffs
continue
end

% Unless we're looking at the deepest level of nesting, which contains
% approximation coefficients, advance the pointer on past the preceding
% levels
if ilevel == nwl
locc = 0;
else
locc = 8*dwtlvm(1)*dwtlvn(1)*dwtlvfr(1);
for i = ilevel + 1 : nwl - 1
locc = locc + 7*dwtlvm(nwl-i+1)*dwtlvn(nwl-i+1)*dwtlvfr(nwl-i+1);
end
end

% Now decide which coefficient type we are considering
switch (itype_coeffs)
case {0}
if (ilevel==nwl)
fprintf('Approximation coefficients (LLL)\n');
locc = locc + 1;
end
case {1}
fprintf('Detail coefficients (LLH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients
locc = locc + nwcm*nwcn*nwcfr + 1;
else
locc = locc + 1;
end
case {2}
fprintf('Detail coefficients (LHL)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 1 set of
% detail coefficients
locc = locc + 2*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 1 set of detail coefficients
locc = locc + nwcm*nwcn*nwcfr + 1;
end
case {3}
fprintf('Detail coefficients (LHH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 2 sets of
% detail coefficients
locc = locc + 3*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 2 sets of detail coefficients
locc = locc + 2*nwcm*nwcn*nwcfr + 1;
end
case {4}
fprintf('Detail coefficients (HLL)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 3 sets of
% detail coefficients
locc = locc + 4*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 3 sets of detail coefficients
locc = locc + 3*nwcm*nwcn*nwcfr + 1;
end
case {5}
fprintf('Detail coefficients (HLH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 4 sets of
% detail coefficients
locc = locc + 5*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 4 sets of detail coefficients
locc = locc + 4*nwcm*nwcn*nwcfr + 1;
end
case {6}
fprintf('Detail coefficients (HHL)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 5 sets of
% detail coefficients
locc = locc + 6*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 4 sets of detail coefficients
locc = locc + 5*nwcm*nwcn*nwcfr + 1;
end
case {7}
fprintf('Detail coefficients (HHH)\n');
if (ilevel==nwl)
% Advance pointer past approximation coefficients and 6 sets of
% detail coefficients
locc = locc + 7*nwcm*nwcn*nwcfr + 1;
else
% Advance pointer past 5 sets of detail coefficients
locc = locc + 6*nwcm*nwcn*nwcfr + 1;
end
end

if itype_coeffs > 0 || ilevel == nwl

if (itype_coeffs==0)
% For a multi level transform approx coeffs stored as
% nwcm x nwcn x nwcfr
i1 = locc;
for k = 1:nwcfr
for j = 1:nwcn
for i = 1:nwcm
d(i,j,k) = c(i1);
i1 = i1 + 1;
end
end
end
else
% ... but detail coefficients are stored as ncwfr x nwcm x nwcn
for k = 1:nwcfr
for j = 1:nwcn
for i = 1:nwcm
i1 = locc - 1 + (j-1)*nwcfr*nwcm + (i-1)*nwcfr + k;
d(i,j,k) = c(i1);
end
end
end
end

% Print out the selected set of coefficients
fprintf('Level %d, Coefficients %d:\n', ilevel, itype_coeffs);
for k = 1:nwcfr
fprintf('Frame %d:\n', k);
for i = 1:nwcm
for j=1:nwcn
fprintf('%8.4f ', d(i, j, k));
end
fprintf('\n');
end
end

end

end
end

% Reconstruct original data
[b, ifail] = c09fd(nwl, c, m, n, fr, icomm);

% Check reconstruction matches original
eps = 10*double(m*n*fr)*x02aj;
err = a-b;
frob = 0;
for i=1:fr
fnew = sqrt(sum(sum(err(:,:,i).^2)));
frob = max(frob,fnew);
end

if frob < eps
fprintf('\nSuccess: the reconstruction matches the original.\n');
else
fprintf('\nFail: Frobenius norm of b-a is too large.\n');
end

Number of Levels : 2

Number of coefficients in 1st dimension for each level:
2        4
Number of coefficients in 2nd dimension for each level:
2        3
Number of coefficients in 3rd dimension for each level:
2        3

--------------------------------
Level 1 output is 4 by 3 by 3.
--------------------------------

Detail coefficients (HLL)
Level 1, Coefficients 4:
Frame 1:
-4.9497   0.0000   0.0000
0.7071   1.7678  -3.1820
0.7071   2.1213   1.7678
0.0000   0.0000   0.0000
Frame 2:
4.2426  -2.1213  -4.9497
0.7071  -0.0000  -0.7071
-1.4142  -3.1820   1.4142
0.0000   0.0000   0.0000
Frame 3:
2.1213  -4.9497  -0.7071
-2.8284  -4.2426   4.9497
2.1213   2.8284  -0.7071
0.0000   0.0000   0.0000

Success: the reconstruction matches the original.