24 #ifndef COM_DAFER45_TBTK_PROPERTY_CONVERTER
25 #define COM_DAFER45_TBTK_PROPERTY_CONVERTER
28 #include "TBTK/Property/AbstractProperty.h"
78 template<
typename DataType>
106 template<
typename DataType>
113 template<
typename DataType>
121 case IndexDescriptor::Format::None:
124 std::vector<std::vector<Subindex>> axis(1);
125 for(
unsigned int n = 0; n < abstractProperty.
getBlockSize(); n++){
126 array[{n}] = abstractProperty(n);
127 axis[0].push_back(n);
131 case IndexDescriptor::Format::Ranges:
133 std::vector<int> ranges
137 std::vector<unsigned int> rangesUnsignedInt;
138 for(
unsigned int n = 0; n < ranges.size(); n++)
139 rangesUnsignedInt.push_back(ranges[n]);
142 const std::vector<DataType> &data = abstractProperty.
getData();
143 for(
unsigned int n = 0; n < abstractProperty.
getSize(); n++)
146 std::vector<std::vector<Subindex>> axes(ranges.size());
147 for(
unsigned int n = 0; n < ranges.size(); n++)
148 for(
unsigned int c = 0; c < (
unsigned int)ranges[n]; c++)
149 axes[n].push_back(c);
155 "PropertyConverter::convert()",
156 "Unsupported format. Only IndexDescriptor::Format::None and"
157 <<
" IndexDescriptor::Format::Ranges supported.",
163 template<
typename DataType>
172 case IndexDescriptor::Format::Custom:
174 std::vector<unsigned int> wildcardPositions;
175 for(
unsigned int n = 0; n < pattern.
getSize(); n++)
176 if(pattern[n].isWildcard())
177 wildcardPositions.push_back(n);
181 std::vector<Index> indexList = indexTree.
getIndexList(pattern);
183 std::vector<Subindex> minSubindices;
184 std::vector<Subindex> maxSubindices;
185 for(
unsigned int n = 0; n < wildcardPositions.size(); n++){
186 Subindex min = indexList[0][wildcardPositions[n]];
187 Subindex max = indexList[0][wildcardPositions[n]];
188 for(
unsigned int c = 1; c < indexList.size(); c++){
190 = indexList[c][wildcardPositions[n]];
196 minSubindices.push_back(min);
197 maxSubindices.push_back(max);
200 minSubindices.push_back(0);
201 maxSubindices.push_back(
206 std::vector<unsigned int> ranges;
207 for(
unsigned int n = 0; n < minSubindices.size(); n++){
209 maxSubindices[n] - minSubindices[n] + 1
216 for(
unsigned int n = 0; n < indexList.size(); n++){
217 const Index index = indexList[n];
218 std::vector<unsigned int> arrayIndices;
219 for(
unsigned int c = 0; c < wildcardPositions.size(); c++){
220 arrayIndices.push_back(
221 index[wildcardPositions[c]]
233 > blockExtendedArrayIndices
235 blockExtendedArrayIndices.push_back(c);
237 array[blockExtendedArrayIndices]
238 = abstractProperty(index, c);
242 array[arrayIndices] = abstractProperty(index);
246 std::vector<std::vector<Subindex>> axes(ranges.size());
254 c < (
unsigned int)ranges[n];
257 axes[n].push_back(minSubindices[n] + c);
265 "PropertyConverter::convert()",
266 "Unsupported format. Only IndexDescriptor::Format::None and"
267 <<
" IndexDescriptor::Format::Ranges supported.",