OON: matrix 'object' operations

From: Chris Hecker (checker@netcom.com)
Date: Tue Mar 18 1997 - 15:25:37 EST


Todd Veldhuizen wrote:
> Modern programming languages allow library developers to abstract
> away enormous amounts of detail from the user. We can write
> A = product(B, C);
> for a matrix product on our desktop Mac.

Yes, we can write it (and even as A = B * C; in C++, if you're into that
sort of thing), but I think it's unclear how to make it both easy to use and
efficient. If you want your code to look exactly like that, what does
product(,) return? My experience is with C++, where this becomes a real
problem. product(,) can't return strictly by value or you've just copied
the A matrix. It can't return by reference for obvious reasons. You could
go to the trouble of doing a reference-counted matrix class, so then you
avoid the copy of the entire matrix on the return, but then what do you get
when you do this: D = A; Is D a new copy of A, or just another reference to
its data? Do you give it copy on write semantics?

It makes you long for the non-oo simplicity of this:

product(B,C,A); // A is the result and was created by the caller

Basically, I've found even the simplest oo-ifying of linear algebra
operations turns up tons of details like that that can have profound impact
on performance.

Chris



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:05 EST