-2

I recently visited the wiki site:

https://en.wikibooks.org/wiki/Algorithm_Implementation/Linear_Algebra/Tridiagonal_matrix_algorithm#Fortran_90

It says that a,b,c are the sub-diagonal, diagonal, and super-diagonal. If 'n' is the size of b, then aren't the sizes of 'a' and 'c' be n-1? It is clear by inspection that both c(1) and c(n) are accessed, which contradicts the sizes I've described.

What's going on here? Is this algorithm wrong? Are the matrix sizes that I've assumed are wrong? What does the input matrix look like for this algorithm?

Any help is greatly appreciated!

Charles
  • 947
  • 1
  • 15
  • 39
  • You could improve your question (and potentially reduce downvotes) by including the relevant code you've linked. Also, you could emphasize the components of code you're having trouble understanding. – Ross Aug 30 '15 at 20:41
  • I appreciate that, I should have specified that I was referring to the "conserved" coefficients code, or maybe just included the code. I'm always confused when I get downvotes and nobody says anything about why. It's really unhelpful. – Charles Aug 30 '15 at 20:53

1 Answers1

1

cp(n) is calculated simply to avoid an awkward if statement - it is never used in determining x. So c(n) is not really used.

a(1) is also unused, as expected.

Ross
  • 2,130
  • 14
  • 25
  • Ah, I see. Thank you for the explanation! Although, it does look like after cp(1) is defined, cp(i-1) is accessed, which means cp(1) is used, but I agree that cp(n) is not used to compute x. Thank you again! – Charles Aug 30 '15 at 20:51