function [ DS0, Di0, beta0, c0,Q0 ] = OOMPFinalRefi( f, D, tol, No, ind )
% OOMPFinalRefi refinament of OOMP by swapping and backward deleting steps.
%
% It creates an atomic decomposition for approximation a signal using OOMP method up to a
% given tolerance. When possible, the sparsity is improved afterwards by a combination of
% swapping and backward deleting steps.
%
% You can choose a tolerance, the maximum number of atoms in the decomposition and an
% initial subspace to influence the OOMP algorithm. Non-selected atoms subtracted by their
% component in the chosen space are also available.
%
% Usage: [ D0, Di0 ] = OOMPFinalRefi( f, D, tol );
% [ DS0, Di0, beta0, c0,Q0 ] = OOMPFinalRefi( f, D, tol, No, ind);
%
% Inputs:
% f analyzing signal
% D dictionary of normalized atoms
% tol desired distance between f and its approximation the routine will stop if
% norm(f'-Dsub*(f*beta)')*sqrt(delta)