1#ifndef SLICED_CTF_TENSOR_DEFINED
2#define SLICED_CTF_TENSOR_DEFINED
6#include <initializer_list>
11template <
typename F =
double>
15 create(T, std::vector<int>(list));
17 template <
typename Iterator>
19 create(T, std::vector<int>(begin, end));
23 std::string indexNames(T.order,
'a');
24 for (
int d(0); d < T.order; ++d) indexNames[d] += d;
27 int64_t slicesCount = 1;
28 for (
unsigned int d(0); d < slicedDims.size(); ++d) {
29 slicesCount *=
slicedLens[d] = T.lens[slicedDims[d]];
32 slices.resize(slicesCount);
33 for (int64_t sliceIndex(0); sliceIndex < slicesCount; ++sliceIndex) {
35 int64_t i(sliceIndex);
36 std::vector<int> slicePosition(slicedDims.size());
37 for (
unsigned int d(0); d < slicedDims.size(); ++d) {
42 std::vector<int> start(T.order), end(T.lens, T.lens + T.order);
44 for (
unsigned int d(0); d < slicedDims.size(); ++d) {
45 start[slicedDims[d]] = slicePosition[d];
46 end[slicedDims[d]] = slicePosition[d] + 1;
52 for (uint64_t i(0); i <
slices.size(); ++i) {
59 return (*
this)(std::vector<int>(slicePos));
61 template <
typename Iterator>
63 return (*
this)(std::vector<int>(begin, end));
67 int64_t sliceIndex(0);
68 for (
int d(
slicedLens.size() - 1); d >= 0; --d) {
70 sliceIndex += slicePosition[d];
72 return *
slices[sliceIndex];
Definition SlicedCtfTensor.hpp:12
std::vector< Tensor< F > * > slices
Definition SlicedCtfTensor.hpp:76
Tensor< F > & operator()(Iterator begin, Iterator end)
Definition SlicedCtfTensor.hpp:62
Tensor< F > & operator()(const std::vector< int > &slicePosition)
Definition SlicedCtfTensor.hpp:65
SlicedCtfTensor(Tensor< F > &T, const std::initializer_list< int > &list)
Definition SlicedCtfTensor.hpp:14
~SlicedCtfTensor()
Definition SlicedCtfTensor.hpp:51
SlicedCtfTensor(Tensor< F > &T, Iterator begin, Iterator end)
Definition SlicedCtfTensor.hpp:18
std::vector< int > slicedLens
Definition SlicedCtfTensor.hpp:75
Tensor< F > & operator()(const std::initializer_list< int > &slicePos)
Definition SlicedCtfTensor.hpp:58
void create(Tensor< F > &T, const std::vector< int > &slicedDims)
Definition SlicedCtfTensor.hpp:21
Definition Algorithm.hpp:10
CTF::Tensor< F > Tensor
Definition Tensor.hpp:9