From: Jonathan S. <jjs...@my...> - 2003-08-01 01:59:46
|
Hi I am relatively new to Blitz++ (and c++ programming in general), but I am very impressed. I have recently translated a good deal of my own Matlab code to c++ by using Blitz arrays. I would like to interpolate within a set of data points given by one-dimensional arrays (e.g. x and y for 1D interpolation) to find a value at an arbitrary point within the range of the data. Not being able to find an existing function to do this, I planned to write a simple linear interpolation function. However, I am stuck at sorting the data points. Essentially, I need to sort x from least to greatest and then reorder y so that there is 1-1 correspondence with the original data points. I can sort x by: sort( &x(0), &x(x.size())+1); but I am at a loss at how to reorder y accordingly. Other than writing a sorting function from scratch, the methods I can think of would be extremely inefficient (O(N^2)). Does anyone have a suggestion? Regards, Jonathan |