35 #ifndef MADNESS_WORLD_ARRAY_H__INCLUDED
36 #define MADNESS_WORLD_ARRAY_H__INCLUDED
49 template <
typename T, std::
size_t N>
50 std::ostream& operator<<(std::ostream& s, const std::array<T,N>&
a) {
52 for(std::size_t i=0; i<
N; ++i) {
54 if (i != (N-1)) s <<
",";
61 template <
typename T, std::
size_t N>
70 template <
class Archive,
class T>
71 struct ArchiveStoreImpl;
72 template <
class Archive,
class T>
73 struct ArchiveLoadImpl;
75 template <
class Archive,
typename T, std::
size_t N>
83 template <
class Archive,
typename T, std::
size_t N>
98 template <
typename T, std::
size_t N>
125 template <
typename Q>
131 template <
typename Q>
137 template <
typename Q,
typename A>
138 explicit Vector(
const std::vector<Q, A>& t) {
142 template <
typename Q>
153 template <
typename Q>
165 template <
typename Q>
172 template <
typename Q,
typename A>
174 MADNESS_ASSERT(other.size() >=
N);
192 const_iterator
end()
const {
return data_.
end(); }
198 const_reverse_iterator
rend()
const {
return data_.
rend(); }
207 const_reference
operator[](size_type i)
const {
return data_[i]; }
208 reference
at(size_type i) {
return data_.
at(i); }
209 const_reference
at(size_type i)
const {
return data_.
at(i); }
213 const_reference
back()
const {
return data_.
back(); }
220 #ifdef MADNESS_ARRAY_HAS_FILL
230 template <
typename Q>
232 for(size_type i = 0; i <
N; ++i)
240 template <
typename Q>
242 for(size_type i = 0; i <
N; ++i)
250 template <
typename Q>
252 for(size_type i = 0; i <
N; ++i)
260 for (std::size_t i=0; i<
N; ++i) d+=(data_[i])*(data_[i]);
265 template <
typename Archive>
277 return l.data_ == r.data_;
281 return l.data_ != r.data_;
285 return l.data_ < r.data_;
289 return l.data_ > r.data_;
293 return l.data_ <= r.data_;
297 return l.data_ >= r.data_;
301 friend std::ostream& operator<<(std::ostream& s, const Vector<T,N>& v) {
307 template <
typename T, std::
size_t N>
325 template <
typename T, std::
size_t N,
typename U>
328 for (std::size_t i = 0; i <
N; ++i)
344 template <
typename T,
typename U, std::
size_t N>
347 for (std::size_t i = 0; i <
N; ++i)
362 template <
typename T, std::
size_t N,
typename U>
365 for (std::size_t i = 0; i <
N; ++i)
379 template <
typename T, std::
size_t N,
typename U>
382 for (std::size_t i = 0; i <
N; ++i)
397 template <
typename T, std::
size_t N,
typename U>
400 for (std::size_t i = 0; i <
N; ++i)
414 template <
typename T, std::
size_t N,
typename U>
417 for (std::size_t i = 0; i <
N; ++i)
432 template <
typename T, std::
size_t N,
typename U>
435 for (std::size_t i = 0; i <
N; ++i)
446 template <
typename T, std::
size_t N>
449 for (std::size_t i = 0; i <
N; ++i)
450 norm2 += v[i] * v[i];
455 template <
typename T>
462 template <
typename T>
469 template <
typename T>
476 template <
typename T>
478 Vector<T,4> r; r[0] = x; r[1] = y; r[2] = z; r[3] = xx;
483 template <
typename T>
485 Vector<T,5> r; r[0] = x; r[1] = y; r[2] = z; r[3] = xx; r[4] = yy;
490 template <
typename T>
492 Vector<T,6> r; r[0] = x; r[1] = y; r[2] = z; r[3] = xx; r[4] = yy; r[5] = zz;
498 template <
typename T, std::
size_t N>
508 MADNESS_ASSERT(n <
N);
513 MADNESS_ASSERT(n > 0);
518 MADNESS_ASSERT(n > 0);
545 template<
typename T, std::
size_t NDIM>
554 template <
typename T>
562 template <
typename T>
571 template <
typename T>
582 template <
typename T>
584 const T& v2,
const T& v3) {
594 template <
typename T>
596 const T& v2,
const T& v3,
608 template <
typename T>
610 const T& v2,
const T& v3,
611 const T& v4,
const T& v5) {
623 #endif // MADNESS_WORLD_ARRAY_H__INCLUDED
void assign(const T &value)
Definition: stdarray_bits.h:83
const_reverse_iterator rend() const
Definition: array.h:198
Vector< T, N > & operator=(const std::vector< Q, A > &other)
Assignment is deep (since a vector is POD)
Definition: array.h:173
Vector(const std::vector< Q, A > &t)
Construct from an STL vector of equal or greater length.
Definition: array.h:138
Function< TENSOR_RESULT_TYPE(L, R), NDIM > operator+(const Function< L, NDIM > &left, const Function< R, NDIM > &right)
Adds two functions with the new result being of type TensorResultType
Definition: mra.h:1759
void clear()
Definition: array.h:534
Vector< T, NDIM > n12(const Vector< T, NDIM > &r, const double eps=1.e-6)
helper function unit vector in direction r
Definition: array.h:546
T norm(Vector< T, N > v)
Compute norm of a Vector.
Definition: array.h:447
void swap(array< T, N > &y)
Definition: stdarray_bits.h:65
std::array< T, N > arrayT
Definition: array.h:101
static size_type max_size()
Definition: stdarray_bits.h:61
reference at(size_type i)
Definition: stdarray_bits.h:49
A simple, fixed dimension Coordinate.
Definition: array.h:99
arrayT::size_type size_type
Definition: array.h:115
std::size_t size() const
Definition: array.h:526
std::reverse_iterator< iterator > reverse_iterator
Definition: stdarray_bits.h:32
Defines hash functions for use in distributed containers.
void swap(Vector< T, N > &other)
Definition: array.h:218
static void store(const Archive &ar, const std::array< T, N > &a)
Definition: array.h:77
void push(const T &value)
Definition: array.h:507
Vector< T, N > & operator=(const T &t)
Fill from scalar value.
Definition: array.h:180
T * c_array()
Definition: array.h:215
Definition: mpreal.h:3066
reference back()
Definition: stdarray_bits.h:55
reference back()
Definition: array.h:212
reverse_iterator rbegin()
Definition: stdarray_bits.h:35
iterator begin()
Definition: array.h:189
Vector(const std::array< Q, N > &t)
Definition: array.h:143
Default store of a thingy via serialize(ar,t)
Definition: archive.h:708
arrayT::difference_type difference_type
Definition: array.h:116
arrayT::iterator iterator
Definition: array.h:109
const_iterator end() const
Definition: array.h:192
Array idential to C++0X arrays.
Definition: stdarray_bits.h:11
const int * const_iterator
Definition: stdarray_bits.h:19
static bool empty()
Definition: stdarray_bits.h:60
bool empty() const
Definition: array.h:530
static const size_type static_size
The size of the vector.
Definition: array.h:119
Vector(const Vector< T, N > &other)
Copy constructor is deep (since a coordinate is POD)
Definition: array.h:148
std::array< T, 1 > array_factory(const T &v0)
Returns a Vector initialized from the arguments.
Definition: array.h:555
const_reference at(size_type i) const
Definition: array.h:209
void fill(const T &t)
Definition: array.h:219
T & top()
Definition: array.h:522
int * iterator
Definition: stdarray_bits.h:18
size_type max_size() const
Definition: array.h:203
friend bool operator!=(const Vector< T, N > &l, const Vector< T, N > &r)
Definition: array.h:280
A simple, fixed-size, stack.
Definition: array.h:499
void reset()
Definition: array.h:538
Vector< T, N > & operator-=(const Vector< Q, N > &q)
In-place element-wise subtraction of another vector.
Definition: array.h:251
const_reference operator[](size_type i) const
Definition: array.h:207
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
std::ptrdiff_t difference_type
Definition: stdarray_bits.h:23
Vector< T, 1 > vec(T x)
Your friendly neighborhood factory function.
Definition: array.h:456
const_iterator begin() const
Definition: array.h:190
reference at(size_type i)
Definition: array.h:208
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence. ...
Definition: mra.h:1835
Vector< T, N > & operator=(const Vector< Q, N > &other)
Assignment is deep (since a vector is POD)
Definition: array.h:166
static size_type size()
Definition: stdarray_bits.h:59
bool empty() const
Definition: array.h:202
const double N
Definition: navstokes_cosines.cc:94
friend bool operator==(const Vector< T, N > &l, const Vector< T, N > &r)
Definition: array.h:276
Stack()
Definition: array.h:505
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
int & reference
Definition: stdarray_bits.h:20
Default load of a thingy via serialize(ar,t)
Definition: archive.h:718
reference front()
Definition: array.h:210
T & pop()
Definition: array.h:512
T normf() const
return the 2-norm of the vector elements
Definition: array.h:258
void serialize(Archive &ar)
Support for MADNESS serialization.
Definition: array.h:266
void hash_range(hashT &seed, It first, It last)
Combine the hash values of an iterator range.
Definition: worldhash.h:271
Vector< T, N > & operator=(const Vector< T, N > &other)
Assignment is deep (since a vector is POD)
Definition: array.h:159
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness::Hash.
Definition: array.h:62
const T * data() const
Definition: array.h:214
reverse_iterator rend()
Definition: array.h:197
const int & const_reference
Definition: stdarray_bits.h:21
arrayT::const_iterator const_iterator
Definition: array.h:110
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?)
Definition: DFcode/moldft.cc:446
reference front()
Definition: stdarray_bits.h:53
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition: vmra.h:325
std::size_t hashT
The hash value type.
Definition: worldhash.h:148
arrayT::const_reference const_reference
Definition: array.h:114
hashT hash() const
Support for MADNESS hashing.
Definition: array.h:271
Vector(Q t)
Initialize all elements to value t.
Definition: array.h:126
Vector()
Default constructor does not initialize vector contents.
Definition: array.h:122
Vector(const Vector< Q, N > &other)
Copy constructor is deep (since a coordinate is POD)
Definition: array.h:154
arrayT::value_type value_type
Definition: array.h:108
iterator begin()
Definition: stdarray_bits.h:26
const T * data() const
Definition: stdarray_bits.h:70
const_reverse_iterator rbegin() const
Definition: array.h:196
const_reference front() const
Definition: array.h:211
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: stdarray_bits.h:33
Vector< T, N > & operator*=(Q q)
In-place element-wise multiplcation by a scalar.
Definition: array.h:231
Vector< T, N > & operator+=(const Vector< Q, N > &q)
In-place element-wise addition of another vector.
Definition: array.h:241
Function< TENSOR_RESULT_TYPE(Q, T), NDIM > operator*(const Function< T, NDIM > &f, const Q alpha)
Returns new function equal to f(x)*alpha.
Definition: mra.h:1553
arrayT::const_reverse_iterator const_reverse_iterator
Definition: array.h:112
friend bool operator>(const Vector< T, N > &l, const Vector< T, N > &r)
Definition: array.h:288
friend bool operator>=(const Vector< T, N > &l, const Vector< T, N > &r)
Definition: array.h:296
reverse_iterator rbegin()
Definition: array.h:195
static void load(const Archive &ar, std::array< T, N > &a)
Definition: array.h:85
reference operator[](size_type i)
Definition: array.h:206
T & front()
Definition: array.h:517
void swap(Vector< T, N > &l, Vector< T, N > &r)
Definition: array.h:308
Function< TENSOR_RESULT_TYPE(L, R), NDIM > operator-(const Function< L, NDIM > &left, const Function< R, NDIM > &right)
Subtracts two functions with the new result being of type TensorResultType
Definition: mra.h:1789
int value_type
Definition: stdarray_bits.h:17
arrayT::reverse_iterator reverse_iterator
Definition: array.h:111
Implements MadnessException.
const_reference back() const
Definition: array.h:213
Vector(const Q(&t)[N])
Construct from a C-style array of the same dimension.
Definition: array.h:132
size_type size() const
Definition: array.h:201
reverse_iterator rend()
Definition: stdarray_bits.h:39
arrayT::reference reference
Definition: array.h:113
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
iterator end()
Definition: array.h:191
std::size_t size_type
Definition: stdarray_bits.h:22
iterator end()
Definition: stdarray_bits.h:28