MantisBT - VTK | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0007887 | VTK | (No Category) | public | 2008-10-29 16:50 | 2008-10-31 15:06 |
Reporter | Serge Lalonde | ||||
Assigned To | François Bertel | ||||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | OS | OS Version | |||
Product Version | |||||
Target Version | Fixed in Version | ||||
Project | |||||
Type | |||||
Summary | 0007887: Calculated values from vtkContourValues::GenerateValues() contain round-off errors | ||||
Description | The class vtkContourValues (in the Common library) is used to generate a set of N linearly spaced values between an upper and lower bound. I discovered that its implementation (in 5.2.0 and still in 5.3.0) caused a numerical error to be introduced in all but the lower bound value. The effect being that values that should be exact would have a very small error introduced. For example, instead of 0, 0.1, 0.2, 0.3, ..., 0.8, 0.9, 1 you would get 0, 0.1, 0.2, 0.3000000000013, 0.40000000000026, ..., 0.8000000000045, 0.99999999999993 (or something very similar). The problem is that the loop to calculate those values was pre-calculating the delta and then incrementing the value before each call to SetValue(). The more accurate method is to calculate the value from scratch each time so that the FPU can properly manage and round-off the errors in the calculation caused by the (finite) double-precision arithmetic. With this fix, the values are exact. Here is the corrected version of GenerateValues() in vtkContourValues.cxx. // Generate numContours equally spaced contour values between specified // range. Contour values will include min/max range values. // The value is calculated using the lower range values and the loop variable // at each iteration to avoid accumulating the floating point error that // happens when using using an intermediate calculation and/or when incrementing. void vtkContourValues::GenerateValues(int numContours, double range[2]) { int i; this->SetNumberOfContours(numContours); if (numContours == 1) { this->SetValue(0, range[0]); } else { for (i= 0; i < numContours; ++i) { this->SetValue(i, range[0] + i*(range[1] - range[0])/(numContours - 1)); } } } | ||||
Steps To Reproduce | |||||
Additional Information | |||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2008-10-29 16:50 | Serge Lalonde | New Issue | |||
2008-10-29 16:56 | François Bertel | Status | backlog => tabled | ||
2008-10-29 16:56 | François Bertel | Assigned To | => François Bertel | ||
2008-10-29 16:57 | François Bertel | Note Added: 0013978 | |||
2008-10-29 17:06 | François Bertel | Note Added: 0013979 | |||
2008-10-29 17:06 | François Bertel | Status | tabled => @80@ | ||
2008-10-29 17:06 | François Bertel | Resolution | open => fixed | ||
2008-10-30 08:42 | Serge Lalonde | Note Added: 0013985 | |||
2008-10-30 08:42 | Serge Lalonde | Status | @80@ => @20@ | ||
2008-10-30 08:42 | Serge Lalonde | Resolution | fixed => reopened | ||
2008-10-30 10:07 | François Bertel | Note Added: 0013987 | |||
2008-10-30 11:34 | Serge Lalonde | Note Added: 0013988 | |||
2008-10-30 12:42 | François Bertel | Note Added: 0013989 | |||
2008-10-30 12:42 | François Bertel | Note Added: 0013990 | |||
2008-10-30 12:42 | François Bertel | Status | @20@ => @80@ | ||
2008-10-30 12:42 | François Bertel | Resolution | reopened => fixed | ||
2008-10-31 15:06 | François Bertel | Status | @80@ => closed | ||
2011-06-16 13:11 | Zack Galbreath | Category | => (No Category) |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|