CODE F2: Gi_vens() - SHORT WRITE-UP NAME: Gi_vens() - Givens method for the calculation of a single eigenvalue and the related eigenvector for a symetric tridiagonal matrix. SYNOPSIS: #include #include #include #include <stdio.h> <math.h> <alloc.h> <stdlib.h> /* For ANSI compability. */ double Gi_vens(double *a, double *b, int n, double lower, double upper, double *lamda, double *x, int *flag) DESCRIPTION: This function computes a single eigenvalue and the related eigen vector for the symetric tridiagonal matrix _ _ | a ,b , 0, ..............................., 0| | 0 0 | | b ,a , b , 0,..............................0| | 0 1 1 | | 0 ,b ,a , b , 0, ..........................0| | 1 2 2 | | ..............................................| | | | | | 0 ,..............................0,b ,a | | n-2 n-1 | using Givens' method. To compute the root of the characteristic equation Newton's method is used. The calculation is performed until limit accuracy or MAXIT (= 40) iterations are performed which one the first. The non zero elements in the matrix is stored in two arrays, the a-array with the elements a ,.........a and the b-array with the elements 0 n-1 b ,.........,b . 0 n-2 REFERENCES: L W Johnson and R D Riess, Numerical Analysis, Addison -Wesley Publishing Company, 1982, pp 123-128. PARAMETERS: *a - Array (vector) storing the matrix elements. a i = *(a + i), i = 0(1)n-1. Space for the a - vector has to be allocated in the calling function, use a = (double *)malloc(n*sizeof(double)) *b - Array (vector) storing the matrix elements. b i = *(b + i), i = 0(1)n-2. Space for the a - vector has to be allocated in the calling function, use b = (double *)malloc((n-1)*sizeof(double)) n lower upper *lamda *x - Order(dimension) of system - Lower interval boundary for eigenvalue. - Upper interval boundary for eigenvalue. - On input see below, for value of flag parameter, for computing the value of the characteristic polynomial. On output see below, for computing the eigenvalue and the related eigenvector. - Array storing computed eigenvector related to the eigenvalue. x = *(x+i), i i = 0(1)n-1. *flag - Input value of flag parameter. = -1, the value of the characteristic polynomial is computed for a given value of lamda and returned through function name Gi_vens. The elements in the Sturm sequence with indices 1 through n are returned in the xarray. = 0, the eigenvalue is computed. It is assumed that the eigenvalue is in the range [lower, upper]. Returned value of flag parameter. = -1, eigenvalue not in the interval [lower, upper]. = 0, limit value not obtained with MAXIT iterations. = 1, the "exact" root is computed. = 2, limit acuracy obtained. The function is to be called by value = Gi_vens(a, b, n, lower, upper, &lamda, x, &flag); EXTERNAL PARAMETERS: None. SEE ALSO: pow_met(), Hy_man(). DIAGNOSTICS: See value of flag parameter flag above.