5#include <Kokkos_Core.hpp>
26template<
typename ValueType>
99 template<
typename func>
171 requires requires(ValueType a, ValueType b) { a* b; };
182 requires requires(ValueType a,
scalar b) { a* b; };
193 requires requires(ValueType a, ValueType b) { a *= b; };
203 requires requires(ValueType a,
scalar b) { a *= b; };
215 [[nodiscard]] ValueType*
data() {
return data_; }
221 [[nodiscard]]
const ValueType*
data()
const {
return data_; }
245 [[nodiscard]]
bool empty()
const {
return size() == 0; }
303 [[nodiscard]] std::pair<localIdx, localIdx>
range()
const {
return {0,
size()}; }
308 ValueType* data_ {
nullptr};
315 void validateOtherVector(
const Vector<ValueType>& rhs)
const;
324template<
typename ValueType>
333template<
typename ValueType>
Reference executor for serial CPU execution.
A class to contain the data and executors for a field and define some basic operations.
Vector(const Executor &exec, const ValueType *in, localIdx size, Executor hostExec=SerialExecutor())
Create a Vector with a given size from existing memory on an executor.
Vector(Vector< ValueType > &&rhs) noexcept
Move constructor, moves the data from the parsed field to the new field.
ValueType & operator[](const localIdx i)=delete
Vector(const Vector< ValueType > &rhs)
Copy constructor, creates a new field with the same size and data as the parsed field.
localIdx size() const
Gets the size of the field.
Vector< ValueType > copyToExecutor(Executor dstExec) const
Copies the data to a new field on a specific executor.
Vector< ValueType > operator*(const Vector< ValueType > &rhs)
Arithmetic multiply operator, multiply by a second field.
Vector(const Executor &exec, const Vector< ValueType > &in)
Create a Vector as a copy of a Vector on a specified executor.
View< ValueType > view(std::pair< localIdx, localIdx > range) &
Gets a sub view of the field as a view.
ValueType * data()
Direct access to the underlying field data.
Vector(const Executor &exec, localIdx size, ValueType value)
Create a Vector with a given size on an executor and uniform value.
std::pair< localIdx, localIdx > range() const
Gets the range of the field.
View< const ValueType > view(std::pair< localIdx, localIdx > range) const &&=delete
label ssize() const
Gets the size of the field.
Vector(const Executor &exec, localIdx size)
Create an uninitialized Vector with a given size on an executor.
void operator=(const ValueType &rhs)
Assignment operator, Sets the field values to that of the passed value.
View< const ValueType > view() const &
Gets the field as a view.
Vector< ValueType > & operator*=(const scalar rhs)
Assignment multiply operator, multiplies every cell in the field by a scalar.
View< const ValueType > view(std::pair< localIdx, localIdx > range) const &
Gets a sub view of the field as a view.
const ValueType * data() const
Direct access to the underlying field data.
void resize(const localIdx size)
Resizes the field to a new size.
Vector< ValueType > & operator*=(const Vector< ValueType > &rhs)
Assignment multiply operator, multiplies this field by another field element-wise.
bool empty() const
Checks if the field is empty.
void apply(func f)
applies a functor, transformation, to the field
Vector< ValueType > operator*(const scalar rhs)
Arithmetic multiply operator, multiplies every cell in the field by a scalar.
const Executor & exec() const
Gets the executor associated with the field.
Vector< ValueType > & operator+=(const Vector< ValueType > &rhs)
Arithmetic add operator, addition of a second field.
~Vector()
Destroy the Vector object.
View< ValueType > view(std::pair< localIdx, localIdx > range) &&=delete
ValueType VectorValueType
Vector(const Executor &exec, std::vector< ValueType > in)
Create a Vector from a given vector of values on an executor.
void copyToHost(Vector< ValueType > &result)
Copies the data (from anywhere) to a parsed host field.
View< ValueType > view() &&=delete
Vector< ValueType > copyToHost() const
Returns a copy of the field back to the host.
Vector< ValueType > & operator-=(const Vector< ValueType > &rhs)
Arithmetic subtraction operator, subtraction by a second field.
const ValueType & operator[](const localIdx i) const =delete
void operator=(const Vector< ValueType > &rhs)
Assignment operator, Sets the field values to that of the parsed field.
View< const ValueType > view() const &&=delete
Vector< ValueType > operator-(Vector< ValueType > lhs, const Vector< ValueType > &rhs)
Arithmetic subtraction operator, subtraction one field from another.
void map(ContType< ValueType > &cont, const Inner inner, std::pair< localIdx, localIdx > range={0, 0})
Map a field using a specific executor.
Vector< ValueType > operator+(Vector< ValueType > lhs, const Vector< ValueType > &rhs)
Arithmetic add operator, addition of two fields.
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor