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


bug #10573: sktrafo_compare isn't transitive

Submitter:  Peter Moulder <pjrm>
Submitted:  Mon 04 Oct 2004 10:27:57 AM UTC
Category:  None Severity:  3 - Normal
Item Group:  Bug Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Release:  0.6.x
* Mandatory Fields

Add a New Comment Rich Markup

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 Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


CC list is empty


There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.


No changes have been made to this item

Back to the top

Powered by Savane 3.13-b921.
Corresponding source code