Chapter 19 fred_singular.h


MPD78
10-31-2009, 12:01 PM
Hello all,

I am trying to follow the example given in 19.3.2 but I am having some trouble. I believe the problem lies in the positioning of my code.

In the fred_singular.h file, I have this layout,

template <class Q>
struct Wwghts {

......

};

struct Quad_matrix {

......

};

Then I have the main function in a .cpp file.

When I try to compile the code I get 5 errors.

The first is a syntax error '{' but all of the bracing is correct.

The second is "unexpected token(s) preceeding '{' skipping apparent function body.

The third is "weights" : is not a member of 'Wwghts<Q>'

Do I just having something in the code out of sequence?

NOTE: All of this code is copyrighted so I can't really post a nice example showing the functions.

Any help would be greatly appreciated.

Thanks
Matt

davekw7x
10-31-2009, 02:59 PM
......positioning ...
With files from the distribution:


#include "../code/nr3.h"
#include "../code/ludcmp.h"
#include "../code/fred_singular.h"

int main()
{
main_fredex();
return 0;
}


Output

1 0.000000 -0.063255
2 0.080554 0.033699
3 0.161107 0.109477
4 0.241661 0.176189
5 0.322215 0.237881
6 0.402768 0.296796
7 0.483322 0.354348
8 0.563876 0.411460
9 0.644429 0.468716
10 0.724983 0.526425
11 0.805537 0.584636
12 0.886090 0.643137
13 0.966644 0.701435
14 1.047198 0.758731
15 1.127751 0.813895
16 1.208305 0.865458
17 1.288859 0.911626
18 1.369412 0.950341
19 1.449966 0.979382
20 1.530519 0.996528
21 1.611073 0.999778
22 1.691627 0.987590
23 1.772180 0.959132
24 1.852734 0.914471
25 1.933288 0.854672
26 2.013841 0.781766
27 2.094395 0.698572
28 2.174949 0.608409
29 2.255502 0.514738
30 2.336056 0.420807
31 2.416610 0.329374
32 2.497163 0.242517
33 2.577717 0.161587
34 2.658271 0.087246
35 2.738824 0.019590
36 2.819378 -0.041694
37 2.899932 -0.097171
38 2.980485 -0.147497
39 3.061039 -0.193227
40 3.141593 -0.234328


The file fred_singular.h is arranged like this:

template <class Q>
struct Wwghts {
.
.
.
}; // Make sure you have the semicolon to close the struct definition
struct Quad_matrix {
.
.
.
}; // Make sure you have the semicolon to close the struct definition
Int main_fredex(void)
{
.
.
.
}


Regards,

Dave

MPD78
10-31-2009, 03:53 PM
Thanks Dave,

I just had some stuff out of order and one typo.

I created a seperate .cpp file and moved the main_fredex inside that file. Once I put everything in one header file, the problems where corrected.

I have the same results that you posted above.

Thanks
Matt