QMCPACK
Vector< T, Alloc > Class Template Reference

Inherited by ParticleAttrib< T, Alloc >.

+ Collaboration diagram for Vector< T, Alloc >:

Public Types

using Type_t = T
 
using value_type = T
 
using iterator = T *
 
using const_iterator = const T *
 
using size_type = typename Alloc::size_type
 
using pointer = typename Alloc::pointer
 
using const_pointer = typename Alloc::const_pointer
 
using This_t = Vector< T, Alloc >
 

Public Member Functions

 Vector (size_type n=0, Type_t val=Type_t())
 constructor with size n More...
 
 Vector (T *ref, size_type n)
 constructor with an initialized ref More...
 
 Vector (const Vector &rhs)
 copy constructor More...
 
template<typename CONTAINER >
 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 allocator. More...
 
template<typename Allocator = Alloc, typename = IsHostSafe<Allocator>>
 Vector (std::initializer_list< T > ts)
 Initializer list constructor that can deal with both POD and nontrivial nested elements with move assignment operators. More...
 
Vectoroperator= (const Vector &rhs)
 
template<typename T1 , typename C1 , typename Allocator = Alloc, typename = IsHostSafe<Allocator>>
Vectoroperator= (const Vector< T1, C1 > &rhs)
 
template<class RHS , typename Allocator = Alloc, typename = IsHostSafe<Allocator>>
Vectoroperator= (const RHS &rhs)
 
virtual ~Vector ()
 Destructor. More...
 
void attachReference (T *ref, size_type n)
 
template<typename CONTAINER >
void attachReference (const CONTAINER &other, T *ref, size_type n)
 Attach to pre-allocated memory and propagate the allocator of the owning container. More...
 
size_type size () const
 return the current size More...
 
void resize (size_type n, Type_t val=Type_t())
 Resize the container. More...
 
void clear ()
 clear More...
 
void zero ()
 
void free ()
 free More...
 
template<typename Allocator = Alloc, typename = IsHostSafe<Allocator>>
Type_toperator[] (size_type i)
 
template<typename Allocator = Alloc, typename = IsHostSafe<Allocator>>
const Type_toperator[] (size_type i) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
pointer data ()
 
const_pointer data () const
 
template<typename Allocator = Alloc, typename = IsDualSpace<Allocator>>
pointer device_data ()
 Return the device_ptr matching X if this is a vector attached or owning dual space memory. More...
 
template<typename Allocator = Alloc, typename = IsDualSpace<Allocator>>
const_pointer device_data () const
 
pointer first_address ()
 
const_pointer first_address () const
 
pointer last_address ()
 
const_pointer last_address () const
 
template<typename Allocator = Alloc, typename = IsDualSpace<Allocator>>
void updateTo (size_type size=0, std::ptrdiff_t offset=0)
 
template<typename Allocator = Alloc, typename = IsDualSpace<Allocator>>
void updateFrom (size_type size=0, std::ptrdiff_t offset=0)
 

Private Member Functions

void resize_impl (size_type n)
 a dumb resize, always free existing memory and resize to n. n must be protected positive More...
 

Static Private Member Functions

static void construct_fill_elements (Type_t *ptr, size_type n_elements, const Type_t &val)
 
static void construct_copy_elements (const Type_t *from, size_type n_elements, Type_t *to)
 
static void destroy_elements (Type_t *ptr, size_type n_elements)
 

Private Attributes

size_type nLocal = 0
 size More...
 
size_type nAllocated = 0
 The number of allocated. More...
 
T * X = nullptr
 pointer to the data accessed through this object More...
 
Alloc mAllocator
 allocator More...
 

Detailed Description

template<class T, typename Alloc = std::allocator<T>>
class qmcplusplus::Vector< T, Alloc >

Definition at line 33 of file OhmmsVector.h.

Member Typedef Documentation

◆ const_iterator

using const_iterator = const T*

Definition at line 39 of file OhmmsVector.h.

◆ const_pointer

using const_pointer = typename Alloc::const_pointer

Definition at line 42 of file OhmmsVector.h.

◆ iterator

using iterator = T*

Definition at line 38 of file OhmmsVector.h.

◆ pointer

using pointer = typename Alloc::pointer

Definition at line 41 of file OhmmsVector.h.

◆ size_type

using size_type = typename Alloc::size_type

Definition at line 40 of file OhmmsVector.h.

◆ This_t

using This_t = Vector<T, Alloc>

Definition at line 43 of file OhmmsVector.h.

◆ Type_t

using Type_t = T

Definition at line 36 of file OhmmsVector.h.

◆ value_type

using value_type = T

Definition at line 37 of file OhmmsVector.h.

Constructor & Destructor Documentation

◆ Vector() [1/5]

