I'm working on translating some MATLAB code to Python so I can learn MATLAB better (trying to think in terms of Python first), and I'm a bit stumped on what this block of code is doing.
n = length(a);
S = zeros(n+1,n+1);
S(1,1) = sqrt(1/b(1));
S(2,:) = (S(1,:)-[0,a(1)*S(1,1:end-1)])/sqrt(b(2));
S(3,:) = (S(2,:)-[0,a(2)*S(2,1:end-1)]-[0,0,sqrt(b(2))*S(1,1:end-2)])/sqrt(b(3));
S(4,:) = (S(3,:)-[0,a(3)*S(3,1:end-1)]-[0,0,sqrt(b(3))*S(2,1:end-2)])/sqrt(b(4));
I understand the first 2 lines (create a n+1 by n+1 matrix S), but I'm having trouble understanding the next 3.
From what I understand (n:m) is Matrix lookup notation. So, S(1, 1) means the value at 1st row, first column, which is set to 1/math.sqrt(b[0]) in terms of Python. This would mean that in our matrix S, the first row is an array who 1/math.sqrt(b[0]), and the rest are 0's, right?
For the 4th line, I'm having real trouble understanding the vode. Are we saying the 2nd row is the 1st row minus an array from 0 to a(1)*S(1,1:end-1)? What exactly does a(1)*S(1,1:end-1) represent here?
I see that the next 2 lines is a recurrence relation based on j-1th and j-2th row for some j >= 3 (2 if Python), but I have very little idea as to what the recurrence relation is computing.
Any help "translating" this code to Python (in terms of pseudocode for understanding, not actual hard code) would be tremendously helpful, as learning MATLAB has been pretty tricky so far for me. Thank you.