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

  • Home
  • SEARCH
  • 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 7799153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:13:00+00:00 2026-06-02T00:13:00+00:00

I am working with a multidimensional array but i get an exception, i have

  • 0

I am working with a multidimensional array but i get an exception, i have searched a lot but i find the same answer i’m using, the exception jumps when i try to allocate matriz[i] = new double[n]. I have tried both the commented and uncommented solutions with no luck.

void interpol(double *arr_x, double *arr_y, int n, double *results) {
    //double** matriz = new double*[n];
    double** matriz;
    matriz = (double**) malloc(n * sizeof(double*));
    for(int i = 0; i < n; i++){    
        //matriz[i] = new double[n+1];
        matriz[i] = (double*) malloc(n+1 * sizeof(double));
        for(int j = 0; j < n; j++) {
            matriz[i][j] = pow(arr_x[i],j);
        }
        matriz[i][n] = arr_y[i];
    }
    gaussiana(matriz, n, results);
}

— EDIT—

The function gaussiana is working fine, since i have tested outside this function. The exception is thrown in either:
//matriz[i] = new double[n];
matriz[i] = (double*) malloc(n * sizeof(double));

n is never more than 10.

The exception thrown is:

First-chance exception at 0x00071c4d in Interpolacion.exe: 0xC0000005:
Access violation reading location 0x00000000.
Unhandled exception at 0x774b15de in Interpolacion.exe: 0xC0000005: Access violation reading location 0x00000000.
The program ‘[8012] Interpolacion.exe: Native’ has exited with code -1073741819 (0xc0000005).

—-EDIT—-
I finally got it working, the issue was not in matriz, but with arr_x/arr_y, the external routine was sending the data wrong (oddly the error and the stacktrace always referred me to the new double[n] assignation)

  • 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-06-02T00:13:02+00:00Added an answer on June 2, 2026 at 12:13 am

    If you want to use the std::vector route, you can use something like below (untested, shown just as a guide). Keep in mind that std::vector<std::vector<double> > is not compatible with double **, so your gaussiana function might need to be rewritten to accept the new type.:

    // Include the header!
    #include <vector>
    
    
    // Be careful about the use of "using namespace std", I'm only using it here
    // because it's a small example
    using namespace std;
    
    vector<vector<double> > matriz;
    
    for (int i = 0; i < n; i++)
    {
        // Create a new vector "v" with n+1 elements
        vector<double> v(n + 1);
    
        // fill this vector
        for (int j = 0; j < n; j++)
            v[j] = pow(arr_x[i], j);
        v[n] = arr_y[i];   
    
        // add it to the matrix
        matriz.push_back(v);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in PHP with array iteration. I have a multidimensional array like
I have a multidimensional array that looks something like this: ourThing = array( 'id'
I have a 2-dimensional array in Ruby that I want to produce a working
I am working on creating a contour plot using Matplotlib. I have all of
I have this code (below) working just fine, however whenever I try to 'wrap'
I have been working on a function for a while to produce a multidimensional
I am working in C++ with ogg/vorbis I have an array with raw PCM
Working on a project at the moment and we have to implement soft deletion
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
I'm trying to create a multidimensional array from a string (received from $_GET, input

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.