|
| constexpr | AScalar ()=default |
| | Default constructor. Element is uninitialized.
|
| constexpr | AScalar (const Accessor &data) |
| | Construct from a copy of the given accessor.
|
| constexpr | AScalar (Accessor &&data) |
| | Construct from a moved accessor.
|
| constexpr | AScalar (const T &val) |
| | Construct from a single value (requires the Accessor to have a 1-argument constructor).
|
| constexpr | ~AScalar ()=default |
| | Destructor.
|
| constexpr | AScalar (const AScalar< T, Accessor > &)=default |
| | Copy constructor (shallow).
|
| constexpr | AScalar (AScalar< T, Accessor > &&)=default |
| | Move constructor (shallow).
|
| constexpr AScalar< T, Accessor > & | operator= (const AScalar< T, Accessor > &other) |
| | Copy assignment (deep — copies the stored value).
|
| constexpr AScalar< T, Accessor > & | operator= (AScalar< T, Accessor > &&other) |
| | Move assignment (deep — copies the stored value).
|
| template<typename OtherScalarType> |
| constexpr | AScalar (const OtherScalarType &other) |
| | Deep copy constructor from a different AScalar accessor or ownership.
|
| template<typename OtherScalarType> |
| constexpr | AScalar (OtherScalarType &&other) |
| | Deep move constructor from a different AScalar accessor or ownership.
|
| template<typename OtherScalarType> |
| constexpr AScalar< T, Accessor > & | operator= (const OtherScalarType &other) |
| | Deep copy assignment from a different AScalar accessor or ownership.
|
| template<typename OtherScalarType> |
| constexpr AScalar< T, Accessor > & | operator= (OtherScalarType &&other) |
| | Deep move assignment from a different AScalar accessor or ownership.
|
| constexpr AScalar< T, Accessor > & | operator= (const T val) |
| | Assignment from a raw arithmetic value.
|
| constexpr | operator T () const |
| | Implicit conversion to the underlying arithmetic type.
|
| constexpr T & | value () |
| | Primary named accessor — returns a reference to the stored value.
|
| constexpr const T & | value () const |
| constexpr T & | operator[] (size_t index) |
| | Subscript accessor for compatibility with generic index-based code (index must be 0).
|
| constexpr const T & | operator[] (size_t index) const |
| constexpr T & | operator() () |
| | Call-operator accessor (no argument — returns the value directly).
|
| constexpr const T & | operator() () const |
| constexpr T & | operator() (size_t index) |
| | Call-operator accessor with an index argument (index must be 0, for generic compatibility).
|
| constexpr const T & | operator() (size_t index) const |
| constexpr decltype(auto) | data () |
| | Access the underlying accessor data.
|
| constexpr decltype(auto) | data () const |
| constexpr void | set (const T &val) |
| | Set the stored value.
|
| constexpr void | fill (const T &val) |
| | Fill the scalar with a value (synonym for set; mirrors AVector::fill).
|
| constexpr deep_copy_t | copy () const |
| | Return an owning deep copy of this scalar.
|
| template<typename U> |
| constexpr auto | cast () const |
| | Cast the value to a different arithmetic type and return an owning AScalar.
|
| constexpr AScalar< T > | operator+ () const |
| | Unary plus.
|
| constexpr AScalar< T > | operator- () const |
| | Unary minus.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator+ (const AScalar< U, OtherAccessor > &other) const |
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AScalar< T, Accessor > & | operator+= (const AScalar< U, OtherAccessor > &other) |
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator- (const AScalar< U, OtherAccessor > &other) const |
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AScalar< T, Accessor > & | operator-= (const AScalar< U, OtherAccessor > &other) |
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator* (const AScalar< U, OtherAccessor > &other) const |
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AScalar< T, Accessor > & | operator*= (const AScalar< U, OtherAccessor > &other) |
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr auto | operator/ (const AScalar< U, OtherAccessor > &other) const |
| | Division — promotes integral/integral pairs to double, matching AVector::operator/ semantics.
|
| template<typename U, ValidAccessor< U > OtherAccessor> |
| constexpr AScalar< T, Accessor > & | operator/= (const AScalar< U, OtherAccessor > &other) |
| | Self-division — does NOT type-promote (integer division is possible).
|
| template<typename U> |
| constexpr auto | operator+ (const U &scalar) const |
| template<typename U> |
| constexpr AScalar< T, Accessor > & | operator+= (const U &scalar) |
| template<typename U> |
| constexpr auto | operator- (const U &scalar) const |
| template<typename U> |
| constexpr AScalar< T, Accessor > & | operator-= (const U &scalar) |
| template<typename U> |
| constexpr auto | operator* (const U &scalar) const |
| template<typename U> |
| constexpr AScalar< T, Accessor > & | operator*= (const U &scalar) |
| template<typename U> |
| constexpr auto | operator/ (const U &scalar) const |
| | Division by arithmetic scalar — promotes integral/integral pairs to double.
|
| template<typename U> |
| constexpr AScalar< T, Accessor > & | operator/= (const U &scalar) |
| | Self-division by arithmetic scalar — does NOT type-promote.
|
template<typename T, ValidAccessor< T > Accessor>
class mundy::AScalar< T, Accessor >
AScalar is the scalar analogue of AVector and AMatrix. It holds a single arithmetic value through a templated Accessor, which may be owning (e.g., Array<T,1>) or non-owning (e.g., a pointer or Kokkos::View slice). This separation of concerns — storage policy vs. value semantics — mirrors the rest of the Mundy math library and makes AScalar Kokkos-compatible.
The primary interface is value(), operator T() (implicit conversion to the underlying type), and the full set of arithmetic operators. AScalar participates naturally in expressions with AVector and AMatrix through non-member operators defined at the bottom of this file.
double raw[1] = {2.0};
Vector3<double> v{1.0, 2.0, 3.0};
auto scaled = v * s;
auto doubled = s * s;
double x = s;
friend class AScalar
Definition Scalar.hpp:498
AScalar< T, Array< T, 1 > > Scalar
Owning scalar with the default Array<T,1> accessor.
Definition Scalar.hpp:520
- Note
- Accessors may be owning or non-owning; they should be lightweight so they can be copied cheaply. The lifetime of the underlying data must exceed the lifetime of any AScalar that views it.