Re: qsort() results: implementation dependent?



Duncan Muirhead schrieb:

I'm not sure if this is specified for qsort but I've learnt not to use
it unless the compare function really is an order, ie unless the compare
function only returns 0 if the two arguments are identical.

You are right, but how to accomplish with that if you are dealing with
doubles? Such a routine is expected to order points belonging to two
different surfaces which are related by a geometrical transformation
(translation or rotation). Ordering them according to the distance from
the origin should store the pairs in sequence and make simple to split
the resulting ordered list in two vector. If you know other (cheap?)
algorithms, I will try them...

Otherwise, in
may experience at least, qsort can fail spectacularly (cause a core dump),
and anyway I'd suspect that if it returns the final order of the array,
(ie the order of the elements that are all equal as fare as the compare is
concerned) is not just implementation but phase-of-the-moon dependent if
the compare can return non zero for two different arguments
Could you perhaps extend your comparison, function, eg if two points
are the same distance from the origin, compare x then y
then z coordinates too?
Duncan

You are right and it is what the real code does. I gave an simpler
example (already tried) to focus on the topic.

Thanks
Max

.



Relevant Pages

  • Re: Define a clock
    ... The same is true of a velocity. ... > We can carry a unit of distance and a unit of mass, but doing so for time is ... >>the measurement of the separation between them. ... > process just fine if you had a given, fixed standard by which to compare the ...
    (sci.physics.relativity)
  • Re: Define a clock
    ... particular measurement that's made by a measuring device called a clock, ... to "distance" *is* a measurement made by a ruler). ... the observability of time depends upon ... > process just fine if you had a given, fixed standard by which to compare the ...
    (sci.physics.relativity)
  • Re: Distance Running In Early Erectus
    ... Marc: "why not move on 4 legs" ... Skeletal indications for distance locomotion in early Homo erectus. ... Dmanisi offers an opportunity to compare locomotor patterns in early Homo ... bipedalism. ...
    (sci.anthropology.paleo)
  • Re: comparing depth of field
    ... Would hyperfocal distance be able to ... I would like to get a non-SLR camera ... To compare depth of field, you need to determine how to compare. ... If the size of a sensor is X times the size of another sensor the aperature ...
    (rec.photo.digital)
  • Re: SR fundamental contradiction
    ... He was the first to specify "at some ... I got the impression that you were describing the distance between the light signal and another point moving at a constant velocity. ... Of course, in that case, the length is increasing with time, so it is not straightforward to compare the lengths between systems. ... So, the length in S', cT', is contracted when compared to a fixed length in S whose endpoints correspond to the ends of the interval at time T'. ...
    (sci.physics.relativity)