comp.lang.ada
 help / color / mirror / Atom feed
From: "Jason C. Wells" <jcw@highperformance.net>
Subject: Why is Function Defined Twice?
Date: Sun, 14 May 2006 10:55:10 -0700
Date: 2006-05-14T10:55:10-07:00	[thread overview]
Message-ID: <126erl3o7kb1p1a@corp.supernews.com> (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;




             reply	other threads:[~2006-05-14 17:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-14 17:55 Jason C. Wells [this message]
2006-05-14 19:25 ` Why is Function Defined Twice? Jeffrey R. Carter
2006-05-14 19:51 ` 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