32#ifndef MADNESS_MRA_KEY_H__INCLUDED
33#define MADNESS_MRA_KEY_H__INCLUDED
59 template<std::
size_t NDIM>
67 template<std::
size_t NDIM>
123 if (
n != other.
n)
return false;
124 for (
unsigned int i=0; i<
NDIM; i++)
125 if (
l[i] != other.
l[i])
return false;
130 return !(*
this == other);
138 if (
n < other.
n)
return true;
139 if (
n > other.
n)
return false;
141 for (
unsigned int i=0; i<
NDIM; i++) {
142 if (
l[i] < other.
l[i])
return true;
143 if (
l[i] > other.
l[i])
return false;
178 for (std::size_t
d = 0;
d <
NDIM; ++
d) {
190 for (std::size_t
d = 0;
d <
NDIM; ++
d) {
192 if (is_periodic[
d]) {
209 template <std::
size_t NDIM2>
210 std::enable_if_t<NDIM >= NDIM2, uint64_t>
215 for (std::size_t
a = 0;
a < NDIM2; ++
a) {
216 const auto d = axes[
a];
219 if (is_periodic[
d]) {
249 for (std::size_t i = 0; i <
NDIM; ++i)
250 pl[i] =
l[i] >> generation;
251 return Key(
n - generation, pl);
257 if (this->n < key.
n) {
260 else if (this->n == key.
n) {
261 return (*
this == key);
264 Level dn = this->n - key.
n;
266 return (mama == key);
283 for (std::size_t i=0; i<
NDIM; ++i)
286 if (bperiodic[i] && ll==TWON1) ll=1;
313 const unsigned int& dim1)
const {
317 const double twotoN = std::pow(2.0,
double(
n));
320 for (
unsigned int i=0; i<
NDIM; i++ ) {
326 if ((i==dim0) or (i==dim1))
continue;
328 const int ll=int (x[i]*twotoN);
329 if (not (
l[i]==ll)) contains=
false;
335 template<std::
size_t LDIM, std::
size_t KDIM>
342 for (
int i=0; i<static_cast<int>(LDIM); ++i) {
347 for (
size_t i=LDIM; i<
NDIM; ++i) {
357 template<std::
size_t VDIM>
359 static_assert(VDIM <=
NDIM,
"VDIM must be less than or equal to NDIM");
361 for (
int i = 0; i < VDIM; ++i) t[i] = this->
translation()[i];
366 template<std::
size_t VDIM>
368 static_assert(VDIM <=
NDIM,
"VDIM must be less than or equal to NDIM");
370 for (
int i = 0; i < VDIM; ++i) t[i] = this->
translation()[
NDIM-VDIM+i];
375 template<std::
size_t VDIM>
378 for (
int i = 0; i < VDIM; ++i) t[i] = this->
translation()[v[i]];
383 template<std::
size_t VDIM>
388 auto v_complement = [](
const std::array<int, VDIM>&
v) {
389 std::array<int,
NDIM - VDIM> result;
390 for (std::size_t i = 0; i <
NDIM - VDIM; i++) result[i] = (
v.back() + i + 1) %
NDIM;
397 template<std::
size_t LDIM>
400 for (
int i=0; i<static_cast<int>(
NDIM); ++i) t[i] =this->l[i];
401 for (
int i=0; i<static_cast<int>(LDIM); ++i) t[
NDIM+i]=rhs.
translation()[i];
412 for (
size_t i=0; i<
NDIM; ++i) {
431 template<std::
size_t NDIM>
443 template<
size_t NDIM>
458 template<std::
size_t NDIM>
481 for (i = 0; i <
NDIM; ++i) {
485 for (std::size_t j = 0; j < i; ++j) {
498 operator bool()
const {
502 template<
typename Archive>
516 template<std::
size_t NDIM,
typename opT>
520 it(parent); it; ++it)
525 template<std::
size_t NDIM,
typename objT>
528 (objT::*memfun)(const
Key<
NDIM>&)) {
530 it(parent); it; ++it)
531 (obj ->* memfun)(it.key());
540 template <
class Archive, std::
size_t NDIM>
547 template <std::
size_t NDIM>
555 template <
class Archive, std::
size_t NDIM>
Provides BoundaryConditions.
Implements an archive wrapping a binary filestream.
Iterates in lexical order thru all children of a key.
Definition key.h:459
Vector< Translation, NDIM > p
Definition key.h:462
KeyChildIterator(const Key< NDIM > &parent)
Definition key.h:470
bool finished
Definition key.h:463
const Key< NDIM > & key() const
Returns the key of the child.
Definition key.h:510
KeyChildIterator()
Definition key.h:466
Key< NDIM > child
Definition key.h:461
Key< NDIM > parent
Definition key.h:460
void serialize(Archive &ar)
Definition key.h:504
KeyChildIterator & operator++()
Pre-increment of an iterator (i.e., ++it)
Definition key.h:477
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:68
Key< VDIM > extract_back() const
extract a new key consisting of last VDIM dimensions of this
Definition key.h:367
Key< NDIM+LDIM > merge_with(const Key< LDIM > &rhs) const
merge with other key (ie concatenate), use level of rhs, not of this
Definition key.h:398
Level level() const
Definition key.h:161
uint64_t distsq_bc(const array_of_bools< NDIM > &is_periodic) const
like distsq() but accounts for periodicity
Definition key.h:186
bool is_farther_out_than(const Key< NDIM > &other) const
return if the other key is pointing in the same direction and is farther out
Definition key.h:411
Vector< Translation, NDIM > l
Definition key.h:76
Key neighbor(const Vector< Translation, NDIM > &disp) const
given a displacement, generate a neighbor key; ignore boundary conditions and disp's level
Definition key.h:305
Key(int n)
Constructor with given n and l=0.
Definition key.h:92
Key(Level n, const Vector< Translation, NDIM > &l)
Constructor with given n, l.
Definition key.h:86
bool is_parent_of(const Key &key) const
Definition key.h:272
bool is_neighbor_of(const Key &key, const array_of_bools< NDIM > &bperiodic) const
Assuming keys are at the same level, returns true if displaced by no more than 1 in any direction.
Definition key.h:280
Key()
Default constructor makes an uninitialized key.
Definition key.h:83
bool is_valid() const
Checks if a key is valid.
Definition key.h:116
hashT hash() const
Definition key.h:150
bool thisKeyContains(const Vector< double, NDIM > &x, const unsigned int &dim0, const unsigned int &dim1) const
check if this MultiIndex contains point x, disregarding these two dimensions
Definition key.h:312
bool is_invalid() const
Checks if a key is invalid.
Definition key.h:111
bool operator==(const Key &other) const
Equality test.
Definition key.h:121
const Translation & operator[](std::size_t d) const
const accessor to elements of this->translation()
Definition key.h:171
Level n
Definition key.h:75
static const std::size_t static_size
Definition key.h:71
uint64_t distsq_bc(const array_of_bools< NDIM > &is_periodic, const std::array< std::size_t, NDIM2 > &axes) const
Definition key.h:211
bool operator!=(const Key &other) const
Definition key.h:129
Key< NDIM-VDIM > extract_complement_key(const std::array< int, VDIM > &v) const
extract a new key with the Translations complementary to the ones indicated in the v array
Definition key.h:384
Key< VDIM > extract_front() const
extract a new key consisting of first VDIM dimensions of this
Definition key.h:358
Key< VDIM > extract_key(const std::array< int, VDIM > &v) const
extract a new key with the Translations indicated in the v array
Definition key.h:376
hashT hashval
Definition key.h:77
Key parent(int generation=1) const
Returns the key of the parent.
Definition key.h:245
void rehash()
Recomputes hashval ... presently only done when reading from external storage.
Definition key.h:422
const Vector< Translation, NDIM > & translation() const
Definition key.h:166
bool operator<(const Key &other) const
Comparison operator less than to enable storage in STL map.
Definition key.h:134
static Key< NDIM > invalid()
Returns an invalid key.
Definition key.h:106
uint64_t distsq() const
Definition key.h:176
Key neighbor(const Key< NDIM > &disp) const
given a displacement, generate a neighbor key; ignore boundary conditions and disp's level
Definition key.h:296
bool is_child_of(const Key &key) const
Definition key.h:256
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:336
A simple, fixed dimension vector.
Definition vector.h:64
syntactic sugar for std::array<bool, N>
Definition array_of_bools.h:19
archive_array< T > wrap(const T *, unsigned int)
Factory function to wrap a dynamically allocated pointer as a typed archive_array.
Definition archive.h:913
static const double v
Definition hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
#define MADNESS_PRAGMA_GCC(x)
Definition madness_config.h:205
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
std::ostream & operator<<(std::ostream &os, const particle< PDIM > &p)
Definition lowrankfunction.h:397
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:260
int64_t Translation
Definition key.h:56
Key< NDIM > displacement(const Key< NDIM > &source, const Key< NDIM > &target)
given a source and a target, return the displacement in translation
Definition key.h:444
int Level
Definition key.h:57
static double pop(std::vector< double > &v)
Definition SCF.cc:113
std::size_t hashT
The hash value type.
Definition worldhash.h:145
void foreach_child(const Key< NDIM > &parent, opT &op)
Applies op(key) to each child key of parent.
Definition key.h:518
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition array_addons.h:78
static long abs(long a)
Definition tensor.h:218
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
static void load(const Archive &ar, Key< NDIM > &t)
Definition key.h:542
Default load of an object via serialize(ar, t).
Definition archive.h:666
static void store(const Archive &ar, const Key< NDIM > &t)
Definition key.h:557
Default store of an object via serialize(ar, t).
Definition archive.h:611
double dist(const Vector< double, 3 > v1, const Vector< double, 3 > v2)
distance between v1 and v2
Definition test_localizer.cc:38
constexpr std::size_t NDIM
Definition testgconv.cc:54
double source(const coordT &r)
Definition testperiodic.cc:48
Implement the madness:Vector class, an extension of std::array that supports some mathematical operat...
Defines hash functions for use in distributed containers.
FLOAT target(const FLOAT &x)
Definition y.cc:295