rgrynko1
07-11-2014, 07:00 PM
I have purchased the code files as well as the book.
I am new to NR, as well as C++ in general, so I need guidance in setting up . I have downloaded the file NR_C304, and am not sure what other steps to take so that I can use NR in my Visual Studio.
NR_C304 is sitting on my desktop, and I open Visual Studio 2013. I start a new console application and attempt to run the first piece of code provided as an example in the electronic text:
#include "stdafx.h"
#include "nr3.h"
#include "calendar.h"
#include "moment.h"
int main(void) {
const int NTOT = 20;
int i, jd, nph = 2;
Doub frac, ave, vrnce;
VecDoub data(NTOT);
for (i = 0; i < NTOT; i++){
flmoon(i, nph, jd, frac);
data[i] = jd;
}
avevar(data, ave, vrnce);
cout << "Average =" << setw(12) << ave;
cout << "Variance =" << setw(13) << vrnce << endl;
return 0
}
I also make sure to add the header file nr3.h: this is where I am confused. On visual studio I go to Header Files > Add > Add existing... I then chose nr3.h, which i have planted on my desktop.
When I try to run the program, the compiler does not recognize nr3.h, or any other associated headers. This occurs even though I add the headers to the headers tab on visual studio.
This boils down to understanding how to add headers that have been installed, so that visual studio C++ can recognize them.
Please let me know what steps I should take so that I can use NR. If possible, a step by step instruction starting from the download of NR_C304 would be extremely helpful. Thank you very much,
-Ross
I am new to NR, as well as C++ in general, so I need guidance in setting up . I have downloaded the file NR_C304, and am not sure what other steps to take so that I can use NR in my Visual Studio.
NR_C304 is sitting on my desktop, and I open Visual Studio 2013. I start a new console application and attempt to run the first piece of code provided as an example in the electronic text:
#include "stdafx.h"
#include "nr3.h"
#include "calendar.h"
#include "moment.h"
int main(void) {
const int NTOT = 20;
int i, jd, nph = 2;
Doub frac, ave, vrnce;
VecDoub data(NTOT);
for (i = 0; i < NTOT; i++){
flmoon(i, nph, jd, frac);
data[i] = jd;
}
avevar(data, ave, vrnce);
cout << "Average =" << setw(12) << ave;
cout << "Variance =" << setw(13) << vrnce << endl;
return 0
}
I also make sure to add the header file nr3.h: this is where I am confused. On visual studio I go to Header Files > Add > Add existing... I then chose nr3.h, which i have planted on my desktop.
When I try to run the program, the compiler does not recognize nr3.h, or any other associated headers. This occurs even though I add the headers to the headers tab on visual studio.
This boils down to understanding how to add headers that have been installed, so that visual studio C++ can recognize them.
Please let me know what steps I should take so that I can use NR. If possible, a step by step instruction starting from the download of NR_C304 would be extremely helpful. Thank you very much,
-Ross