This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Template programming: tensor product algebra

Tags: None
(comma "," separated)
duetosymmetry
Registered Member
Posts
18
Karma
0
Hi folks,
I've got no experience with template (meta?)programming, but I'm pretty sure that what I want is straightforward. I was hoping for some guidance. Here's the background:

Let's say I have two vectors spaces, V and W, of dimensions N and M. I can represent a vector v∈V as a column vector, and a vector w∈W as a row vector. Then consider the tensor product space T = V⊗W which has dimension N*M. It can be represented as a matrix of dimensions (N,M) -- any sum over 'outer' products v⊗w.

Now consider a linear operator acting on t∈T. A linear operator L*t can be written as a sum of tensor products of linear operators acting on V and acting on W. For example, let's say L = A⊗B, where A:V→V and B:W→W. Represented as matrices, A is an (N,N) matrix that acts on the left on v, and B is an (M,M) matrix that acts on the right on w. So for L to act on t, this can be represented as L*t = (A*v) ⊗ (w*B).

The space of linear operators acting on T is a linear vector space that forms an algebra. I would like to be able to treat elements from this algebra like I would write operators in normal mathematical notation ("acting on the left" on T). So imagine writing code like:
Code: Select all
int N, M;
...
MatrixXc A1(N,N), A2(N,N);
MatrixXc B1(M,M), B2(M,M);
Operator o1 = tensorProd(A1, B1) + tensorProd(A2,B2);
Operator o2 = tensorProd(A2, B2) * tensorProd(A1,B1);
MatrixXc t1(N,M), t2(N,M), t3(N,M);
...
t2 = o1*t1;
t3 = o2*t1;

which translates, in matrix language, into
Code: Select all
t2 = A1*t1*B1 + A2*t1*B2;
t3 = A2*A1*t1*B1*B2;


So -- can anyone advise me in how to make such an operator algebra? It is (obviously) quite similar to the algebra of matrices that already exists in Eigen, in that operator sums and products are also operator expressions. However, this is something to be built on top of matrices, so it doesn't have to do things like know whether it is stored in column/row major order, etc.

Cheers
Leo


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]