将矩阵X的 一些行和一些列提取出来形成矩阵Y,其他行索引和列索引分别存于R,C
template <
typename DerivedX,
typename DerivedR,
typename DerivedC,
typename DerivedY>
IGL_INLINE void igl::slice(
const Eigen::PlainObjectBase<DerivedX> & X,
const Eigen::PlainObjectBase<DerivedR> & R,
const Eigen::PlainObjectBase<DerivedC> & C,
Eigen::PlainObjectBase<DerivedY> & Y)
{
#ifndef NDEBUG
int xm = X.rows();
int xn = X.cols();
#endif
int ym = R.size();
int yn = C.size();
// special case when R or C is empty
if(ym == 0 || yn == 0)
{
Y.resize(ym,yn);
return;
}
assert(R.minCoeff() >= 0);
assert(R.maxCoeff() < xm);
assert(C.minCoeff() >= 0);
assert(C.maxCoeff() < xn);
// Resize output
Y.resize(ym,yn);
// loop over output rows, then columns
for(int i = 0;i<ym;i++)
{
for(int j = 0;j<yn;j++)
{
Y(i,j) = X(R(i),C(j));
}
}
}
SparseMatrix<T> Auu;
slice(A,data.unknown,data.unknown,Auu);