Vector ( size_type  n = 0,
Type_t  val = Type_t() 
)
inlineexplicit

constructor with size n

Definition at line 46 of file OhmmsVector.h.

46  : nLocal(n)
47  {
48  if (n)
49  {
50  resize_impl(n);
52  }
53  }
static void construct_fill_elements(Type_t *ptr, size_type n_elements, const Type_t &val)
Definition: OhmmsVector.h:302
void resize_impl(size_type n)
a dumb resize, always free existing memory and resize to n. n must be protected positive ...
Definition: OhmmsVector.h:291
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ Vector() [2/5]

Vector ( T *  ref,
size_type  n 
)
inlineexplicit

constructor with an initialized ref

Definition at line 56 of file OhmmsVector.h.

56 : nLocal(n), X(ref) {}
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ Vector() [3/5]

Vector ( const Vector< T, Alloc > &  rhs)
inline

copy constructor

Definition at line 59 of file OhmmsVector.h.

59  : nLocal(rhs.nLocal)
60  {
61  if (nLocal)
62  {
63  resize_impl(rhs.size());
64  construct_copy_elements(rhs.data(), rhs.size(), X);
65  }
66  }
static void construct_copy_elements(const Type_t *from, size_type n_elements, Type_t *to)
Definition: OhmmsVector.h:311
void resize_impl(size_type n)
a dumb resize, always free existing memory and resize to n. n must be protected positive ...
Definition: OhmmsVector.h:291
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ Vector() [4/5]

Vector ( const CONTAINER &  from,
T *  ref,
size_type  n 
)
inline

This allows construction of a Vector on another containers owned memory that is using a dualspace allocator.

It can be any span of that memory. You're going to get a bunch of compile errors if the Container in questions is not using a the QMCPACK realspace dualspace allocator "interface"

Definition at line 74 of file OhmmsVector.h.

74  : nLocal(n), X(ref)
75  {
76  qmc_allocator_traits<Alloc>::attachReference(from.mAllocator, mAllocator, ref - from.data());
77  }
static void attachReference(Allocator &from, Allocator &to, std::ptrdiff_t ptr_offset)
So we can write generic tests that work with all QMCPACK allocators.
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286
Alloc mAllocator
allocator
Definition: OhmmsVector.h:288

◆ Vector() [5/5]

Vector ( std::initializer_list< T >  ts)
inline

Initializer list constructor that can deal with both POD and nontrivial nested elements with move assignment operators.

Definition at line 83 of file OhmmsVector.h.

84  {
85  if (ts.size())
86  {
87  resize_impl(ts.size());
88  construct_copy_elements(std::data(ts), ts.size(), X);
89  }
90  }
static void construct_copy_elements(const Type_t *from, size_type n_elements, Type_t *to)
Definition: OhmmsVector.h:311
void resize_impl(size_type n)
a dumb resize, always free existing memory and resize to n. n must be protected positive ...
Definition: OhmmsVector.h:291
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ ~Vector()

virtual ~Vector ( )
inlinevirtual

Destructor.

Definition at line 128 of file OhmmsVector.h.

128 { free(); }
void free()
free
Definition: OhmmsVector.h:196

Member Function Documentation

◆ attachReference() [1/2]

void attachReference ( T *  ref,
size_type  n 
)
inline

Definition at line 131 of file OhmmsVector.h.

Referenced by SoaDistanceTableAAOMPTarget< T, D, SC >::acquireResource(), Matrix< ST, qmcplusplus::Mallocator< ST > >::attachReference(), J1Spin< FT >::copyFromBuffer(), J1OrbitalSoA< FT >::copyFromBuffer(), JeeIOrbitalSoA< FT >::copyFromBuffer(), and SoaDistanceTableAAOMPTarget< T, D, SC >::move().

132  {
133  if (nAllocated)
134  {
135  free();
136  // std::cerr << "Allocated OhmmsVector attachReference called.\n" << std::endl;
137  // Nice idea but "default" constructed WFC elements in the batched driver make this a mess.
138  //throw std::runtime_error("Pointer attaching is not allowed on Vector with allocated memory.");
139  }
140  nLocal = n;
141  nAllocated = 0;
142  X = ref;
143  }
void free()
free
Definition: OhmmsVector.h:196
size_type nLocal
size
Definition: OhmmsVector.h:282
size_type nAllocated
The number of allocated.
Definition: OhmmsVector.h:284
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ attachReference() [2/2]

void attachReference ( const CONTAINER &  other,
T *  ref,
size_type  n 
)
inline

Attach to pre-allocated memory and propagate the allocator of the owning container.

Required for sane access to dual space memory

Definition at line 149 of file OhmmsVector.h.

150  {
151  if (nAllocated)
152  {
153  free();
154  }
155  nLocal = n;
156  nAllocated = 0;
157  X = ref;
158  qmc_allocator_traits<Alloc>::attachReference(other.mAllocator, mAllocator, ref - other.data());
159  }
void free()
free
Definition: OhmmsVector.h:196
static void attachReference(Allocator &from, Allocator &to, std::ptrdiff_t ptr_offset)
So we can write generic tests that work with all QMCPACK allocators.
size_type nLocal
size
Definition: OhmmsVector.h:282
size_type nAllocated
The number of allocated.
Definition: OhmmsVector.h:284
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286
Alloc mAllocator
allocator
Definition: OhmmsVector.h:288

◆ begin() [1/2]

iterator begin ( )
inline

Definition at line 232 of file OhmmsVector.h.

Referenced by Matrix< ST, qmcplusplus::Mallocator< ST > >::add2Column(), Array< T, D >::Array(), Array< T, D >::begin(), Matrix< ST, qmcplusplus::Mallocator< ST > >::begin(), QMCCostFunction::checkConfigurations(), EstimatorManagerBase::collectBlockAverages(), EstimatorManagerNew::collectMainEstimators(), EstimatorManagerNew::collectScalarEstimators(), CombinedTraceSample< TraceReal >::combine(), SkEstimator::evaluate(), SkAllEstimator::evaluate(), SOECPComponent::evaluateValueAndDerivatives(), NonLocalECPComponent::evaluateValueAndDerivatives(), DensityMatrices1B::generate_samples(), OneBodyDensityMatrices::generateSamples(), EstimatorManagerNew::makeBlockAverages(), OneBodyDensityMatrices::normalizeBasis(), Array< T, D >::operator=(), LatticeGaussianProduct::registerData(), J1OrbitalSoA< FT >::registerData(), J1Spin< FT >::registerData(), JeeIOrbitalSoA< FT >::registerData(), Matrix< ST, qmcplusplus::Mallocator< ST > >::replaceColumn(), Matrix< ST, qmcplusplus::Mallocator< ST > >::replaceRow(), MultiWalkerTalker::reportVector(), MockQMCHamiltonianAndReporter::reportVector(), SkEstimator::setObservables(), SkAllEstimator::setObservables(), SkEstimator::setParticlePropertyList(), SkAllEstimator::setParticlePropertyList(), EstimatorManagerBase::stopBlock(), qmcplusplus::TEST_CASE(), and EinsplineSetBuilder::TileIons().

232 { return X; }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ begin() [2/2]

const_iterator begin ( ) const
inline

Definition at line 233 of file OhmmsVector.h.

233 { return X; }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ clear()

void clear ( )
inline

clear

Definition at line 191 of file OhmmsVector.h.

Referenced by ParticleSet::clear(), qmcplusplus::TEST_CASE(), and EnergyDensityEstimator::unset_ptcl().

191 { nLocal = 0; }
size_type nLocal
size
Definition: OhmmsVector.h:282

◆ construct_copy_elements()

static void construct_copy_elements ( const Type_t from,
size_type  n_elements,
Type_t to 
)
inlinestaticprivate

Definition at line 311 of file OhmmsVector.h.

Referenced by Vector< T, std::allocator< T > >::Vector().

312  {
314  {
315  if constexpr (std::is_trivial<T>::value)
316  std::copy_n(from, n_elements, to);
317  else
318  for (size_type i = 0; i < n_elements; i++)
319  new (to + i) Type_t(*(from + i));
320  }
321  }
static constexpr bool is_host_accessible
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
typename Alloc::size_type size_type
Definition: OhmmsVector.h:40

◆ construct_fill_elements()

static void construct_fill_elements ( Type_t ptr,
size_type  n_elements,
const Type_t val 
)
inlinestaticprivate

Definition at line 302 of file OhmmsVector.h.

Referenced by Vector< T, std::allocator< T > >::resize(), and Vector< T, std::allocator< T > >::Vector().

303  {
304  if constexpr (std::is_trivial<T>::value)
305  qmc_allocator_traits<Alloc>::fill_n(ptr, n_elements, val);
307  for (size_type i = 0; i < n_elements; i++)
308  new (ptr + i) Type_t(val);
309  }
static constexpr bool is_host_accessible
typename Alloc::size_type size_type
Definition: OhmmsVector.h:40
static void fill_n(value_type *ptr, size_t n, const value_type &value)

◆ data() [1/2]

pointer data ( )
inline

Definition at line 238 of file OhmmsVector.h.

Referenced by DelayedUpdate< T, T_FP >::acceptRow(), DelayedUpdateSYCL< T, T_FP >::acceptRow(), DelayedUpdateCUDA< T, T_FP >::acceptRow(), MomentumDistribution::accumulate(), SoaSphericalTensor< ST >::batched_evaluateV(), SoaCartesianTensor< T >::batched_evaluateV(), SoaSphericalTensor< ST >::batched_evaluateVGL(), SoaCartesianTensor< T >::batched_evaluateVGL(), MultiDiracDeterminant::buildTableMatrix_calculateRatios(), MultiDiracDeterminant::buildTableMatrix_calculateRatios_impl(), EstimatorManagerBase::collectBlockAverages(), J1OrbitalSoA< FT >::computeGL(), JeeIOrbitalSoA< FT >::computeGL(), J1Spin< FT >::computeGL(), DiracMatrixComputeOMPTarget< VALUE_FP >::computeInvertAndLog(), TwoBodyJastrow< FT >::computeU(), J1OrbitalSoA< FT >::computeU(), J1Spin< FT >::computeU(), TwoBodyJastrow< FT >::computeU3(), J1OrbitalSoA< FT >::computeU3(), J1Spin< FT >::computeU3(), JeeIOrbitalSoA< FT >::computeU3(), qmcplusplus::convertToReal(), Array< T, D >::data(), Matrix< ST, qmcplusplus::Mallocator< ST > >::data(), Array< T, D >::data_at(), DiracDeterminantWithBackflow::dummyEvalLi(), MomentumEstimator::evaluate(), PWOrbitalSet::evaluate(), PWRealOrbitalSet::evaluate(), PWBasis::evaluate(), DiracDeterminantWithBackflow::evaluateDerivatives(), MultiDiracDeterminant::evaluateDerivatives(), MultiDiracDeterminant::evaluateDerivativesWF(), MultiDiracDeterminant::evaluateForWalkerMove(), MultiDiracDeterminant::evaluateForWalkerMoveWithSpin(), DiracDeterminantWithBackflow::evaluateLog(), SoaSphericalTensor< ST >::evaluateV(), SOECPComponent::evaluateValueAndDerivatives(), NonLocalECPComponent::evaluateValueAndDerivatives(), Array< T, D >::first_address(), Matrix< ST, qmcplusplus::Mallocator< ST > >::first_address(), container_traits< Vector< T, ALLOC > >::getElementPtr(), DelayedUpdate< T, T_FP >::getInvRow(), DelayedUpdateSYCL< T, T_FP >::getInvRow(), DelayedUpdateCUDA< T, T_FP >::getInvRow(), Matrix< ST, qmcplusplus::Mallocator< ST > >::getMessage(), LRRPABFeeHandlerTemp< Func, BreakupBasis >::InitBreakup(), LRRPAHandlerTemp< Func, BreakupBasis >::InitBreakup(), LRHandlerTemp< Func, BreakupBasis >::InitBreakup(), LRHandlerSRCoulomb< Func, BreakupBasis >::InitBreakup(), qmcplusplus::InverseUpdateByColumn(), qmcplusplus::InverseUpdateByRow(), Array< T, D >::last_address(), Matrix< ST, qmcplusplus::Mallocator< ST > >::last_address(), qmcplusplus::testing::makeRngVector(), SoaDistanceTableAB< T, D, SC >::move(), SoaDistanceTableAA< T, D, SC >::move(), SoaDistanceTableAAOMPTarget< T, D, SC >::move(), SoaDistanceTableABOMPTarget< T, D, SC >::move(), MultiDiracDeterminant::mw_buildTableMatrix_calculateGradRatios(), DiracMatrixComputeCUDA< VALUE_FP >::mw_computeInvertAndLog_stride(), SoaAtomicBasisSet< ROT, SH >::mw_evaluateV(), SoaAtomicBasisSet< ROT, SH >::mw_evaluateVGL(), MultiDiracDeterminant::mw_updateRatios(), MultiDiracDeterminant::mw_updateRatios_det0(), MultiDiracDeterminant::mw_updateRatios_generic(), Vector< T, std::allocator< T > >::operator=(), Matrix< ST, qmcplusplus::Mallocator< ST > >::operator[](), qmcplusplus::MatrixOperators::product(), qmcplusplus::MatrixOperators::product_Atx(), Matrix< ST, qmcplusplus::Mallocator< ST > >::putMessage(), DiracDeterminantWithBackflow::ratio(), DiracDeterminantWithBackflow::ratioGrad(), TwoBodyJastrow< FT >::ratioGrad(), h5data_proxy< Vector< T > >::read(), DiracMatrixComputeOMPTarget< VALUE_FP >::reset(), RotatedSPOs::table_method_eval(), RotatedSPOs::table_method_evalWF(), qmcplusplus::TEST_CASE(), qmcplusplus::test_gemv_batched(), qmcplusplus::test_ger_batched(), qmcplusplus::test_LCAO_DiamondC_2x1x1_real(), DiracDeterminantWithBackflow::testDerivFjj(), DiracDeterminantWithBackflow::testL(), SoaDistanceTableAB< T, D, SC >::update(), SoaDistanceTableAA< T, D, SC >::update(), SoaDistanceTableABOMPTarget< T, D, SC >::update(), SoaDistanceTableAAOMPTarget< T, D, SC >::update(), DelayedUpdate< T, T_FP >::updateInvMat(), SoaDistanceTableAA< T, D, SC >::updatePartial(), SoaDistanceTableAAOMPTarget< T, D, SC >::updatePartial(), Vector< T, std::allocator< T > >::Vector(), h5data_proxy< Vector< T > >::write(), and EstimatorManagerNew::writeScalarH5().

