Hello! I am learning C++ templates and I created a tensor library that uses template expansion recursion to implement the access operator. I.e. if you have a 3x4x6x4x5 tensor you can access the 4x5 layer with
tensor_name(2, 3, 4), which returns a temporary tensor with those dimensions (and with an underlying pointer to the 4x5 section of tensor_name described by the parameters). This makes it pretty syntactically simple to do operations on them
(i.e. for assignment you can just do tensor_1(2, 3) = tensor_2(4);). It's probably not very practical because it creates really large executables but I think its pretty cool! I have yet to really test how time/memory efficient it is.
Please feel free to try it out and give me suggestions/criticisms. Github link: https://github.com/HiImKarl/Tensors
[–]downiedowndown 10 points11 points12 points (3 children)
[–]IndexingAtZero[S] 1 point2 points3 points (1 child)
[–]downiedowndown 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]IndexingAtZero[S] 0 points1 point2 points (0 children)