NRvector<T> redefinition

03-02-2011, 12:37 PM
I am using NR3 Fitab (linear regression). Because I would also like to have my application compatible with other fitters that accept STL vector<double> rather than NRvectors I would like to somehow redefine VecDoub_I to vector<double> is this possible without makinkg changes to the Fitab code.
Thank you.

03-02-2011, 01:21 PM
...I would like to somehow redefine VecDoub_I to vector<double>...

The header file <nr3.h> contains the following lines:

#define NRvector vector
// All of the stuff that's needed for "normal" NRvector definitions
#endif //ifdef _USESTDVECTOR_

So, the first non-comment lines in your code might look like

#include <nr3.h>
// Your NR3 program goes here


// "Regular" NRvectors don't have things like push_back, but
// you can use std::vectors by defining _USESTDVECTOR_
// With this defined, all of the std::vector operations are available,
// and you can use any and all NR functions that expect any kind
// of NRvector as an argument.
// davekw7x
#include <nr3.h>

int main()
// Do other stuff if you want to
for (unsigned i = 0; i < x.size(); i++) {
cout << "x[" << i << "] = " << x[i] << endl;
return 0;


x[0] = 1.23

If you comment out the #define directive, it won't compile.