Implementation of Jury's Algorithm

Posted by fasxxzczc on Wednesday, 21 March 2012

Implementation of Jury's Algorithm




1:  #include<iostream.h>  
2:  #include<conio.h>  
3:  #include<stdio.h>  
4:  #include<stdlib.h>  
5:  #include<math.h>  
6:  void main(void)  
7:  {  
8:   int b[10]={0},mat[10],num1,temp,a[5],i,j;  
9:   clrscr();  
10:   cout<<"\n\t\tImplementation of Jury's Algorithm";  
11:   cout<<"\n\tInput number of coeff for D(z)::";  
12:   cin>>num1;  
13:   cout<<"\n\tInput Values::\n";  
14:   for(i=0;i<num1;i++)  
15:   {  
16:   cout<<"\n\tb["<<i<<"]::";  
17:   cin>>b[i];  
18:   }  
19:   if(b[num1-1]<0)  
20:   {  
21:       cout<<"System Unstable";  
22:       getch();  
23:       exit(0);  
24:   }  
25:   int Dz=0;  
26:   for(i=0;i<num1;i++)  
27:   Dz=Dz+pow(-1,i)*pow(-1,-i)*b[i];  
28:   if(Dz<0)  
29:   {  
30:       cout<<"System Unstable";  
31:       getch();  
32:       exit(0);  
33:   }  
34:   temp=num1-1;  
35:   for(i=0;i<(num1-3);i++)  
36:   {  
37:   if(b[0]<b[temp])  
38:   {  
39:       cout<<"\n\tSystem Unstable";  
40:       getch();  
41:       exit(0);  
42:   }  
43:   for(j=0;j<=temp;j++)  
44:    mat[j]=b[0]*b[j]-b[temp]*b[-j+temp];  
45:   temp--;  
46:   for(j=0;j<=temp;j++)  
47:    b[j]=mat[j];  
48:   }  
49:   if(b[0]<b[temp])  
50:   {  
51:       cout<<"\n\tSystem Unstable";  
52:       getch();  
53:       exit(0);  
54:   }  
55:   cout<<"\n\tSystem Stable";  
56:   getch();  
57:  }  

{ 0 comments... read them below or add one }

Post a Comment