Re: [eigen] [RFC] Tensor module: class hierarchy

[ Thread Index | Date Index | More Archives ]

Hello Christian,

just a comment concerning your TODO-list:

* generic expressions with index placeholders, such has result(_1, _2, _3) = tensor1(_1, _, _) * tensor2(_, _2, _3) or similar (need to define a nice API for this)

I don't know if you know about FTensor library from Walter Landry:

He can do the following code:

FTensor::Index<'i', 3> i;
FTensor::Index<'j', 3> j;
FTensor::Index<'k', 3> k;
FTensor::Index<'l', 3> l;

FTensor::Tensor2<double, 3,3> cauchy;
FTensor::Tensor2<double, 3,3> P;
FTensor::Tensor2<double, 3,3> f;
double JF;


// single contraction with 'j'
// so, he has Einstein summation convention!
P(i, k) = JF * cauchy(j, i) * f(k, j);


FTensor::Tensor4<double, 3,3,3,3> C4;
FTensor::Tensor4<double, 3,3,3,3> IdydI;


// dyadic products of 2nd order tensor
// additionally with some transpositions

C4(i, j, k, l) =    IdydI(i, k, j, l)
                 +  f(j, i) * f(l, k)
                 -  f(l, i) * f(j, k);

Personally, I like his notation very much,
because it's very close to the usual
index notation for tensors.
Thus, he defines a lot of operator*,
operator+ etc. for all kinds of contractions
and other tensor products ... and he defines
some special tensors of different order
with symmetries ...

A similar library is



On 06/08/2014 01:26 PM, Christian Seiler wrote:
Hi there,

I am currently working on the tensor module to try to make it more
useful. (In case you are not familiar with it: I put some introductory
words in the wiki: [1])

The current state is: it basically only stores data for now.

My goal for the immediate future is to implement a class hierarchy
similar to that which Eigen uses itself. This will then allow me to
introduce some basic expressions such as adding two tensors etc, which
will immediately make the tensor module quite a bit more useful than

My problem here is that I have some conceptual questions I'd like to
discuss before proceeding. I've documented the details under:

Basically I have three immediate things I'd like to have feedback on:

1. the names of the new class hierarchy: do you agree or do you have
    better ideas?

2. packet access for tensors: should I just deviate from Eigen by
    changing the argument order of writePacket for tensors or should
    writePacket() for tensors only accept std::array for index
    specification? (see wiki page for an explanation)

3. expression template names: is it possible to somehow reuse the
    CwiseBinaryOp etc. names for tensors (obviously with a different
    implementation behind it) or do I have to go the way of

Any other general comments / ideas / suggestions are of course also welcome.

Thank you!



Mail converted by MHonArc 2.6.19+