2 use Math
::GSL qw
/:all/;
3 use Math
::GSL
::Eigen qw
/:all/;
4 use Math
::GSL
::Matrix qw
/:all/;
5 use Math
::GSL
::Vector qw
/:all/;
6 use Math
::GSL
::Complex qw
/:all/;
7 use Math
::GSL
::Errno qw
/:all/;
11 my $matrix = Math
::GSL
::Matrix
->new(2,2)
13 ->set_row(1, [1, 0] );
15 Finding eigenvalue/eigenvectors for
20 my $evec = gsl_matrix_complex_alloc
(2,2);
21 my $eigen = gsl_eigen_nonsymmv_alloc
(2);
22 my $vector = gsl_vector_complex_alloc
(2);
24 # this actually computes the eigenvalues and vectors
25 gsl_eigen_nonsymmv
($matrix->raw,$vector, $evec, $eigen);
27 my $x = gsl_vector_complex_real
($vector);
28 my $y = gsl_vector_complex_imag
($vector);
30 my $eig1 = as_complex
( gsl_vector_get
($x->{vector
}, 0) , gsl_vector_get
($y->{vector
}, 0) );
31 my $eig2 = as_complex
( gsl_vector_get
($x->{vector
}, 1) , gsl_vector_get
($y->{vector
}, 1) );
33 my $u1 = as_complex
( gsl_matrix_complex_get
($evec, 0, 0) );
34 my $u2 = as_complex
( gsl_matrix_complex_get
($evec, 1, 0) );
35 my $v1 = as_complex
( gsl_matrix_complex_get
($evec, 0, 1) );
36 my $v2 = as_complex
( gsl_matrix_complex_get
($evec, 1, 1) );
56 ($x,$y) = (gsl_real
($w),gsl_imag
($w));
60 my $z = Math
::Complex
->make( $x, $y);