🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #168

Re: Exponentiation operator proposal

#168
From: Dag Bruck
Date: Tue, 15 Sep 1992 06:16
103 lines
4310 bytes
In <comp.std.c++,comp.lang.c++> bs@alice.att.com (Bjarne Stroustrup) writes:
>
>How frequent is a**p anyway?

I asked the net how frequent exponentiation is, and got very few
answers back; there are some interesting observations, though. Nobody
took the offer to look at the really big FORTRAN libraries.  In my
view the results are inconclusive at this point.

I haven't looked at the latest version of the proposal, but I strongly
ask the authors to support their requests with solid user's experience
from related applications, not necessarily in C++.  If you can show
that exponentiation is more common than division (just as an example),
that is indeed a very strong argument.  Sorry to nit pick if you have
already done it.

In any case, here follows the answers I got, somewhat edited for
clarity:

			-- Dag

========================================================================

From: matt@physics.berkeley.edu (Matt Austern)
Subject: Re: Power operator for C++
Date: 6 Jul 92 14:28:39
Organization: Lawrence Berkeley Laboratory (Theoretical Physics Group)

In article <1992Jul5.133125.5575@lth.se> dag@control.lth.se (Dag Bruck) writes:

> I ask someone with access to a lot of numerical code (perhaps written
> in FORTRAN) to do us a favour: gather some statistics that can tell us
> how common exponentiation is compared to other operators, such as,
> addition, subtraction, multiplication and division.  Compared to
> square root?

I just did a bit of grepping on a moderate-sized (30,000 lines)
Fortran program, called Papageno.  I suspect that it is fairly typical
of code used in particle physics.

Some statistics:
	Operator	Number of lines containing operator
	--------	-----------------------------------
	  total		32000
	  +		10711
	  *		6805
	  -		6253
	  /		3382
	  **		1481

The result, then, is that exponentiation is about half as common in
this program as division.  To me, at least, this qualifies as
"common".  Certainly nobody would suggest that a division operator is
unnecessary just because it is used only half as much as subtraction!

(Many lines uses exponentiation more than once; in total, the operator
** is used 4496 times in PAPAGENO.)

Looking over the code, by the way, it seems that the vast majority of
the time, ** is used to raise a quantity to an integral power.  (I
didn't gather statistics; that would require more effort than a simple
grep!)  This suggests that pow(double,double) is not a good
substitute; a better substitute would be pow(double,int), which is not
in the standard library.


From: maxtal@extro.ucc.su.OZ.AU (John (MAX) Skaller)
Subject: Re: Power operator for C++
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Mon, 6 Jul 1992 06:22:57 GMT

	I have a program which calculates gaussian dispersion of
toxic materials in air. In the bits that do calculations work,
here are the scores in terms of line counts
[I did grep token file | wc]

Lines total:	172
+		27
-		24
*		25
/		32
%		2
=,==,etc	79
pow		13
fsqr		12	// inline to square number
sqrt		3

IMHO if you cheat a bit and add the last three you get 28, second
only to use of '/'. I'd be happy to post the code if that was
desired [minus flames on style :-)



Date: Tue, 7 Jul 92 17:11:44 -0700
From: Paul Kunz <pfkeb@KAON.SLAC.Stanford.EDU>
Subject: Power operator for C++

   I asked Bill Atwood about what happen to **2 type constructs in
Gismo.   He looked puzzled.   He agrees that in the FORTRAN programs
the code is littered with **2, but he's not sure what happened to
such constructs in the Gismo C++ code.   Perhaps they have disappeared
into member functions of some base or low level classes so they are
not so visible anymore.   We don't know.
Technical Details
Message-ID: <1992Sep15.061626.21735@lth.se>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!lth.se!newsuser
References: <23660@alice.att.com> <1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com> <23663@alice.att.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++,comp.lang.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!lth.se!newsuser
From: dag@control.lth.se (Dag Bruck)
Subject: Re: Exponentiation operator proposal
Message-ID: <1992Sep15.061626.21735@lth.se>
Sender: newsuser@lth.se (LTH network news server)
Organization: Department of Automatic Control, Lund, Sweden
References: <23660@alice.att.com> <1992Sep13.193507.27813@ima.isc.com> <BuJJxs.8Hx@world.std.com> <23663@alice.att.com>
Date: Tue, 15 Sep 1992 06:16:26 GMT
Lines: 103