Home > tt2 > @tt_matrix > subsref.m

subsref

PURPOSE ^

Evaluate cores of TT-matrix and fields of the TT-matrix structure

SYNOPSIS ^

function elem = subsref(tt,s)

DESCRIPTION ^

 Evaluate cores of TT-matrix and fields of the TT-matrix structure
   A=TT{I} computes the I-th core of the TT-representation
   

 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 elem = subsref(tt,s)
0002 % Evaluate cores of TT-matrix and fields of the TT-matrix structure
0003 %   A=TT{I} computes the I-th core of the TT-representation
0004 %
0005 %
0006 % TT-Toolbox 2.2, 2009-2012
0007 %
0008 %This is TT Toolbox, written by Ivan Oseledets et al.
0009 %Institute of Numerical Mathematics, Moscow, Russia
0010 %webpage: http://spring.inm.ras.ru/osel
0011 %
0012 %For all questions, bugs and suggestions please mail
0013 %ivan.oseledets@gmail.com
0014 %---------------------------
0015 
0016 switch s(1).type
0017     case '()'
0018         error('Elementwise computation is not yet supported');
0019     case '.'
0020         switch s(1).subs               
0021             case 'n'
0022                 elem=tt.n;
0023                 if (numel(s)>1)
0024                     s = s(2:end);
0025                     elem = subsref(elem, s);
0026                 end;                
0027             case 'm'
0028                 elem=tt.m;
0029                 if (numel(s)>1)
0030                     s = s(2:end);
0031                     elem = subsref(elem, s);
0032                 end;    
0033             case 'tt'
0034                 elem=tt.tt;
0035             otherwise
0036                 % Dispatch to the underlying TT - may be rank, core, etc.
0037                 elem = subsref(tt.tt, s);
0038                 if (numel(s)>1)
0039                     s = s(2:end);
0040                     elem = subsref(elem, s);
0041                 end;                
0042 %                 error(['No field ', s.subs, ' is here.']);
0043         end
0044     case '{}'
0045         pp=s.subs;
0046         mn=numel(pp);
0047         if ( mn > 1 )
0048           error('Invalid number of cores asked');
0049         end
0050         pp = pp{1};
0051         elem=core(tt.tt,pp);
0052         elem=reshape(elem, tt.tt.r(pp), tt.n(pp), tt.m(pp), tt.tt.r(pp+1));
0053         
0054         if (numel(s)>1)
0055             s = s(2:end);
0056             elem = subsref(elem, s);
0057         end;
0058     otherwise
0059         error('Invalid subsref.');
0060 end

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