Boost logo

Boost :

From: Walter Landry (wlandry_at_[hidden])
Date: 2004-06-05 10:02:13

David Abrahams <dave_at_[hidden]> wrote:
> Walter Landry <wlandry_at_[hidden]> writes:
> > Have you looked at
> >
> >
> >
> > It implements a fair number of different tensor types (e.g. symmetric,
> > antisymmetic), the element type is templated, and it has natural ways
> > of specifying contractions. It doesn't have separate covariant and
> > contravariant tensors, but that wouldn't be that hard to implement.
> > It would just be a fair amount of work for quesionable gain. I used
> > it for my General Relativity code, and I never missed the distinction
> > between covariant and contravariant indices.
> >
> > I bill it as a high performance tensor library, though now I think it
> > might actually be better to use ordinary loops instead of the
> > compile-time loops.
> Really? Please say more.
> I clearly remember your talk on that work; weren't you saying that
> ordinary loops were so hard to write correctly that they compromised
> the chances of success in your projects?

Sorry, I was not clear. Yes, if I had written out all of those loops
by hand, I would never have finished. Rather, my comment above is
about the internal mechanism to auto-generate the loops. In FTensor,
I used compile time loops. Now I think it might be better to just use
run-time loops. To use a factorial as an example, instead of
something like

template<int N>
class Factorial {
    enum { value = N * Factorial<N-1>::value };

class Factorial<1> {
    enum { value = 1 };

I think it might be better to ditch a lot of the template
metaprogramming stuff and just use

int factorial(int F)
    int result(1);
    for(int i=F; i>1; --i)
    return result;

I described some benchmarks here:

Of course, it is possible that I just screwed up the implementation of
FTensor ;)

Walter Landry

Boost list run by bdawes at, gregod at, cpdaniel at, john at