|
| constexpr | AVector ()=default |
| | Default constructor. Assume elements are uninitialized.
|
| constexpr | AVector (const Accessor &data) |
| | Constructor from a given accessor.
|
| constexpr | AVector (Accessor &&data) |
| | Constructor from a given accessor.
|
| constexpr | AVector (const T &value) |
| | Constructor to initialize all elements to a single value. Requires the number of arguments to be N and the type of each to be T. Only enabled if the Accessor has a N-argument constructor.
|
| template<typename... Args> |
| constexpr | AVector (Args &&... args) |
| | Constructor to initialize all elements explicitly. Requires the number of arguments to be N and the type of each to be T. Only enabled if the Accessor has a N-argument constructor.
|
| constexpr | ~AVector ()=default |
| | Destructor.
|
| constexpr | AVector (const AVector< T, N, Accessor > &)=default |
| | Copy constructor (shallow).
|
| constexpr | AVector (AVector< T, N, Accessor > &&)=default |
| | Move constructor (shallow).
|
| constexpr AVector< T, N, Accessor > & | operator= (const AVector< T, N, Accessor > &other) |
| | Copy assignment (deep).
|
| constexpr AVector< T, N, Accessor > & | operator= (AVector< T, N, Accessor > &&other) |
| | Move assignment (deep).
|
| template<ValidVectorType OtherVectorType> |
| constexpr | AVector (const OtherVectorType &other) |
| | Deep copy constructor with different accessor or ownership Deep copy construction from different is often ill-advised since the accessor must be default constructed and then populated. For an accessor stored as a pointer (a T* or a T[N]), this is illegal.
|
| template<ValidVectorType OtherVectorType> |
| constexpr | AVector (OtherVectorType &&other) |
| | Deep move constructor with different accessor or ownership.
|
| template<ValidVectorType OtherVectorType> |
| constexpr AVector< T, N, Accessor > & | operator= (const OtherVectorType &other) |
| | Deep copy assignment operator with different accessor or ownership.
|
| template<ValidVectorType OtherVectorType> |
| constexpr AVector< T, N, Accessor > & | operator= (OtherVectorType &&other) |
| | Deep move assignment operator with different accessor or ownership.
|
| constexpr AVector< T, N, Accessor > & | operator= (const T value) |
| | Deep copy assignment operator from a single value.
|
| constexpr | operator T () |
| | Allow for automatic conversion of a length 1 vector to a scalar.
|
| constexpr T & | operator[] (size_t index) |
| | Element access operator via a single index.
|
| constexpr const T & | operator[] (size_t index) const |
| constexpr T & | operator() (size_t index) |
| | Element access operator via a single index.
|
| constexpr const T & | operator() (size_t index) const |
| constexpr decltype(auto) | data () |
| | Get the internal data accessor.
|
| constexpr decltype(auto) | data () const |
| constexpr deep_copy_t | copy () const |
| | Get a deep copy of the vector.
|
| template<typename U> |
| constexpr auto | cast () const |
| | Cast (and copy) the vector to a different type.
|
| template<size_t Offset, size_t Size> |
| constexpr auto | view_subset () |
| | Get a view into the Size entries starting at Offset.
|
| template<size_t Offset, size_t Size> |
| constexpr auto | view_subset () const |
| | Get a view into the Size entries starting at Offset.
|
| template<typename... Args> |
| constexpr void | set (Args &&... args) |
| | Set all elements of the vector.
|
| template<ValidAccessor< T > OtherAccessor> |
| constexpr void | set (const OtherAccessor &accessor) |
| | Set all elements of the vector using an accessor.
|
| constexpr void | fill (const T &value) |
| | Set all elements of the vector to a single value.
|
| constexpr AVector< T, N > | operator+ () const |
| | Unary plus operator.
|
| constexpr AVector< T, N > | operator- () const |
| | Unary minus operator.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator+ (const AVector< U, N, OtherAccessor > &other) const -> AVector< scalar_sum_result_t< T, U >, N > |
| | AVector-vector addition.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AVector< T, N, Accessor > & | operator+= (const AVector< U, N, OtherAccessor > &other) |
| | AVector-vector addition.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator- (const AVector< U, N, OtherAccessor > &other) const -> AVector< scalar_difference_result_t< T, U >, N > |
| | AVector-vector subtraction.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AVector< T, N, Accessor > & | operator-= (const AVector< U, N, OtherAccessor > &other) |
| | Self-vector subtraction.
|
| template<typename U> |
| constexpr auto | operator+ (const U &scalar) const -> AVector< scalar_sum_result_t< T, U >, N > |
| | AVector-scalar addition.
|
| template<typename U> |
| constexpr AVector< T, N, Accessor > & | operator+= (const U &scalar) |
| | Self-scalar addition.
|
| template<typename U> |
| constexpr auto | operator- (const U &scalar) const -> AVector< scalar_difference_result_t< T, U >, N > |
| | AVector-scalar subtraction.
|
| template<typename U> |
| constexpr AVector< T, N, Accessor > & | operator-= (const U &scalar) |
| | AVector-scalar subtraction.
|
| template<typename U> |
| constexpr auto | operator* (const U &scalar) const -> AVector< scalar_product_result_t< T, U >, N > |
| | AVector-scalar multiplication.
|
| template<typename U> |
| constexpr AVector< T, N, Accessor > & | operator*= (const U &scalar) |
| | Self-scalar multiplication.
|
| template<typename U> |
| constexpr auto | operator/ (const U &scalar) const -> AVector< scalar_quotient_result_t< T, U >, N > |
| | AVector-scalar division. (Type promotes the result to a double if both vector and scalar are integral.).
|
| template<typename U> |
| constexpr AVector< T, N, Accessor > & | operator/= (const U &scalar) |
| | Self-scalar division (Does not type-promote the result!!).
|
template<typename
T, size_t N, ValidAccessor<
T > Accessor>
class mundy::AVector< T, N, Accessor >
- Template Parameters
-
| T | The type of the entries. |
| Accessor | The type of the accessor. |
This class is designed to be used with Kokkos. It is a simple Nx1 vector with scalar entries. It is templated on the type of the entries and Accessor type. See Accessor.hpp for more details on the Accessor type requirements.
The goal of AVector is to be a lightweight class that can be used with Kokkos to perform mathematical operations on vectors in R3. It does not own the data, but rather it is templated on an Accessor type that provides access to the underlying data. This allows us to use AVector with Kokkos::Views, raw pointers, or any other type that meets the ValidAccessor requirements without copying the data. This is especially important for GPU-compatible code.
Vectors can be constructed by passing an accessor to the constructor. However, if the accessor has a N-argument constructor, then the AVector can also be constructed by passing the elements directly to the constructor. Similarly, if the accessor has an initializer list constructor, then the AVector can be constructed by passing an initializer list to the constructor. This is a convenience feature which makes working with the default accessor (Array<T, N>) easier. For example, the following are all valid ways to construct an AVector:
double data[3] = {1.0, 2.0, 3.0};
Class for an Nx1 vector with scalar-like entries.
Definition Vector.hpp:115
constexpr decltype(auto) data()
Get the internal data accessor.
Definition Vector.hpp:338
friend class AVector
Definition Vector.hpp:559
constexpr void set(Args &&... args)
Set all elements of the vector.
Definition Vector.hpp:382
A simplistic array type with a fixed size and type.
Definition Array.hpp:42
constexpr auto dot(const AQuaternion< U, Accessor1 > &q1, const AQuaternion< T, Accessor2 > &q2)
Get the dot product of two quaternions.
Definition Quaternion.hpp:780
- Note
- Accessors may be owning or non-owning, that is irrelevant to the AVector class; however, these accessors should be lightweight such that they can be copied around without much overhead. Furthermore, the lifetime of the data underlying the accessor should be as long as the AVector that use it.