OpenVDB 13.2.0
Loading...
Searching...
No Matches
Vec4Aligned< T > Struct Template Reference

Over-aligned Vec4 for user-owned arrays; see Vec2Aligned. More...

#include <nanovdb/math/Math.h>

Public Types

using ValueType = T

Public Member Functions

 Vec4Aligned () noexcept=default
__hostdev__ constexpr Vec4Aligned (const Vec4< T > &v) noexcept
__hostdev__ constexpr Vec4 operator- () const noexcept
 Component-wise negation.
__hostdev__ constexpr Vec4 operator- (const Vec4 &v) const noexcept
 Component-wise difference.
__hostdev__ constexpr Vec4 operator+ (const Vec4 &v) const noexcept
 Component-wise sum.
__hostdev__ constexpr Vec4 operator* (const Vec4 &v) const noexcept
 Component-wise (Hadamard) product.
__hostdev__ constexpr Vec4 operator* (const T &s) const noexcept
 Component-wise multiply by scalar s.
__hostdev__ constexpr Vec4 operator/ (const Vec4 &v) const noexcept
 Component-wise division.
__hostdev__ constexpr Vec4 operator/ (const T &s) const noexcept
 Component-wise divide by scalar s (integer-safe).
__hostdev__ constexpr Vec4 & operator+= (const Vec4 &v) noexcept
 In-place component-wise addition.
__hostdev__ constexpr Vec4 & operator-= (const Vec4 &v) noexcept
 In-place component-wise subtraction.
__hostdev__ constexpr Vec4 & operator*= (const T &s) noexcept
 In-place component-wise multiply by scalar s.
__hostdev__ constexpr Vec4 & operator/= (const T &s) noexcept
 In-place component-wise divide by scalar s.
__hostdev__ Vec4 & normalize () noexcept
 Normalize in place (divide by length()). Not constexpr — calls std::sqrt.
__hostdev__ Vec4 normalized () const noexcept
 Return a normalized (unit-length) copy; const counterpart of normalize().
__hostdev__ constexpr bool operator== (const Vec4 &rhs) const noexcept
 Component-wise equality.
__hostdev__ constexpr bool operator!= (const Vec4 &rhs) const noexcept
 Component-wise inequality.
__hostdev__ constexpr Vec4 & minComponent (const Vec4 &other) noexcept
 Take the component-wise minimum of *this and other in place.
__hostdev__ constexpr Vec4 & maxComponent (const Vec4 &other) noexcept
 Take the component-wise maximum of *this and other in place.
__hostdev__ constexpr ValueType min () const noexcept
 Return the smallest vector component.
__hostdev__ constexpr ValueType max () const noexcept
 Return the largest vector component.
__hostdev__ constexpr Vec4< int32_t > floor () const noexcept
 Round each component down (toward negative infinity)
__hostdev__ constexpr Vec4< int32_t > ceil () const noexcept
 Round each component up (toward positive infinity)
__hostdev__ constexpr Vec4< int32_t > round () const noexcept
 Round each component to its closest integer value.
__hostdev__ constexpr const T & operator[] (int i) const noexcept
 Indexed element access. Asserts 0 <= i < N in debug builds.
__hostdev__ constexpr T & operator[] (int i) noexcept
__hostdev__ constexpr const T & x () const noexcept
__hostdev__ constexpr T & x () noexcept
__hostdev__ constexpr const T & y () const noexcept
__hostdev__ constexpr T & y () noexcept
__hostdev__ constexpr const T & z () const noexcept
__hostdev__ constexpr T & z () noexcept
__hostdev__ constexpr const T & w () const noexcept
__hostdev__ constexpr T & w () noexcept
__hostdev__ constexpr T * asPointer () noexcept
 raw pointer to the underlying N-element storage
__hostdev__ constexpr const T * asPointer () const noexcept
__hostdev__ constexpr Derived plus (const Derived &rhs) const noexcept
 Return *this + rhs as a Derived.
__hostdev__ constexpr Derived minus (const Derived &rhs) const noexcept
 Return *this - rhs as a Derived.
__hostdev__ constexpr Derived mul (const Derived &rhs) const noexcept
 Return component-wise *this * rhs as a Derived (Hadamard product).
__hostdev__ constexpr Derived div (const Derived &rhs) const noexcept
 Return component-wise *this / rhs as a Derived.
__hostdev__ constexpr Derived negate () const noexcept
 Return -(*this) as a Derived.
__hostdev__ constexpr Derived scale (T s) const noexcept
 Return s * (*this) as a Derived (scalar broadcast).
__hostdev__ constexpr Derived divideBy (T s) const noexcept
 Return (*this) / s element-wise as a Derived. Floating-point T multiplies by the reciprocal 1/s; integer T divides each element, since 1/s would truncate to zero.
__hostdev__ constexpr VecBase & addAssign (const VecBase &rhs) noexcept
 Component-wise add rhs into *this and return *this.
__hostdev__ constexpr VecBase & subAssign (const VecBase &rhs) noexcept
 Component-wise subtract rhs from *this and return *this.
__hostdev__ constexpr VecBase & mulAssign (const VecBase &rhs) noexcept
 Component-wise multiply *this by rhs (Hadamard product) and return *this.
__hostdev__ constexpr VecBase & divAssign (const VecBase &rhs) noexcept
 Component-wise divide *this by rhs and return *this.
__hostdev__ constexpr VecBase & scaleAssign (T s) noexcept
 Multiply every component by scalar s in place; return *this. s is taken by value so v *= v[0] scales every component by the original value.
__hostdev__ constexpr VecBase & divideAssignScalar (T s) noexcept
 Divide every component by scalar s in place; return *this. Uses the same floating-point reciprocal / integer per-element split as divideBy. s is taken by value so v /= v[0] is safe.
__hostdev__ constexpr bool equals (const VecBase &rhs) const noexcept
 Return true iff every component compares equal to rhs.
__hostdev__ constexpr T dot (const V &v) const noexcept
 dot product. V must have operator[] valid for 0..N-1. Sums in the promoted type of the element products and converts to T once on return, so e.g. Vec3i::dot(Vec3d) does not truncate partial sums.
__hostdev__ constexpr T lengthSqr () const noexcept
 Squared L2 length (sum of squared components). Constexpr, no sqrt.
__hostdev__ T length () const noexcept
 L2 length (Euclidean norm). Not constexpr — calls Sqrt.
__hostdev__ constexpr T smallestComponent () const noexcept
 return the smallest of the N components
__hostdev__ constexpr T largestComponent () const noexcept
 return the largest of the N components
__hostdev__ constexpr VecBase & mergeMin (const V &other) noexcept
 Component-wise take the min of *this and other (in place); return *this.
__hostdev__ constexpr VecBase & mergeMax (const V &other) noexcept
 Component-wise take the max of *this and other (in place); return *this.
__hostdev__ constexpr Result floorAs () const noexcept
 floor-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value is passed through.
__hostdev__ constexpr Result ceilAs () const noexcept
 ceil-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value is passed through.
__hostdev__ constexpr Result roundAs () const noexcept
 nearest-integer rounding for floating T via the scalar math::Round (halfway cases toward +inf, exact for every input), so float and double agree; pass-through for integer T.

Static Public Attributes

static constexpr int size = 4
static constexpr int SIZE

Static Protected Member Functions

static __hostdev__ constexpr Derived generate (F f, std::integer_sequence< int, I... >) noexcept
 Return a Derived whose component i is f(i), built through its N-component constructor. This is constexpr-valid in C++17 without first value-initializing a result and overwriting it.
static __hostdev__ constexpr Derived generate (F f) noexcept

Protected Attributes

T mVec [N]

Detailed Description

template<typename T>
struct nanovdb::math::Vec4Aligned< T >

Over-aligned Vec4 for user-owned arrays; see Vec2Aligned.

Member Typedef Documentation

◆ ValueType

template<typename T>
using ValueType = T
inherited

Constructor & Destructor Documentation

◆ Vec4Aligned() [1/2]

template<typename T>
Vec4Aligned ( )
defaultnoexcept

◆ Vec4Aligned() [2/2]

template<typename T>
__hostdev__ constexpr Vec4Aligned ( const Vec4< T > & v)
inlineconstexprnoexcept

Member Function Documentation

◆ addAssign()

__hostdev__ constexpr VecBase & addAssign ( const VecBase< T, 4 > & rhs)
inlineconstexprnoexceptinherited

Component-wise add rhs into *this and return *this.

◆ asPointer() [1/2]

__hostdev__ constexpr const T * asPointer ( ) const
inlineconstexprnoexceptinherited

◆ asPointer() [2/2]

__hostdev__ constexpr T * asPointer ( )
inlineconstexprnoexceptinherited

raw pointer to the underlying N-element storage

◆ ceil()

template<typename T>
__hostdev__ constexpr Vec4< int32_t > ceil ( ) const
inlinenodiscardconstexprnoexceptinherited

Round each component up (toward positive infinity)

Returns
Vec4<int32_t>
Note
Only constexpr for integer T (ceilAs uses non-constexpr math::Ceil for floating point).

◆ ceilAs()

__hostdev__ constexpr Result ceilAs ( ) const
inlinenodiscardconstexprnoexceptinherited

ceil-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value is passed through.

Note
Only the integer-T specialization is usable as a constant expression; the floating-point branch calls math::Ceil, which isn't constexpr until C++23.

◆ div()

__hostdev__ constexpr Derived div ( const Derived & rhs) const
inlinenodiscardconstexprnoexceptinherited

Return component-wise *this / rhs as a Derived.

◆ divAssign()

__hostdev__ constexpr VecBase & divAssign ( const VecBase< T, 4 > & rhs)
inlineconstexprnoexceptinherited

Component-wise divide *this by rhs and return *this.

◆ divideAssignScalar()

__hostdev__ constexpr VecBase & divideAssignScalar ( T s)
inlineconstexprnoexceptinherited

Divide every component by scalar s in place; return *this. Uses the same floating-point reciprocal / integer per-element split as divideBy. s is taken by value so v /= v[0] is safe.

◆ divideBy()

__hostdev__ constexpr Derived divideBy ( T s) const
inlinenodiscardconstexprnoexceptinherited

Return (*this) / s element-wise as a Derived. Floating-point T multiplies by the reciprocal 1/s; integer T divides each element, since 1/s would truncate to zero.

◆ dot()

__hostdev__ constexpr T dot ( const V & v) const
inlinenodiscardconstexprnoexceptinherited

dot product. V must have operator[] valid for 0..N-1. Sums in the promoted type of the element products and converts to T once on return, so e.g. Vec3i::dot(Vec3d) does not truncate partial sums.

◆ equals()

__hostdev__ constexpr bool equals ( const VecBase< T, 4 > & rhs) const
inlinenodiscardconstexprnoexceptinherited

Return true iff every component compares equal to rhs.

◆ floor()

template<typename T>
__hostdev__ constexpr Vec4< int32_t > floor ( ) const
inlinenodiscardconstexprnoexceptinherited

Round each component down (toward negative infinity)

Returns
Vec4<int32_t> (NanoVDB has no Coord4)
Note
Only constexpr for integer T (floorAs uses non-constexpr math::Floor for floating point).

◆ floorAs()

__hostdev__ constexpr Result floorAs ( ) const
inlinenodiscardconstexprnoexceptinherited

floor-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value is passed through.

Note
Only the integer-T specialization is usable as a constant expression; the floating-point branch calls math::Floor, which isn't constexpr until C++23.

◆ generate() [1/2]

__hostdev__ constexpr Derived generate ( F f)
inlinestaticconstexprprotectednoexceptinherited

◆ generate() [2/2]

__hostdev__ constexpr Derived generate ( F f,
std::integer_sequence< int, I... >  )
inlinestaticconstexprprotectednoexceptinherited

Return a Derived whose component i is f(i), built through its N-component constructor. This is constexpr-valid in C++17 without first value-initializing a result and overwriting it.

◆ largestComponent()

__hostdev__ constexpr T largestComponent ( ) const
inlinenodiscardconstexprnoexceptinherited

return the largest of the N components

◆ length()

__hostdev__ T length ( ) const
inlinenodiscardnoexceptinherited

L2 length (Euclidean norm). Not constexpr — calls Sqrt.

◆ lengthSqr()

