QMCPACK
PrefetchedRange.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2022 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef QMCPLUSPLUS_PREFETCHED_RANGE_H
13 #define QMCPLUSPLUS_PREFETCHED_RANGE_H
14 
15 namespace qmcplusplus
16 {
17 /// helper class for the prefetched range of a vector
19 {
20  // [first, last) rows of Ainv
21  int first, last;
22 
23 public:
24  PrefetchedRange() : first(0), last(0){};
25  void setRange(int first_in, int last_in)
26  {
27  first = first_in;
28  last = last_in;
29  }
30  inline void clear() { first = last = 0; };
31  inline int getOffset(int index) const
32  {
33  if (!checkRange(index))
34  throw std::runtime_error("index not in range \n");
35  return index - first;
36  }
37  inline bool checkRange(int index) const { return (index >= first) && (index < last); };
38 };
39 } // namespace qmcplusplus
40 
41 #endif // QMCPLUSPLUS_PREFETCHED_RANGE_H
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
int getOffset(int index) const
void setRange(int first_in, int last_in)
bool checkRange(int index) const
helper class for the prefetched range of a vector