Blitz logo

Blitz Support :

From: Bob Uva (bobu21_at_[hidden])
Date: 2003-07-31 22:39:07


You can create a Point object that contains both the x and y coordinates,
and then have a comparison function in the form of an overloaded less than
(<) operator. The sort function will use that 'less-than' operator function
to do the comparison. You said that you're new to c++ as well. If you don't
know
how to write an overloaded operator member function, you can find good
tutorials
in many elementary c++ texts. I strongly suggest going through an elementary
text
before attempting any serious c++ programming.

-Bob

-----Original Message-----
From: blitz-support-bounces_at_[hidden]
[mailto:blitz-support-bounces_at_[hidden]]On Behalf Of Jonathan
Stickel
Sent: Thursday, July 31, 2003 5:00 PM
To: blitz-support_at_[hidden]
Subject: [Blitz-support] interpolation / sorting multidimensional arrays

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

_______________________________________________
Blitz-support mailing list
Blitz-support_at_[hidden]
http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support