IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 21 years ago

Closed 21 years ago

Last modified 20 years ago

#325 closed defect (fixed)

psVectorSortIndex algorithm

Reported by: Paul Price Owned by: robert.desonia@…
Priority: high Milestone:
Component: types Version: unspecified
Severity: normal Keywords:
Cc:

Description

The algorithm adopted for psVectorSortIndex (sort the vector and then find out
where my data ends up) is by no means optimal. The natural algorithm is:

  1. Generate a vector of indices (0,1,2,3,4,5,...,N)
  2. Make a comparison function that, given two indices, compares the

corresponding values of the input vector (e.g., given 2 and 5, it compares
myVector->data.F32[2] and myVector->data.F32[5]).

  1. Sort the vector of indices (#1) using qsort(), employing the comparison

function (#2)

  1. Return the sorted vector of indices.

Change History (4)

comment:1 by robert.desonia@…, 21 years ago

Status: newassigned

It is not as simple as that, as there is no way to pass the vector into the
compare function. One could create a global variable set to the vector
currently being sorted, but there is thread-safety problems associated with that
approach.

Let me think about a better way to skin this one for awhile.

comment:2 by robert.desonia@…, 21 years ago

Resolution: fixed
Status: assignedclosed

rewrote the function by sticking the data in an array of structs that holds the
data along with the index then usinf qsort to sort the structs. This ensures
all the indices are included in the output, even in the case of duplicate values.

-rdd

comment:3 by Paul Price, 20 years ago

Keywords: VERIFIED added

Bug has been resolved.... closing.

comment:4 by Paul Price, 20 years ago

Keywords: VERIFIED removed

Bugs have been fixed... closing.

Note: See TracTickets for help on using tickets.