Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Moment_of_Correlation_2DPIV_uncertainty/postprocess_codes/tridiagSolve.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (28 sloc)
588 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [y]=tridiagSolve(a,b,c, d) | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% Program: thomas | |
% | |
% To solve a tridiagonal | |
% linear system using the | |
% Thomas algorithm | |
% | |
% The ith equation is: | |
% | |
% a(i)*y(i-1) + b(i)*y(i) + c(i)*y(i+1) = d(i) | |
% | |
% N x N matrix | |
% | |
% note that a(1)=0 and c(N)=0 | |
% | |
% Andrew Duggleby 2007 | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
N=length(d); | |
for k=2:N | |
m=a(k)/b(k-1); | |
b(k)=b(k)-m*c(k-1); | |
d(k)=d(k)-m*d(k-1); | |
end | |
y(N)=d(N)/b(N); | |
for k=N-1:-1:1 | |
y(k)=(d(k)-c(k)*y(k+1))/b(k); | |
end |