![]() |
OpenVDB 14.0.0
|
Base class for fixed-size matrices. Provides shared element-wise arithmetic, scalar arithmetic, equality, transpose, mat*mat, and mat*vec. Storage is a flat row-major array mData[ROWS * COLS]. Derived classes supply constructors plus any dimension-specific extras (e.g. inverse() on Mat2).
More...
#include <nanovdb/math/Math.h>
Public Types | |
| using | ValueType = T |
Public Member Functions | |
| MatBase () noexcept=default | |
Default-construct (entries are left uninitialized for trivially-default-constructible T). | |
| template<typename S> | |
| __hostdev__ constexpr | MatBase (S *array) noexcept |
Read ROWS*COLS elements from array in row-major order, converting each element from S to T via static_cast. | |
| __hostdev__ constexpr T * | operator[] (int row) noexcept |
2D row access. Returns a pointer to the start of row; the caller indexes into it with the column. Asserts 0 <= row < ROWS in debug builds; column index is the caller's responsibility (use 0 <= col < COLS). | |
| __hostdev__ constexpr const T * | operator[] (int row) const noexcept |
Const overload of operator[](int); see non-const variant. | |
| __hostdev__ constexpr T * | data () noexcept |
| return a raw pointer to the underlying 1D storage (row-major) | |
| __hostdev__ constexpr const T * | data () const noexcept |
| return a const raw pointer to the underlying 1D storage (row-major) | |
| template<typename Derived> | |
| __hostdev__ constexpr Derived | plus (const Derived &rhs) const noexcept |
return *this + rhs as a Derived | |
| template<typename Derived> | |
| __hostdev__ constexpr Derived | minus (const Derived &rhs) const noexcept |
return *this - rhs as a Derived | |
| template<typename Derived> | |
| __hostdev__ constexpr Derived | negate () const noexcept |
return -(*this) as a Derived | |
| template<typename Derived> | |
| __hostdev__ constexpr Derived | scale (T s) const noexcept |
return s * (*this) as a Derived | |
| __hostdev__ constexpr MatBase & | addAssign (const MatBase &rhs) noexcept |
Element-wise add rhs into *this and return *this. | |
| __hostdev__ constexpr MatBase & | subAssign (const MatBase &rhs) noexcept |
Element-wise subtract rhs from *this and return *this. | |
| __hostdev__ constexpr MatBase & | scaleAssign (T s) noexcept |
Multiply every element by scalar s in place; return *this. s is taken by value so m *= m[0][0] scales every element by the original value. | |
| template<typename Derived> | |
| __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 MatBase & | divideAssignScalar (T s) noexcept |
Divide every element 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 m /= m[0][0] is safe. | |
| __hostdev__ constexpr bool | equals (const MatBase &rhs) const noexcept |
Return true iff every element compares equal to rhs. | |
| template<typename Result> | |
| __hostdev__ constexpr Result | transposeAs () const noexcept |
return the transpose of *this as the Result type. | |
| template<typename Result, typename Rhs> | |
| __hostdev__ constexpr Result | multiply (const Rhs &rhs) const noexcept |
return (*this) * rhs as the Result type. | |
| template<typename VecResult, typename VecRhs> | |
| __hostdev__ constexpr VecResult | multiplyVec (const VecRhs &v) const noexcept |
return (*this) * v as the VecResult type. | |
Static Public Member Functions | |
| static __hostdev__ constexpr int | rows () noexcept |
| Compile-time row count. | |
| static __hostdev__ constexpr int | cols () noexcept |
| Compile-time column count. | |
| static __hostdev__ constexpr int | size () noexcept |
Compile-time element count, i.e. ROWS * COLS. | |
Protected Member Functions | |
| template<typename... Args> | |
| __hostdev__ constexpr | MatBase (Args... args) noexcept |
Variadic component-init ctor — used only by derived ctors (Mat2(T a, T b, T c, T d) : Base(a, b, c, d) {}). The member-init list directly initializes mData, avoiding the default-construct- then-assign that a body-assignment ctor would impose on a non-fundamental T. | |
Static Protected Member Functions | |
| template<typename Result, typename F, int... I> | |
| static __hostdev__ constexpr Result | generate (F f, std::integer_sequence< int, I... >) noexcept |
Return a Result whose row-major element idx is f(idx), built through its Count-element constructor. This is constexpr-valid in C++17 without first value-initializing a result and overwriting it. | |
| template<typename Result, int Count = ROWS * COLS, typename F> | |
| static __hostdev__ constexpr Result | generate (F f) noexcept |
Protected Attributes | |
| T | mData [ROWS *COLS] |
Base class for fixed-size matrices. Provides shared element-wise arithmetic, scalar arithmetic, equality, transpose, mat*mat, and mat*vec. Storage is a flat row-major array mData[ROWS * COLS]. Derived classes supply constructors plus any dimension-specific extras (e.g. inverse() on Mat2).
| using ValueType = T |
|
defaultnoexcept |
Default-construct (entries are left uninitialized for trivially-default-constructible T).
|
inlineconstexprnoexcept |
Read ROWS*COLS elements from array in row-major order, converting each element from S to T via static_cast.
|
inlineexplicitconstexprprotectednoexcept |
Variadic component-init ctor — used only by derived ctors (Mat2(T a, T b, T c, T d) : Base(a, b, c, d) {}). The member-init list directly initializes mData, avoiding the default-construct- then-assign that a body-assignment ctor would impose on a non-fundamental T.
|
inlineconstexprnoexcept |
Element-wise add rhs into *this and return *this.
|
inlinestaticnodiscardconstexprnoexcept |
Compile-time column count.
|
inlineconstexprnoexcept |
return a const raw pointer to the underlying 1D storage (row-major)
|
inlineconstexprnoexcept |
return a raw pointer to the underlying 1D storage (row-major)
|
inlineconstexprnoexcept |
Divide every element 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 m /= m[0][0] is safe.
|
inlinenodiscardconstexprnoexcept |
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.
|
inlinenodiscardconstexprnoexcept |
Return true iff every element compares equal to rhs.
|
inlinestaticconstexprprotectednoexcept |
|
inlinestaticconstexprprotectednoexcept |
Return a Result whose row-major element idx is f(idx), built through its Count-element constructor. This is constexpr-valid in C++17 without first value-initializing a result and overwriting it.
|
inlinenodiscardconstexprnoexcept |
return *this - rhs as a Derived
|
inlinenodiscardconstexprnoexcept |
return (*this) * rhs as the Result type.
| Result | a matrix type whose dimensions are (ROWS, Rhs::cols()) |
| Rhs | a matrix type whose row count equals COLS |
|
inlinenodiscardconstexprnoexcept |
return (*this) * v as the VecResult type.
| VecResult | a vector type whose SIZE equals ROWS |
| VecRhs | a vector type whose SIZE equals COLS |
|
inlinenodiscardconstexprnoexcept |
return -(*this) as a Derived
|
inlineconstexprnoexcept |
Const overload of operator[](int); see non-const variant.
|
inlineconstexprnoexcept |
2D row access. Returns a pointer to the start of row; the caller indexes into it with the column. Asserts 0 <= row < ROWS in debug builds; column index is the caller's responsibility (use 0 <= col < COLS).
|
inlinenodiscardconstexprnoexcept |
return *this + rhs as a Derived
|
inlinestaticnodiscardconstexprnoexcept |
Compile-time row count.
|
inlinenodiscardconstexprnoexcept |
return s * (*this) as a Derived
|
inlineconstexprnoexcept |
Multiply every element by scalar s in place; return *this. s is taken by value so m *= m[0][0] scales every element by the original value.
|
inlinestaticnodiscardconstexprnoexcept |
Compile-time element count, i.e. ROWS * COLS.
|
inlineconstexprnoexcept |
Element-wise subtract rhs from *this and return *this.
|
inlinenodiscardconstexprnoexcept |
return the transpose of *this as the Result type.
| Result | a matrix type whose dimensions are (COLS, ROWS) |
|
protected |