У меня есть несколько вопросов новичка относительно eigen.
Ниже приведена небольшая функция для их иллюстрации.
У меня есть вектор, размер которого будет увеличиваться от одной итерации к следующей, от h = 1 до h = h_m с h_m
<code>//we always have that h<h_m<n//
//declare the matrix to its final size: //a.3<br>
MatrixXf xSub(h_m,p); //a.1
VectorXi Indexn1(n); //a.2
//declare the vector to its final size: //a.3
VectorXi RIndex(h_m); //a.4</p>
<p>int h=10,j=0;</p>
<p>while(h<h_m){ //b.0
Indexn1.setLinSpaced(n,0,n-1); //b.1
random_shuffle(Indexn1.data(),Indexn1.data()+n); //b.2
RIndex.resize(h);
RIndex = Indexn1.segment(0,h); //b.3
....
....
j++; //b.4
h=ceil(j/(2.0*J)*(n-p-1)+p+1); //b.5
xSub.resize(h,NoChange);
xS_mean = xSub.colwise().mean() //b.6
}
строка b_4 вызывает эту ошибку во время выполнения (после нескольких итераций
из b.0-> b.4 выше):
eigen / Eigen / src / Core / Block.h: 278: Eigen :: Block :: Block (XprType &, Eigen :: Block :: Index) [с XprType = Eigen :: Matrix , int BlockRows = 1, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen :: Block :: Index = long int]: утверждение `(i> = 0) && (((BlockRows == 1) && (BlockCols == XprType :: ColsAtCompileTime) && i
Отменено
Можете ли вы помочь понять, что это значит, чтобы я мог решить проблему?
РЕДАКТИРОВАТЬ: после замечания cbamber85 действительно кажется, что ошибка происходит на одну строку выше.
//index of the h smallest elements of the vector dP:
RIndex.resize(h);
RIndex = SSubInd(dP,h);
//constructs the corresponding sub-matrix of elements of x with index given above:
//this is the offending line.
xSub.resize(h,NoChange);
xSub = RSubMatrix(x,RIndex);
Взгляд на RSubMatrix:
MatrixXf RSubMatrix(MatrixXf& x, VectorXi& Index){
MatrixXf xSub(Index.size(),x.cols());
for(int i=0;i<Index.size();i++){
xSub.row(i)=x.row(Index(i));
}
return xSub;
}
(