Home > tt2 > exp > filters_wtt.m

filters_wtt

PURPOSE ^

Computes the WTT transform filters for a given tensor

SYNOPSIS ^

function [wtt_transform] = filters_wtt (a,rmax,eps,sz)

DESCRIPTION ^

Computes the WTT transform filters for a given tensor
   [WTT_TRANSFORM]=FILTERS_WTT(A,RMAX,EPS,SZ)
   Computes the set of filters for transform of A, A should be given 
   either as d-dimensional array, or as by size-vector SZ
   WTT_TRANSFORM is a structure with two fields: 
   u and rks


 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [wtt_transform] = filters_wtt (a,rmax,eps,sz)
0002 %Computes the WTT transform filters for a given tensor
0003 %   [WTT_TRANSFORM]=FILTERS_WTT(A,RMAX,EPS,SZ)
0004 %   Computes the set of filters for transform of A, A should be given
0005 %   either as d-dimensional array, or as by size-vector SZ
0006 %   WTT_TRANSFORM is a structure with two fields:
0007 %   u and rks
0008 %
0009 %
0010 % TT-Toolbox 2.2, 2009-2012
0011 %
0012 %This is TT Toolbox, written by Ivan Oseledets et al.
0013 %Institute of Numerical Mathematics, Moscow, Russia
0014 %webpage: http://spring.inm.ras.ru/osel
0015 %
0016 %For all questions, bugs and suggestions please mail
0017 %ivan.oseledets@gmail.com
0018 %---------------------------
0019 
0020 if ( nargin == 1 )
0021 sz=size(a); d = numel(sz);
0022 else
0023    d = numel(sz);
0024 end
0025 N=numel(a);
0026 rks=zeros(d,1); u=cell(d-1,1);
0027 rks(1)=1;
0028 a=reshape(a,[sz(1),N/sz(1)]);
0029 for k=1:d-1
0030    [m,p]=size(a);
0031    if ( m > p ) 
0032       [u1,s1,v1]=svd(a);
0033    else
0034       [u1,s1,v1]=svd(a,'econ');
0035    end
0036    %Fix for u1 SLIGHTLY
0037 %   a1=a;
0038 %    if ( m > p )
0039 %  for s=1:5
0040 %    b1=u1'*a1;
0041 %    m1=size(b1,2);
0042 %    sp=zeros(m,1);
0043 %    for q=1:m1
0044 %      b=b1(:,q);
0045 %      sp(q)=norm(b,2)/norm(b,1); %this is a sparsity measure: for one 1 it is 1, for all ones --- 1/sqrt(np)
0046 %    end
0047 %    sgm=0.95; %cutoff for sparse vectors
0048 %    ind1=find(sp>sgm);
0049 %    if ( numel(ind1) > 0 )
0050 %     a1=a1(:,ind1);
0051 %     if ( m > p )
0052 %       [u1,s1,v1]=svd(a1);
0053 %     else
0054 %       [u1,s1,v1]=svd(a1,'econ');
0055 %     end
0056 %    end
0057 %  end
0058 %    end
0059  s1=diag(s1);
0060    %s1
0061    r0=my_chop2(s1,eps*norm(s1)/sqrt(d-1));
0062       r=min([m,p,rmax,r0]);
0063    N = N*r/(sz(k)*rks(k));
0064    rks(k+1)=r;
0065    a=u1'*a; 
0066    a=a(1:r,:); a=reshape(a,[r*sz(k+1),N/(r*sz(k+1))]);
0067    u{k}=u1;
0068 end
0069 rks(d)=1;
0070 u{d}=v1;
0071 wtt_transform=struct;
0072 wtt_transform.u=u;
0073 wtt_transform.rks=rks;
0074 wtt_transform.sz=sz;
0075 return
0076 end

Generated on Wed 08-Feb-2012 18:20:24 by m2html © 2005