8 #ifndef PAPER_CODE_PNOTENSORS_H_
9 #define PAPER_CODE_PNOTENSORS_H_
18 template <
typename Int>
19 size_t tridx(Int row, Int col) {
20 return (row < col) ? (row + col * (col + 1) / 2)
21 : (col + row * (row + 1) / 2);
25 template <
typename Int>
27 return n * (n + 1) / 2;
41 std::tuple<size_t,bool>
ijk(
size_t i,
size_t j,
size_t k)
const {
42 assert(i <
size_t(
n_));
43 assert(j <
size_t(
n_));
44 assert(
k <
size_t(
n_));
47 return j >=
k ? std::make_tuple(
tridx(i,j) *
n_ +
k,
false) : std::make_tuple(
tridx(i,
k) *
n_ + j,
true);
50 return std::make_tuple(
tridx(i,j) *
n_ +
k,
false);
54 assert(i <
size_t(
n_));
55 assert(j <
size_t(
n_));
56 assert(
k <
size_t(
n_));
65 assert(i <
size_t(
n_));
66 assert(j <
size_t(
n_));
67 assert(
k <
size_t(
n_));
70 std::tie(
ijk,std::ignore) = this->
ijk(i,j,
k);
74 assert(i <
size_t(
n_));
75 assert(j <
size_t(
n_));
76 assert(
k <
size_t(
n_));
83 assert(i <
size_t(
n_));
84 assert(j <
size_t(
n_));
85 assert(
k <
size_t(
n_));
98 std::valarray<madness::Tensor<T>>
data_;
104 template <
typename T>
112 std::tuple<size_t,bool>
ijk(
size_t i,
size_t j,
size_t k)
const {
113 assert(i <
size_t(
n_));
114 assert(j <
size_t(
n_));
115 assert(
k <
size_t(
n_));
118 return i >=
k ? std::make_tuple(
tridx(i,j) *
n_ +
k,
false) : std::make_tuple(
tridx(
k,j) *
n_ + i,
true);
120 return std::make_tuple(
tridx(i,j) *
n_ +
k,
false);
123 assert(i <
size_t(
n_));
124 assert(j <
size_t(
n_));
125 assert(
k <
size_t(
n_));
133 assert(i <
size_t(
n_));
134 assert(j <
size_t(
n_));
135 assert(
k <
size_t(
n_));
139 std::tie(
ijk, std::ignore) = this->
ijk(i, j,
k);
143 assert(i <
size_t(
n_));
144 assert(j <
size_t(
n_));
145 assert(
k <
size_t(
n_));
153 assert(i <
size_t(
n_));
154 assert(j <
size_t(
n_));
155 assert(
k <
size_t(
n_));
169 std::valarray<madness::Tensor<T>>
data_;
Definition: PNOTensors.h:34
bool is_initialized(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:64
madness::Tensor< T > get(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:73
Tensor_IJ_IK(size_t n)
Definition: PNOTensors.h:36
void reset()
Definition: PNOTensors.h:92
int n_
Definition: PNOTensors.h:97
std::tuple< size_t, bool > ijk(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:41
std::valarray< madness::Tensor< T > > data_
Definition: PNOTensors.h:98
bool is_unique(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:53
void set(size_t i, size_t j, size_t k, const madness::Tensor< T > &t)
Definition: PNOTensors.h:82
Definition: PNOTensors.h:105
int n_
Definition: PNOTensors.h:168
std::valarray< madness::Tensor< T > > data_
Definition: PNOTensors.h:169
bool is_unique(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:122
Tensor_IJ_KJ(size_t n)
Definition: PNOTensors.h:107
madness::Tensor< T > get(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:142
std::tuple< size_t, bool > ijk(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:112
void reset()
Definition: PNOTensors.h:163
void set(size_t i, size_t j, size_t k, const madness::Tensor< T > &t)
Definition: PNOTensors.h:152
bool is_initialized(size_t i, size_t j, size_t k) const
Definition: PNOTensors.h:132
A tensor is a multidimension array.
Definition: tensor.h:317
Tensor< T > swapdim(long idim, long jdim)
Returns new view/tensor swaping dimensions i and j.
Definition: tensor.h:1605
General header file for using MADNESS.
Definition: PNOTensors.h:16
size_t tridx(Int row, Int col)
index in packed lower triangle matrix, row >= col
Definition: PNOTensors.h:19
size_t ntri(Int n)
Definition: PNOTensors.h:26
void swap(Vector< T, N > &l, Vector< T, N > &r)
Swap the contents of two Vectors.
Definition: vector.h:497
static const long k
Definition: rk.cc:44