Solved

# Adding Graphs

Posted on 1999-01-20

I have a struct declared like this:

struct Graphs

{

double x[100];

double y[100];

.

.

.

};

Graphs graph[10];

Graphs TotalGraph;

What I want to do now is to Add the 10 graphs to give me the sum in TotalGraph. The problem is however that not all the x-values are the same (but they are ordered from low to high), so you can not simply add the corresponding y-values. At the moment I put all the values in a large array, sort them using qsort, and then use the difference between two subsequent y-values to determine the total y-value at each discrete x-value. Although this works well enough, it's not fast enough.

Any ideas?