alan
12-11-2003, 04:20 PM
Hi,
I use the Fortran 77 Numerical Recipes programs (I got them from MS Fortran PowerStation ver4.0, and they are upgraded to the 2.10 version) to verify the C++ Numerical Recipes programs because the C++ codes are input from the book. When I ran the xsvdcmp.cpp and xsvdcmp.for (I couldn¡¯t find the input problem.), I found:
When the Number of Rows equals the Number of Columns, I can get the same solution.
When the Number of Rows is greater than the Number of Columns, I can¡¯t get the same solution. I can¡¯t find the reasons, Please help. Thank you.
Here is the original matrix and the two solutions ran by CPP program and by Fortran77 program.
The matrix is:
Number of Rows, Columns
5,3
Matrix
1.0 2.0 3.0
2.0 3.0 4.0
3.0 4.0 5.0
4.0 5.0 6.0
5.0 6.0 7.0
The CPP solution:
-0.219236 -0.742924 0.530877
-0.321266 -0.443608 -0.282197
-0.423296 -0.144292 -0.718999
-0.525326 0.155023 0.161080
-0.627356 0.454339 0.309239
The Fortran77 solution:
-0.219236 -0.742923 0.558841
-0.321266 -0.443608 -0.814382
-0.423296 -0.144292 0.045120
-0.525326 0.155023 0.117540
-0.627356 0.454339 0.092880
I use the Fortran 77 Numerical Recipes programs (I got them from MS Fortran PowerStation ver4.0, and they are upgraded to the 2.10 version) to verify the C++ Numerical Recipes programs because the C++ codes are input from the book. When I ran the xsvdcmp.cpp and xsvdcmp.for (I couldn¡¯t find the input problem.), I found:
When the Number of Rows equals the Number of Columns, I can get the same solution.
When the Number of Rows is greater than the Number of Columns, I can¡¯t get the same solution. I can¡¯t find the reasons, Please help. Thank you.
Here is the original matrix and the two solutions ran by CPP program and by Fortran77 program.
The matrix is:
Number of Rows, Columns
5,3
Matrix
1.0 2.0 3.0
2.0 3.0 4.0
3.0 4.0 5.0
4.0 5.0 6.0
5.0 6.0 7.0
The CPP solution:
-0.219236 -0.742924 0.530877
-0.321266 -0.443608 -0.282197
-0.423296 -0.144292 -0.718999
-0.525326 0.155023 0.161080
-0.627356 0.454339 0.309239
The Fortran77 solution:
-0.219236 -0.742923 0.558841
-0.321266 -0.443608 -0.814382
-0.423296 -0.144292 0.045120
-0.525326 0.155023 0.117540
-0.627356 0.454339 0.092880