home *** CD-ROM | disk | FTP | other *** search
- main()
-
- {
- int i,n,nm,count,*iv1,matz,ierr,*ivector();
- double **a,**z,*fv1,*wr,*wi;
- double rg(),**dmatrix(),*dvector();
-
- /*
-
-
- this routine serves as a test driver for the c version of the
- eispack eigenvector routines.
- on input :
-
- nm must be set to the row dimension of the two-dimensional
- array parameters as declared in the calling program
- dimension statement.
-
- n is the order of the matrix a.
-
- a contains the real general matrix.
-
- matz is an integer variable set equal to zero if
- only eigenvalues are desired. otherwise it is set to
- any non-zero integer for both eigenvalues and eigenvectors.
-
- on output
-
- wr and wi contain the real and imaginary parts,
- respectively, of the eigenvalues. complex conjugate
- pairs of eigenvalues appear consecutively with the
- eigenvalue having the positive imaginary part first.
-
- z contains the real and imaginary parts of the eigenvectors
- if matz is not zero. if the j-th eigenvalue is real, the
- j-th column of z contains its eigenvector. if the j-th
- eigenvalue is complex with positive imaginary part, the
- j-th and (j+1)-th columns of z contain the real and
- imaginary parts of its eigenvector. the conjugate of this
- vector is the eigenvector for the conjugate eigenvalue.
-
- ierr is an integer output variable set equal to an error
- completion code described in the documentation for hqr
- and hqr2. the normal completion code is zero.
-
- iv1 and fv1 are temporary storage arrays.
-
- written by : m. myers last change : 5 september 1989 */
-
- a=dmatrix(1,8,1,8);
- z=dmatrix(1,8,1,8);
- wr=dvector(1,8);
- wi=dvector(1,8);
- iv1=ivector(1,15000);
- fv1=dvector(1,15000);
- nm = 8;
- n = 8;
- matz=1;
-
- a[1][1] = -31.e0 ; a[1][2] = 96.e0 ; a[1][3] = 84.e0 ; a[1][4] = -96.e0;
- a[1][5] = -240.e0 ; a[1][6] = 384.e0 ; a[1][7] = 0.e0 ; a[1][8] = 0.e0;
- a[2][1] = -30.e0 ; a[2][2] = 74.e0 ; a[2][3] = 45.e0 ; a[2][4] = -60.e0;
- a[2][5] = -150.e0 ; a[2][6] = 240.e0 ; a[2][7] = 0.e0 ; a[2][8] = 0.e0;
- a[3][1] = -12.e0 ; a[3][2] = 6.e0 ; a[3][3] =-25.e0 ; a[3][4] = 24.e0;
- a[3][5] = 60.e0 ; a[3][6] = -96.e0 ; a[3][7] = 0.e0 ; a[3][8] = 0.e0;
- a[4][1] = -12.e0 ; a[4][2] = 18.e0 ; a[4][3] = -6.e0 ; a[4][4] = 43.e0;
- a[4][5] = 85.e0 ; a[4][6] =-145.e0 ; a[4][7] = 0.e0 ; a[4][8] = 0.e0;
- a[5][1] = -36.e0 ; a[5][2] = 54.e0 ; a[5][3] =-18.e0 ; a[5][4] = 66.e0;
- a[5][5] = 102.e0 ; a[5][6] =-174.e0 ; a[5][7] = 0.e0 ; a[5][8] = 0.e0;
- a[6][1] = -24.e0 ; a[6][2] = 36.e0 ; a[6][3] =-12.e0 ; a[6][4] = 50.e0;
- a[6][5] = 80.e0 ; a[6][6] =-137.e0 ; a[6][7] = 0.e0 ; a[6][8] = 0.e0;
- a[7][1] = 0.e0 ; a[7][2] = 0.e0 ; a[7][3] = 0.e0 ; a[7][4] = 0.e0;
- a[7][5] = 0.e0 ; a[7][6] = 0.e0 ; a[7][7] = -1.e0 ; a[7][8] = 1.e0 ;
- a[8][1] = 0.e0 ; a[8][2] = 0.e0 ; a[8][3] = 0.e0 ; a[8][4] = 0.e0;
- a[8][5] = 0.e0 ; a[8][6] = 0.e0 ; a[8][7] = 4.e0 ; a[8][8] = 2.e0;
-
- printf("a matrix : \n----------\n");
- for (i=1;i<=8;i++)
- {printf("%7.2f %7.2f %7.2f %7.2f ",a[i][1],a[i][2],a[i][3],a[i][4]);
- printf("%7.2f %7.2f %7.2f %7.2f \n",a[i][5],a[i][6],a[i][7],a[i][8]);}
-
-
- ierr=rg(nm,n,a,wr,wi,matz,z,iv1,fv1);
-
- count = 1;
- printf("\n \n \n C-Source Version of the EISPACK Eigenvalue/Eigenvector Routines \n");
- printf(" --------------------------------------------------------------- \n \n");
-
- while (count <= nm)
- { if (wi[count] == 0.e0)
- {printf("\n \n Real Eigenvalue : %8.4f \n", wr[count]);
- if (matz != 0)
- for (i=1;i<=nm;i++)
- printf(" ( %8.4f ) \n",z[i][count]);
- count = count + 1;}
- else
- {printf("\n \n Complex Eigenvalue : %8.4f + %8.4f i \n \n",wr[count],wi[count]);
- if (matz != 0)
- for (i=1;i<=nm;i++)
- printf(" ( %8.4f + %8.4f i ) \n",z[i][count],z[i][count+1]);
- printf("\n \n Complex Eigenvalue : %8.4f + %8.4f i \n \n",wr[count+1],wi[count+1]);
- if (matz != 0)
- for (i=1;i<=nm;i++)
- printf(" ( %8.4f - %8.4f i ) \n",z[i][count],z[i][count+1]);
- count = count + 2;
- }
- }
- }
-
-