Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7592605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:56:56+00:00 2026-05-30T20:56:56+00:00

I have several newbie questions concerning eigen. Below is a small function to illustrate

  • 0

I have several newbie questions concerning eigen.

Below is a small function to illustrate them.

  1. I have a vector whose size will growth from one iteration to the next, from h=1 to h=h_m with h_m<n (n given). I couldn’t find and equivalent to the .reserve() function for eigen objects, meaning i have to resize these object at each iteration. Could you advise of a way to avoid this?

    //we always have that h<h_m<n//
    //declare the matrix to its final size: //a.3
    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

    int h=10,j=0;

    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 }

  2. the line b_4 causes this error at run time (after several iterations
    of b.0->b.4 above):

    eigen/Eigen/src/Core/Block.h:278: Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Block(XprType&, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index) [with XprType = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001>, int BlockRows = 1, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index = long int]: Assertion `(i>=0) && ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows()) ||((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols()))' failed.
    Aborted

Can you help understanding what it means so I can solve the problem?

EDIT: following cbamber85's remark it indeed appears that the error is happening one line above.

//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);     

Looking unto 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;
}

🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:56:58+00:00Added an answer on May 30, 2026 at 8:56 pm

    The error message means that an Eigen::Block (which represent a submatrix) was constructed with indices that are out of bound. Blocks are constructed in many places, including the member function .row(). Assuming that the error originates in the expression xSub.row(i) = x.row(Index(i)), it means that i is greater than or equal to the number of rows in either xSub or x.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have several questions. Don't flame me - I'm newbie, but eager to know more.
Django newbie here, I have several types of models, in each of them the
I'm newbie to Ubuntu. Installed LAMP. Have several questions about it 1) let's say
I have several newbie questions about EC2, thanks for your attention, 1) why EC2
I have several tables whose only unique data is a uniqueidentifier (a Guid) column.
Several (newbie) questions: 1) I see a lot of public Person SelectedPerson { get;
I'm a complete newbie with MySQL indexes. I have several MyISAM tables on MySQL
Is it possible to have several command prompts running simultaneously and switch between them,
I have a function that has several outputs, all of which native, i.e. integers
I am a newbie to Jquery as will be evident. I have 2 scripts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.