[Beowulf] Teaching Scientific Computation (looking fo the perfect text)

David Mathog mathog at caltech.edu
Wed Nov 21 09:22:33 PST 2007


Joe Landman <landman at scalableinformatics.com> wrote:
> There are a myriad 
> of ways to handle complex in C, but you can't easily write
> 
> 	complex A,B,C,D
> 
> 	A = B + C*D
> 
> with anything like the clarity of Fortran.

The reason it's clear is that + means addition, and * means
multiplication, exactly as you'd expect.

> Of course, this is usually the time at which the C++ folks come out of 
> the background and start talking about objects, interfaces,
overloading, ...
> 
> Anyone ever debugged an overloaded operator?  It ain't fun, at any level.

Operator overloading reminds me of Bill Clinton's:
"It depends what the meaning of 'is' is."  If operator
overloading is used unwisely, so that the meaning of "+" is not just
"addition of this type of data", then pity the poor schmuck who has to
maintain the code.  Unfortunately you don't have to look far for
data types where there is no single operator overload mapping that
makes sense.  If A,B,C,D are 3D vectors then + has a single obvious
meaning, but * is ambiguous, is it a dot product or a cross product?
That's the point where C++ overloading breaks down, at least for me,
and a function or #define is easier to work with, something like :

  A = B + CROSS_PRODUCT(C,D)

Regards,

David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech



More information about the Beowulf mailing list