Hi there!
This is my first post in a programming forum and my first post in English, too. I will try to express my problem as clear as I possibly can.
I am implementing a numerical algorithm and - after changing some parameters - my program interrupted due to a segmentation fault.
Then I isolated the problem and discovered that one cannot declare such a (big) array:
Now the algorithm - from the highest point of view - just changes such an array in several steps, the number of steps is fixed in advance. (In the first step, it is filled with some input values.)
In each step, there's a loop over all elements. Depending on the values of these elements, new values a written to a temporary array.
Then the temporary array is copied into the original one, and a new step starts.
Now - I think - I have three major problems:
1.
I cannot handle this much data via this array, but in a way I have to. It might be interesting that the size of the array which I fix in the beginning is the worst case for the algorithm. Possibly I don't need that much space, but I don't know in advance. It depends on the problem itself.
2.
The runtime is crucial here. Is there a way I can save the copy-procedure in each step of the algorithm?
3.
In each step, the data has to be passed to several sub-functions. (Using the array, I can comfortably and efficiently pass the pointer of the first element to the sub-functions so that I have access to the data.)
Is there a 'data structure' (in terms of something similar to 'my' array) which can solve the problem 1. and 3. (2. should be optional in the beginning)?
I would be very grateful for some advice. Thanks in advance!
red vintage