comp.lang.ada
 help / color / mirror / Atom feed
* Why is Function Defined Twice?
@ 2006-05-14 17:55 Jason C. Wells
  2006-05-14 19:25 ` Jeffrey R. Carter
  2006-05-14 19:51 ` Simon Wright
  0 siblings, 2 replies; 3+ messages in thread
From: Jason C. Wells @ 2006-05-14 17:55 UTC (permalink / raw)


I am trying to do some basic linear algebra as my first non-hello world
exercise.  I am also trying to work in the concept of library reuse into
my exercise.

I don't understand why the function ASUM is defined twice in the
following example.  Which version gets called when I use ASUM?  How does
Ada determine precedence on which gets called?  What is the big concept
that I need to associate with this practice so I can go do more studying?

These both look like they do the mostly same thing but with different
sets of input parameters.

Thanks,
Jason C. Wells

***
This example comes from Ada BLAS at:
http://topo.math.u-psud.fr/~sands/Programs/BLAS/html/index.htm

    function ASUM (
      N    : Natural;
      X    : Vector_Type;
      INCX : Natural
    ) return Float_Type'Base is
    begin
       if N > 0 and (N - 1) * INCX >= X'Length then
          raise Argument_Error;
       end if;

       case Precision is
          when Single =>
             return SCASUM (Fortran_Integer (N), X, Fortran_Integer (INCX));
          when Double =>
             return DZASUM (Fortran_Integer (N), X, Fortran_Integer (INCX));
          when Unsupported =>
             raise Unsupported_Precision_Error;
       end case;
    end ASUM;

    function ASUM (X : Vector_Type) return Float_Type'Base is
    begin
       case Precision is
          when Single =>
             return SCASUM (X'Length, X, 1);
          when Double =>
             return DZASUM (X'Length, X, 1);
          when Unsupported =>
             raise Unsupported_Precision_Error;
       end case;
    end ASUM;




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-14 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-14 17:55 Why is Function Defined Twice? Jason C. Wells
2006-05-14 19:25 ` Jeffrey R. Carter
2006-05-14 19:51 ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox