20 #ifndef OHMMS_NEW_VECTOR_H 21 #define OHMMS_NEW_VECTOR_H 25 #include <type_traits> 32 template<
class T,
typename Alloc = std::allocator<T>>
73 template<
typename CONTAINER>
82 template<
typename Allocator = Alloc,
typename = IsHostSafe<Allocator>>
107 template<
typename T1,
typename C1,
typename Allocator = Alloc,
typename = IsHostSafe<Allocator>>
110 if (std::is_convertible<T1, T>::value)
120 template<
class RHS,
typename Allocator = Alloc,
typename = IsHostSafe<Allocator>>
148 template<
typename CONTAINER>
168 static_assert(std::is_same<value_type, typename Alloc::value_type>::value,
169 "Vector and Alloc data types must agree!");
171 throw std::runtime_error(
"Resize not allowed on Vector constructed by initialized memory.");
210 template<
typename Allocator = Alloc,
typename = IsHostSafe<Allocator>>
216 template<
typename Allocator = Alloc,
typename = IsHostSafe<Allocator>>
244 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
249 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
262 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
271 template<
typename Allocator = Alloc,
typename = IsDualSpace<Allocator>>
304 if constexpr (std::is_trivial<T>::value)
307 for (
size_type i = 0; i < n_elements; i++)
308 new (ptr + i)
Type_t(val);
315 if constexpr (std::is_trivial<T>::value)
318 for (
size_type i = 0; i < n_elements; i++)
319 new (to + i)
Type_t(*(from + i));
326 for (
size_type i = 0; i < n_elements; i++)
327 (ptr + i)->~Type_t();
341 template<
class T,
class C>
375 template<
class T,
class C>
387 template<
class T,
class C>
397 template<
class T,
class C,
class Op,
class RHS>
404 for (
int i = 0; i < lhs.
size(); ++i)
418 throw std::runtime_error(
"Error in evaluate: LHS and RHS don't conform in OhmmsVector.");
422 template<
class T,
class Alloc>
428 for (
int i = 0; i < rhs.
size(); i++)
429 if (lhs[i] != rhs[i])
437 template<
class T,
class Alloc>
441 return !(lhs == rhs);
445 template<
class T,
class Alloc>
446 std::ostream& operator<<(std::ostream& out, const Vector<T, Alloc>& rhs)
449 for (
int i = 0; i < rhs.size(); i++)
450 out << rhs[i] << std::endl;
454 template<
class T,
class Alloc>
459 for (
int i = 0; i < rhs.
size(); i++)
466 #endif // OHMMS_PARTICLEATTRIB_PEPE_H void resize(size_type n, Type_t val=Type_t())
Resize the container.
static Type_t apply(const Vector< T, C > &vec, const EvalLeaf1 &f)
static bool apply(const Scalar< T > &, const SizeLeaf &)
helper functions for EinsplineSetBuilder
const_pointer device_data() const
static void updateTo(Allocator &a, value_type *host_ptr, size_t n, size_t offset=0)
Vector & operator=(const RHS &rhs)
static void construct_copy_elements(const Type_t *from, size_type n_elements, Type_t *to)
const_pointer first_address() const
Type_t & operator[](size_type i)
ForEach< Expr, FTag, CTag >::Type_t forEach(const Expr &e, const FTag &f, const CTag &c)
const_iterator begin() const
pointer device_data()
Return the device_ptr matching X if this is a vector attached or owning dual space memory...
void updateFrom(size_type size=0, std::ptrdiff_t offset=0)
Vector(size_type n=0, Type_t val=Type_t())
constructor with size n
bool operator==(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
typename std::allocator< T > ::const_pointer const_pointer
const_pointer data() const
static void attachReference(Allocator &from, Allocator &to, std::ptrdiff_t ptr_offset)
So we can write generic tests that work with all QMCPACK allocators.
Vector(T *ref, size_type n)
constructor with an initialized ref
Vector(const CONTAINER &from, T *ref, size_type n)
This allows construction of a Vector on another containers owned memory that is using a dualspace all...
void attachReference(const CONTAINER &other, T *ref, size_type n)
Attach to pre-allocated memory and propagate the allocator of the owning container.
bool operator()(int s) const
static Leaf_t make(const Vector< T, C > &a)
void attachReference(T *ref, size_type n)
size_type size() const
return the current size
Matrix< T1, C1 > & assign(Matrix< T1, C1 > &lhs, const RHS &rhs)
static void destroy_elements(Type_t *ptr, size_type n_elements)
template class analogous to std::allocator_traits.
Vector & operator=(const Vector &rhs)
static void updateFrom(Allocator &a, value_type *host_ptr, size_t n, size_t offset=0)
const_iterator end() const
static void construct_fill_elements(Type_t *ptr, size_type n_elements, const Type_t &val)
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Vector(std::initializer_list< T > ts)
Initializer list constructor that can deal with both POD and nontrivial nested elements with move ass...
Vector & operator=(const Vector< T1, C1 > &rhs)
void evaluate(Matrix< T, Alloc > &lhs, const Op &op, const Expression< RHS > &rhs)
static bool apply(const Vector< T, C > &v, const SizeLeaf &s)
void updateTo(size_type size=0, std::ptrdiff_t offset=0)
void resize_impl(size_type n)
a dumb resize, always free existing memory and resize to n. n must be protected positive ...
SizeLeaf(const SizeLeaf &model)
const_pointer last_address() const
typename std::allocator< T > ::pointer pointer
Vector(const Vector &rhs)
copy constructor
std::istream & operator>>(std::istream &is, Matrix< T, Alloc > &rhs)
typename Alloc::size_type size_type
static void fill_n(value_type *ptr, size_t n, const value_type &value)
size_type nAllocated
The number of allocated.
bool operator!=(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
T * X
pointer to the data accessed through this object
const Type_t & operator[](size_type i) const
virtual ~Vector()
Destructor.
Alloc mAllocator
allocator