VTK/VTK6/Migration/DoublePrecisionPi: Difference between revisions

From KitwarePublic
< VTK
Jump to navigationJump to search
(Created page with "VTK6 represents a major upgrade to VTK. The upgrade presents an opportunity to provide consistent representation and usage of Pi and TwoPi. This experiment uses the [http://en.w...")
 
 
(One intermediate revision by the same user not shown)
Line 35: Line 35:


==Analyze==
==Analyze==
Sometime around vtk4.4, most floating point calculations were converted from single precision to double precision. Apparently at that time, the vtkMath::Pi() was not converted to double. Rather, vtkMath::DoublePi() was introduced. Also, throughout the toolkit, some developers chose to use explicit representations of Pi. These varied in precision.


==Improve==
==Improve==
A [http://review.source.kitware.com/#/c/5723/ gerrit patch] introduced the following changes to 41 files:
# vtkMath::Pi now returns double.
# vtkMath::TwoPi() is replaced with 2.0 * vtkMath::Pi().
# Remove vtkMath::DoublePi and vtkMath::DoubleTwoPi and mark them as deprecated.
# Replace explicit use of 3.1415... and 6.28... with the vtkMath constants.
Because of these changes, 4 baseline images were updated.
In addition, the conversion to double uncovered a precision-related bug in vtkSuperquadricSource. The diffs for that bug fix are [http://review.source.kitware.com/#/c/5723/8/Filters/Sources/vtkSuperquadricSource.cxx here].


==Control==
==Control==
Gerrit reviewers should watch for the introduction of explicit representation of Pi and 2Pi
Gerrit reviewers should watch for the introduction of explicit representation of Pi and 2Pi

Latest revision as of 15:48, 31 May 2012

VTK6 represents a major upgrade to VTK. The upgrade presents an opportunity to provide consistent representation and usage of Pi and TwoPi.

This experiment uses the DMAIC methodology of the Six Sigma management process to "Define", "Measure", "Analyze", "Improve" and "Control" valgrind defects in VTK.

The basic methodology (from Wikipedia) consists of the following five steps:

  • Define process goals that are consistent with customer demands and VTK's strategy.
  • Measure key aspects of the current process and collect relevant data.
  • Analyze the data to verify cause-and-effect relationships. Determine what the relationships are, and attempt to ensure that all factors have been considered.
  • Improve or optimize the process.
  • Control to ensure that any deviations from target are corrected before they result in defects. Set up pilot runs to establish software quality, move on to production, set up control mechanisms and continuously monitor the process.

Define

Provide a consistent use if Pi and TwoPi throughout the toolkit. Currently Pi is used in the following manner:

  1. vtkMath::Pi() returns a single precision representation of Pi.
  2. vtkMath::DoublePi() returns a double precision representation of Pi.
  3. Explict forms like 3.1415927
    1. 3.141593
    2. 3.1415926
    3. 3.141592653589
    4. 3.141592654
    5. 3.14159265358979
    6. 3.141592653589793
    7. 3.14159265358979323846

Similar uses exist for TwoPi, DoubleTwoPi and 6.28...

Measure

Pi usage was measured using the unix grep command on just .cxx files.

  1. vtkMath::Pi() - 64 files
  2. vtkMath::DoublePi() - 13 files
  3. Explicit Pi - 19 files
  4. vtkMath::TwoPi - 0 files
  5. vtkMath::DoubleTwoPi() - 4 files
  6. Explicit 2Pi - 5 files

Analyze

Sometime around vtk4.4, most floating point calculations were converted from single precision to double precision. Apparently at that time, the vtkMath::Pi() was not converted to double. Rather, vtkMath::DoublePi() was introduced. Also, throughout the toolkit, some developers chose to use explicit representations of Pi. These varied in precision.

Improve

A gerrit patch introduced the following changes to 41 files:

  1. vtkMath::Pi now returns double.
  2. vtkMath::TwoPi() is replaced with 2.0 * vtkMath::Pi().
  3. Remove vtkMath::DoublePi and vtkMath::DoubleTwoPi and mark them as deprecated.
  4. Replace explicit use of 3.1415... and 6.28... with the vtkMath constants.

Because of these changes, 4 baseline images were updated.

In addition, the conversion to double uncovered a precision-related bug in vtkSuperquadricSource. The diffs for that bug fix are here.

Control

Gerrit reviewers should watch for the introduction of explicit representation of Pi and 2Pi