![]() |
OpenVDB 13.2.0
|
Opt-in over-aligned vectors for user-owned arrays, so each element can load with one full-width vector instruction (e.g. 128 bits for Vec4Aligned<float>). Whether that is faster depends on the access pattern and the GPU, so measure.
More...
#include <nanovdb/math/Math.h>
Public Types | |
| using | ValueType = T |
Public Member Functions | |
| Vec2Aligned () noexcept=default | |
| __hostdev__ constexpr | Vec2Aligned (const Vec2< T > &v) noexcept |
| __hostdev__ constexpr Vec2 | operator- () const noexcept |
| Component-wise negation. | |
| __hostdev__ constexpr Vec2 | operator- (const Vec2 &v) const noexcept |
| Component-wise difference. | |
| __hostdev__ constexpr Vec2 | operator- (const Coord2 &ijk) const noexcept |
Subtract an integer Coord2 from this vector (component-wise). | |
| __hostdev__ constexpr Vec2 | operator+ (const Vec2 &v) const noexcept |
| Component-wise sum. | |
| __hostdev__ constexpr Vec2 | operator+ (const Coord2 &ijk) const noexcept |
Add an integer Coord2 to this vector (component-wise). | |
| __hostdev__ constexpr Vec2 | operator* (const Vec2 &v) const noexcept |
| Component-wise (Hadamard) product. | |
| __hostdev__ constexpr Vec2 | operator* (const T &s) const noexcept |
| Component-wise multiply by scalar s. | |
| __hostdev__ constexpr Vec2 | operator/ (const Vec2 &v) const noexcept |
| Component-wise division. | |
| __hostdev__ constexpr Vec2 | operator/ (const T &s) const noexcept |
| Component-wise divide by scalar s (integer-safe). | |
| __hostdev__ constexpr Vec2 & | operator+= (const Vec2 &v) noexcept |
| In-place component-wise addition. | |
| __hostdev__ constexpr Vec2 & | operator+= (const Coord2 &ijk) noexcept |
In-place component-wise addition of an integer Coord2. | |
| __hostdev__ constexpr Vec2 & | operator-= (const Vec2 &v) noexcept |
| In-place component-wise subtraction. | |
| __hostdev__ constexpr Vec2 & | operator-= (const Coord2 &ijk) noexcept |
In-place component-wise subtraction of an integer Coord2. | |
| __hostdev__ constexpr Vec2 & | operator*= (const T &s) noexcept |
| In-place component-wise multiply by scalar s. | |
| __hostdev__ constexpr Vec2 & | operator/= (const T &s) noexcept |
| In-place component-wise divide by scalar s. | |
| __hostdev__ Vec2 & | normalize () noexcept |
Normalize in place (divide by length()). Not constexpr — calls std::sqrt. | |
| __hostdev__ Vec2 | normalized () const noexcept |
Return a normalized (unit-length) copy; const counterpart of normalize(). | |
| __hostdev__ constexpr bool | operator== (const Vec2 &rhs) const noexcept |
| Component-wise equality. | |
| __hostdev__ constexpr bool | operator!= (const Vec2 &rhs) const noexcept |
| Component-wise inequality. | |
| __hostdev__ constexpr Vec2 & | minComponent (const Vec2 &other) noexcept |
Take the component-wise minimum of *this and other in place. | |
| __hostdev__ constexpr Vec2 & | maxComponent (const Vec2 &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 Coord2 | floor () const noexcept |
| Round each component down (toward negative infinity) | |
| __hostdev__ constexpr Coord2 | ceil () const noexcept |
| Round each component up (toward positive infinity) | |
| __hostdev__ constexpr Coord2 | 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 = 2 |
| 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] |
Opt-in over-aligned vectors for user-owned arrays, so each element can load with one full-width vector instruction (e.g. 128 bits for Vec4Aligned<float>). Whether that is faster depends on the access pattern and the GPU, so measure.
Each derives from its Vec class and converts to and from it, so the Vec operators work unchanged and return the plain Vec type. Vec3Aligned is padded to four components, so an array of them is not layout-compatible with an array of Vec3. The plain Vec classes stay naturally aligned; see Vec4.
|
inherited |
|
defaultnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexceptinherited |
Component-wise add rhs into *this and return *this.
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
raw pointer to the underlying N-element storage
|
inlinenodiscardconstexprnoexceptinherited |
Round each component up (toward positive infinity)
T (ceilAs uses non-constexpr math::Ceil for floating point).
|
inlinenodiscardconstexprnoexceptinherited |
ceil-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value is passed through.
T specialization is usable as a constant expression; the floating-point branch calls math::Ceil, which isn't constexpr until C++23.
|
inlinenodiscardconstexprnoexceptinherited |
Return component-wise *this / rhs as a Derived.
|
inlineconstexprnoexceptinherited |
Component-wise divide *this by rhs and return *this.
|
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.
|
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.
|
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.
|
inlinenodiscardconstexprnoexceptinherited |
Return true iff every component compares equal to rhs.
|
inlinenodiscardconstexprnoexceptinherited |
Round each component down (toward negative infinity)
T (floorAs uses non-constexpr math::Floor for floating point).
|
inlinenodiscardconstexprnoexceptinherited |
floor-rounded components into the Result type (whose [i] must accept int32_t). For integer T the value is passed through.
T specialization is usable as a constant expression; the floating-point branch calls math::Floor, which isn't constexpr until C++23.
|
inlinestaticconstexprprotectednoexceptinherited |
|
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.
|
inlinenodiscardconstexprnoexceptinherited |
return the largest of the N components
|
inlinenodiscardnoexceptinherited |
L2 length (Euclidean norm). Not constexpr — calls Sqrt.
|
inlinenodiscardconstexprnoexceptinherited |
Squared L2 length (sum of squared components). Constexpr, no sqrt.
|
inlinenodiscardconstexprnoexceptinherited |
Return the largest vector component.
|
inlineconstexprnoexceptinherited |
Take the component-wise maximum of *this and other in place.
|
inlineconstexprnoexceptinherited |
Component-wise take the max of *this and other (in place); return *this.
|
inlineconstexprnoexceptinherited |
Component-wise take the min of *this and other (in place); return *this.
|
inlinenodiscardconstexprnoexceptinherited |
Return the smallest vector component.
|
inlineconstexprnoexceptinherited |
Take the component-wise minimum of *this and other in place.
|
inlinenodiscardconstexprnoexceptinherited |
Return *this - rhs as a Derived.
|
inlinenodiscardconstexprnoexceptinherited |
Return component-wise *this * rhs as a Derived (Hadamard product).
|
inlineconstexprnoexceptinherited |
Component-wise multiply *this by rhs (Hadamard product) and return *this.
|
inlinenodiscardconstexprnoexceptinherited |
Return -(*this) as a Derived.
|
inlinenoexceptinherited |
Normalize in place (divide by length()). Not constexpr — calls std::sqrt.
|
inlinenodiscardnoexceptinherited |
Return a normalized (unit-length) copy; const counterpart of normalize().
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise inequality.
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise multiply by scalar s.
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise (Hadamard) product.
|
inlineconstexprnoexceptinherited |
In-place component-wise multiply by scalar s.
|
inlinenodiscardconstexprnoexceptinherited |
Add an integer Coord2 to this vector (component-wise).
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise sum.
|
inlineconstexprnoexceptinherited |
In-place component-wise addition of an integer Coord2.
|
inlineconstexprnoexceptinherited |
In-place component-wise addition.
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise negation.
|
inlinenodiscardconstexprnoexceptinherited |
Subtract an integer Coord2 from this vector (component-wise).
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise difference.
|
inlineconstexprnoexceptinherited |
In-place component-wise subtraction of an integer Coord2.
|
inlineconstexprnoexceptinherited |
In-place component-wise subtraction.
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise divide by scalar s (integer-safe).
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise division.
|
inlineconstexprnoexceptinherited |
In-place component-wise divide by scalar s.
|
inlinenodiscardconstexprnoexceptinherited |
Component-wise equality.
|
inlineconstexprnoexceptinherited |
Indexed element access. Asserts 0 <= i < N in debug builds.
|
inlineconstexprnoexceptinherited |
|
inlinenodiscardconstexprnoexceptinherited |
Return *this + rhs as a Derived.
|
inlinenodiscardconstexprnoexceptinherited |
Round each component to its closest integer value.
T (roundAs uses non-constexpr math::Round for floating point).
|
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.
floorAs — only the integer-T branch is constexpr-usable.
|
inlinenodiscardconstexprnoexceptinherited |
Return s * (*this) as a Derived (scalar broadcast).
|
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.
|
inlinenodiscardconstexprnoexceptinherited |
return the smallest of the N components
|
inlineconstexprnoexceptinherited |
Component-wise subtract rhs from *this and return *this.
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
inlineconstexprnoexceptinherited |
|
protectedinherited |
|
staticconstexprinherited |
|
staticconstexprinherited |