238 { return X; }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ data() [2/2]

const_pointer data ( ) const
inline

Definition at line 239 of file OhmmsVector.h.

239 { return X; }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ destroy_elements()

static void destroy_elements ( Type_t ptr,
size_type  n_elements 
)
inlinestaticprivate

Definition at line 323 of file OhmmsVector.h.

Referenced by Vector< T, std::allocator< T > >::free(), and Vector< T, std::allocator< T > >::resize().

324  {
325  if constexpr (!std::is_trivial<T>::value && qmc_allocator_traits<Alloc>::is_host_accessible)
326  for (size_type i = 0; i < n_elements; i++)
327  (ptr + i)->~Type_t();
328  }
static constexpr bool is_host_accessible
typename Alloc::size_type size_type
Definition: OhmmsVector.h:40

◆ device_data() [1/2]

◆ device_data() [2/2]

const_pointer device_data ( ) const
inline

Definition at line 250 of file OhmmsVector.h.

251  {
252  return mAllocator.get_device_ptr();
253  }
Alloc mAllocator
allocator
Definition: OhmmsVector.h:288

◆ end() [1/2]

◆ end() [2/2]

const_iterator end ( ) const
inline

Definition at line 236 of file OhmmsVector.h.

236 { return X + nLocal; }
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ first_address() [1/2]

pointer first_address ( )
inline

◆ first_address() [2/2]

const_pointer first_address ( ) const
inline

Definition at line 256 of file OhmmsVector.h.

256 { return X; }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ free()

◆ last_address() [1/2]

pointer last_address ( )
inline

◆ last_address() [2/2]

const_pointer last_address ( ) const
inline

Definition at line 259 of file OhmmsVector.h.

259 { return X + nLocal; }
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ operator=() [1/3]

Vector& operator= ( const Vector< T, Alloc > &  rhs)
inline

Definition at line 93 of file OhmmsVector.h.