__hostdev__ constexpr T lengthSqr ( ) const
inlinenodiscardconstexprnoexceptinherited

Squared L2 length (sum of squared components). Constexpr, no sqrt.

◆ max()

template<typename T>
__hostdev__ constexpr ValueType max ( ) const
inlinenodiscardconstexprnoexceptinherited

Return the largest vector component.

◆ maxComponent()

template<typename T>
__hostdev__ constexpr Vec4 & maxComponent ( const Vec4< T > & other)
inlineconstexprnoexceptinherited

Take the component-wise maximum of *this and other in place.

◆ mergeMax()

__hostdev__ constexpr VecBase & mergeMax ( const V & other)
inlineconstexprnoexceptinherited

Component-wise take the max of *this and other (in place); return *this.

◆ mergeMin()

__hostdev__ constexpr VecBase & mergeMin ( const V & other)
inlineconstexprnoexceptinherited

Component-wise take the min of *this and other (in place); return *this.

◆ min()

template<typename T>
__hostdev__ constexpr ValueType min ( ) const
inlinenodiscardconstexprnoexceptinherited

Return the smallest vector component.

◆ minComponent()

template<typename T>
__hostdev__ constexpr Vec4 & minComponent ( const Vec4< T > & other)
inlineconstexprnoexceptinherited

Take the component-wise minimum of *this and other in place.

◆ minus()

__hostdev__ constexpr Derived minus ( const Derived & rhs) const
inlinenodiscardconstexprnoexceptinherited

Return *this - rhs as a Derived.

◆ mul()

__hostdev__ constexpr Derived mul ( const Derived & rhs) const
inlinenodiscardconstexprnoexceptinherited

Return component-wise *this * rhs as a Derived (Hadamard product).

◆ mulAssign()

__hostdev__ constexpr VecBase & mulAssign ( const VecBase< T, 4 > & rhs)
inlineconstexprnoexceptinherited

Component-wise multiply *this by rhs (Hadamard product) and return *this.

◆ negate()

__hostdev__ constexpr Derived negate ( ) const
inlinenodiscardconstexprnoexceptinherited

Return -(*this) as a Derived.

◆ normalize()

template<typename T>
__hostdev__ Vec4 & normalize ( )
inlinenoexceptinherited

Normalize in place (divide by length()). Not constexpr — calls std::sqrt.

◆ normalized()

template<typename T>
__hostdev__ Vec4 normalized ( ) const
inlinenodiscardnoexceptinherited

Return a normalized (unit-length) copy; const counterpart of normalize().

◆ operator!=()

template<typename T>
__hostdev__ constexpr bool operator!= ( const Vec4< T > & rhs) const
inlinenodiscardconstexprnoexceptinherited

Component-wise inequality.

◆ operator*() [1/2]

template<typename T>
__hostdev__ constexpr Vec4 operator* ( const T & s) const
inlinenodiscardconstexprnoexceptinherited

Component-wise multiply by scalar s.

◆ operator*() [2/2]

template<typename T>
__hostdev__ constexpr Vec4 operator* ( const Vec4< T > & v) const
inlinenodiscardconstexprnoexceptinherited

Component-wise (Hadamard) product.

◆ operator*=()

template<typename T>
__hostdev__ constexpr Vec4 & operator*= ( const T & s)
inlineconstexprnoexceptinherited

In-place component-wise multiply by scalar s.

◆ operator+()

template<typename T>
__hostdev__ constexpr Vec4 operator+ ( const Vec4< T > & v) const
inlinenodiscardconstexprnoexceptinherited

Component-wise sum.

◆ operator+=()

template<typename T>
__hostdev__ constexpr Vec4 & operator+= ( const Vec4< T > & v)
inlineconstexprnoexceptinherited

In-place component-wise addition.

◆ operator-() [1/2]

template<typename T>
__hostdev__ constexpr Vec4 operator- ( ) const
inlinenodiscardconstexprnoexceptinherited

Component-wise negation.

◆ operator-() [2/2]

template<typename T>
__hostdev__ constexpr Vec4 operator- ( const Vec4< T > & v) const
inlinenodiscardconstexprnoexceptinherited

Component-wise difference.

