Advertisement
Guest User

Untitled

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