IDENTITY_MATRIX 1 用于初始化单位矩阵,当且仅当矩阵为方阵
D_TYPE double 矩阵默认使用的基元类型
template < int l, int m, typename T = D_TYPE >
class matrix;
默认构造函数会构造零矩阵,允许使用宏IDENTITY_MATRIX
构造单位矩阵
matrix< l, m, T> ( const int opt = 0 );
- opt: 构造参数
初始化构造函数
matrix< l, m, T > ( const T src[l][m] );
- src: 包含矩阵所有元素的二位数组变量
拷贝构造函数
matrix< l, m, T > ( const matrix < l, m, T >& src );
- src: 同阶矩阵
初始化构造函数
matrix < l, m, T > ( const std::initializer_list< std::initializer_list< T > >& src )
- src: 二维初始化列表,利用C++11语法允许使用更简单的方式初始化矩阵。例如:
matrix< 3, 3 > item {
{ 1, 2, 4 },
{ 2, 4, 8 },
{ 4, 8, 16 },
};
重载下标运算符
T* operator [] ( const int opt ) const
- opt: 下标
重载赋值运算符
matrix < l, m, T >& operator = ( const matrix < l, m, T >& opt )
- opt: 同阶矩阵
重载相等比较运算符(矩阵不存在顺序序列,故而未重载<、>、<=、>=)
bool operator == ( const matrix < l, m, T >& opt ) const
- opt: 同阶矩阵
重载加法运算符
matrix < l, m, T > operator + ( const matrix < l, m, T >& opt ) const
- opt: 同阶矩阵
重载减法运算符
matrix < l, m, T > operator - ( const matrix < l, m, T >& opt ) const
- opt: 同阶矩阵
重载数乘运算运算符
matrix < l, m, T > operator * ( T opt ) const
- opt: 矩阵单元
重载乘法运算符
template < int n >
matrix < l, n, T > operator * ( const matrix < m, n, T >& opt ) const
- opt: 行数与源矩阵列数相等的矩阵
重载数除除法运算符
matrix < l, m, T > operator / ( T opt ) const
- opt: 矩阵单元
重载幂运算符(当 opt == -1
时进行矩阵求逆运算)
matrix < l, m, T > operator ^ ( int opt ) const
- opt: 幂次
矩阵对应行列式求值(当且仅当矩阵为方阵)
T det() const
矩阵转置
matrix< m, l > trans() const
静态方法 矩阵对应行列式求值(当且仅当矩阵为方阵)
template < int o >
static T det ( const matrix < o, o, T >& opt);
opt: 求值矩阵
静态方法 矩阵余子式(当且仅当矩阵为方阵)
template < int o >
static matrix < o - 1, o - 1, T > cofactor ( const matrix < o, o, T >& opt, int r, int c )
- opt: 求值矩阵
- r: 余子式去行行号(从0开始)
- c: 余子式去列列号(从0开始)
静态方法 矩阵转置
template < int o, int p >
static matrix < p, o, T > trans ( const matrix < o, p, T >& opt )
- opt: 求值矩阵
静态方法 矩阵求逆
template < int o >
static matrix < o, o, T > inv ( const matrix < o, o, T >& opt )
- opt: 求值矩阵