% script for testing the frame transformation using fixed frames
% script: testframtrans
%
% This simple script tests the switching between frames using the Gram matrix. 
%
% date: 27/06/2006 
%
% Author:  XXL .. Peter Balazs, contact: a8927259@unet.univie.ac.at
%
% Literature : [Xxl] P. Balazs; Frames, Finite Dimensionality and
%               Algorithms; in preparation (2006)
%
% See also: RandFrame.m
%

D1 = [ cos(0*2*pi/360) cos(120*2*pi/360) cos(240*2*pi/360) ; sin(0*2*pi/360) sin(120*2*pi/360)  sin(240*2*pi/360) ];
D1 = D1/norm(D1);
    % normalized tight frame (Parsebal frame)
D2 = [   -0.4205    0.0682   -0.3814    0.1361 ;
         -0.3176    0.4542    0.6770   -0.2592];
    % second frame
    
G12 = CrossGram(pinv(D1)',D2);
    % cross-Gram matrix

%test with random signal
N_test = 100000;
mmm = 0;
for ii = 1:N_test
    f = rand(2,1); % random signal
    coeff1 = D1'*f; % coefficents with first frame
    coeff2 = D2'*f; % coefficients with second frame
    frametrans = G12 * coeff1; % frame transformation
    error = norm(coeff2-frametrans); % norm of error
    if error > mmm
        mmm = error;
    end
end
disp(sprintf('The maximal error in %g runs was %g',N_test,mmm));