Article View: sci.math.num-analysis
Article #195Re: Bug in SVDCMP of "Numerical Recipees in C"
From: Darrell Roy Hougen
Date: Thu, 06 Aug 1992 02:45
Date: Thu, 06 Aug 1992 02:45
39 lines
2324 bytes
2324 bytes
iwelch@agsm.ucla.edu (Ivo Welch) writes: *I have the 1989 version of Numerical Recipees in C, both in book and *electronic form. I believe I have found a bug---or at least a nuisance. When *a matrix contains some extreme values, it is possible to get an access *violation. [ Code deleted. ] *# note that l ends with a value of 0 if the loop exits. Typically, *# rv1[l]=0, so the loop is exited early---no problem then. However, *# if the matrix is poorly setup (and I have had such a case), rv1[1] *# can become NaN (0/0), and the loop completes rather than breaks. *# I believe rv1[1] turned into NaN, since my matrix contained an IEEE *# -Inf. I have had the same problem, but *only* when my input matrix contained an Inf or NaN as appears to be the case in your example. So, unless you intend to work with infinities, it would appear that the code works. However, the fact that the program produces a segmentation violation and core dumps as the result of a data error *is* annoying. *# I presume this problem can be fixed if the condition reads l>=2, *# and nm=l-1 is moved into both the start and iteration. Perhaps you should just check for l == 0 at the end of the loop and exit gracefully with an error message. If you disallow l = 1 in the body of the loop, the code may not work properly. I think there is a comment in the book (if not in the code) that rv1[1] is always zero so that the loop will always exit before l = 0. If rv1[1] is not zero, there must be something wrong with the data. Therefore, you could check the value of rv1[1] to see if it is correct at various points in the code. Darrell P.S. I would also be interested in seeing a bug list for Numerical Recipes in C is anyone has it on line.
Technical Details
Message-ID:
<l814huINN9mk@roundup.crhc.uiuc.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!m.cs.uiuc.edu!roundup.crhc.uiuc.edu!uirvli!hougenReferences:
<1992Aug5.104832.27184@mic.ucla.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!m.cs.uiuc.edu!roundup.crhc.uiuc.edu!uirvli!hougen From: hougen@uirvli.csl.uiuc.edu (Darrell Roy Hougen) Newsgroups: sci.math.num-analysis,sci.math.stat Subject: Re: Bug in SVDCMP of "Numerical Recipees in C" Date: 6 Aug 1992 02:45:18 GMT Organization: Center for Reliable and High-Performance Computing, University of Illinois at Urbana-Champaign Lines: 39 Message-ID: <l814huINN9mk@roundup.crhc.uiuc.edu> References: <1992Aug5.104832.27184@mic.ucla.edu> NNTP-Posting-Host: uirvli.csl.uiuc.edu