先来段代码感受一下

	Mat C = (Mat_<double>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
	Mat D = (Mat_<double>(3, 3) << 1, 2, 3, 4, 6,7, 8, 9, 10);
	cout << "C = " << endl << " " << C << endl << endl;
	cout << "D = " << endl << " " << D << endl << endl;
	cout << "C.at<double>(1,2) = " << endl << " " << C.at<double>(1,2) << endl << endl;
	D.at<double>(1, 2) = 66;
	cout << "D1 = " << endl << " " << D << endl << endl;


Mat_类一般应用于矩阵(matrix)的运算。

Mat_类继承自Mat类,对数据类型更加灵活,可定义为Mat_<_Tp>的矩阵形式

    template<typename _Tp> class Mat_ : public Mat //定义类模板的方式
    {
    public:
        // ... some specific methods
        //         and
        // no new extra fields
    };

如果在编译时使用了大量的元素访问操作,并且知道矩阵类型,MAT_可以更方便。直接用Mat_类型的变量M_(row,col)访问

    Mat_<double> M(20, 20);
	for (int i = 0; i < M.rows; i++)
		for (int j = 0; j < M.cols; j++)
			M(i, j) = 1. / (i + j + 1);//不使用at,直接用()索引,更方便
	Mat E, V;
	eigen(M, E, V);
	cout << E.at<double>(0, 0) << endl;
	cout << E.at<double>(M.rows - 1, 0);
	getchar();
	return 0;
1.90713
1.06238e-17