Error C2109. Probability Density Function

Hi All. I'm a newbie in C++.

I want to change the function of probability density function from Gaussian to Kernel(Opendtect). But, I have got an error, "Error C2109: subscript requires array or pointer type"

Is anyone have solution? I'm using Visual Studio 2013. Thanks before.
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
float Gaussian2DProbDenFunc::gtVal( float p0, float p1) const
{
	float x1 = p0;
	float x2 = p1;
	
	const float onemccsq = std0_*std1_;
	const float fac = (float)(0.5 / (M_PI*onemccsq));
	
	int N;
	int epow;
	int r;
	int s;

	double sum = 0.0;
	for (int i = 1; i < N; ++i)
	{
		for (int j = 1; j < N; ++j)
		{
			r = pow((x1 - x1[i]), 2);
			s = pow((x2 - x2[j]), 2);

			epow[x1][x2] = Math::Exp(-1.0f * (r + s) / onemccsq);
			sum += epow[x1][x2];
		}
	}
	return fac * epow;
}

This isn't the full program, just to where the errors occur.
The problem is that nowhere in your code have you defined any array variables.

1
2
3
4
5
6
7
8
9
10
11
12
13
                        // Neither x1 nor x2 are arrays, they are single floating point numbers.
			r = pow((x1 - x1[i]), 2);
			s = pow((x2 - x2[j]), 2);

                        // epow is not a multidimensional array, just a single int.
			epow[x1][x2] = Math::Exp(-1.0f * (r + s) / onemccsq);

                        // Also array indexes must be integral types, not floating point types.
			sum += epow[x1][x2];
		}
	}
        // Why are you all of a sudden treating epow as a single int here?
	return fac * epow;




Topic archived. No new replies allowed.