typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime, int Options = 0, // 默认(无需更改) int MaxRowsAtCompileTime = RowsAtCompileTime, // 默认(最大行数,提前知道极限) int MaxColsAtCompileTime = ColsAtCompileTime // 默认(最大列数,提前知道极限) > 其中: 前三个参数:需要我们指定 后...
MatrixXd::Random(rows,cols) // rand(rows,cols)*2-1 // MatrixXd::Random returns uniform random numbers in (-1, 1). C.setRandom(rows,cols) // C = rand(rows,cols)*2-1 VectorXd::LinSpaced(size,low,high) // linspace(low,high,size)' v.setLinSpaced(size,low,high) // v = lins...
SparseMatrix<double,RowMajor> sm2; sm2.row(i) = ...; sm2.topRows(nrows) = ...; sm2.middleRows(i,nrows) = ...; sm2.bottomRows(nrows) = ...; 另外,稀疏矩阵提供了SparseMatrixBase::innerVector()和SparseMatrixBase::innerVectors()方法,它们是分别是列主存贮col/middleCols和行主存贮的row/...
sm1.block(startRow, startCol, rows, cols); sm1.block(startRow, startCol); sm1.topLeftCorner(rows, cols); sm1.topRightCorner(rows, cols); sm1.bottomLeftCorner( rows, cols); sm1.bottomRightCorner( rows, cols); Contrary to dense matrices, here all these methods are read-only. See ...
row(m)&col(n): 返回矩阵的第m行/第n列; rows()&cols(): 返回矩阵的行/列数; 注意此处的block(),row()和col()方法返回的都是左值, 因此可以对其进行修改并作用到原始矩阵上. 对于矩阵大小未知的情况, 通常使用MatrixX[c|d|f]定义矩阵, 当需要使用矩阵时再通过resize()方法指定矩阵的大小即可. ...
MatrixXd::Random(rows,cols) // rand(rows,cols)*2-1 // MatrixXd::Random returns uniform random numbers in (-1, 1). C.setRandom(rows,cols) // C = rand(rows,cols)*2-1 VectorXd::LinSpaced(size,low,high) // linspace(low,high,size)' ...
Matrix<double,3,3> A;// Fixed rows and cols. Same as Matrix3d.Matrix<double,3,3, RowMajor> E;// Row major; default is column-major.代表着行优先,在内存中,存储时按行存储Matrix3f P, Q, R;// 3x3 float matrix. // Dynamic Matrix ...
MatrixXd::Identity(rows,cols) // eye(rows,cols) C.setIdentity(rows,cols) // C = eye(rows,cols) MatrixXd::Zero(rows,cols) // zeros(rows,cols) C.setZero(rows,cols) // C = ones(rows,cols) MatrixXd::Ones(rows,cols) // ones(rows,cols) ...
MatrixXd::Random(rows,cols) // 元素随机在-1->1 C.setRandom(rows,cols) // 同上 VectorXd::LinSpaced(size,low,high) // 线性分布的数组 v.setLinSpaced(size,low,high) // 线性分布的数组 6、特殊操作 6.1 块操作 块操作有两种表达方式:从(i,j)处提取pxq大小的矩阵块。
RowsAtCompileTime:指定行数或者设置成动态(Dynamic); ColsAtCompileTime:指定列数或者设置成动态(Dynamic); Options:标志位,可以是ColMajor或RowMajor,默认是ColMajor; 从上面可以看出,行数和列数是允许固定大小,也允许动态大小的,所以下面的几种类型是可以的。 Matrix<double, 10, 5> Matrix<double, 10, Dynamic...