function mHatDictionary = GenerateHats( hats, szSpace, dictionary )
% GenerateHats Generates a hat dictionary
%
% Builds a dictionary for a space of size szSpace from one or more hat dictionaries or 
% basis, where the length of there support is given in the vectot hats.
%
% Usage:            mHatDictionary = GenerateHats( hats, szSpace, dictionary );
%
% Inputs:
%   hats            vector of support lengths for each dictionary
%   szSpace         number of discrete points in each atom
%   dictionary      set to 0 if the dictionary is composed from several hat basis, or 1 if 
%                   it is composed from several hat dictionaries
%
% Outputs:
%   mHatDictionary  matrix whose columns are the atoms fromt he hat dictionaries

% See   http://www.ncrg.aston.ac.uk/Projects/HNLApprox/
%       http://www.nonlinear-approx.info/

index = 0;
lTop = 1;

for i = 1:numel(hats);
    
    vPrototype = GenerateTrapezium( hats(i), lTop );
    mVectors = TranslatePrototype( vPrototype, szSpace, dictionary );
    mHatDictionary(:,index+1:index+size(mVectors,2)) = mVectors;
    index = index + size(mVectors,2);
    
end