What do you think, what is the easiest way to implement the special cases of the Hurwitz algorithm, that is, when one or more elements in a row of the matrix are zero?
The core of my program implementing the Hurwitz Algorithm is this (in AEC, the programming language I designed and implemented):
What should be done at the place of TODO, instead of returning an error code? Neso Academy video presents two ways of dealing with that, none of which seem easy to program.
The core of my program implementing the Hurwitz Algorithm is this (in AEC, the programming language I designed and implemented):
Code:
Function popuni_matricu() Which Returns Integer16 Does
Integer16 broj_stupaca :=
(stupanj_polinoma + 1) / 2 + mod(stupanj_polinoma + 1, 2),
broj_redaka := stupanj_polinoma + 1;
Integer16 i := 0;
//Popunimo matricu prvo not-a-numbersima...
While i < broj_redaka Loop
Integer16 j := 0;
While j < broj_stupaca Loop
matrica[f(i, j)] := 0. / 0.;
j += 1;
EndWhile
i += 1;
EndWhile
//Zatim idemo primjeniti Hurwitzov algoritam...
i := 0;
While i < broj_redaka Loop
Integer16 j := 0;
While j < broj_stupaca Loop
If i = 0 Then // Prvi redak
matrica[f(i, j)] := polinom[j * 2];
ElseIf i = 1 Then // Drugi redak
matrica[f(i, j)] := (j * 2 + 1 < stupanj_polinoma + 1) ?
polinom[j * 2 + 1] :
0;
Else // Ostali reci...
If matrica[f(i - 1, 0)] = 0 Then
//TODO: Implementirati što se radi u posebnim slučajevima...
Return 0;
EndIf
matrica[f(i, j)] := (matrica[f(i - 1, 0)] *
(j + 1 < broj_stupaca ?
matrica[f(i - 2, j + 1)] : 0) -
(matrica[f(i - 2, 0)] *
(j + 1 < broj_stupaca ?
matrica[f(i - 1, j + 1)] : 0))) /
matrica[f(i - 1 , 0)];
EndIf
j += 1;
EndWhile
i += 1;
EndWhile
If matrica[f(broj_redaka - 1, 0)] = polinom[stupanj_polinoma] Then
Return 1;
EndIf
Return 0;
EndFunction