Mat::~Mat
Mat的析构函数。
C++: Mat::~Mat()
析构函数调用Mat::release()。
Mat::operator =
提供矩阵赋值操作。
C++: Mat& Mat::operator=(const Mat& m)
C++: Mat& Mat::operator=(const MatExpr_Base& expr)
C++: Mat& Mat::operator=(const Scalar& s)
参数:
m
expr
C=A+B 扩展成add(A, B, C) , andadd() 要当心C重新分配数据的操作。.
s
Mat::operator MatExpr
提供一种Mat-to-MatExpr转换运算符
C++: Mat::operator MatExpr_() const
转换运算符不能显示调用而是由矩阵表达式引擎(Matrix Expression engine)内部调用The cast operator should not be called explicitly. It is used internally by the Matrix Expressions engine.
Mat::row
创建一个指定行数的矩阵头。.
C++: Mat Mat::row(int i) const
参数:
i –
该方法创建一个具有指定了行数的新矩阵头的矩阵并返回它。这是一个复杂度为O(1) 的操作,无须考虑矩阵的尺寸。新矩阵和原矩阵共享一份基础数据。这是一个典型基本矩阵处理操作的例子, axpy是LU和许多其它算法都使用的一个函数
inline void matrix_axpy(Mat& A, int i, int j, double alpha)
{
A.row(i) += A.row(j)*alpha;
}
Note:在当前实现中,下面的代码不会无法按预期的效果工作:
Mat A ;
...
A.row(i) = A.row(j) ;/ /不起作用
发生这种情况是因为 A.row(i) 形成临时矩阵头进一步分配给另一个矩阵头。请记住,每个操作复杂度为O(1),即没有复制任何数据。因此,如果你预期第 j行被复制到第 i行,那么上述赋值不成立。要做到这一点,应该把这种简单的赋值转换到表达式中或使用 Mat::copyTo() 方法:
Mat A ;
...
/ / 可行,但看上去有点目的不明确。
A.row(i) = A.row(j)