Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-03-28 13:18:36


On 28 Mar 2001, Gabriel Dos Reis wrote:
Gabrie> * define a well-delimited kernel -- no fancy syntax, just keep it as
Gabrie> simple as possible;
Gabrie>
Gabrie> * for higer-level layers, provide both traditional functions and
Gabrie> overloaded operators -- nifty syntax is where you don't really
Gabrie> care about a 5-10% of performance lost.

Just yesterday we had a visitor from the POOMA group here at ND, and he
was suggesting a similar approach.

Gabrie> | Gabrie> What is really wrong with operator()?
Gabrie> |
Gabrie> | By operator(), do you mean indexing into an array using the notation
Gabrie> | A(i,j,k)?
Gabrie>
Gabrie> Sort of. The problem with operator[] is that it requires proxy
Gabrie> classes which come with their own set of extra-problems (semantics,
Gabrie> and performance).
Gabrie>
Gabrie> | ... If so, it's a bit unsavory because there will be some
Gabrie> | hard coded limit to the number of dimensions you can support
Gabrie>
Gabrie> I understand. But a multidimensional array already has the limit hard
Gabrie> coded in its type. So the question is how can we statically vary
Gabrie> indexing arity with that of the array dimension.
Gabrie> Perhaps should we have to introduce an index class template...
Gabrie> Doing so will effectively lets one use operator[], but it will break
Gabrie> with C-array indexing syntax.

I like where you're going with this, but let me put a twist on it ;) For
this "kernel" level array that uses simple indexing via an index_set
class, we could use operator() to differentiate it from the C-array
indexing syntax. Then the higher-level array could add the proxied
operator[].

A slight variation to the index_set class interface is to instead have the
interface just take a pointer to the start of the indices. The interface I
posted provided this in the elt() method. I'm wondering which has the
better tradeoff of flexibility and usability.

Gabrie> | ... , and
Gabrie> | it would be nice to avoid the kind of repetitive code you see
Gabrie> | in Blitz++.
Gabrie>
Gabrie>
Gabrie> | ... Also, operator[] is what builtin arrays use.
Gabrie>
Gabrie> I can understand the desire to keep C-array indexing syntax, but by
Gabrie> definition that syntax doesn't come with the problems we have with
Gabrie> proxy arrays.
Gabrie>
Gabrie> We need to abstract over that syntax.

Right. One nice thing about the kernel interface is that it will
provide an interface for writing dimension independent code.

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk