At 12:25 18/03/97 -0800, Chris Hecker <checker@netcom.com> wrote:
>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
>
Actually, one can implement a pretty transparent implementation of composite
operators in C++ using templates, which can remove temporaries and call
optimised routines for subexpressions. I have a prototype version
downloadable at http://www.gil.com.au/~bparker/ if anyone is interested, but
I am awaiting a compiler with the latest template features to make it fully
functional.
,Brian Parker (bparker@gil.com.au)
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:05 EST