Sorry for late response.
Here is brief syntax:
#include "tensor/tensor.hpp"operators and constructors are generated using boost_pp.
#include "tensor/product.hpp"
namespace cc {
template<class E0, class E1, class E2>
void f(int i, int j, int k,
const tensor::expression<E0> &t2_,
const tensor::expression<E1> &VVVO_,
const tensor::expression<E2> &OVOO_,
tensor::tensor<3> &X) {
USING_TENSOR_INDEX((a)(b)(c)(e)); // tensor::index<'a'> a; .. etc
USING_TENSOR_INDEX((l)(m));
const E0 &t2 = t2_();
const E1 &VVVO = VVVO_();
X(a,b,c) += (t2(a,e,i,j)*VVVO(b,c,e,k)); // ok
X(a,b,c) += 3.0*(t2(a,e,i,j)*VVVO(b,c,e,k)); // ok
X(a,c,b) += (t2(a,e,i,j)*VVVO(b,c,e,k)); // ok, transposed
X(a,b,k) += (t2(a,e,i,j)*VVVO(b,c,e,k)); // compile error rank2 + rank3
X(a,b,c) += (t2(a,e,m,j)*VVVO(b,c,m,k)); // compile error, rank3 + rank4
X(a,b,m) += (t2(a,e,i,j)*VVVO(b,c,i,k)); // compile error, index mismatch
}
void f(int i, int j, int k) {
size_t size[4];
tensor::tensor<4> t2, VVVO(size), OVOO(200,200,200,100);
tensor::tensor<3> X(100,100,100);
triples(i, j, k, t2, VVVO, OVOO, X);
}
}
// No contravariance/covariance per se.