Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: August 18, 2025, 12:20 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routh-Hurwitz Stability Criterion
#23
RE: Routh-Hurwitz Stability Criterion
(April 22, 2023 at 9:24 am)FlatAssembler Wrote: With the help from people from forum.hr, I have modified the code of my program like this:
[hide]
Code:
Function obrni_polinom() Which Returns Nothing Is Declared;

Function f(Integer16 i, Integer16 j) Which Returns Integer16 Does
 // Za pretvaranje indeksa dvodimenzionalnog polja u indeks jednodimenzionalnog
 // polja. Kada u svoj AEC compiler još nisam implementirao dvodimenzionalna
 // polja...
 Return 20 * i + j;
EndFunction

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 // Posebni slučajevi, kada se u prvom
                                        // stupcu matrice pojavi nula.
         If jesmo_li_obrnuli_polinom Then // Obrtanje polinoma nije "upalilo".
           Return 0;
         Else // Možda obrtanje polinoma "upali"...
           obrni_polinom(); // https://www.forum.hr/showpost.php?p=97955497&postcount=16
           jesmo_li_obrnuli_polinom := 1;
           Return popuni_matricu();
         EndIf
       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

Function broj_korijena_u_desnoj_poluravnini() Which Returns Integer16 Does
 Integer16 i := 1, brojac := 0;
 While i < stupanj_polinoma + 1 Loop
   brojac += not(signum(matrica[f(i, 0)]) = signum(matrica[f(i - 1, 0)]));
   i += 1;
 EndWhile
 Return brojac;
EndFunction

Function obrni_polinom() Which Returns Nothing Does
 Decimal64 pomocni_polinom[20];
 Integer16 i := 0, j := stupanj_polinoma;
 While i < stupanj_polinoma + 1 Loop
   pomocni_polinom[i] := polinom[j];
   i += 1;
   j -= 1;
 EndWhile
 i := 0;
 While i < stupanj_polinoma + 1 Loop
   polinom[i] := pomocni_polinom[i];
   i += 1;
 EndWhile
EndFunction
Thief and assassin for hire. Member in good standing of the Rogues Guild.
Reply



Messages In This Thread
Routh-Hurwitz Stability Criterion - by FlatAssembler - April 10, 2023 at 3:01 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 10, 2023 at 3:27 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 11, 2023 at 5:57 am
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 13, 2023 at 2:52 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 14, 2023 at 8:14 am
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 14, 2023 at 12:34 pm
RE: Routh-Hurwitz Stability Criterion - by The Valkyrie - April 10, 2023 at 3:23 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 11, 2023 at 5:48 am
RE: Routh-Hurwitz Stability Criterion - by arewethereyet - April 11, 2023 at 6:16 am
RE: Routh-Hurwitz Stability Criterion - by The Valkyrie - April 11, 2023 at 8:43 am
RE: Routh-Hurwitz Stability Criterion - by Angrboda - April 10, 2023 at 5:59 pm
RE: Routh-Hurwitz Stability Criterion - by arewethereyet - April 10, 2023 at 6:30 pm
RE: Routh-Hurwitz Stability Criterion - by zebo-the-fat - April 11, 2023 at 3:59 am
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 13, 2023 at 3:36 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 22, 2023 at 9:24 am
RE: Routh-Hurwitz Stability Criterion - by Ravenshire - April 22, 2023 at 2:45 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 26, 2023 at 10:20 am
RE: Routh-Hurwitz Stability Criterion - by Ravenshire - April 26, 2023 at 2:38 pm
RE: Routh-Hurwitz Stability Criterion - by The Valkyrie - April 25, 2023 at 3:32 pm
RE: Routh-Hurwitz Stability Criterion - by arewethereyet - April 22, 2023 at 9:28 am
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 25, 2023 at 11:36 am
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 29, 2023 at 5:30 pm
RE: Routh-Hurwitz Stability Criterion - by FlatAssembler - April 30, 2023 at 2:20 pm



Users browsing this thread: 1 Guest(s)