(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix;
- Compute_Vectors : Boolean := True);
+ Compute_Vectors : Boolean);
-- Perform Jacobi's eigensystem algorithm on real symmetric matrix A
function Length is new Square_Matrix_Length (Real'Base, Real_Matrix);
-- Perform a Givens rotation
procedure Sort_Eigensystem
- (Values : in out Real_Vector;
- Vectors : in out Real_Matrix);
+ (Values : in out Real_Vector;
+ Vectors : in out Real_Matrix;
+ Compute_Vectors : Boolean);
-- Sort Values and associated Vectors by decreasing absolute value
procedure Swap (Left, Right : in out Real);
is
begin
Jacobi (A, Values, Vectors, Compute_Vectors => True);
- Sort_Eigensystem (Values, Vectors);
+ Sort_Eigensystem (Values, Vectors, Compute_Vectors => True);
end Eigensystem;
-----------------
Vectors : Real_Matrix (1 .. 0, 1 .. 0);
begin
Jacobi (A, Values, Vectors, Compute_Vectors => False);
- Sort_Eigensystem (Values, Vectors);
+ Sort_Eigensystem (Values, Vectors, Compute_Vectors => False);
end;
end return;
end Eigenvalues;
(A : Real_Matrix;
Values : out Real_Vector;
Vectors : out Real_Matrix;
- Compute_Vectors : Boolean := True)
+ Compute_Vectors : Boolean)
is
-- This subprogram uses Carl Gustav Jacob Jacobi's iterative method
-- for computing eigenvalues and eigenvectors and is based on
----------------------
procedure Sort_Eigensystem
- (Values : in out Real_Vector;
- Vectors : in out Real_Matrix)
+ (Values : in out Real_Vector;
+ Vectors : in out Real_Matrix;
+ Compute_Vectors : Boolean)
is
procedure Swap (Left, Right : Integer);
-- Swap Values (Left) with Values (Right), and also swap the
procedure Swap (Left, Right : Integer) is
begin
Swap (Values (Left), Values (Right));
- Swap_Column (Vectors, Left - Values'First + Vectors'First (2),
- Right - Values'First + Vectors'First (2));
+ if Compute_Vectors then
+ Swap_Column (Vectors, Left - Values'First + Vectors'First (2),
+ Right - Values'First + Vectors'First (2));
+ end if;
end Swap;
begin