Blender V4.3
BLI_math_matrix_types.hh File Reference
#include <array>
#include <cmath>
#include <ostream>
#include <type_traits>
#include "BLI_math_vector_types.hh"
#include "BLI_utildefines.h"
#include "BLI_utility_mixins.hh"

Go to the source code of this file.

Classes

struct  blender::MatBase< T, NumCol, NumRow, Alignment >
 
struct  blender::MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment >
 
struct  blender::MutableMatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment >
 

Namespaces

namespace  blender
 
namespace  blender::detail
 

Macros

#define BLI_ENABLE_IF_MAT(_size, _test)   int S = _size, BLI_ENABLE_IF((S _test))
 

Typedefs

using blender::float2x2 = MatBase<float, 2, 2>
 
using blender::float2x3 = MatBase<float, 2, 3>
 
using blender::float2x4 = MatBase<float, 2, 4>
 
using blender::float3x2 = MatBase<float, 3, 2>
 
using blender::float3x3 = MatBase<float, 3, 3>
 
using blender::float3x4 = MatBase<float, 3, 4>
 
using blender::float4x2 = MatBase<float, 4, 2>
 
using blender::float4x3 = MatBase<float, 4, 3>
 
using blender::float4x4 = MatBase<float, 4, 4>
 
using blender::float4x4_view = MatView<float, 4, 4, 4, 4, 0, 0, alignof(float)>
 
using blender::float4x4_mutableview = MutableMatView<float, 4, 4, 4, 4, 0, 0, alignof(float)>
 
using blender::double2x2 = MatBase<double, 2, 2>
 
using blender::double2x3 = MatBase<double, 2, 3>
 
using blender::double2x4 = MatBase<double, 2, 4>
 
using blender::double3x2 = MatBase<double, 3, 2>
 
using blender::double3x3 = MatBase<double, 3, 3>
 
using blender::double3x4 = MatBase<double, 3, 4>
 
using blender::double4x2 = MatBase<double, 4, 2>
 
using blender::double4x3 = MatBase<double, 4, 3>
 
using blender::double4x4 = MatBase<double, 4, 4>
 

Functions

template<typename T , int A_NumCol, int A_NumRow, int B_NumCol, int B_NumRow, typename MatA , typename MatB >
MatBase< T, B_NumCol, A_NumRow > blender::detail::matrix_mul_impl (const MatA &a, const MatB &b)
 
template<typename T , int A_NumCol, int A_NumRow, int B_NumCol, int B_NumRow>
MatBase< T, B_NumCol, A_NumRow > blender::operator* (const MatBase< T, A_NumCol, A_NumRow > &a, const MatBase< T, B_NumCol, B_NumRow > &b)
 
template<typename T , int A_NumCol, int A_NumRow, int A_SrcNumCol, int A_SrcNumRow, int A_SrcStartCol, int A_SrcStartRow, int A_SrcAlignment, int B_NumCol, int B_NumRow, int B_SrcNumCol, int B_SrcNumRow, int B_SrcStartCol, int B_SrcStartRow, int B_SrcAlignment>
MatBase< T, B_NumCol, A_NumRow > blender::operator* (const MatView< T, A_NumCol, A_NumRow, A_SrcNumCol, A_SrcNumRow, A_SrcStartCol, A_SrcStartRow, A_SrcAlignment > &a, const MatView< T, B_NumCol, B_NumRow, B_SrcNumCol, B_SrcNumRow, B_SrcStartCol, B_SrcStartRow, B_SrcAlignment > &b)
 
template<typename T , int A_NumCol, int A_NumRow, int A_SrcNumCol, int A_SrcNumRow, int A_SrcStartCol, int A_SrcStartRow, int A_SrcAlignment, int B_NumCol, int B_NumRow>
MatBase< T, B_NumCol, A_NumRow > blender::operator* (const MatView< T, A_NumCol, A_NumRow, A_SrcNumCol, A_SrcNumRow, A_SrcStartCol, A_SrcStartRow, A_SrcAlignment > &a, const MatBase< T, B_NumCol, B_NumRow > &b)
 
template<typename T , int A_NumCol, int A_NumRow, int B_NumCol, int B_NumRow, int B_SrcNumCol, int B_SrcNumRow, int B_SrcStartCol, int B_SrcStartRow, int B_SrcAlignment>
MatBase< T, B_NumCol, A_NumRow > blender::operator* (const MatBase< T, A_NumCol, A_NumRow > &a, const MatView< T, B_NumCol, B_NumRow, B_SrcNumCol, B_SrcNumRow, B_SrcStartCol, B_SrcStartRow, B_SrcAlignment > &b)
 
template<>
float4x4 blender::operator* (const float4x4 &a, const float4x4 &b)
 
template<>
float3x3 blender::operator* (const float3x3 &a, const float3x3 &b)
 
template float2x2 blender::operator* (const float2x2 &a, const float2x2 &b)
 
template double2x2 blender::operator* (const double2x2 &a, const double2x2 &b)
 
template double3x3 blender::operator* (const double3x3 &a, const double3x3 &b)
 
template double4x4 blender::operator* (const double4x4 &a, const double4x4 &b)
 

Detailed Description

Template for matrix types.

The blender::MatBase<T, NumCol, NumRow> is a Row x Col matrix (in mathematical notation) laid out as column major in memory.

This class overloads +, -, * and +=, -=, *= mathematical operators. They are all using per component operation, except for a few: MatBase<C,R> * Vector<C> the vector product with the matrix. Vector<R> * MatBase<C,R> the vector product with the transposed matrix. MatBase<C,R> * MatBase<R,C> and MatBase<C,R> *= MatBase<R,C> the matrix multiplication.

The blender::MatView allows working on a subset of a matrix without having to move the data around. It can be obtained using the MatBase.view<NumCol, NumRow>(). It is const by default if the matrix type is. Otherwise, a blender::MutableMatView is returned.

A blender::MutableMatView. It is mostly the same as blender::MatView, but can to be modified.

This allow working with any number type T (float, double, mpq, ...) and to use these types in shared shader files (code compiled in both C++ and Shader language). To this end, only low level constructors are defined inside the class itself and every function working on matrices are defined outside of the class in the blender::math namespace.

Definition in file BLI_math_matrix_types.hh.

Macro Definition Documentation

◆ BLI_ENABLE_IF_MAT

#define BLI_ENABLE_IF_MAT ( _size,
_test )   int S = _size, BLI_ENABLE_IF((S _test))

Definition at line 89 of file BLI_math_matrix_types.hh.