Tensor class was written in 1997 during my study of templates
(I found it examining my archives).
But I've not seen any such classes since. So I think it can be useful for students. The main reason I've wrote
it - for the convolution of tensors with any dimensionality. Also you can get and use any sub-tensor using
operator, for example can be written like
The demo project shows usage of tensors. You can:
Declare and init tensors (you should specify dimension and indexes range).
Tensor2 t1(2); t1 = 1.0;
t1 = 2.0;
t1 = 3.0;
t1 = 4.0;
Convolute tensors - note that you can use different dimensions and one or more
constants in indices.
Use some arithmetical operations.
result3 = t1 + t2*2;
Print part or whole tensor.
Invert 4-dimension tensor with indexes (0,1).
ti = inverse(t);
To Do list
It can be easy to implement some more operations with tensors (different multiplication and so).
Please let me know, if you need some.
Make sure to check out the my web site which is more likely to have updates and betas:
Mike has been programming in C/C++ for 11 years and Visual C++/MFC for 4 years. His background includes pure and applied mathematics, engineering and physics, and he is currently based in Moscow, Russia.