* Question on procedure parameter style
@ 2010-12-23 17:59 Simon Wright
2010-12-23 18:51 ` Ada novice
2010-12-23 20:38 ` Simon Wright
0 siblings, 2 replies; 4+ messages in thread
From: Simon Wright @ 2010-12-23 17:59 UTC (permalink / 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question on procedure parameter style
2010-12-23 17:59 Question on procedure parameter style Simon Wright
@ 2010-12-23 18:51 ` Ada novice
2010-12-23 20:38 ` Simon Wright
1 sibling, 0 replies; 4+ messages in thread
From: Ada novice @ 2010-12-23 18:51 UTC (permalink / raw)
On Dec 23, 6:59 pm, Simon Wright <si...@pushface.org> wrote:
> Hi all,
>
> Working on adding generalized eigenvalues tohttps://sourceforge.net/projects/gnat-math-extn/, I've started with
Thanks Simon for considering implementing the generalized eigenvalue
problem. It's a very useful tool for many people.
Wish you all the best in this endeavour.
Cheers
YC
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question on procedure parameter style
2010-12-23 17:59 Question on procedure parameter style Simon Wright
2010-12-23 18:51 ` Ada novice
@ 2010-12-23 20:38 ` Simon Wright
2010-12-23 21:21 ` Simon Wright
1 sibling, 1 reply; 4+ messages in thread
From: Simon Wright @ 2010-12-23 20:38 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> 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;
I've now read up on this at
http://en.wikipedia.org/wiki/Generalized_eigenvalue_problem#Generalized_eigenvalue_problem,
and there's a hint there that lambda is in fact complex.
So I think I'll go with
type General_Eigenvalue is record
Alpha : General;
Beta : General;
end record;
type General_Eigenvalue_Vector
is array (Integer range <>) of General_Eigenvalue;
for both the Real and the Complex problem.
Also, instead of Generalized_Eigensystem, the procedure will be called
just Eigensystem (another overloading).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question on procedure parameter style
2010-12-23 20:38 ` Simon Wright
@ 2010-12-23 21:21 ` Simon Wright
0 siblings, 0 replies; 4+ messages in thread
From: Simon Wright @ 2010-12-23 21:21 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> type General_Eigenvalue is record
> Alpha : General;
> Beta : General;
> end record;
> type General_Eigenvalue_Vector
> is array (Integer range <>) of General_Eigenvalue;
M-x replace-string was the wrong operation here. I meant to say
type General_Eigenvalue is record
Alpha : Complex;
Beta : Complex;
end record;
type General_Eigenvalue_Vector
is array (Integer range <>) of General_Eigenvalue;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-23 21:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-23 17:59 Question on procedure parameter style Simon Wright
2010-12-23 18:51 ` Ada novice
2010-12-23 20:38 ` Simon Wright
2010-12-23 21:21 ` Simon Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox