11 #ifndef CUBBYFLOW_ARRAY_IMPL_HPP 12 #define CUBBYFLOW_ARRAY_IMPL_HPP 18 template <
typename T,
size_t N>
23 template <
typename T,
size_t N,
size_t I>
26 template <
typename... Args>
35 template <
typename T,
size_t N>
40 Call(size, value, n, T{});
51 template <
typename T,
size_t N,
size_t I>
57 size[I - 1] = lst.size();
61 for (
auto subLst : lst)
70 [[maybe_unused]]
size_t otherSize =
73 assert(otherSize == tempSizeN[I - 2]);
83 template <
typename T,
size_t N>
95 template <
typename T,
size_t N,
size_t I>
102 for (
auto subLst : lst)
104 assert(i < arr.
Size()[I - 1]);
112 template <
typename... RemainingIndices>
114 RemainingIndices... indices)
118 for (
auto subLst : lst)
120 assert(i < arr.
Size()[I - 1]);
128 template <
typename T,
size_t N>
137 assert(i < arr.
Size()[0]);
144 template <
typename... RemainingIndices>
146 RemainingIndices... indices)
152 assert(i < arr.
Size()[0]);
154 arr(i, indices...) = val;
161 template <
typename T,
size_t N>
167 template <
typename T,
size_t N>
170 m_data.resize(Product<size_t, N>(size_, 1), initVal);
171 Base::SetPtrAndSize(m_data.data(), size_);
174 template <
typename T,
size_t N>
175 template <
typename... Args>
182 m_data.resize(Product<size_t, N>(size, 1), initVal);
183 Base::SetPtrAndSize(m_data.data(), size);
186 template <
typename T,
size_t N>
192 m_data.resize(Product<size_t, N>(newSize, 1));
193 Base::SetPtrAndSize(m_data.data(), newSize);
197 template <
typename T,
size_t N>
198 template <
typename OtherDerived>
204 template <
typename T,
size_t N>
205 template <
typename OtherDerived>
211 template <
typename T,
size_t N>
217 template <
typename T,
size_t N>
220 *
this = std::move(other);
223 template <
typename T,
size_t N>
231 template <
typename T,
size_t N>
234 m_data = std::move(other.m_data);
236 Base::SetPtrAndSize(other.data(), other.Size());
242 template <
typename T,
size_t N>
243 template <
typename OtherDerived>
251 template <
typename T,
size_t N>
252 template <
typename OtherDerived>
261 template <
typename T,
size_t N>
262 template <
typename D>
265 Resize(other.
Size());
267 [&](
auto... idx) { this->At(idx...) = other(idx...); });
270 template <
typename T,
size_t N>
271 template <
typename D>
274 Resize(other.
Size());
276 [&](
auto... idx) { this->At(idx...) = other(idx...); });
279 template <
typename T,
size_t N>
282 std::fill(m_data.begin(), m_data.end(), val);
285 template <
typename T,
size_t N>
288 Array newArray(size_, initVal);
292 [&](
auto... idx) { newArray(idx...) = (*this)(idx...); });
294 *
this = std::move(newArray);
297 template <
typename T,
size_t N>
298 template <
typename... Args>
306 Resize(size, initVal);
309 template <
typename T,
size_t N>
313 m_data.push_back(val);
315 Base::SetPtrAndSize(m_data.data(), m_data.size());
318 template <
typename T,
size_t N>
319 template <
typename OtherDerived,
size_t M>
323 m_data.insert(m_data.end(), extra.
begin(), extra.
end());
325 Base::SetPtrAndSize(m_data.data(), m_data.size());
328 template <
typename T,
size_t N>
329 template <
typename OtherDerived,
size_t M>
333 m_data.insert(m_data.end(), extra.
begin(), extra.
end());
335 Base::SetPtrAndSize(m_data.data(), m_data.size());
338 template <
typename T,
size_t N>
341 Base::ClearPtrAndSize();
346 template <
typename T,
size_t N>
349 Base::SwapPtrAndSize(other);
351 std::swap(m_data, other.m_data);
354 template <
typename T,
size_t N>
360 template <
typename T,
size_t N>
static void Call(Array< T, N > &arr, NestedInitializerListsT< T, 1 > lst, RemainingIndices... indices)
Definition: Array-Impl.hpp:145
static size_t Call(Vector< size_t, N > &size, NestedInitializerListsT< T, I > lst)
Definition: Array-Impl.hpp:54
static void Call(Array< T, N > &arr, NestedInitializerListsT< T, I > lst, RemainingIndices... indices)
Definition: Array-Impl.hpp:113
Definition: ArrayBase.hpp:19
static size_t Call(Vector< size_t, N > &size, NestedInitializerListsT< T, 1 > lst)
Definition: Array-Impl.hpp:86
Definition: ArrayView.hpp:60
Array()
Definition: Array-Impl.hpp:162
Iterator end()
Definition: ArrayBase-Impl.hpp:102
Vector< size_t, N > m_size
Definition: ArrayBase.hpp:125
Definition: Array-Impl.hpp:52
Definition: Matrix.hpp:27
static void call(Array< T, N > &arr, NestedInitializerListsT< T, 1 > lst)
Definition: Array-Impl.hpp:131
Definition: pybind11Utils.hpp:20
void Fill(ArrayView< T, N > a, const Vector< size_t, N > &begin, const Vector< size_t, N > &end, const T &val)
Definition: ArrayUtils-Impl.hpp:19
static void Call(Vector< size_t, N > &size, T &value, size_t n)
Definition: Array-Impl.hpp:38
Definition: Array-Impl.hpp:19
Iterator begin()
Definition: ArrayBase-Impl.hpp:90
Definition: Array-Impl.hpp:96
static void Call(Vector< size_t, N > &size, T &value, size_t n, Args... args)
Definition: Array-Impl.hpp:27
constexpr auto Min(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition: MatrixExpression-Impl.hpp:1103
Definition: Array-Impl.hpp:24
Generic N-dimensional array class interface.
Definition: Array.hpp:32
typename NestedInitializerLists< T, N >::Type NestedInitializerListsT
Definition: NestedInitializerList.hpp:57
static void Call(Vector< size_t, N > &size, T &value, size_t n, const T &initVal)
Definition: Array-Impl.hpp:43
void ForEachIndex(const Vector< IndexType, N > &begin, const Vector< IndexType, N > &end, const Func &func)
Definition: IterationUtils-Impl.hpp:51
const Vector< size_t, N > & Size() const
Definition: ArrayBase-Impl.hpp:51
static void Call(Array< T, N > &arr, NestedInitializerListsT< T, I > lst)
Definition: Array-Impl.hpp:98