94  {
95  if (this == &rhs)
96  return *this;
97  if (nLocal != rhs.nLocal)
98  resize(rhs.nLocal);
100  std::copy_n(rhs.data(), nLocal, X);
101  else
103  return *this;
104  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
static constexpr bool is_host_accessible
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
size_type nLocal
size
Definition: OhmmsVector.h:282
static void fill_n(value_type *ptr, size_t n, const value_type &value)
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ operator=() [2/3]

Vector& operator= ( const Vector< T1, C1 > &  rhs)
inline

Definition at line 108 of file OhmmsVector.h.

109  {
110  if (std::is_convertible<T1, T>::value)
111  {
112  if (nLocal != rhs.nLocal)
113  resize(rhs.nLocal);
114  std::copy_n(rhs.data(), nLocal, X);
115  }
116  return *this;
117  }
void resize(size_type n, Type_t val=Type_t())
Resize the container.
Definition: OhmmsVector.h:166
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ operator=() [3/3]

Vector& operator= ( const RHS &  rhs)
inline

Definition at line 121 of file OhmmsVector.h.

122  {
123  assign(*this, rhs);
124  return *this;
125  }
Matrix< T1, C1 > & assign(Matrix< T1, C1 > &lhs, const RHS &rhs)

◆ operator[]() [1/2]

Type_t& operator[] ( size_type  i)
inline

Definition at line 211 of file OhmmsVector.h.

212  {
213  return X[i];
214  }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ operator[]() [2/2]

const Type_t& operator[] ( size_type  i) const
inline

Definition at line 217 of file OhmmsVector.h.

218  {
219  return X[i];
220  }
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ resize()

void resize ( size_type  n,
Type_t  val = Type_t() 
)
inline

Resize the container.

For performance consideration, previous data may or may not get kept. Please avoid relying on previous data after resizing.

Definition at line 166 of file OhmmsVector.h.

Referenced by CombinedTraceSample< TraceReal >::add_component(), qmcplusplus::applyCuspCorrection(), BackflowTransformation::BackflowTransformation(), EinsplineSetBuilder::BroadcastOrbitalInfo(), LatticeGaussianProductBuilder::buildComponent(), MultiSlaterDetTableMethod::calcIndividualDetRatios(), qmcplusplus::complex_test_case(), SpaceWarpTransformation::computeSWT(), qmcplusplus::double_test_case(), JeeIOrbitalSoA< FT >::evalGradSource(), CoulombPBCAB::evalPerParticleConsts(), RotatedSPOs::evaluateDerivatives(), MultiSlaterDetTableMethod::evaluateDerivativesMSD(), JeeIOrbitalSoA< FT >::evaluateDerivRatios(), BareKineticEnergy::evaluateOneBodyOpMatrix(), BareKineticEnergy::evaluateOneBodyOpMatrixForceDeriv(), NonLocalECPComponent::evaluateOneWithForces(), SOECPComponent::evaluateValueAndDerivatives(), NonLocalECPComponent::evaluateValueAndDerivatives(), FakeSPO::FakeSPO(), EwaldHandlerQuasi2D::fillFk(), EwaldHandler2D::fillFk(), EwaldHandler3D::fillFk(), LRRPABFeeHandlerTemp< Func, BreakupBasis >::fillFk(), LRRPAHandlerTemp< Func, BreakupBasis >::fillFk(), LRHandlerTemp< Func, BreakupBasis >::fillFk(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillVk(), LRRPABFeeHandlerTemp< Func, BreakupBasis >::fillXk(), LRRPAHandlerTemp< Func, BreakupBasis >::fillXk(), LRHandlerTemp< Func, BreakupBasis >::fillXk(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillYk(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkg(), EwaldHandler3D::fillYkgstrain(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkgstrain(), ForceBase::ForceBase(), JeeIOrbitalSoA< FT >::init(), DummyLRHandler< Func >::initBreakup(), LRHandlerSRCoulomb< Func, BreakupBasis >::InitBreakup(), Backflow_ee_kSpace::initialize(), J1Spin< FT >::initialize(), DensityMatrices1B::initialize(), J1OrbitalSoA< FT >::initialize(), ForceCeperley::InitMatrix(), ForceChiesaPBCAA::InitMatrix(), LatticeGaussianProduct::LatticeGaussianProduct(), ForceChiesaPBCAA::makeClone(), MomentumDistribution::MomentumDistribution(), MultiSlaterDetTableMethod::MultiSlaterDetTableMethod(), BareKineticEnergy::mw_evaluatePerParticle(), CoulombPBCAB::mw_evaluatePerParticle(), NonLocalECPotential::NonLocalECPotential(), OneBodyDensityMatrices::normalizeBasis(), OneBodyDensityMatrices::OneBodyDensityMatrices(), Vector< T, std::allocator< T > >::operator=(), EnergyDensityEstimator::put(), LCAOSpinorBuilder::putFromH5(), LCAOrbitalBuilder::putOccupation(), MomentumEstimator::putSpecial(), h5data_proxy< Vector< T > >::read(), EinsplineSetBuilder::ReadOrbitalInfo_ESHDF(), PWBasis::reset(), container_traits< Vector< T, ALLOC > >::resize(), SoaDistanceTableAB< T, D, SC >::resize(), MomentumEstimator::resize(), AGPDeterminant::resize(), SoaDistanceTableAA< T, D, SC >::resize(), DelayedUpdate< T, T_FP >::resize(), Array< T, D >::resize(), PWRealOrbitalSet::resize(), DelayedUpdateSYCL< T, T_FP >::resize(), DelayedUpdateCUDA< T, T_FP >::resize(), BasisSetBase< T >::resize(), SoaDistanceTableAAOMPTarget< T, D, SC >::resize(), Matrix< ST, qmcplusplus::Mallocator< ST > >::resize(), BackflowFunctionBase::resize(), DiracDeterminantWithBackflow::resize(), MultiDiracDeterminant::resize(), ParticleSet::resize(), SplineC2R< ST >::resize_kpoints(), SplineC2C< ST >::resize_kpoints(), SplineC2R< ST >::resizeStorage(), SplineR2R< ST >::resizeStorage(), SplineC2C< ST >::resizeStorage(), SplineC2COMPTarget< ST >::resizeStorage(), SplineC2ROMPTarget< ST >::resizeStorage(), J1Spin< FT >::resizeWFOptVectors(), J1OrbitalSoA< FT >::resizeWFOptVectors(), JeeIOrbitalSoA< FT >::resizeWFOptVectors(), TwoBodyJastrow< FT >::resizeWFOptVectors(), EnergyDensityEstimator::set_ptcl(), SkAllEstimator::SkAllEstimator(), SkEstimator::SkEstimator(), SkPot::SkPot(), SoaCartesianTensor< T >::SoaCartesianTensor(), SoaDistanceTableABOMPTarget< T, D, SC >::SoaDistanceTableABOMPTarget(), EstimatorManagerBase::start(), EstimatorManagerNew::startDriverRun(), RotatedSPOs::table_method_eval(), RotatedSPOs::table_method_evalWF(), qmcplusplus::TEST_CASE(), qmcplusplus::test_gemv_batched(), qmcplusplus::test_ger_batched(), qmcplusplus::test_J3_polynomial3D(), qmcplusplus::test_lcao_spinor(), qmcplusplus::test_lcao_spinor_excited(), BackflowTransformation::testDeriv(), SlaterDetWithBackflow::testDerivGL(), DiracDeterminantWithBackflow::testGG(), DiracDeterminantWithBackflow::testGGG(), EstimatorManagerNewTest::testMakeBlockAverages(), BackflowTransformation::testPbyP(), EinsplineSetBuilder::TileIons(), and VirtualParticleSet::VirtualParticleSet().

167  {
168  static_assert(std::is_same<value_type, typename Alloc::value_type>::value,
169  "Vector and Alloc data types must agree!");
170  if (nLocal > nAllocated)
171  throw std::runtime_error("Resize not allowed on Vector constructed by initialized memory.");
172 
173  if (n > nAllocated)
174  {
175  if (nLocal)
177  resize_impl(n);
178  construct_fill_elements(X, n, val);
179  }
180  else
181  {
182  if (n > nLocal)
184  if (n < nLocal)
185  destroy_elements(X + n, nLocal - n);
186  nLocal = n;
187  }
188  }
static void destroy_elements(Type_t *ptr, size_type n_elements)
Definition: OhmmsVector.h:323
static void construct_fill_elements(Type_t *ptr, size_type n_elements, const Type_t &val)
Definition: OhmmsVector.h:302
void resize_impl(size_type n)
a dumb resize, always free existing memory and resize to n. n must be protected positive ...
Definition: OhmmsVector.h:291
size_type nLocal
size
Definition: OhmmsVector.h:282
size_type nAllocated
The number of allocated.
Definition: OhmmsVector.h:284
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

◆ resize_impl()

void resize_impl ( size_type  n)
inlineprivate

a dumb resize, always free existing memory and resize to n. n must be protected positive

Definition at line 291 of file OhmmsVector.h.

Referenced by Vector< T, std::allocator< T > >::resize(), and Vector< T, std::allocator< T > >::Vector().

292  {
293  if (nAllocated)
294  {
295  mAllocator.deallocate(X, nAllocated);
296  }
297  X = mAllocator.allocate(n);
298  nLocal = n;
299  nAllocated = n;
300  }
size_type nLocal
size
Definition: OhmmsVector.h:282
size_type nAllocated
The number of allocated.
Definition: OhmmsVector.h:284
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286
Alloc mAllocator
allocator
Definition: OhmmsVector.h:288

◆ size()

size_type size ( void  ) const
inline

return the current size

Definition at line 162 of file OhmmsVector.h.

Referenced by qmcplusplus::accum_constant(), qmcplusplus::accum_sample(), SelfHealingOverlap::accumulate(), BackflowBuilder::addRPA(), LeafFunctor< Vector< T, C >, SizeLeaf >::apply(), LeafFunctor< ParticleAttrib< T >, SizeLeafPA >::apply(), qmcplusplus::applyCuspCorrection(), PAOps< T, 3, T1 >::axpy(), PAOps< T, 2, T1 >::axpy(), SoaSphericalTensor< ST >::batched_evaluateVGL(), SoaCartesianTensor< T >::batched_evaluateVGL(), Communicate::bcast(), EinsplineSetBuilder::BroadcastOrbitalInfo(), MultiDiracDeterminant::build_occ_vec(), qmcplusplus::check_force_copy(), EstimatorManagerBase::collectBlockAverages(), CombinedTraceSample< TraceReal >::combine(), DensityMatrices1B::compare(), qmcplusplus::complex_test_case(), qmcplusplus::computeRadialPhiBar(), ParticleSet::convert(), ParticleSet::convert2Cart(), ParticleSet::convert2Unit(), qmcplusplus::convertToReal(), PAOps< T, 3, T1 >::copy(), SplineC2R< ST >::create_spline(), SplineR2R< ST >::create_spline(), SplineC2C< ST >::create_spline(), SplineC2COMPTarget< ST >::create_spline(), SplineC2ROMPTarget< ST >::create_spline(), ParticleSet::createSK(), qmcplusplus::double_test_case(), SelfHealingOverlapLegacy::evaluate(), qmcplusplus::evaluate(), RotatedSPOs::evaluateDerivatives(), MultiDiracDeterminant::evaluateDerivatives(), TrialWaveFunction::evaluateDerivatives(), MultiDiracDeterminant::evaluateDerivativesWF(), MultiSlaterDetTableMethod::evaluateDerivativesWF(), MultiSlaterDetTableMethod::evaluateDerivRatios(), LRHandlerBase::evaluateGrad(), MultiSlaterDetTableMethod::evaluateLog(), SOECPComponent::evaluateValueAndDerivatives(), NonLocalECPComponent::evaluateValueAndDerivatives(), EwaldHandlerQuasi2D::fillFk(), EwaldHandler2D::fillFk(), EwaldHandler3D::fillFk(), LRRPABFeeHandlerTemp< Func, BreakupBasis >::fillFk(), LRRPAHandlerTemp< Func, BreakupBasis >::fillFk(), LRHandlerTemp< Func, BreakupBasis >::fillFk(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillYk(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkg(), EwaldHandler3D::fillYkgstrain(), LRHandlerSRCoulomb< Func, BreakupBasis >::fillYkgstrain(), SoaAtomicBasisSet< ROT, SH >::finalize(), DensityMatrices1B::get_energies(), MCWalkerConfiguration::getParticleNum(), container_traits< Vector< T, ALLOC > >::getSize(), h5data_proxy< Vector< T > >::h5data_proxy(), SpaceGrid::initialize_voronoi(), Array< T, D >::last_address(), EstimatorManagerNew::makeBlockAverages(), qmcplusplus::makeGaussRandom(), qmcplusplus::makeGaussRandomWithEngine(), BackflowBuilder::makeLongRange_twoBody(), VirtualParticleSet::makeMoves(), VirtualParticleSet::makeMovesWithSpin(), qmcplusplus::testing::makeRngVector(), qmcplusplus::makeUniformRandom(), SoaDistanceTableAAOMPTarget< T, D, SC >::move(), DiracMatrixComputeCUDA< VALUE_FP >::mw_computeInvertAndLog_stride(), MultiDiracDeterminant::mw_InverseUpdateByColumn(), VirtualParticleSet::mw_makeMoves(), VirtualParticleSet::mw_makeMovesWithSpin(), MultiDiracDeterminant::mw_updateRatios(), MultiDiracDeterminant::mw_updateRatios_det0(), qmcplusplus::operator==(), qmcplusplus::operator>>(), putContent(), EinsplineSetBuilder::ReadOrbitalInfo_ESHDF(), ParticleSet::resetGroups(), DensityMatrices1B::same(), PAOps< T, 3, T1 >::scale(), PAOps< T, 2, T1 >::scale(), EnergyDensityEstimator::set_ptcl(), RealSpacePositions::setAllParticlePos(), RealSpacePositionsOMPTarget::setAllParticlePos(), Array< T, D >::size(), EstimatorManagerBase::start(), EstimatorManagerBase::stop(), EstimatorManagerBase::stopBlock(), qmcplusplus::Sum(), Array< T, D >::sum(), TraceSample< TraceReal >::sum(), TEST_CASE(), qmcplusplus::TEST_CASE(), qmcplusplus::test_diamond_2x1x1_xml_input(), TraceSample< TraceReal >::TraceSample(), SymmetryGroup::TransformAllPositions(), SoaDistanceTableAA< T, D, SC >::update(), SoaDistanceTableAAOMPTarget< T, D, SC >::update(), Vector< T, std::allocator< T > >::updateFrom(), SoaDistanceTableAA< T, D, SC >::updatePartial(), SoaDistanceTableAAOMPTarget< T, D, SC >::updatePartial(), Vector< T, std::allocator< T > >::updateTo(), Vector< T, std::allocator< T > >::Vector(), and EstimatorManagerNew::writeScalarH5().

162 { return nLocal; }
size_type nLocal
size
Definition: OhmmsVector.h:282

◆ updateFrom()

void updateFrom ( size_type  size = 0,
std::ptrdiff_t  offset = 0 
)
inline

Definition at line 272 of file OhmmsVector.h.

Referenced by Array< T, D >::updateFrom(), and Matrix< ST, qmcplusplus::Mallocator< ST > >::updateFrom().

273  {
274  if (size == 0)
276  else
278  }
size_type size() const
return the current size
Definition: OhmmsVector.h:162
static void updateFrom(Allocator &a, value_type *host_ptr, size_t n, size_t offset=0)
size_type nLocal
size
Definition: OhmmsVector.h:282
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286
Alloc mAllocator
allocator
Definition: OhmmsVector.h:288

◆ updateTo()

◆ zero()

void zero ( )
inline

Definition at line 193 of file OhmmsVector.h.

static void fill_n(value_type *ptr, size_t n, const value_type &value)
size_type nAllocated
The number of allocated.
Definition: OhmmsVector.h:284
T * X
pointer to the data accessed through this object
Definition: OhmmsVector.h:286

Member Data Documentation

◆ mAllocator

◆ nAllocated

◆ nLocal

◆ X


The documentation for this class was generated from the following file: