QMCPACK
MatrixAccessor.hpp
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) 2021 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
8 //
9 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
10 //////////////////////////////////////////////////////////////////////////////////////
11 #ifndef QMCPLUSPLUS_MATRIX_ACCESSOR_HPP
12 #define QMCPLUSPLUS_MATRIX_ACCESSOR_HPP
13 
14 namespace qmcplusplus
15 {
16 namespace testing
17 {
18 enum class MA_ori
19 {
20  ROW,
21  COLUMN
22 };
23 
24 /** Read only access, for testing!
25  *
26  * Makes checkMatrix dependency free
27  */
28 template<typename T>
30 {
31 public:
32  using value_type = T;
33 
34  MatrixAccessor(const T* data, size_t m, size_t n, MA_ori ori = MA_ori::ROW)
35  : m_(m),
36  n_(n),
37  data_(data),
38  ori_(ori){
39 
40  };
41 
42  T operator()(size_t i, size_t j) const
43  {
44  if (ori_ == MA_ori::ROW)
45  return data_[i * n_ + j];
46  else
47  return data_[i + j * m_];
48  }
49 
50  size_t rows() { return m_; }
51  size_t cols() { return n_; }
52 
53 private:
54  size_t m_;
55  size_t n_;
56  const T* data_;
58 };
59 
60 } // namespace testing
61 } // namespace qmcplusplus
62 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
T operator()(size_t i, size_t j) const
MatrixAccessor(const T *data, size_t m, size_t n, MA_ori ori=MA_ori::ROW)
Read only access, for testing!