fluo
02-14-2013, 07:28 AM
Hello,
I would like to try the example program "xcorrel.cpp" which calls the function "correl". I copied the main from the NR directory I have bought and I have included some header files (copied in the same directory of my main).
When I compile with the command g++ I find this errors:
#include <iostream>
#include <iomanip>
#include "nr3.h"
#include "fourier.h"
#include "correl.h"
using namespace std;
int main()
{
const int N=64;
int i,j;
DP cmp;
Vec_DP data1(N),data2(N),ans(N);
for (i=0;i<N;i++) {
if ((i > N/2-N/8-1) && (i < N/2+N/8-1))
data1[i]=1.0;
else
data1[i]=0.0;
data2[i]=data1[i];
}
NR::correl(data1,data2,ans);
// Calculate directly
cout << setw(3) << "n" << setw(15) << "CORREL";
cout << setw(19) << "direct calc." << endl;
cout << fixed << setprecision(6);
for (i=0;i<=16;i++) {
cmp=0.0;
for (j=0;j<N;j++)
cmp += data1[((i+j) % N)]*data2[j];
cout << setw(3) << i << setw(16) << ans[i];
cout << setw(16) << cmp << endl;
}
return 0;
}
esercizio.cpp: In function 'int main()':
esercizio.cpp:12: error: 'DP' was not declared in this scope
esercizio.cpp:12: error: expected `;' before 'cmp'
esercizio.cpp:13: error: 'Vec_DP' was not declared in this scope
esercizio.cpp:13: error: expected `;' before 'data1'
esercizio.cpp:17: error: 'data1' was not declared in this scope
esercizio.cpp:19: error: 'data1' was not declared in this scope
esercizio.cpp:20: error: 'data2' was not declared in this scope
esercizio.cpp:20: error: 'data1' was not declared in this scope
esercizio.cpp:22: error: 'NR' has not been declared
esercizio.cpp:22: error: 'data1' was not declared in this scope
esercizio.cpp:22: error: 'data2' was not declared in this scope
esercizio.cpp:22: error: 'ans' was not declared in this scope
esercizio.cpp:28: error: 'cmp' was not declared in this scope
Thank you for your attention,
Fluo
I would like to try the example program "xcorrel.cpp" which calls the function "correl". I copied the main from the NR directory I have bought and I have included some header files (copied in the same directory of my main).
When I compile with the command g++ I find this errors:
#include <iostream>
#include <iomanip>
#include "nr3.h"
#include "fourier.h"
#include "correl.h"
using namespace std;
int main()
{
const int N=64;
int i,j;
DP cmp;
Vec_DP data1(N),data2(N),ans(N);
for (i=0;i<N;i++) {
if ((i > N/2-N/8-1) && (i < N/2+N/8-1))
data1[i]=1.0;
else
data1[i]=0.0;
data2[i]=data1[i];
}
NR::correl(data1,data2,ans);
// Calculate directly
cout << setw(3) << "n" << setw(15) << "CORREL";
cout << setw(19) << "direct calc." << endl;
cout << fixed << setprecision(6);
for (i=0;i<=16;i++) {
cmp=0.0;
for (j=0;j<N;j++)
cmp += data1[((i+j) % N)]*data2[j];
cout << setw(3) << i << setw(16) << ans[i];
cout << setw(16) << cmp << endl;
}
return 0;
}
esercizio.cpp: In function 'int main()':
esercizio.cpp:12: error: 'DP' was not declared in this scope
esercizio.cpp:12: error: expected `;' before 'cmp'
esercizio.cpp:13: error: 'Vec_DP' was not declared in this scope
esercizio.cpp:13: error: expected `;' before 'data1'
esercizio.cpp:17: error: 'data1' was not declared in this scope
esercizio.cpp:19: error: 'data1' was not declared in this scope
esercizio.cpp:20: error: 'data2' was not declared in this scope
esercizio.cpp:20: error: 'data1' was not declared in this scope
esercizio.cpp:22: error: 'NR' has not been declared
esercizio.cpp:22: error: 'data1' was not declared in this scope
esercizio.cpp:22: error: 'data2' was not declared in this scope
esercizio.cpp:22: error: 'ans' was not declared in this scope
esercizio.cpp:28: error: 'cmp' was not declared in this scope
Thank you for your attention,
Fluo