1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
|
@cindex eigenvalues and eigenvectors
This chapter describes functions for computing eigenvalues and
eigenvectors of matrices. There are routines for real symmetric,
real nonsymmetric, complex hermitian, real generalized symmetric-definite,
complex generalized hermitian-definite, and real generalized nonsymmetric
eigensystems. Eigenvalues can be computed with or without eigenvectors.
The hermitian and real symmetric matrix algorithms are symmetric bidiagonalization
followed by QR reduction. The nonsymmetric algorithm is the Francis QR
double-shift. The generalized nonsymmetric algorithm is the QZ method due
to Moler and Stewart.
The functions described in this chapter are declared in the header file
@file{gsl_eigen.h}.
@menu
* Real Symmetric Matrices::
* Complex Hermitian Matrices::
* Real Nonsymmetric Matrices::
* Real Generalized Symmetric-Definite Eigensystems::
* Complex Generalized Hermitian-Definite Eigensystems::
* Real Generalized Nonsymmetric Eigensystems::
* Sorting Eigenvalues and Eigenvectors::
* Eigenvalue and Eigenvector Examples::
* Eigenvalue and Eigenvector References::
@end menu
@node Real Symmetric Matrices
@section Real Symmetric Matrices
@cindex symmetric matrix, real, eigensystem
@cindex real symmetric matrix, eigensystem
For real symmetric matrices, the library uses the symmetric
bidiagonalization and QR reduction method. This is described in Golub
& van Loan, section 8.3. The computed eigenvalues are accurate to an
absolute accuracy of @math{\epsilon ||A||_2}, where @math{\epsilon} is
the machine precision.
@deftypefun {gsl_eigen_symm_workspace *} gsl_eigen_symm_alloc (const size_t @var{n})
@tindex gsl_eigen_symm_workspace
This function allocates a workspace for computing eigenvalues of
@var{n}-by-@var{n} real symmetric matrices. The size of the workspace
is @math{O(2n)}.
@end deftypefun
@deftypefun void gsl_eigen_symm_free (gsl_eigen_symm_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_symm (gsl_matrix * @var{A}, gsl_vector * @var{eval}, gsl_eigen_symm_workspace * @var{w})
This function computes the eigenvalues of the real symmetric matrix
@var{A}. Additional workspace of the appropriate size must be provided
in @var{w}. The diagonal and lower triangular part of @var{A} are
destroyed during the computation, but the strict upper triangular part
is not referenced. The eigenvalues are stored in the vector @var{eval}
and are unordered.
@end deftypefun
@deftypefun {gsl_eigen_symmv_workspace *} gsl_eigen_symmv_alloc (const size_t @var{n})
@tindex gsl_eigen_symmv_workspace
This function allocates a workspace for computing eigenvalues and
eigenvectors of @var{n}-by-@var{n} real symmetric matrices. The size of
the workspace is @math{O(4n)}.
@end deftypefun
@deftypefun void gsl_eigen_symmv_free (gsl_eigen_symmv_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_symmv (gsl_matrix * @var{A}, gsl_vector * @var{eval}, gsl_matrix * @var{evec}, gsl_eigen_symmv_workspace * @var{w})
This function computes the eigenvalues and eigenvectors of the real
symmetric matrix @var{A}. Additional workspace of the appropriate size
must be provided in @var{w}. The diagonal and lower triangular part of
@var{A} are destroyed during the computation, but the strict upper
triangular part is not referenced. The eigenvalues are stored in the
vector @var{eval} and are unordered. The corresponding eigenvectors are
stored in the columns of the matrix @var{evec}. For example, the
eigenvector in the first column corresponds to the first eigenvalue.
The eigenvectors are guaranteed to be mutually orthogonal and normalised
to unit magnitude.
@end deftypefun
@node Complex Hermitian Matrices
@section Complex Hermitian Matrices
For hermitian matrices, the library uses the complex form of
the symmetric bidiagonalization and QR reduction method.
@cindex hermitian matrix, complex, eigensystem
@cindex complex hermitian matrix, eigensystem
@deftypefun {gsl_eigen_herm_workspace *} gsl_eigen_herm_alloc (const size_t @var{n})
@tindex gsl_eigen_herm_workspace
This function allocates a workspace for computing eigenvalues of
@var{n}-by-@var{n} complex hermitian matrices. The size of the workspace
is @math{O(3n)}.
@end deftypefun
@deftypefun void gsl_eigen_herm_free (gsl_eigen_herm_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_herm (gsl_matrix_complex * @var{A}, gsl_vector * @var{eval}, gsl_eigen_herm_workspace * @var{w})
This function computes the eigenvalues of the complex hermitian matrix
@var{A}. Additional workspace of the appropriate size must be provided
in @var{w}. The diagonal and lower triangular part of @var{A} are
destroyed during the computation, but the strict upper triangular part
is not referenced. The imaginary parts of the diagonal are assumed to be
zero and are not referenced. The eigenvalues are stored in the vector
@var{eval} and are unordered.
@end deftypefun
@deftypefun {gsl_eigen_hermv_workspace *} gsl_eigen_hermv_alloc (const size_t @var{n})
@tindex gsl_eigen_hermv_workspace
This function allocates a workspace for computing eigenvalues and
eigenvectors of @var{n}-by-@var{n} complex hermitian matrices. The size of
the workspace is @math{O(5n)}.
@end deftypefun
@deftypefun void gsl_eigen_hermv_free (gsl_eigen_hermv_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_hermv (gsl_matrix_complex * @var{A}, gsl_vector * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_eigen_hermv_workspace * @var{w})
This function computes the eigenvalues and eigenvectors of the complex
hermitian matrix @var{A}. Additional workspace of the appropriate size
must be provided in @var{w}. The diagonal and lower triangular part of
@var{A} are destroyed during the computation, but the strict upper
triangular part is not referenced. The imaginary parts of the diagonal
are assumed to be zero and are not referenced. The eigenvalues are
stored in the vector @var{eval} and are unordered. The corresponding
complex eigenvectors are stored in the columns of the matrix @var{evec}.
For example, the eigenvector in the first column corresponds to the
first eigenvalue. The eigenvectors are guaranteed to be mutually
orthogonal and normalised to unit magnitude.
@end deftypefun
@node Real Nonsymmetric Matrices
@section Real Nonsymmetric Matrices
@cindex nonsymmetric matrix, real, eigensystem
@cindex real nonsymmetric matrix, eigensystem
The solution of the real nonsymmetric eigensystem problem for a
matrix @math{A} involves computing the Schur decomposition
@tex
\beforedisplay
$$
A = Z T Z^T
$$
\afterdisplay
@end tex
@ifinfo
@example
A = Z T Z^T
@end example
@end ifinfo
where @math{Z} is an orthogonal matrix of Schur vectors and @math{T},
the Schur form, is quasi upper triangular with diagonal
@math{1}-by-@math{1} blocks which are real eigenvalues of @math{A}, and
diagonal @math{2}-by-@math{2} blocks whose eigenvalues are complex
conjugate eigenvalues of @math{A}. The algorithm used is the double-shift
Francis method.
@deftypefun {gsl_eigen_nonsymm_workspace *} gsl_eigen_nonsymm_alloc (const size_t @var{n})
@tindex gsl_eigen_nonsymm_workspace
This function allocates a workspace for computing eigenvalues of
@var{n}-by-@var{n} real nonsymmetric matrices. The size of the workspace
is @math{O(2n)}.
@end deftypefun
@deftypefun void gsl_eigen_nonsymm_free (gsl_eigen_nonsymm_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun void gsl_eigen_nonsymm_params (const int @var{compute_t}, const int @var{balance}, gsl_eigen_nonsymm_workspace * @var{w})
This function sets some parameters which determine how the eigenvalue
problem is solved in subsequent calls to @code{gsl_eigen_nonsymm}.
If @var{compute_t} is set to 1, the full Schur form @math{T} will be
computed by @code{gsl_eigen_nonsymm}. If it is set to 0,
@math{T} will not be computed (this is the default setting). Computing
the full Schur form @math{T} requires approximately 1.5--2 times the
number of flops.
If @var{balance} is set to 1, a balancing transformation is applied
to the matrix prior to computing eigenvalues. This transformation is
designed to make the rows and columns of the matrix have comparable
norms, and can result in more accurate eigenvalues for matrices
whose entries vary widely in magnitude. See @ref{Balancing} for more
information. Note that the balancing transformation does not preserve
the orthogonality of the Schur vectors, so if you wish to compute the
Schur vectors with @code{gsl_eigen_nonsymm_Z} you will obtain the Schur
vectors of the balanced matrix instead of the original matrix. The
relationship will be
@tex
\beforedisplay
$$
T = Q^t D^{-1} A D Q
$$
\afterdisplay
@end tex
@ifinfo
@example
T = Q^t D^(-1) A D Q
@end example
@end ifinfo
@noindent
where @var{Q} is the matrix of Schur vectors for the balanced matrix, and
@var{D} is the balancing transformation. Then @code{gsl_eigen_nonsymm_Z}
will compute a matrix @var{Z} which satisfies
@tex
\beforedisplay
$$
T = Z^{-1} A Z
$$
\afterdisplay
@end tex
@ifinfo
@example
T = Z^(-1) A Z
@end example
@end ifinfo
@noindent
with @math{Z = D Q}. Note that @var{Z} will not be orthogonal. For
this reason, balancing is not performed by default.
@end deftypefun
@deftypefun int gsl_eigen_nonsymm (gsl_matrix * @var{A}, gsl_vector_complex * @var{eval}, gsl_eigen_nonsymm_workspace * @var{w})
This function computes the eigenvalues of the real nonsymmetric matrix
@var{A} and stores them in the vector @var{eval}. If @math{T} is
desired, it is stored in the upper portion of @var{A} on output.
Otherwise, on output, the diagonal of @var{A} will contain the
@math{1}-by-@math{1} real eigenvalues and @math{2}-by-@math{2}
complex conjugate eigenvalue systems, and the rest of @var{A} is
destroyed. In rare cases, this function may fail to find all
eigenvalues. If this happens, an error code is returned
and the number of converged eigenvalues is stored in @code{w->n_evals}.
The converged eigenvalues are stored in the beginning of @var{eval}.
@end deftypefun
@deftypefun int gsl_eigen_nonsymm_Z (gsl_matrix * @var{A}, gsl_vector_complex * @var{eval}, gsl_matrix * @var{Z}, gsl_eigen_nonsymm_workspace * @var{w})
This function is identical to @code{gsl_eigen_nonsymm} except that it also
computes the Schur vectors and stores them into @var{Z}.
@end deftypefun
@deftypefun {gsl_eigen_nonsymmv_workspace *} gsl_eigen_nonsymmv_alloc (const size_t @var{n})
@tindex gsl_eigen_nonsymmv_workspace
This function allocates a workspace for computing eigenvalues and
eigenvectors of @var{n}-by-@var{n} real nonsymmetric matrices. The
size of the workspace is @math{O(5n)}.
@end deftypefun
@deftypefun void gsl_eigen_nonsymmv_free (gsl_eigen_nonsymmv_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun void gsl_eigen_nonsymmv_params (const int @var{balance}, gsl_eigen_nonsymm_workspace * @var{w})
This function sets parameters which determine how the eigenvalue
problem is solved in subsequent calls to @code{gsl_eigen_nonsymmv}.
If @var{balance} is set to 1, a balancing transformation is applied
to the matrix. See @code{gsl_eigen_nonsymm_params} for more information.
Balancing is turned off by default since it does not preserve the
orthogonality of the Schur vectors.
@end deftypefun
@deftypefun int gsl_eigen_nonsymmv (gsl_matrix * @var{A}, gsl_vector_complex * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_eigen_nonsymmv_workspace * @var{w})
This function computes eigenvalues and right eigenvectors of the
@var{n}-by-@var{n} real nonsymmetric matrix @var{A}. It first calls
@code{gsl_eigen_nonsymm} to compute the eigenvalues, Schur form @math{T}, and
Schur vectors. Then it finds eigenvectors of @math{T} and backtransforms
them using the Schur vectors. The Schur vectors are destroyed in the
process, but can be saved by using @code{gsl_eigen_nonsymmv_Z}. The
computed eigenvectors are normalized to have unit magnitude. On
output, the upper portion of @var{A} contains the Schur form
@math{T}. If @code{gsl_eigen_nonsymm} fails, no eigenvectors are
computed, and an error code is returned.
@end deftypefun
@deftypefun int gsl_eigen_nonsymmv_Z (gsl_matrix * @var{A}, gsl_vector_complex * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_matrix * @var{Z}, gsl_eigen_nonsymmv_workspace * @var{w})
This function is identical to @code{gsl_eigen_nonsymmv} except that it also saves
the Schur vectors into @var{Z}.
@end deftypefun
@node Real Generalized Symmetric-Definite Eigensystems
@section Real Generalized Symmetric-Definite Eigensystems
@cindex generalized symmetric eigensystems
The real generalized symmetric-definite eigenvalue problem is to find
eigenvalues @math{\lambda} and eigenvectors @math{x} such that
@tex
\beforedisplay
$$
A x = \lambda B x
$$
\afterdisplay
@end tex
@ifinfo
@example
A x = \lambda B x
@end example
@end ifinfo
where @math{A} and @math{B} are symmetric matrices, and @math{B} is
positive-definite. This problem reduces to the standard symmetric
eigenvalue problem by applying the Cholesky decomposition to @math{B}:
@tex
\beforedisplay
$$
\eqalign{
A x & = \lambda B x \cr
A x & = \lambda L L^t x \cr
\left( L^{-1} A L^{-t} \right) L^t x & = \lambda L^t x
}
$$
\afterdisplay
@end tex
@ifinfo
@example
A x = \lambda B x
A x = \lambda L L^t x
( L^@{-1@} A L^@{-t@} ) L^t x = \lambda L^t x
@end example
@end ifinfo
Therefore, the problem becomes @math{C y = \lambda y} where
@c{$C = L^{-1} A L^{-t}$}
@math{C = L^@{-1@} A L^@{-t@}}
is symmetric, and @math{y = L^t x}. The standard
symmetric eigensolver can be applied to the matrix @math{C}.
The resulting eigenvectors are backtransformed to find the
vectors of the original problem. The eigenvalues and eigenvectors
of the generalized symmetric-definite eigenproblem are always real.
@deftypefun {gsl_eigen_gensymm_workspace *} gsl_eigen_gensymm_alloc (const size_t @var{n})
@tindex gsl_eigen_gensymm_workspace
This function allocates a workspace for computing eigenvalues of
@var{n}-by-@var{n} real generalized symmetric-definite eigensystems. The
size of the workspace is @math{O(2n)}.
@end deftypefun
@deftypefun void gsl_eigen_gensymm_free (gsl_eigen_gensymm_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_gensymm (gsl_matrix * @var{A}, gsl_matrix * @var{B}, gsl_vector * @var{eval}, gsl_eigen_gensymm_workspace * @var{w})
This function computes the eigenvalues of the real generalized
symmetric-definite matrix pair (@var{A}, @var{B}), and stores them
in @var{eval}, using the method outlined above. On output, @var{B}
contains its Cholesky decomposition and @var{A} is destroyed.
@end deftypefun
@deftypefun {gsl_eigen_gensymmv_workspace *} gsl_eigen_gensymmv_alloc (const size_t @var{n})
@tindex gsl_eigen_gensymmv_workspace
This function allocates a workspace for computing eigenvalues and
eigenvectors of @var{n}-by-@var{n} real generalized symmetric-definite
eigensystems. The size of the workspace is @math{O(4n)}.
@end deftypefun
@deftypefun void gsl_eigen_gensymmv_free (gsl_eigen_gensymmv_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_gensymmv (gsl_matrix * @var{A}, gsl_matrix * @var{B}, gsl_vector * @var{eval}, gsl_matrix * @var{evec}, gsl_eigen_gensymmv_workspace * @var{w})
This function computes the eigenvalues and eigenvectors of the real
generalized symmetric-definite matrix pair (@var{A}, @var{B}), and
stores them in @var{eval} and @var{evec} respectively. The computed
eigenvectors are normalized to have unit magnitude. On output,
@var{B} contains its Cholesky decomposition and @var{A} is destroyed.
@end deftypefun
@node Complex Generalized Hermitian-Definite Eigensystems
@section Complex Generalized Hermitian-Definite Eigensystems
@cindex generalized hermitian definite eigensystems
The complex generalized hermitian-definite eigenvalue problem is to find
eigenvalues @math{\lambda} and eigenvectors @math{x} such that
@tex
\beforedisplay
$$
A x = \lambda B x
$$
\afterdisplay
@end tex
@ifinfo
@example
A x = \lambda B x
@end example
@end ifinfo
where @math{A} and @math{B} are hermitian matrices, and @math{B} is
positive-definite. Similarly to the real case, this can be reduced
to @math{C y = \lambda y} where
@c{$C = L^{-1} A L^{-\dagger}$}
@math{C = L^@{-1@} A L^@{-H@}}
is hermitian, and
@c{$y = L^{\dagger} x$}
@math{y = L^H x}. The standard
hermitian eigensolver can be applied to the matrix @math{C}.
The resulting eigenvectors are backtransformed to find the
vectors of the original problem. The eigenvalues
of the generalized hermitian-definite eigenproblem are always real.
@deftypefun {gsl_eigen_genherm_workspace *} gsl_eigen_genherm_alloc (const size_t @var{n})
@tindex gsl_eigen_genherm_workspace
This function allocates a workspace for computing eigenvalues of
@var{n}-by-@var{n} complex generalized hermitian-definite eigensystems. The
size of the workspace is @math{O(3n)}.
@end deftypefun
@deftypefun void gsl_eigen_genherm_free (gsl_eigen_genherm_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_genherm (gsl_matrix_complex * @var{A}, gsl_matrix_complex * @var{B}, gsl_vector * @var{eval}, gsl_eigen_genherm_workspace * @var{w})
This function computes the eigenvalues of the complex generalized
hermitian-definite matrix pair (@var{A}, @var{B}), and stores them
in @var{eval}, using the method outlined above. On output, @var{B}
contains its Cholesky decomposition and @var{A} is destroyed.
@end deftypefun
@deftypefun {gsl_eigen_genhermv_workspace *} gsl_eigen_genhermv_alloc (const size_t @var{n})
@tindex gsl_eigen_genhermv_workspace
This function allocates a workspace for computing eigenvalues and
eigenvectors of @var{n}-by-@var{n} complex generalized hermitian-definite
eigensystems. The size of the workspace is @math{O(5n)}.
@end deftypefun
@deftypefun void gsl_eigen_genhermv_free (gsl_eigen_genhermv_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_genhermv (gsl_matrix_complex * @var{A}, gsl_matrix_complex * @var{B}, gsl_vector * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_eigen_genhermv_workspace * @var{w})
This function computes the eigenvalues and eigenvectors of the complex
generalized hermitian-definite matrix pair (@var{A}, @var{B}), and
stores them in @var{eval} and @var{evec} respectively. The computed
eigenvectors are normalized to have unit magnitude. On output,
@var{B} contains its Cholesky decomposition and @var{A} is destroyed.
@end deftypefun
@node Real Generalized Nonsymmetric Eigensystems
@section Real Generalized Nonsymmetric Eigensystems
@cindex generalized eigensystems
Given two square matrices (@math{A}, @math{B}), the generalized
nonsymmetric eigenvalue problem is to find eigenvalues @math{\lambda} and
eigenvectors @math{x} such that
@tex
\beforedisplay
$$
A x = \lambda B x
$$
\afterdisplay
@end tex
@ifinfo
@example
A x = \lambda B x
@end example
@end ifinfo
We may also define the problem as finding eigenvalues @math{\mu} and
eigenvectors @math{y} such that
@tex
\beforedisplay
$$
\mu A y = B y
$$
\afterdisplay
@end tex
@ifinfo
@example
\mu A y = B y
@end example
@end ifinfo
Note that these two problems are equivalent (with @math{\lambda = 1/\mu})
if neither @math{\lambda} nor @math{\mu} is zero. If say, @math{\lambda}
is zero, then it is still a well defined eigenproblem, but its alternate
problem involving @math{\mu} is not. Therefore, to allow for zero
(and infinite) eigenvalues, the problem which is actually solved is
@tex
\beforedisplay
$$
\beta A x = \alpha B x
$$
\afterdisplay
@end tex
@ifinfo
@example
\beta A x = \alpha B x
@end example
@end ifinfo
The eigensolver routines below will return two values @math{\alpha}
and @math{\beta} and leave it to the user to perform the divisions
@math{\lambda = \alpha / \beta} and @math{\mu = \beta / \alpha}.
If the determinant of the matrix pencil @math{A - \lambda B} is zero
for all @math{\lambda}, the problem is said to be singular; otherwise
it is called regular. Singularity normally leads to some
@math{\alpha = \beta = 0} which means the eigenproblem is ill-conditioned
and generally does not have well defined eigenvalue solutions. The
routines below are intended for regular matrix pencils and could yield
unpredictable results when applied to singular pencils.
The solution of the real generalized nonsymmetric eigensystem problem for a
matrix pair @math{(A, B)} involves computing the generalized Schur
decomposition
@tex
\beforedisplay
$$
A = Q S Z^T
$$
$$
B = Q T Z^T
$$
\afterdisplay
@end tex
@ifinfo
@example
A = Q S Z^T
B = Q T Z^T
@end example
@end ifinfo
where @math{Q} and @math{Z} are orthogonal matrices of left and right
Schur vectors respectively, and @math{(S, T)} is the generalized Schur
form whose diagonal elements give the @math{\alpha} and @math{\beta}
values. The algorithm used is the QZ method due to Moler and Stewart
(see references).
@deftypefun {gsl_eigen_gen_workspace *} gsl_eigen_gen_alloc (const size_t @var{n})
@tindex gsl_eigen_gen_workspace
This function allocates a workspace for computing eigenvalues of
@var{n}-by-@var{n} real generalized nonsymmetric eigensystems. The
size of the workspace is @math{O(n)}.
@end deftypefun
@deftypefun void gsl_eigen_gen_free (gsl_eigen_gen_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun void gsl_eigen_gen_params (const int @var{compute_s}, const int @var{compute_t}, const int @var{balance}, gsl_eigen_gen_workspace * @var{w})
This function sets some parameters which determine how the eigenvalue
problem is solved in subsequent calls to @code{gsl_eigen_gen}.
If @var{compute_s} is set to 1, the full Schur form @math{S} will be
computed by @code{gsl_eigen_gen}. If it is set to 0,
@math{S} will not be computed (this is the default setting). @math{S}
is a quasi upper triangular matrix with 1-by-1 and 2-by-2 blocks
on its diagonal. 1-by-1 blocks correspond to real eigenvalues, and
2-by-2 blocks correspond to complex eigenvalues.
If @var{compute_t} is set to 1, the full Schur form @math{T} will be
computed by @code{gsl_eigen_gen}. If it is set to 0,
@math{T} will not be computed (this is the default setting). @math{T}
is an upper triangular matrix with non-negative elements on its diagonal.
Any 2-by-2 blocks in @math{S} will correspond to a 2-by-2 diagonal
block in @math{T}.
The @var{balance} parameter is currently ignored, since generalized
balancing is not yet implemented.
@end deftypefun
@deftypefun int gsl_eigen_gen (gsl_matrix * @var{A}, gsl_matrix * @var{B}, gsl_vector_complex * @var{alpha}, gsl_vector * @var{beta}, gsl_eigen_gen_workspace * @var{w})
This function computes the eigenvalues of the real generalized nonsymmetric
matrix pair (@var{A}, @var{B}), and stores them as pairs in
(@var{alpha}, @var{beta}), where @var{alpha} is complex and @var{beta} is
real. If @math{\beta_i} is non-zero, then
@math{\lambda = \alpha_i / \beta_i} is an eigenvalue. Likewise,
if @math{\alpha_i} is non-zero, then
@math{\mu = \beta_i / \alpha_i} is an eigenvalue of the alternate
problem @math{\mu A y = B y}. The elements of @var{beta} are normalized
to be non-negative.
If @math{S} is desired, it is stored in @var{A} on output. If @math{T}
is desired, it is stored in @var{B} on output. The ordering of
eigenvalues in (@var{alpha}, @var{beta}) follows the ordering
of the diagonal blocks in the Schur forms @math{S} and @math{T}. In rare
cases, this function may fail to find all eigenvalues. If this occurs, an
error code is returned.
@end deftypefun
@deftypefun int gsl_eigen_gen_QZ (gsl_matrix * @var{A}, gsl_matrix * @var{B}, gsl_vector_complex * @var{alpha}, gsl_vector * @var{beta}, gsl_matrix * @var{Q}, gsl_matrix * @var{Z}, gsl_eigen_gen_workspace * @var{w})
This function is identical to @code{gsl_eigen_gen} except that it also
computes the left and right Schur vectors and stores them into @var{Q}
and @var{Z} respectively.
@end deftypefun
@deftypefun {gsl_eigen_genv_workspace *} gsl_eigen_genv_alloc (const size_t @var{n})
@tindex gsl_eigen_genv_workspace
This function allocates a workspace for computing eigenvalues and
eigenvectors of @var{n}-by-@var{n} real generalized nonsymmetric
eigensystems. The size of the workspace is @math{O(7n)}.
@end deftypefun
@deftypefun void gsl_eigen_genv_free (gsl_eigen_genv_workspace * @var{w})
This function frees the memory associated with the workspace @var{w}.
@end deftypefun
@deftypefun int gsl_eigen_genv (gsl_matrix * @var{A}, gsl_matrix * @var{B}, gsl_vector_complex * @var{alpha}, gsl_vector * @var{beta}, gsl_matrix_complex * @var{evec}, gsl_eigen_genv_workspace * @var{w})
This function computes eigenvalues and right eigenvectors of the
@var{n}-by-@var{n} real generalized nonsymmetric matrix pair
(@var{A}, @var{B}). The eigenvalues are stored in (@var{alpha}, @var{beta})
and the eigenvectors are stored in @var{evec}. It first calls
@code{gsl_eigen_gen} to compute the eigenvalues, Schur forms, and
Schur vectors. Then it finds eigenvectors of the Schur forms and
backtransforms them using the Schur vectors. The Schur vectors are
destroyed in the process, but can be saved by using
@code{gsl_eigen_genv_QZ}. The computed eigenvectors are normalized
to have unit magnitude. On output, (@var{A}, @var{B}) contains
the generalized Schur form (@math{S}, @math{T}). If @code{gsl_eigen_gen}
fails, no eigenvectors are computed, and an error code is returned.
@end deftypefun
@deftypefun int gsl_eigen_genv_QZ (gsl_matrix * @var{A}, gsl_matrix * @var{B}, gsl_vector_complex * @var{alpha}, gsl_vector * @var{beta}, gsl_matrix_complex * @var{evec}, gsl_matrix * @var{Q}, gsl_matrix * @var{Z}, gsl_eigen_genv_workspace * @var{w})
This function is identical to @code{gsl_eigen_genv} except that it also
computes the left and right Schur vectors and stores them into @var{Q}
and @var{Z} respectively.
@end deftypefun
@node Sorting Eigenvalues and Eigenvectors
@section Sorting Eigenvalues and Eigenvectors
@cindex sorting eigenvalues and eigenvectors
@deftypefun int gsl_eigen_symmv_sort (gsl_vector * @var{eval}, gsl_matrix * @var{evec}, gsl_eigen_sort_t @var{sort_type})
This function simultaneously sorts the eigenvalues stored in the vector
@var{eval} and the corresponding real eigenvectors stored in the columns
of the matrix @var{evec} into ascending or descending order according to
the value of the parameter @var{sort_type},
@table @code
@item GSL_EIGEN_SORT_VAL_ASC
ascending order in numerical value
@item GSL_EIGEN_SORT_VAL_DESC
descending order in numerical value
@item GSL_EIGEN_SORT_ABS_ASC
ascending order in magnitude
@item GSL_EIGEN_SORT_ABS_DESC
descending order in magnitude
@end table
@end deftypefun
@deftypefun int gsl_eigen_hermv_sort (gsl_vector * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_eigen_sort_t @var{sort_type})
This function simultaneously sorts the eigenvalues stored in the vector
@var{eval} and the corresponding complex eigenvectors stored in the
columns of the matrix @var{evec} into ascending or descending order
according to the value of the parameter @var{sort_type} as shown above.
@end deftypefun
@deftypefun int gsl_eigen_nonsymmv_sort (gsl_vector_complex * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_eigen_sort_t @var{sort_type})
This function simultaneously sorts the eigenvalues stored in the vector
@var{eval} and the corresponding complex eigenvectors stored in the
columns of the matrix @var{evec} into ascending or descending order
according to the value of the parameter @var{sort_type} as shown above.
Only @code{GSL_EIGEN_SORT_ABS_ASC} and @code{GSL_EIGEN_SORT_ABS_DESC} are
supported due to the eigenvalues being complex.
@end deftypefun
@deftypefun int gsl_eigen_gensymmv_sort (gsl_vector * @var{eval}, gsl_matrix * @var{evec}, gsl_eigen_sort_t @var{sort_type})
This function simultaneously sorts the eigenvalues stored in the vector
@var{eval} and the corresponding real eigenvectors stored in the columns
of the matrix @var{evec} into ascending or descending order according to
the value of the parameter @var{sort_type} as shown above.
@end deftypefun
@deftypefun int gsl_eigen_genhermv_sort (gsl_vector * @var{eval}, gsl_matrix_complex * @var{evec}, gsl_eigen_sort_t @var{sort_type})
This function simultaneously sorts the eigenvalues stored in the vector
@var{eval} and the corresponding complex eigenvectors stored in the columns
of the matrix @var{evec} into ascending or descending order according to
the value of the parameter @var{sort_type} as shown above.
@end deftypefun
@deftypefun int gsl_eigen_genv_sort (gsl_vector_complex * @var{alpha}, gsl_vector * @var{beta}, gsl_matrix_complex * @var{evec}, gsl_eigen_sort_t @var{sort_type})
This function simultaneously sorts the eigenvalues stored in the vectors
(@var{alpha}, @var{beta}) and the corresponding complex eigenvectors
stored in the columns of the matrix @var{evec} into ascending or
descending order according to the value of the parameter @var{sort_type}
as shown above. Only @code{GSL_EIGEN_SORT_ABS_ASC} and
@code{GSL_EIGEN_SORT_ABS_DESC} are supported due to the eigenvalues being
complex.
@end deftypefun
@comment @deftypefun int gsl_eigen_jacobi (gsl_matrix * @var{matrix}, gsl_vector * @var{eval}, gsl_matrix * @var{evec}, unsigned int @var{max_rot}, unsigned int * @var{nrot})
@comment This function finds the eigenvectors and eigenvalues of a real symmetric
@comment matrix by Jacobi iteration. The data in the input matrix is destroyed.
@comment @end deftypefun
@comment @deftypefun int gsl_la_invert_jacobi (const gsl_matrix * @var{matrix}, gsl_matrix * @var{ainv}, unsigned int @var{max_rot})
@comment Invert a matrix by Jacobi iteration.
@comment @end deftypefun
@comment @deftypefun int gsl_eigen_sort (gsl_vector * @var{eval}, gsl_matrix * @var{evec}, gsl_eigen_sort_t @var{sort_type})
@comment This functions sorts the eigensystem results based on eigenvalues.
@comment Sorts in order of increasing value or increasing
@comment absolute value, depending on the value of
@comment @var{sort_type}, which can be @code{GSL_EIGEN_SORT_VALUE}
@comment or @code{GSL_EIGEN_SORT_ABSVALUE}.
@comment @end deftypefun
@node Eigenvalue and Eigenvector Examples
@section Examples
The following program computes the eigenvalues and eigenvectors of the 4-th order Hilbert matrix, @math{H(i,j) = 1/(i + j + 1)}.
@example
@verbatiminclude examples/eigen.c
@end example
@noindent
Here is the beginning of the output from the program,
@example
$ ./a.out
eigenvalue = 9.67023e-05
eigenvector =
-0.0291933
0.328712
-0.791411
0.514553
...
@end example
@noindent
This can be compared with the corresponding output from @sc{gnu octave},
@example
octave> [v,d] = eig(hilb(4));
octave> diag(d)
ans =
9.6702e-05
6.7383e-03
1.6914e-01
1.5002e+00
octave> v
v =
0.029193 0.179186 -0.582076 0.792608
-0.328712 -0.741918 0.370502 0.451923
0.791411 0.100228 0.509579 0.322416
-0.514553 0.638283 0.514048 0.252161
@end example
@noindent
Note that the eigenvectors can differ by a change of sign, since the
sign of an eigenvector is arbitrary.
The following program illustrates the use of the nonsymmetric
eigensolver, by computing the eigenvalues and eigenvectors of
the Vandermonde matrix
@c{$V(x;i,j) = x_i^{n - j}$}
@math{V(x;i,j) = x_i^@{n - j@}}
with @math{x = (-1,-2,3,4)}.
@example
@verbatiminclude examples/eigen_nonsymm.c
@end example
@noindent
Here is the beginning of the output from the program,
@example
$ ./a.out
eigenvalue = -6.41391 + 0i
eigenvector =
-0.0998822 + 0i
-0.111251 + 0i
0.292501 + 0i
0.944505 + 0i
eigenvalue = 5.54555 + 3.08545i
eigenvector =
-0.043487 + -0.0076308i
0.0642377 + -0.142127i
-0.515253 + 0.0405118i
-0.840592 + -0.00148565i
...
@end example
@noindent
This can be compared with the corresponding output from @sc{gnu octave},
@example
octave> [v,d] = eig(vander([-1 -2 3 4]));
octave> diag(d)
ans =
-6.4139 + 0.0000i
5.5456 + 3.0854i
5.5456 - 3.0854i
2.3228 + 0.0000i
octave> v
v =
Columns 1 through 3:
-0.09988 + 0.00000i -0.04350 - 0.00755i -0.04350 + 0.00755i
-0.11125 + 0.00000i 0.06399 - 0.14224i 0.06399 + 0.14224i
0.29250 + 0.00000i -0.51518 + 0.04142i -0.51518 - 0.04142i
0.94451 + 0.00000i -0.84059 + 0.00000i -0.84059 - 0.00000i
Column 4:
-0.14493 + 0.00000i
0.35660 + 0.00000i
0.91937 + 0.00000i
0.08118 + 0.00000i
@end example
Note that the eigenvectors corresponding to the eigenvalue
@math{5.54555 + 3.08545i} differ by the multiplicative constant
@math{0.9999984 + 0.0017674i} which is an arbitrary phase factor
of magnitude 1.
@node Eigenvalue and Eigenvector References
@section References and Further Reading
Further information on the algorithms described in this section can be
found in the following book,
@itemize @w{}
@item
G. H. Golub, C. F. Van Loan, @cite{Matrix Computations} (3rd Ed, 1996),
Johns Hopkins University Press, ISBN 0-8018-5414-8.
@end itemize
@noindent
Further information on the generalized eigensystems QZ algorithm
can be found in this paper,
@itemize @w{}
@item
C. Moler, G. Stewart, ``An Algorithm for Generalized Matrix Eigenvalue
Problems'', SIAM J. Numer. Anal., Vol 10, No 2, 1973.
@end itemize
@noindent
@cindex LAPACK
Eigensystem routines for very large matrices can be found in the
Fortran library @sc{lapack}. The @sc{lapack} library is described in,
@itemize @w{}
@item
@cite{LAPACK Users' Guide} (Third Edition, 1999), Published by SIAM,
ISBN 0-89871-447-8.
@uref{http://www.netlib.org/lapack}
@end itemize
@noindent
The @sc{lapack} source code can be found at the website above along with
an online copy of the users guide.
|