comp.lang.ada
 help / color / mirror / Atom feed
* Does Ada need elemental functions to make it suitable for scientific work?
@ 2012-07-09 23:27 Nasser M. Abbasi
       [not found] ` <d78nv7dhf88bqv7hrd9eft231a4h2scs10@invalid.netcom.com>
                   ` (5 more replies)
  0 siblings, 6 replies; 81+ messages in thread
From: Nasser M. Abbasi @ 2012-07-09 23:27 UTC (permalink / raw)



I have been trying Ada to see how suitable it is for computational
work (I am studying finite elements, and wanted to try Ada for
basic programs).

And even though I find its type system a great asset to help
catch many errors, I find it a little awkward for programming on
arrays and matrices which ones does alot in scientific numerical
programming. The most important feature which I found missing is
that Ada functions do not automatically work on arrays and matrices.

In Fortran, we see

http://en.wikipedia.org/wiki/Fortran_95_language_features#Elemental_operations.2C_assignments_and_procedures

"Most intrinsic functions are elemental and Fortran 95
extends this feature to non-intrinsic procedures"

intrinsic functions in Fortran are those build-in (like
sin/cos, etc...)

Lets look at a very simple example to help explain what I mean.
I wanted to raise each entry in a vector to the second power.

In Fortran, I can just write V**2, where V is a vector. In Ada,
I can't do that. Since ** is not defined on this array type
and this number type.

I would have to write a loop to iterate over V and do V(I)**2 on
each element.

This for me, is a step backward. This is how Fortran77 was.

I know I am a newbie in Ada, and I could have overlooked a
simple solution to do this. But I really do not want to
write packages and define operators each time and for each type
I make to have it work as elemental function each time.

This is something that should be build into the language.

Here are two complete trivial examples of what I mean.

I was wondering if there is a chance that something like
this can be added to Ada like what was done for Fortran?

---- fortran -------------------------
!-- showing how to use Fortran for vectored operations
!-- equations work on vectors, no need for loop
program f08
   implicit none

   integer, parameter :: N = 7
   real   , parameter :: D(N) = [-0.2,1.0,1.5,3.0,-1.0,4.2,3.1]
   real   , parameter :: H(N) = [2.1,2.4,1.8,2.6,2.6,2.2,1.8]
   real               :: V(N)

   V = D**2 * H       ! all vectored operations
   print *, v
end program f08
---------------------------------
>gfortran f08.f90
>./a.out
   8.39999989E-02  2.4000001 4.0499997 23.400000  2.5999999  38.807995  17.297998

---------Ada ------------------
procedure foo2 is
   N : integer :=7;
   type array_t is array(1..N) OF float;
   
   D : constant array_t :=(-0.2,1.0,1.5,3.0,-1.0,4.2,3.1);
   H : constant array_t :=(2.1,2.4,1.8,2.6,2.6,2.2,1.8);
   V : array_t;
   
   begin
     V := D**2 * H;
end foo2;
-------------------

>gnatmake foo2.adb
gcc -c foo2.adb
foo2.adb:11:10: invalid operand types for operator "**"
foo2.adb:11:10: left operand has type "array_t" defined at line 4
foo2.adb:11:10: right operand has type universal integer
gnatmake: "foo2.adb" compilation error
>

--Nasser



