bugSkencil - Bugs: bug #10573, sktrafo_compare isn't transitive

 
 

bug #10573: sktrafo_compare isn't transitive

Submitted by:  Peter Moulder <pjrm>
Submitted on:  Mon 04 Oct 2004 10:27:57 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: BugStatus: None
Privacy: PublicAssigned to: None
Open/Closed: OpenRelease: 0.6.x

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 04 Oct 2004 10:27:57 AM UTC, original submission:

I'm not sure if this is strictly a bug, but:
sktrafo_compare in Sketch/Modules/sktrafo.c doesn't provide a <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">strict weak ordering</a>. E.g. it isn't transitive: we can have three SkTrafo objects a,b,c such that a<b and b<c yet a==c.

This has various consequences. E.g. sort() on a list of SkTrafo's isn't guaranteed to put the list into order; and a dictionary implemented as a tree won't work for SkTrafo keys.

To make sktrafo_compare provide a strict weak ordering, you could change the comparison to as if it were a sequence of 6 doubles, with m11 being the major sort key and so on.
The simplest implementation would be a bitwise comparison memcmp(&a->m11, &b->m11, 6*sizeof(double)), which is robust against NaN.
If you wanted to use floating point comparisons rather than bitwise comparison, then you'd have to test explicitly for isnan, and have NaN compare, say, greater than all non-NaN values (as Java's Double.compareTo does) and equal to all NaN values.

Peter Moulder <pjrm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup1