This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Eigen value problem
- To: Jim dot Love at asml dot com, gsl-discuss at sources dot redhat dot com
- Subject: Re: Eigen value problem
- From: "Varghese John" <vjohn111 at hotmail dot com>
- Date: Mon, 01 Oct 2001 13:45:07 -0400
Thank you for your prompt reply.
I just switched to gsl 9.2+
and the problem disappeared!
Was this a known issue?
Anyway, thank you for the prompt reply.
Regards,
John
>From: "Jim Love" <Jim.Love@asml.com>
>To: <vjohn111@hotmail.com>, <gsl-discuss@sources.redhat.com>
>Subject: Re: Eigen value problem
>Date: Mon, 01 Oct 2001 12:30:06 -0400
>
>This program works for me just fine (gsl 0.9.2 on win32 and redhat 7.1).
>Here is the output for a 2x2 and a 3x3:
>
>The Input Matrix:
> 1 2
> 2 1
>
>The EigenValues :
>eigenvalue = 3
>eigenvalue = -1
>
>The Input Matrix:
> 4 1 1
> 1 2 2
> 1 2 9
>
>The EigenValues :
>eigenvalue = 9.79216
>eigenvalue = 3.93673
>eigenvalue = 1.27111
>
>James A. Love
>X4477
>Pager 1-800-286-1188 Pin# 400659
>
> >>> "Varghese John" <vjohn111@hotmail.com> 10/01/01 11:51AM >>>
>
>Hi,
>I am having problems with the following program.
>trying to get eigen values for the 2x2 matrix, and the program hangs?
>
>--it works fine for a 3x3 matrix!
>
>thanks.
>vj
>-----------------------------------------------
>#include <gsl/gsl_eigen.h>
>#include <stdio.h>
>#include <math.h>
>
>#define TestSize 2
>
>void GetEigen1();
>void GetEigenvaluesForSymmMat( gsl_matrix * m, int mSize, gsl_vector * v);
>
>
>int main(){
> GetEigen1();
> return(0);
>}
>
>void GetEigen1(){
>
> int i;
> int j;
> int x;
>
> gsl_matrix * m = gsl_matrix_alloc(TestSize, TestSize);
> gsl_matrix_set_zero(m);
>
>
> /* matrix = ((1, 2), (2, 1)) */
>
> gsl_matrix_set(m, 0, 0, 1.0);
> gsl_matrix_set(m, 0, 1, 2.0);
> gsl_matrix_set(m, 1, 0, 2.0);
> gsl_matrix_set(m, 1, 1, 1.0);
>
>
>
> /* matrix = ((4, 1, 1), (1, 2, 2), (1, 2, 9)) */
> /*
> gsl_matrix_set(m, 0, 0, 4.0);
> gsl_matrix_set(m, 0, 1, 1.0);
> gsl_matrix_set(m, 0, 2, 1.0);
> gsl_matrix_set(m, 1, 0, 1.0);
> gsl_matrix_set(m, 1, 1, 2.0);
> gsl_matrix_set(m, 1, 2, 2.0);
> gsl_matrix_set(m, 2, 0, 1.0);
> gsl_matrix_set(m, 2, 1, 2.0);
> gsl_matrix_set(m, 2, 2, 9.0);
> */
>
>
> printf("The Input Matrix: \n");
> for (i = 0; i < TestSize; i++){
> for (j = 0; j <TestSize; j++){
> printf("%6.4g \t", gsl_matrix_get (m, i, j));
> }
> printf("\n");
> }
> printf("\n");
>
> //use this vector to store the eigen values.
> gsl_vector *v=gsl_vector_alloc(TestSize);
> GetEigenvaluesForSymmMat( m, TestSize, v);
> printf("The EigenValues : \n");
>
> //print the result
> for (x = 0; x < TestSize; x++)
> {
> printf("eigenvalue = %g\n", gsl_vector_get(v, x));
> }
>}
>
>
>//This function computes the eigen values of a symmetric block
>//and returns the ordered eigen values in the vector v.
>
>void GetEigenvaluesForSymmMat( gsl_matrix * m, int mSize, gsl_vector * v)
>{
>
> gsl_vector *eval = gsl_vector_alloc (mSize);
> gsl_vector_set_zero(eval);
> gsl_matrix *evec = gsl_matrix_alloc (mSize, mSize);
> gsl_matrix_set_zero(evec);
> gsl_eigen_symmv_workspace * w =
> gsl_eigen_symmv_alloc (mSize);
>
> gsl_eigen_symmv (m, eval, evec, w);
>
> gsl_eigen_symmv_free(w);
>
> gsl_eigen_symmv_sort (eval, evec, GSL_EIGEN_SORT_ABS_DESC);
>
> gsl_vector_memcpy(v, eval);
>
>}
>
>
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp