error C3861: identifier not found

Hi,

I'm working on a program that was written by someone else. It is for a research project that builds on the original author's work.

I didn't know any c++ before I started, but I know enough about programming to get by for the most part. The problem I'm having at the moment is this:

The code as it is produces 3 voxel grids with the values representing the x, y, and z components of the vector potential of a dipole at the origin respectively. I want to modify the code so that it produces the vector potential of two dipoles, separated by a distance.

The functions that produces the dipole is in a header file. I simply copied the dipole function and renamed it, then altered the code in the renamed version. I wanted to keep the original in there so I could easily call whichever one I wanted.

The problem is that I get an "identifier not found" error when I build the code. I get the same problem for each component of the vector potential, so I will only post the code for one.

The function is called in the main function like this
Dipole_TS_theta4(TS_Proj1, ny, lx, ly, lz, rad_sup);

At the top of the main function is

#include "../prvt.h"

In the prvt.cpp file are the function definitions


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void Dipole_TS_theta4(vector<vector<vector<complex<double> > > > &T_Proj,
			 const size_t ny, const double lx,
			 const double ly, const double lz, const double rad_sup)
{
	const size_t nt = T_Proj.size();
	const size_t nz = T_Proj[0].size();
	const size_t nx = T_Proj[0][0].size();
	//
	vector<vector<vector<complex<double> > > > Wx = CreateWF(nx, ny, nz, complex<double>(0,0));
	vector<vector<vector<complex<double> > > > Wy = CreateWF(nx, ny, nz, complex<double>(0,0));
	vector<vector<vector<complex<double> > > > Wz = CreateWF(nx, ny, nz, complex<double>(0,0));
	//
	const double PI = 3.141592653589793;
	const double dth = PI/(nt-1);
	const double h = ly/ny;
	complex<double> XI0, XI1, XI2;
	double theta;
	for(size_t t=0; t<nt; t++)
	{
		theta = t*dth;
		/*
			Find the vector potential, Wx, Wy, and Wz at a particular angle theta
		*/
		FirstProjection_MD4(Wx, Wy, Wz, lx, ly, lz, theta, rad_sup);
		/*
			Project in the -y-direction by integrating in the -y-direction.
			Using composite Simpson's rule
		*/
		for(size_t k=0; k<nz; k++)
		{
			for(size_t i=0; i<nx; i++)
			{
				XI0 = Wy[k][0][i] +Wy[k][ny-1][i];
				XI1 = complex<double>(0,0);
				XI2 = complex<double>(0,0);
				for(size_t j=1; j<ny/2; j++)
				{
					XI2 += Wy[k][2*j][i];
					XI1 += Wy[k][2*j-1][i];
				}
				T_Proj[t][k][i] = -h*(XI0 +2.0*XI2 +4.0*XI1)/3.0;
			}
		}
	}
}


and

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
void FirstProjection_MD4(vector<vector<vector<complex<double> > > > &Wx, 
				  vector<vector<vector<complex<double> > > > &Wy,
				  vector<vector<vector<complex<double> > > > &Wz, const double lx, const double ly, 
				  const double lz, const double theta, const double rad_sup)
{
	const size_t nz = Wx.size();
	const size_t ny = Wx[0].size();
	const size_t nx = Wx[0][0].size();
	const double dx = lx/nx;
	const double dy = ly/ny;
	const double dz = lz/nz;
	const double x0 = lx/2.0;
	const double y0 = ly/2.0;
	const double z0 = lz/2.0;
	double z, rleft, rleft2, rleft3,rright, rright2, rright3,xleft,y,xright,xleft1,y1,xright1;
	const double R = 10.0;
	const double R2 = R*R;
	const double R3 = R2*R;
	const double mu = 0.04;
	const double reg_param = 0.01;
	const double cos_theta = cos(theta);
	const double sin_theta = sin(theta);
	complex<double> wx, wy;
	for(size_t k=0; k<nz; k++)
	{
		z = k*dz -z0;
		for(size_t j=0; j<ny; j++)
		{
			y= j*dy -y0;
			for(size_t i=0; i<nx; i++)
			{
				xleft = i*dx -3*x0/4;
				//
				xleft1 = xleft*cos_theta -y*sin_theta;
				y1 = xleft*sin_theta +y*cos_theta;
				//
				rleft2 = xleft1*xleft1 + y1*y1 +z*z;
				rleft = sqrt(rleft2);
				rleft3 = rleft2*rleft;	

				xright = i*dx -x0/4;
				//
				xright1 = xright*cos_theta -y*sin_theta;
				
				//
				rright2 = xright1*xright1 + y1*y1 +z*z;
				rright = sqrt(rright2);
				rright3 = rright2*rright;	

				/*
					Rotate the wavefield in the xy-plane
				*/
				wx = complex<double>(((-mu/(rleft3/R3 +reg_param))*y1/R)+((-mu/(rright3/R3 +reg_param))*y1/R), 0);
				wy = complex<double>(((mu/(rleft3/R3 +reg_param))*xleft1/R)+((mu/(rleft3/R3 +reg_param))*xleft1/R), 0);
				Wx[k][j][i] = wx*cos_theta +wy*sin_theta;
				Wy[k][j][i] = -wx*sin_theta +wy*cos_theta;
				Wz[k][j][i] = complex<double>(0, 0);
			}
		}
	}
	/*
		Set the wavefield outside a radius rad_sup to zero
	*/
	CircularApertureWF(Wx, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, rad_sup);
	CircularApertureWF(Wy, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, rad_sup);
	CircularApertureWF(Wz, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, rad_sup);
}


When I compile, I get the error

'FirstProjection_MD4': identifier not found

Strangely, I don't get the problem for Dipole_TS_theta4

I also just noticed that I get the problem even if I only call the original functions (they don't have the 4 at the end of the name) unless I delete my new attempted definitions from the pvrt.cpp file. If I remove them the code compiles and runs properly. I've tried searching but it always turns out to be a typo or something that causes the error, and I can't see a typo in my code. Hopefully someone can help out. Thanks in advance :)

Are you declaring FirstProjection_MD4()? If not, then it should be defined before Dipole_TS_theta4().
Every symbol needs to be at least be declared before it's used, or the compiler can't figure out how to parse the code.

By the way,
vector<vector<vector<complex<double> > > >
That's terrible. Was this in the original code?
Last edited on
Thanks heaps. Swapping the order fixed it (At least it compiled. I haven't tried running it yet). Your explanation makes perfect sense, but I'm confused as to why this wasn't causing a problem with the definition of the original functions, which were/are in the same order and weren't previously declared either.

And yes, that was in the original code. When you say it's terrible, are you saying that just because it looks bad, or is it poor coding?
It incurs in a huge amount of copying every time one of the sizes changes. There are better ways to represent matrices.
closed account (zb0S216C)
Is irstProjection_MD4( ) declared after the definition of Dipole_TS_theta4( ) or before it (prototype)?

Wazzak
Topic archived. No new replies allowed.