comp.lang.ada
 help / color / mirror / Atom feed
* 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

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