[Beowulf] Teaching Scientific Computation (looking fo the perfect text)
Robert G. Brown
rgb at phy.duke.edu
Wed Nov 21 14:27:40 EST 2007
On Wed, 21 Nov 2007, David Mathog wrote:
> 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?
Unless, of course, one works in a graded (geometric) division algebra...
but yes, I agree. And it isn't much harder to call csum(a,b,c) where
they are complex structs, or do whatever the GSL uses to accomplish the
same thing (I haven't used its complex arithmetic much).
> 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)
Ah but are A and B vectors or pseudovectors? Just kidding...;-)
> David Mathog
> mathog at caltech.edu
> Manager, Sequence Analysis Facility, Biology Division, Caltech
> Beowulf mailing list, Beowulf at beowulf.org
> To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
Robert G. Brown
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Lulu Bookstore: http://stores.lulu.com/store.php?fAcctID=877977
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
More information about the Beowulf