TV_operator_2D

PURPOSE ^

03/12/00 By Andrea Borsic

SYNOPSIS ^

function TVop=TV_operator_2D(msh);

DESCRIPTION ^

 03/12/00 By Andrea Borsic

 This function constructs Total Variation operator

 function TVop=tv_op(msh);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function TVop=TV_operator_2D(msh);
0002 % 03/12/00 By Andrea Borsic
0003 %
0004 % This function constructs Total Variation operator
0005 %
0006 % function TVop=tv_op(msh);
0007 
0008 % $Id: TV_operator_2D.m 3039 2012-06-06 14:58:10Z bgrychtol $
0009 
0010 
0011 num_tri=length(msh.TC);
0012 num_nod=length(msh.PC);
0013 
0014 list=[];
0015 
0016 %We build a selection array, to index the T matrix
0017 
0018 SEL=[ 1 2 3; 2 3 1];
0019 
0020 INC=spalloc(num_nod,num_nod,num_tri*3);
0021 
0022 for k=1:num_tri
0023    
0024    for j=1:3
0025       
0026       m=msh.TC(SEL(1,j),k);
0027       n=msh.TC(SEL(2,j),k);
0028       
0029       if m<n % ( only the upper triangular )
0030          
0031          if (INC(m,n)==0) INC(m,n)=k;
0032          else
0033             len=sqrt((msh.PC(1,m)-msh.PC(1,n))^2+(msh.PC(2,m)-msh.PC(2,n))^2);
0034                 list(size(list,1)+1,:)=[len,k,INC(m,n)]; % Triangles and length of the shared edge are written into the list
0035          end % if then else
0036          
0037       else
0038          
0039          if (INC(n,m)==0) INC(n,m)=k;
0040          else
0041             len=sqrt((msh.PC(1,m)-msh.PC(1,n))^2+(msh.PC(2,m)-msh.PC(2,n))^2);
0042                 list(size(list,1)+1,:)=[len,k,INC(n,m)]; % Triangles and length of the shared edge are written into the list
0043          end % if then else
0044          
0045          
0046       end % if m<n
0047       
0048    end % for j
0049    
0050 end % for k
0051 
0052 TVop=spalloc(num_tri,num_tri,2*length(list));
0053 
0054 for i=1:length(list)
0055    
0056    TVop(i,list(i,2))=list(i,1);
0057    
0058    TVop(i,list(i,3))=-list(i,1);
0059     
0060 end % for
0061 
0062 TVl=list(:,1);
0063 
0064 % Bye Bye
0065

Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005