04 块操作
块操作
[TOC]
block函数
fixed-size version
matrix.block<p, q>(i, j); // 从(i ,j)开始的p行q列 组成的block |
dynamic-size version
matrix.block(i, j, p, q); // 从(i ,j)开始的p行q列 组成的block |
案例
|
lvalue & rvalue
.block()
函数的返回值通常作为一个右值,但也可以是一个左值使用。
|
col()和row()
用于处理矩阵的行列操作。
|
常见Corner相关的函数
Block operation | dynamic-size block expression | fixed-size block expression |
---|---|---|
左上角的 p * q 块* | matrix.topLeftCorner(p,q); |
matrix.topLeftCorner<p,q>(); |
左下角的 p * q 块* | matrix.bottomLeftCorner(p,q); |
matrix.bottomLeftCorner<p,q>(); |
右上 p * q 块* | matrix.topRightCorner(p,q); |
matrix.topRightCorner<p,q>(); |
右下角的 p * q 块* | matrix.bottomRightCorner(p,q); |
matrix.bottomRightCorner<p,q>(); |
包含前 q 行的块* | matrix.topRows(q); |
matrix.topRows<q>(); |
包含最后 q 行的块* | matrix.bottomRows(q); |
matrix.bottomRows<q>(); |
包含前 p 列的块* | matrix.leftCols(p); |
matrix.leftCols<p>(); |
包含最后 q 列的块* | matrix.rightCols(q); |
matrix.rightCols<q>(); |
包含从 i 开始的 q 列的块* | matrix.middleCols(i,q); |
matrix.middleCols<q>(i); |
包含从 i 开始的 q 行的块* | matrix.middleRows(i,q); |
matrix.middleRows<q>(i); |
|
Vector的block运算
Block operation | dynamic-size block expression | fixed-size block expression |
---|---|---|
包含第一个元素的块n * |
vector.head(n); |
vector.head<n>(); |
包含最后一个元素的块n * |
vector.tail(n); |
vector.tail<n>(); |
包含元素的块,从位置开始i 开始n 个 * |
vector.segment(i,n); |
vector.segment<n>(i); |
|
发布于