32#ifndef MADNESS_MRA_KEY_H__INCLUDED
33#define MADNESS_MRA_KEY_H__INCLUDED
60 template<std::
size_t NDIM>
68 template<std::
size_t NDIM>
130 if (
n != other.
n)
return false;
131 for (
unsigned int i=0; i<
NDIM; i++)
132 if (
l[i] != other.
l[i])
return false;
137 return !(*
this == other);
145 if (
n < other.
n)
return true;
146 if (
n > other.
n)
return false;
148 for (
unsigned int i=0; i<
NDIM; i++) {
149 if (
l[i] < other.
l[i])
return true;
150 if (
l[i] > other.
l[i])
return false;
185 for (std::size_t
d = 0;
d <
NDIM; ++
d) {
197 for (std::size_t
d = 0;
d <
NDIM; ++
d) {
199 if (is_periodic[
d]) {
216 template <std::
size_t NDIM2>
222 for (std::size_t
a = 0;
a <
NDIM2; ++
a) {
226 if (is_periodic[
d]) {
256 for (std::size_t i = 0; i <
NDIM; ++i)
264 if (this->n < key.
n) {
267 else if (this->n == key.
n) {
268 return (*
this == key);
273 return (
mama == key);
290 for (std::size_t i=0; i<
NDIM; ++i)
320 const unsigned int&
dim1)
const {
324 const double twotoN = std::pow(2.0,
double(
n));
327 for (
unsigned int i=0; i<
NDIM; i++ ) {
342 template<std::
size_t LDIM, std::
size_t KDIM>
350 for (
size_t i=0; i<LDIM; ++i) {
353 for (
size_t i=LDIM; i<
NDIM; ++i) {
360 MADNESS_EXCEPTION(
"Key::break_apart: LDIM+KDIM must equal NDIM or LDIM==NDIM",1);
365 template<std::
size_t VDIM>
367 static_assert(
VDIM <=
NDIM,
"VDIM must be less than or equal to NDIM");
374 template<std::
size_t VDIM>
376 static_assert(
VDIM <=
NDIM,
"VDIM must be less than or equal to NDIM");
383 template<std::
size_t VDIM>
391 template<std::
size_t VDIM>
398 for (std::size_t i = 0; i <
NDIM -
VDIM; i++) result[i] = (
v.back() + i + 1) %
NDIM;
405 template<std::
size_t LDIM>
408 for (
size_t i=0; i<
NDIM; ++i) t[i] =this->l[i];
409 for (
size_t i=0; i<LDIM; ++i) t[
NDIM+i]=
rhs.translation()[i];
420 for (
size_t i=0; i<
NDIM; ++i) {
439 template<std::
size_t NDIM>
451 template<
size_t NDIM>
466 template<std::
size_t NDIM>
489 for (i = 0; i <
NDIM; ++i) {
493 for (std::size_t j = 0; j < i; ++j) {
510 template<
typename Archive>
524 template<std::
size_t NDIM,
typename opT>
528 it(parent); it; ++it)
533 template<std::
size_t NDIM,
typename objT>
536 (objT::*memfun)(const
Key<
NDIM>&)) {
538 it(parent); it; ++it)
539 (
obj ->* memfun)(it.key());
548 template <
class Archive, std::
size_t NDIM>
555 template <std::
size_t NDIM>
563 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:467
Vector< Translation, NDIM > p
Definition key.h:470
KeyChildIterator(const Key< NDIM > &parent)
Definition key.h:478
bool finished
Definition key.h:471
const Key< NDIM > & key() const
Returns the key of the child.
Definition key.h:518
KeyChildIterator()
Definition key.h:474
Key< NDIM > child
Definition key.h:469
Key< NDIM > parent
Definition key.h:468
void serialize(Archive &ar)
Definition key.h:512
KeyChildIterator & operator++()
Pre-increment of an iterator (i.e., ++it)
Definition key.h:485
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:69
Key< VDIM > extract_back() const
extract a new key consisting of last VDIM dimensions of this
Definition key.h:375
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:406
Level level() const
Definition key.h:168
uint64_t distsq_bc(const array_of_bools< NDIM > &is_periodic) const
like distsq() but accounts for periodicity
Definition key.h:193
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:419
Vector< Translation, NDIM > l
Definition key.h:77
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:312
Key(int n)
Constructor with given n and l=0.
Definition key.h:94
Key(Level n, const Vector< Translation, NDIM > &l)
Constructor with given n, l.
Definition key.h:87
bool is_parent_of(const Key &key) const
Definition key.h:279
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:287
Key()
Default constructor makes an uninitialized key.
Definition key.h:84
bool is_valid() const
Checks if a key is valid.
Definition key.h:123
hashT hash() const
Definition key.h:157
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:319
bool is_invalid() const
Checks if a key is invalid.
Definition key.h:118
bool operator==(const Key &other) const
Equality test.
Definition key.h:128
const Translation & operator[](std::size_t d) const
const accessor to elements of this->translation()
Definition key.h:178
Level n
Definition key.h:76
static const std::size_t static_size
Definition key.h:72
uint64_t distsq_bc(const array_of_bools< NDIM > &is_periodic, const std::array< std::size_t, NDIM2 > &axes) const
Definition key.h:218
bool operator!=(const Key &other) const
Definition key.h:136
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:392
Key< VDIM > extract_front() const
extract a new key consisting of first VDIM dimensions of this
Definition key.h:366
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:384
hashT hashval
Definition key.h:78
Key parent(int generation=1) const
Returns the key of the parent.
Definition key.h:252
void rehash()
Recomputes hashval ... presently only done when reading from external storage.
Definition key.h:430
const Vector< Translation, NDIM > & translation() const
Definition key.h:173
bool operator<(const Key &other) const
Comparison operator less than to enable storage in STL map.
Definition key.h:141
static Key< NDIM > invalid()
Returns an invalid key.
Definition key.h:109
uint64_t distsq() const
Definition key.h:183
Key neighbor(const Key< NDIM > &disp) const
given a displacement, generate a neighbor key; ignore boundary conditions and disp's level
Definition key.h:303
bool is_child_of(const Key &key) const
Definition key.h:263
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:343
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:914
static const double v
Definition hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#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:401
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:260
int64_t Translation
Definition key.h:57
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:452
int Level
Definition key.h:58
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:526
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
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:550
Default load of an object via serialize(ar, t).
Definition archive.h:667
static void store(const Archive &ar, const Key< NDIM > &t)
Definition key.h:565
Default store of an object via serialize(ar, t).
Definition archive.h:612
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