74 int Alignment = (((NumCol * NumRow) % 4 == 0) ? 4 : 1) *
sizeof(
T)>
82 static constexpr int min_dim = (NumRow < NumCol) ? NumRow : NumCol;
101 requires(NumCol == 3)
109 requires(NumCol == 4)
119 template<
typename U,
int OtherNumCol,
int OtherNumRow>
122 if constexpr ((OtherNumRow >= NumRow) && (OtherNumCol >= NumCol)) {
129 if (i < OtherNumCol && j < OtherNumRow) {
130 (*this)[i][j] = other[i][j];
133 (*this)[i][j] =
T(1);
136 (*this)[i][j] =
T(0);
152 requires(std::is_convertible_v<U, T>)
173 return *
reinterpret_cast<const c_style_mat *
>(
this);
185 return reinterpret_cast<const T *
>(
this);
191 return reinterpret_cast<T *
>(
this);
196 template<
int ViewNumCol = NumCol,
197 int ViewNumRow = NumRow,
207 template<
int ViewNumCol = NumCol,
208 int ViewNumRow = NumRow,
246 return *
reinterpret_cast<vec3_type *
>(&(*this)[0]);
253 return *
reinterpret_cast<vec3_type *
>(&(*this)[1]);
260 return *
reinterpret_cast<vec3_type *
>(&(*this)[2]);
267 return *
reinterpret_cast<loc_type *
>(&(*this)[NumCol - 1]);
274 return *
reinterpret_cast<const vec3_type *
>(&(*this)[0]);
281 return *
reinterpret_cast<const vec3_type *
>(&(*this)[1]);
288 return *
reinterpret_cast<const vec3_type *
>(&(*this)[2]);
295 return *
reinterpret_cast<const loc_type *
>(&(*this)[NumCol - 1]);
425 for (
int i = 0; i < NumCol; i++) {
468 T value = (
reinterpret_cast<const T *
>(
this))[i];
477 const T &value = (
reinterpret_cast<const T *
>(
this))[i];
485 for (
int i = 0; i < NumRow; i++) {
487 for (
int j = 0; j < NumCol; j++) {
490 if (j < NumCol - 1) {
495 if (i < NumRow - 1) {
530 BLI_STATIC_ASSERT(SrcStartCol >= 0,
"View does not fit source matrix dimensions");
531 BLI_STATIC_ASSERT(SrcStartRow >= 0,
"View does not fit source matrix dimensions");
533 "View does not fit source matrix dimensions");
535 "View does not fit source matrix dimensions");
539 explicit MatView(
const float (*src)[SrcNumRow])
548 return *
reinterpret_cast<const col_type *
>(&
mat[
index + SrcStartCol][SrcStartRow]);
581 template<
int OtherSrcNumCol,
583 int OtherSrcStartCol,
584 int OtherSrcStartRow,
585 int OtherSrcAlignment>
594 OtherSrcAlignment> &
b)
606 template<
int OtherSrcNumCol,
608 int OtherSrcStartCol,
609 int OtherSrcStartRow,
610 int OtherSrcAlignment>
618 OtherSrcAlignment> &a,
647 return *
this *
b.view();
689 for (
int i = 0; i < NumCol; i++) {
723 :
MatView<T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment> {
757 template<
int OtherSrcNumCol,
759 int OtherSrcStartCol,
760 int OtherSrcStartRow,
761 int OtherSrcAlignment>
769 OtherSrcAlignment> &other)
772 (
reinterpret_cast<const void *
>(&other.mat[0][0]) !=
773 reinterpret_cast<const void *
>(&this->mat[0][0])) ||
775 ((OtherSrcStartCol > SrcStartCol) || (OtherSrcStartCol + NumCol <= SrcStartCol) ||
776 (OtherSrcStartRow > SrcStartRow + NumRow) ||
777 (OtherSrcStartRow + NumRow <= SrcStartRow)),
778 "Operation is undefined if views overlap.");
785 *
this = other.
view();
791 template<
int OtherSrcNumCol,
793 int OtherSrcStartCol,
794 int OtherSrcStartRow,
795 int OtherSrcAlignment>
803 OtherSrcAlignment> &
b) &
811 return *
this +=
b.view();
820 template<
int OtherSrcNumCol,
822 int OtherSrcStartCol,
823 int OtherSrcStartRow,
824 int OtherSrcAlignment>
832 OtherSrcAlignment> &
b) &
840 return *
this -=
b.view();
850 template<
int OtherSrcNumCol,
852 int OtherSrcStartCol,
853 int OtherSrcStartRow,
854 int OtherSrcAlignment>
862 OtherSrcAlignment> &
b) &
864 *
this = *
static_cast<MatViewT *
>(
this) *
b;
870 return *
this *=
b.view();
914 static_assert(A_NumCol == B_NumRow);
929template<
typename T,
int A_NumCol,
int A_NumRow,
int B_NumCol,
int B_NumRow>
#define BLI_assert_msg(a, msg)
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
MatBase< T, B_NumCol, A_NumRow > matrix_mul_impl(const MatA &a, const MatB &b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
MatBase< double, 4, 2 > double4x2
MatBase< float, 2, 2 > float2x2
MatBase< float, 2, 3 > float2x3
MatBase< float, 4, 4 > float4x4
MatBase< float, 2, 4 > float2x4
MatBase< double, 3, 3 > double3x3
MatBase< float, 3, 4 > float3x4
MatBase< double, 3, 4 > double3x4
MatView< float, 4, 4, 4, 4, 0, 0, alignof(float)> float4x4_view
MatBase< double, 2, 2 > double2x2
MatBase< float, 4, 2 > float4x2
MatBase< float, 3, 2 > float3x2
MatBase< float, 4, 3 > float4x3
MatBase< float, 3, 3 > float3x3
MutableMatView< float, 4, 4, 4, 4, 0, 0, alignof(float)> float4x4_mutableview
MatBase< double, 2, 4 > double2x4
MatBase< double, 3, 2 > double3x2
MatBase< double, 4, 3 > double4x3
void hash_unique_default(const T &value, UniqueHashBytes &hash)
MatBase< double, 2, 3 > double2x3
MatBase< T, B_NumCol, A_NumRow > operator*(const MatBase< T, A_NumCol, A_NumRow > &a, const MatBase< T, B_NumCol, B_NumRow > &b)
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
MatBase< double, 4, 4 > double4x4
constexpr void unroll(Fn fn)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
friend MatBase operator-(const MatBase &a)
MatBase(col_type _x, col_type _y, col_type _z, col_type _w)
static MatBase diagonal(T value)
friend MatBase operator*(const MatBase &a, T b)
MatBase(col_type _x, col_type _y)
friend MatBase operator-(T a, const MatBase &b)
friend MatBase operator+(T a, const MatBase &b)
static constexpr int col_len
MatBase(const MatBase< U, NumRow, NumCol > &vec)
VecBase< T, NumRow > col_type
static constexpr int row_len
MatBase(const T(*ptr)[NumCol])
col_type & operator[](int index)
T[NumCol][NumRow] c_style_mat
friend col_type operator*(const MatBase &a, const row_type &b)
MutableMatView< T, ViewNumCol, ViewNumRow, NumCol, NumRow, SrcStartCol, SrcStartRow, Alignment > view()
static constexpr int min_dim
friend MatBase operator+(const MatBase &a, T b)
const vec3_type & z_axis() const
friend MatBase operator*(T a, const MatBase &b)
const vec3_type & x_axis() const
friend MatBase operator-(const MatBase &a, T b)
const col_type & operator[](int index) const
MatBase & operator*=(const MatBase &b) &
MatBase(col_type _x, col_type _y, col_type _z)
friend row_type operator*(const col_type &a, const MatBase &b)
friend MatBase operator+(const MatBase &a, const MatBase &b)
VecBase< T, 3 > vec3_type
friend std::ostream & operator<<(std::ostream &stream, const MatBase &mat)
VecBase< T,(NumRow< NumCol) ? NumRow :(NumRow - 1)> loc_type
MatBase & operator-=(const MatBase &b) &
const c_style_mat & ptr() const
VecBase< T, NumCol > row_type
friend MatBase operator-(const MatBase &a, const MatBase &b)
const vec3_type & y_axis() const
MatBase & operator+=(const MatBase &b) &
MatBase & operator+=(T b) &
MatBase(const MatBase< U, OtherNumCol, OtherNumRow > &other)
friend bool operator!=(const MatBase &a, const MatBase &b)
const MatView< T, ViewNumCol, ViewNumRow, NumCol, NumRow, SrcStartCol, SrcStartRow, Alignment > view() const
friend bool operator==(const MatBase &a, const MatBase &b)
static MatBase all(T value)
void hash_unique(UniqueHashBytes &hash) const
MatBase & operator-=(T b) &
MatBase & operator*=(T b) &
const loc_type & location() const
const T * base_ptr() const
static MatBase identity()
friend MatT operator-(const MatView &a, const MatView< T, NumCol, NumRow, OtherSrcNumCol, OtherSrcNumRow, OtherSrcStartCol, OtherSrcStartRow, OtherSrcAlignment > &b)
const col_type & operator[](int index) const
friend MatT operator-(const MatT &a, const MatView &b)
MatT operator*(const MatT &b) const
MatView(const SrcMatT &src)
friend MatT operator*(const MatView &a, T b)
MatBase< T, SrcNumCol, SrcNumRow, SrcAlignment > SrcMatT
friend bool operator!=(const MatView &a, const MatView &b)
friend MatT operator-(const MatView &a, T b)
friend MatT operator-(const MatView &a)
friend std::ostream & operator<<(std::ostream &stream, const MatView &mat)
friend col_type operator*(const MatView &a, const row_type &b)
MatBase< T, NumCol, NumRow > MatT
friend bool operator==(const MatView &a, const MatView &b)
friend MatT operator-(const MatView< T, NumCol, NumRow, OtherSrcNumCol, OtherSrcNumRow, OtherSrcStartCol, OtherSrcStartRow, OtherSrcAlignment > &a, const MatView &b)
friend row_type operator*(const col_type &a, const MatView &b)
friend MatT operator+(const MatView &a, T b)
friend MatT operator+(T a, const MatView &b)
friend MatT operator-(const MatView &a, const MatT &b)
MatView(const float(*src)[SrcNumRow])
VecBase< T, NumCol > row_type
friend MatT operator*(T a, const MatView &b)
VecBase< T, NumRow > col_type
friend MatView operator-(T a, const MatView &b)
friend col_type operator*(MutableMatView &a, const row_type &b)
friend row_type operator*(const col_type &a, MutableMatView &b)
MutableMatView & operator+=(const MatT &b) &
MutableMatView & operator*=(const MatT &b) &
col_type & operator[](int index)
MutableMatView & operator+=(T b) &
MatBase< T, NumCol, NumRow > MatT
MutableMatView & operator*=(const MatView< T, NumCol, NumRow, OtherSrcNumCol, OtherSrcNumRow, OtherSrcStartCol, OtherSrcStartRow, OtherSrcAlignment > &b) &
MutableMatView & operator+=(const MatView< T, NumCol, NumRow, OtherSrcNumCol, OtherSrcNumRow, OtherSrcStartCol, OtherSrcStartRow, OtherSrcAlignment > &b) &
MutableMatView(SrcMatT &src)
MutableMatView & operator-=(const MatView< T, NumCol, NumRow, OtherSrcNumCol, OtherSrcNumRow, OtherSrcStartCol, OtherSrcStartRow, OtherSrcAlignment > &b) &
MutableMatView & operator=(const MatView< T, NumCol, NumRow, OtherSrcNumCol, OtherSrcNumRow, OtherSrcStartCol, OtherSrcStartRow, OtherSrcAlignment > &other)
MutableMatView(float src[SrcNumCol][SrcNumRow])
MutableMatView & operator-=(const MatT &b) &
MatBase< T, SrcNumCol, SrcNumRow, SrcAlignment > SrcMatT
MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > MatViewT
MutableMatView & operator=(const MatT &other)
MutableMatView & operator*=(T b) &
VecBase< T, NumCol > row_type
MutableMatView & operator-=(T b) &
VecBase< T, NumRow > col_type