◆ operator-=()

template<typename T>
__hostdev__ constexpr Vec4 & operator-= ( const Vec4< T > & v)
inlineconstexprnoexceptinherited

In-place component-wise subtraction.

◆ operator/() [1/2]

template<typename T>
__hostdev__ constexpr Vec4 operator/ ( const T & s) const
inlinenodiscardconstexprnoexceptinherited

Component-wise divide by scalar s (integer-safe).

◆ operator/() [2/2]

template<typename T>
__hostdev__ constexpr Vec4 operator/ ( const Vec4< T > & v) const
inlinenodiscardconstexprnoexceptinherited

Component-wise division.

◆ operator/=()

template<typename T>
__hostdev__ constexpr Vec4 & operator/= ( const T & s)
inlineconstexprnoexceptinherited

In-place component-wise divide by scalar s.

◆ operator==()

template<typename T>
__hostdev__ constexpr bool operator== ( const Vec4< T > & rhs) const
inlinenodiscardconstexprnoexceptinherited

Component-wise equality.

◆ operator[]() [1/2]

__hostdev__ constexpr const T & operator[] ( int i) const
inlineconstexprnoexceptinherited

Indexed element access. Asserts 0 <= i < N in debug builds.

◆ operator[]() [2/2]

__hostdev__ constexpr T & operator[] ( int i)
inlineconstexprnoexceptinherited

◆ plus()

__hostdev__ constexpr Derived plus ( const Derived & rhs) const
inlinenodiscardconstexprnoexceptinherited

Return *this + rhs as a Derived.

◆ round()

template<typename T>
__hostdev__ constexpr Vec4< int32_t > round ( ) const
inlinenodiscardconstexprnoexceptinherited

Round each component to its closest integer value.

Returns
Vec4<int32_t>
Note
Only constexpr for integer T (roundAs uses non-constexpr math::Round for floating point).

◆ roundAs()

__hostdev__ constexpr Result roundAs ( ) const
inlinenodiscardconstexprnoexceptinherited

nearest-integer rounding for floating T via the scalar math::Round (halfway cases toward +inf, exact for every input), so float and double agree; pass-through for integer T.

Note
See floorAs — only the integer-T branch is constexpr-usable.

◆ scale()

__hostdev__ constexpr Derived scale ( T s) const
inlinenodiscardconstexprnoexceptinherited

Return s * (*this) as a Derived (scalar broadcast).

◆ scaleAssign()

__hostdev__ constexpr VecBase & scaleAssign ( T s)
inlineconstexprnoexceptinherited

Multiply every component by scalar s in place; return *this. s is taken by value so v *= v[0] scales every component by the original value.

◆ smallestComponent()

__hostdev__ constexpr T smallestComponent ( ) const
inlinenodiscardconstexprnoexceptinherited

return the smallest of the N components

◆ subAssign()

__hostdev__ constexpr VecBase & subAssign ( const VecBase< T, 4 > & rhs)
inlineconstexprnoexceptinherited

Component-wise subtract rhs from *this and return *this.

◆ w() [1/2]

__hostdev__ constexpr const T & w ( ) const
inlineconstexprnoexceptinherited

◆ w() [2/2]

__hostdev__ constexpr T & w ( )
inlineconstexprnoexceptinherited

◆ x() [1/2]

__hostdev__ constexpr const T & x ( ) const
inlineconstexprnoexceptinherited

◆ x() [2/2]

__hostdev__ constexpr T & x ( )
inlineconstexprnoexceptinherited

◆ y() [1/2]

__hostdev__ constexpr const T & y ( ) const
inlineconstexprnoexceptinherited

◆ y() [2/2]

__hostdev__ constexpr T & y ( )
inlineconstexprnoexceptinherited

◆ z() [1/2]

__hostdev__ constexpr const T & z ( ) const
inlineconstexprnoexceptinherited

◆ z() [2/2]

__hostdev__ constexpr T & z ( )
inlineconstexprnoexceptinherited

Member Data Documentation

◆ mVec

T mVec[N]
protectedinherited

◆ SIZE

int SIZE
staticconstexprinherited

◆ size

template<typename T>
int size = 4
staticconstexprinherited