Advertisement
Guest User

Untitled

a guest
Apr 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.61 KB | None | 0 0
  1. function [valp vecp] = PutereInv(d, s, h, y, maxIter, tol)
  2.  
  3.   a = s;
  4.  
  5.   n = length(d);
  6.  
  7.   for k = 1:maxIter
  8.  
  9.   daux = d - h;
  10.  
  11.    z = Thomas(s, daux, s, y);
  12.    
  13.    %disp(z);
  14.    
  15.    vecp = z/norm(z);
  16.    
  17.    %disp(vecp);
  18.    
  19.    temp = zeros(1, n);
  20.    
  21.    temp(1) = d(1)*vecp(1) + s(1)*vecp(2);
  22.    temp(n) = s(n-1)*vecp(n-1) + d(n)*vecp(n);
  23.    
  24.    for i = 2:n-1
  25.     temp(i) = s(i-1)*vecp(i-1) + vecp(i)*d(i) + s(i)*vecp(i+1);
  26.    endfor
  27.    
  28.    %disp(temp)
  29.    
  30.    valp = temp*vecp;
  31.    
  32.    if(norm(temp' - valp*vecp) < tol)
  33.     break;
  34.    endif
  35.    
  36.    h = valp;
  37.  
  38.   endfor
  39.  
  40. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement