1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.


Discussion in 'Meet and Greet' started by SADS, Jul 5, 2011.

  1. SADS

    SADS New Member

    Jul 5, 2011
    Likes Received:
    Trophy Points:
    Hi friends,

    I wrote a code to build a matrix with specific calculations. When I'm using 3000 elements works well ... But I did a test with 150.000 (150.000 x 150.000) and I had problems.

    " terminate called after throwing an instance of 'std::bad_alloc' "

    I'm copying the code part of the problem:

    void buildMatrix(ofstream &myfileOutSubsetZ, ofstream &myfileOutSubset,ofstream &myfileOut,ofstream &myfileLog,vector<string> &vetorInd)
    float **AAA = 0;
    AAA = new float *[vetorInd.size()];
    for(int i=0;i<vetorInd.size();i++)
    AAA= new float [vetorInd.size()]; // PROBLEM!
    I captured the exception:


    Can you help me please?

Share This Page