svd...STRANGE error message! PLS help!


erdos
12-24-2007, 10:26 AM
Dear members,

I am new to C++ and am getting some very odd error messages when using the svd algorithm. I have copied the algorithm by hand from second edition of the NR C++ book.

I am able to build the routine and i get zero warnings and errors. However, when I run the the svd routine on a test case 2x2 matrix I get message (a message window opens up, which has options: Abort, Retry and Ignore):

Debug Error!
Damage: after Normal block (#55) at 0x004A1BF0

Yesterday I was getting another message entitled "Assertion Failure with dbgheap.c "!

I have no idea what is happening. I have compared my code with the book's so many times. I can't seem to find any errors.

I have attached my code.

Any advice rendered would be deeply appreciated.

Thanks!

Erdos.

Saul Teukolsky
12-24-2007, 01:55 PM
Dear Erdos,

Most reports of user problems are from typing errors. Yours has at least one: ++a[i][j] should be ++a[i][i]. Whether this is the source of your mysterious errors or not, I don't know. If you are going to make extensive use of the code, you might want to invest in a download copy.

Best wishes,
Saul Teukolsky

erdos
12-24-2007, 03:34 PM
Many thanks for this! Its working perfectly now! I can't believe a silly mistake such as this caused me so much pain!

I think I shall be following your advice and will invest in a download copy. The NR book I have is the 2nd edition C++ one..and I have used a few other routines in the book and written up some of my own as well. I shall be needing some optimisations routines from it now.

I was wondering whether the 3rd Edition code is much different? I am new to C++, and have already invested quite a bit of time writing up my own routines within the context of the NR Vec and Mat classes etc from the 2nd edition. I don't wish to spend more time coding..assuming the 3rd edition's code is drastically different.

Any advice?

Perhaps the easiest and most efficient (in terms of time and effort) route would be to get the 2nd Edition's code.

Once again, thanks ALOT for your help!

Regards,

Erdos.