
David Abrahams <dave@boost-consulting.com> wrote:
Walter Landry <wlandry@ucsd.edu> writes:
Have you looked at
http://www.oonumerics.org/FTensor/
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 { public: enum { value = N * Factorial<N-1>::value }; }; class Factorial<1> { public: 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) result*=i; return result; } I described some benchmarks here: http://groups.google.com/groups?q=g:thl3194341146d&dq=&hl=en&lr=&ie=UTF-8&selm=87d6rdlirf.fsf%40grue.ucsd.edu&rnum=7 Of course, it is possible that I just screwed up the implementation of FTensor ;) Cheers, Walter Landry wlandry@ucsd.edu