MPQC  3.0.0-alpha
tensor.hpp
1 #ifndef MPQC_MATH_TENSOR_HPP
2 #define MPQC_MATH_TENSOR_HPP
3 
4 #include "mpqc/math/tensor/ref.hpp"
5 
6 namespace mpqc {
7 
10 
12  template<typename T, size_t N, class Order = TensorColumnMajor>
13  struct Tensor: TensorRef<T, N, Order> {
14 
15  public:
16 
17  explicit Tensor(const size_t (&dims)[N]) :
18  TensorRef<T, N, Order>(allocate(dims), dims) {
19  }
20 
21  Tensor(const Tensor &u) :
22  TensorRef<T, N, Order>(allocate(u.dims()), u.dims()) {
24  }
25 
26  template<typename U>
27  Tensor(const TensorRef<U, N, Order> &u) :
28  TensorRef<T, N, Order>(allocate(u.dims()), u.dims()) {
30  }
31 
32  ~Tensor() {
34  }
35 
36  Tensor& operator=(const Tensor &u) {
38  }
39 
40  protected:
41 
42  static T* allocate(const size_t (&dims)[N]) {
43  size_t size = 1;
44  for (size_t i = 0; i < N; ++i) {
45  size *= dims[i];
46  }
47  return new T[size];
48  }
49 
50  };
51 
53 
54 }
55 
56 #endif /* MPQC_MATH_TENSOR_HPP */
mpqc
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
mpqc::TensorRef
Tensor reference class.
Definition: ref.hpp:15
mpqc::Tensor
Tensor reference class.
Definition: tensor.hpp:13
mpqc::TensorRef::operator=
TensorRef & operator=(const TensorRef &u)
fast assignment operator
Definition: ref.hpp:28

Generated at Sun Jan 26 2020 23:24:01 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.