IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 22 years ago

Closed 22 years ago

Last modified 21 years ago

#254 closed defect (fixed)

Ordinary polynomial evaluation is incorrect

Reported by: Paul Price Owned by: Paul Price
Priority: normal Milestone:
Component: types Version: 0.3.0
Severity: major Keywords:
Cc: gusciora@…

Description

The implementation of the evaluation of ordinary polynomials is incorrect. The
accumulation is placed inside the "if (mask)" test, such that accumulation does
not take place if a coefficient is masked.

This is the case both in rel_3 and the mainline (I have revision 1.71 of
psFunctions.c, dated 3 Dec, but the lines in question don't appear to have been
updated since then).

I will attach example code demonstrating the bug (I suggest that it be worked in
to unit tests to demonstrate the masking functionality). It calculates a 1D
polynomial in two ways. The first is to mask out one of the coefficients; the
other is to set that coefficient to zero and not mask it. These two methods
should produce the same result. Here's what I get:

price@mithrandir:/home/mithrandir/price/testing>./polynomialBug
Value using mask: 1.000000
Value using coefficient zeroing: 0.500000

The fix is to move lines such as "xSum *= x;" outside the "if (mask)" block.

Note that this bug applies to evaluation of single- and double-precision
versions of ordinary polynomials of all dimensions.

Attachments (1)

polynomialBug.c (755 bytes ) - added by Paul Price 22 years ago.
Code to reproduce polynomial bug.

Download all attachments as: .zip

Change History (8)

by Paul Price, 22 years ago

Attachment: polynomialBug.c added

Code to reproduce polynomial bug.

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

Owner: changed from robert.desonia@… to george.gusciora@…

comment:2 by gusciora@…, 22 years ago

Resolution: fixed
Status: newclosed

I fixed this in our current development version of psLib.

Actually, according to version 10 of the SDRS, your code isn't quite right
either. The SDRS states "those coefficients that have the corresponding mask
element non-zero shall not be masked". So, according to the SDRS, setting the
mask element to zero, not one, masks that coefficient.

Personally, I prefer your code, not the SDR: masks set to one should mean the
coefficients will be ignored (that's how we use masks in the images).

What do you think?

comment:3 by gusciora@…, 22 years ago

Resolution: fixed
Status: closedreopened

comment:4 by gusciora@…, 22 years ago

Owner: changed from george.gusciora@… to Paul Price
Status: reopenednew

comment:5 by Paul Price, 22 years ago

Status: newassigned

I used 1 to mask because that's what the code does.

This is a matter for personal preference, but we should be consistent
throughout. I shall propose to Gene that throughout psLib we adopt for masks
that non-zero stands for "ignore this", while zero means "use this".

comment:6 by Paul Price, 22 years ago

Cc: gusciora@… added
Resolution: fixed
Status: assignedclosed

Adopted: if a mask is non-zero, the corresponding value is not included. This
affects polynomials and minimization.

comment:7 by Eric.VanAlst@…, 21 years ago

SDR-11 states proper mask usage.

Note: See TracTickets for help on using tickets.