^ permalink raw reply	[flat|nested] 81+ messages in thread
* RE: Matrix Multiplication
@ 1999-12-16  0:00 Carlisle, Martin
  1999-12-16  0:00 ` Howard W. LUDWIG
  0 siblings, 1 reply; 81+ messages in thread
From: Carlisle, Martin @ 1999-12-16  0:00 UTC (permalink / raw)
  To: comp.lang.ada

Suppose you have such a machine (wow! talk about complex instruction sets!).
I then grant that any good Fortran compiler would use it.  However, it also
follows that any Ada compiler could create a small function to use it (e.g.
using Machine code insertions), and then pragma Inline that function.

--Martin

-----Original Message-----
From: mario@klebsch.de [mailto:mario@klebsch.de]
Sent: Wednesday, December 15, 1999 11:01 AM
To: comp.lang.ada@ada.eu.org
Subject: Re: Matrix Multiplication


"Carlisle, Martin" <Martin.Carlisle@usafa.af.mil> writes:

>The idea that matrix multiplication would always be inlined seems absurd to
>me.  The simple implementation has O(n^3) running time.

What about compiling for a CPU, that does have an instruction for
matrix multiplication? It seems absurd to me, not to use that
instruction, if it is available.

73, Mario
-- 
Mario Klebsch						mario@klebsch.de

_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/cgi-bin/mailman/listinfo/comp.lang.ada







^ permalink raw reply	[flat|nested] 81+ messages in thread
* RE: Matrix Multiplication
@ 1999-12-15  0:00 Carlisle, Martin
  1999-12-15  0:00 ` Mario Klebsch
                   ` (2 more replies)
  0 siblings, 3 replies; 81+ messages in thread
From: Carlisle, Martin @ 1999-12-15  0:00 UTC (permalink / raw)
  To: comp.lang.ada

The idea that matrix multiplication would always be inlined seems absurd to
me.  The simple implementation has O(n^3) running time.  Any enhancement
requires a fair amount of code, which I surely wouldn't want replicated
every time I did a matrix multiply.  The overhead of a function call, in
this case, would be so small as to be negligible.

--Martin

----------------------------------------------
Martin C. Carlisle, PhD
Assistant Professor of Computer Science
US Air Force Academy
DISCLAIMER:  This message represents the author's opinions, and not
necessarily those of the US Air Force Academy or the US Air Force. 

-----Original Message-----
From: Richard Maine [mailto:maine@qnet.com]
Sent: Tuesday, December 14, 1999 8:25 PM
To: comp.lang.ada@ada.eu.org
Subject: Re: Matrix Multiplication


"E. Robert Tisdale" <edwin@netwood.net> writes:

> That's even easier.  The Ada version could call the f90 intrinsic too.
> All you would need to do is link the f90 library which contains matmul.

I will not get into the language comparison or benchmarking aspects of
this thread.

I just note that "linking the f90 library that contains matmul" isn't
necessarily that straightforward.  Matmul is an intrinsic.  It is not
at all given  that there even *IS* a library that contains it; a compiler
is quite free to always do it inline.  And even if much of the work is
in a library routine, the interface to them isn't necessarily known
outside of the compiler.

Intrinsics are basically part of the compiler internals.  They *MAY* be
implemented with callable library routines, but there is no guarantee of
that.
And it certainly isn't a portable way to call them.

-- 
Richard Maine
maine@qnet.com

_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/cgi-bin/mailman/listinfo/comp.lang.ada







^ permalink raw reply	[flat|nested] 81+ messages in thread
* Matrix Multiplication
@ 1999-12-14  0:00 William Dale
  1999-12-14  0:00 ` David C. Hoos, Sr.
                   ` (5 more replies)
  0 siblings, 6 replies; 81+ messages in thread
From: William Dale @ 1999-12-14  0:00 UTC (permalink / raw)


OK, 
I was challenged by one of my co-workers - a control and guidance type -
not a real software engineer. 

His claim  : "Fortran is faster doing floating point multiplication than
Ada" 

I could not get any other specifications such as hardware, particular
compiler, version, vendor, special math libraries or any other
equivocations.  Just he 
claims the above in all cases. 

So could I get some help getting times for a Matrix inversion on a 50X50
flotaing point matrix in both languages.  Anyone already done these
types of tests? Any sugestions on special libraries that he may not know
about to do such things in Ada. Obviously he has the Fortan side nailed. 

I know it is silly but this is the kind of FUD that gets thown around
all the time.  Either language could win - it depends on many of the
above issues.  

Thanks!
Bill Dale
mailto:william.dale.jr@lmco.com




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

end of thread, other threads:[~2012-08-07  7:35 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-09 23:27 Does Ada need elemental functions to make it suitable for scientific work? Nasser M. Abbasi
     [not found] ` <d78nv7dhf88bqv7hrd9eft231a4h2scs10@invalid.netcom.com>
2012-07-10  4:22   ` Nasser M. Abbasi
2012-07-10 14:26     ` Marco
2012-07-10  4:24 ` gautier_niouzes
2012-07-10  5:22   ` Ada novice
2012-07-10  7:27     ` Dmitry A. Kazakov
2012-07-10  8:06     ` gautier_niouzes
     [not found]     ` <637de084-0e71-4077-a1c5-fc4200cad3cf@googlegroups.com>
2012-07-10  8:39       ` Nasser M. Abbasi
2012-07-10  8:58         ` Ada novice
2012-07-10  9:07         ` Dmitry A. Kazakov
2012-07-10  9:21           ` Nasser M. Abbasi
2012-07-10  9:26             ` Nasser M. Abbasi
2012-07-10  9:50             ` Dmitry A. Kazakov
2012-07-20  1:56             ` Randy Brukardt
2012-07-20 21:49               ` Adam Beneschan
2012-07-12  0:31           ` robin.vowels
2012-07-12  7:12             ` Dmitry A. Kazakov
2012-07-29 13:39               ` Robin Vowels
2012-07-29 14:22                 ` Dmitry A. Kazakov
2012-07-29 20:54                   ` glen herrmannsfeldt
     [not found]                     ` <apib1897s56dkultqmfl3emvk1os3tfdak@invalid.netcom.com>
2012-07-30  4:15                       ` glen herrmannsfeldt
     [not found]                         ` <nfhd181tv9u87mcqfb7rgd8lm48ihr9f4r@invalid.netcom.com>
2012-07-31  8:53                           ` MATRIX MULTIPLICATION Robin Vowels
2012-07-31  9:05                             ` Robin Vowels
2012-07-30  0:49                   ` Does Ada need elemental functions to make it suitable for scientific work? Robin Vowels
2012-07-12  0:22         ` robin.vowels
2012-07-20  1:51         ` Randy Brukardt
2012-07-29 13:53           ` Robin Vowels
2012-07-29 15:51             ` J-P. Rosen
2012-07-29 16:07               ` Dmitry A. Kazakov
2012-07-29 20:30                 ` Simon Wright
2012-07-29 20:59                   ` glen herrmannsfeldt
2012-07-29 21:44                   ` J-P. Rosen
2012-07-29 22:54                     ` Simon Wright
2012-07-30  0:53               ` Robin Vowels
2012-07-30  2:20               ` Shmuel Metz
2012-07-10 12:46       ` Brian Drummond
2012-07-10 11:06 ` Simon Wright
2012-07-10 11:59 ` Georg Bauhaus
2012-07-10 12:20 ` Brian Drummond
2012-07-10 19:52 ` Ada novice
2012-07-11  8:41   ` gautier_niouzes
2012-07-11  9:42     ` Ken Thomas
  -- strict thread matches above, loose matches on Subject: below --
1999-12-16  0:00 Matrix Multiplication Carlisle, Martin
1999-12-16  0:00 ` Howard W. LUDWIG
1999-12-15  0:00 Carlisle, Martin
1999-12-15  0:00 ` Mario Klebsch
1999-12-19  0:00   ` Robert Dewar
1999-12-19  0:00 ` Robert Dewar
1999-12-19  0:00 ` Robert Dewar
1999-12-14  0:00 William Dale
1999-12-14  0:00 ` David C. Hoos, Sr.
1999-12-14  0:00 ` Gautier
1999-12-15  0:00   ` Gautier
     [not found]   ` <5l1f5s4kck891a2s6o8bhvkirm4q79hm6c@4ax.com>
1999-12-15  0:00     ` Gautier
1999-12-15  0:00       ` Marin D. Condic
1999-12-15  0:00         ` Ted Dennison
1999-12-15  0:00           ` Gautier
1999-12-15  0:00             ` Tucker Taft
1999-12-16  0:00             ` Ted Dennison
1999-12-16  0:00             ` Ted Dennison
1999-12-15  0:00         ` Gautier
1999-12-16  0:00           ` Marin D. Condic
1999-12-27  0:00             ` Jeffrey L Straszheim
1999-12-15  0:00 ` Ted Dennison
1999-12-15  0:00   ` William B. Clodius
1999-12-15  0:00     ` Ted Dennison
1999-12-15  0:00       ` William B. Clodius
1999-12-16  0:00         ` Robert A Duff
1999-12-16  0:00           ` William B. Clodius
1999-12-15  0:00 ` E. Robert Tisdale
     [not found]   ` <3856FD3F.8291A71C@ucar.edu>
1999-12-15  0:00     ` E. Robert Tisdale
1999-12-14  0:00       ` Richard Maine
     [not found] ` <01bf4708$99ef98f0$022a6282@dieppe>
1999-12-15  0:00   ` Robert A Duff
1999-12-15  0:00     ` Marin D. Condic
1999-12-16  0:00     ` Pascal Obry
1999-12-16  0:00       ` Greg Martin
1999-12-16  0:00       ` Brian Rogoff
1999-12-16  0:00     ` Dieter Britz
1999-12-15  0:00   ` Gautier
1999-12-15  0:00 ` Greg Lindahl
1999-12-15  0:00   ` Preben Randhol

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