This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
numerical results differ after irrelevant code change
- From: "Michael D. Berger" <m dot d dot berger at ieee dot org>
- To: <gcc at gcc dot gnu dot org>
- Date: Sun, 08 May 2011 10:54:49 -0400
- Subject: numerical results differ after irrelevant code change
On a CentOS box with:
# uname -a
Linux xxxxxx 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5
17:53:09 EST 2011 i686 i686 i386 GNU/Linux
# gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
and using:
Template Numerical Toolkit (TNT).
as well as numerical software I have written, all in C++, I am doing some
voluminous and complex arithmetic. On two occasions I have encountered
situations in which small, irrelevant modifications of the code result in
small changes in the result. In a recent example, using type double, a
result that is theoretically zero, is being approximated, reasonably, by a
value of -1.16e-16. When an unused matrix variable member is added to a
template class not used in that part of the calculations, the result is
changed to -1.05e-16, also a reasonable result, but different. When the new
variable is commented out, the difference disappears. The problem does not
in itself compromise the usefulness of the result, but it does compromise
confidence.
Thanks for any suggestions.
Mike.
--
Michael D. Berger
m.d.berger@ieee.org