From: Simon Wright <simon@pushface.org>
Subject: Question on procedure parameter style
Date: Thu, 23 Dec 2010 17:59:06 +0000
Date: 2010-12-23T17:59:06+00:00 [thread overview]
Message-ID: <m2lj3g9xqt.fsf@pushface.org> (raw)
Hi all,
Working on adding generalized eigenvalues to
https://sourceforge.net/projects/gnat-math-extn/, I've started with
-- Obtain the generalized eigenvalues and the right generalized
-- eigenvectors of a pair of non-symmetric real matrices.
--
-- A generalized eigenvalue for a pair of matrices (A,B) is a
-- scalar lambda or a ratio alpha/beta = lambda, such that A -
-- lambda*B is singular (or, equivalently, beta*A - alpha*B is
-- singular).
--
-- It is usually represented as the pair (alpha,beta), as there
-- is a reasonable interpretation for beta = 0, and even for both
-- being zero.
--
-- The right eigenvector v(j) corresponding to the eigenvalue
-- lambda(j) of (A,B) satisfies
-- A * v(j) = lambda(j) * B * v(j).
--
-- Alphas'Range and Betas'Range must be the same as A'Range (1).
-- The ranges of A, B and Vectors must be the same.
procedure Generalized_Eigensystem
(A : Real_Arrays.Real_Matrix;
B : Real_Arrays.Real_Matrix;
Alphas : out Complex_Arrays.Complex_Vector;
Betas : out Real_Arrays.Real_Vector;
Vectors : out Real_Arrays.Real_Matrix);
The comment is adapted from the man page for LAPACK's SGGEV. (BTW,
clearly lambda is complex; is it OK to refer to lambda as a _scalar_?)
My question is, what do people think about this way of returning the
eigenvalues (in Alphas & Betas)? An alternative would be to declare
types
type Real_Eigenvalue is record
Alpha : Complex;
Beta : Real;
end record;
type Real_Eigenvalue_Vector
is array (Integer range <>) of Real_Eigenvalue;
and replace the Alphas and Betas 'out' parameters by
Values : out Real_Eigenvalue_Vector;
but then I have the problem that for the complex generalized eigenvalue
problem I'd have to write
type Complex_Eigenvalue is record
Alpha : Complex;
Beta : Complex;
end record;
type Complex_Eigenvalue_Vector
is array (Integer range <>) of Complex_Eigenvalue;
which is all geting a bit confusing (I was going to say "complex"...).
Thanks in advance for any comments.
next reply other threads:[~2010-12-23 17:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-23 17:59 Simon Wright [this message]
2010-12-23 18:51 ` Question on procedure parameter style Ada novice
2010-12-23 20:38 ` Simon Wright
2010-12-23 21:21 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox