1 #ifndef FUNCTIONS_GRID_H
2 #define FUNCTIONS_GRID_H
6 #include "functions_type.h"
32 namespace functions_grid {
48 template<
typename S,
typename T,
typename Q,
size_t N,
size_t L> requires (L==N)
49 inline S getLevelElementIndex(
const T* Dl,
const Q *Al) {
58 template<
typename S,
typename T,
typename Q,
size_t N,
size_t L> requires (L<N)
59 inline S getLevelElementIndex(
const T* Dl,
const Q *Al) {
60 return (S) ((*Al)+(*Dl)*getLevelElementIndex<S,T,Q,N,L+1>(Dl+1,Al+1));
68 template<
typename S,
typename T,
typename Q,
size_t N>
69 inline S getElementIndex(
const std::array<T,N>& D,
const std::array<Q,N>& I) {
70 return getLevelElementIndex<S,T,Q,N,1>(D.data(),I.data());
78 template<
typename S,
typename T,
size_t N>
79 inline S getElementIndex(
const T* D,
const T* I) {
80 return getLevelElementIndex<S,T,T,N,1>(D,I);
88 template<
typename S,
typename T,
typename Q,
size_t N,
size_t M>
89 inline S getElementIndex(
const std::array<T,N>& D,
const std::array<Q,M>& I) {
90 return getLevelElementIndex<S,T,Q,M,1>(D.data(),I.data());
103 template<
typename T,
typename S,
size_t N,
size_t i> requires (i==N)
104 inline void getLevelElementIndices(
const T* Di,S& index,T *Ai) {
113 template<
typename T,
typename S,
size_t N,
size_t i> requires (i<N)
114 inline void getLevelElementIndices(
const T* Di,S& index,T *Ai) {
117 getLevelElementIndices<T,S,N,i+1>(Di+1,index,Ai+1);
127 template<
typename T,
typename S,
size_t N> requires functions_type::isArithmeticType<T>
128 inline void getElementIndices(
const std::array<T,N>& D,S& index,std::array<T,N>& I) {
129 return getLevelElementIndices<T,S,N,1>(D.data(),index,I.data());
138 template<
typename T,
typename S,
size_t N,
size_t M> requires functions_type::isArithmeticType<T>
139 inline void getElementIndices(
const std::array<T,N>& D,S& index,std::array<T,M>& I) {
140 return getLevelElementIndices<T,S,M,1>(D.data(),index,I.data());
149 template<
typename T,
typename S,
size_t N> requires functions_type::isArithmeticType<T>
150 inline void getElementIndices(
const T* D,S& index,T* I) {
151 return getLevelElementIndices<T,S,N,1>(D,index,I);
162 template<
typename T,
size_t N,
size_t L> requires (L==N)
163 inline void nextLevelElementIndices(
const T* Nl,T* Il) {
171 template<
typename T,
size_t N,
size_t L> requires (L<N)
172 inline void nextLevelElementIndices(
const T* Nl,T* Il) {
176 nextLevelElementIndices<T,N,L+1>(Nl+1,Il+1);
187 template<
typename T,
size_t N> requires (functions_type::isArithmeticType<T>)
188 inline void nextElementIndices(
const std::array<T,N>& size,std::array<T,N>& indices) {
189 return nextLevelElementIndices<T,N,1>(size.data(),indices.data());
196 template<
typename T,
size_t N> requires (functions_type::isArithmeticType<T>)
197 inline void nextElementIndices(
const T* size,T* indices) {
198 return nextLevelElementIndices<T,N,1>(size,indices);
209 template<
typename T,
size_t N,
size_t L> requires (L==N)
210 inline tBoolean hasNextLevelElement(
const T* Nl,T* Il) {
212 return ((*Il)<(*Nl));
219 template<
typename T,
size_t N,
size_t L> requires (L<N)
220 inline tBoolean hasNextLevelElement(
const T* Nl,T* Il) {
224 return hasNextLevelElement<T,N,L+1>(Nl+1,Il+1);
236 template<
typename T,
size_t N> requires (functions_type::isArithmeticType<T>)
237 inline tBoolean hasNextElement(
const std::array<T,N>& size,std::array<T,N>& indices) {
238 return hasNextLevelElement<T,N,1>(size.data(),indices.data());
255 template<
typename T,
size_t N,
size_t L> requires (L==N)
256 inline tBoolean hasNextLevelElementIndicesWithinBlock(
const T* Nl,
const T* Sl,
const T* El,T* Il) {
258 return ((*Il)<(*El));
269 template<
typename T,
size_t N,
size_t L> requires (L<N)
270 inline tBoolean hasNextLevelElementIndicesWithinBlock(
const T* Nl,
const T* Sl,
const T* El,T* Il) {
274 return hasNextLevelElementIndicesWithinBlock<T,N,L+1>(Nl+1,Sl+1,El+1,Il+1);
287 template<
typename T,
size_t N> requires (functions_type::isArithmeticType<T>)
288 inline tBoolean hasNextElementIndicesWithinBlock(
const std::array<T,N>& size,
289 const std::array<T,N>& start,
290 const std::array<T,N>& end,
291 std::array<T,N>& indices) {
292 return hasNextLevelElementIndicesWithinBlock<T,N,1>(size.data(),start.data(),end.data(),indices.data());
301 template<
typename T,
size_t N,
size_t i> requires (i==N)
302 inline tBoolean isLevelIndicesInBound(
const T* Di,
const T *Bi) {
310 template<
typename T,
size_t N,
size_t i> requires (i<N)
311 inline tBoolean isLevelIndicesInBound(
const T* Di,
const T *Bi) {
312 return ((*Di)<(*Bi)) && isLevelIndicesInBound<T,N,i+1>(Di+1,Bi+1);
320 template<
typename T,
size_t N> requires functions_type::isArithmeticType<T>
321 inline tBoolean isIndicesInBound(
const T* I,
const T* Ns) {
322 return isLevelIndicesInBound<T,N,1>(I,Ns);
330 template<
typename T,
size_t N> requires functions_type::isArithmeticType<T>
331 inline tBoolean isIndicesInBound(
const std::array<T,N>& I,
const std::array<T,N>& Ns) {
332 return isLevelIndicesInBound<T,N,1>(I.data(),Ns.data());