Help with arrays

I get errors on the lines where I'm attempting to multiply elements of the arrays. It says "expression must have arithmetic or unscoped enum type". What's wrong?

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
double computeSum(double **xData, double **yData, double dataSize, double &m, double &b)
{
  int i;
  double sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0; temp;

  for (i = 0; i < dataSize; i++)
  {
    temp = xData[i] * yData[i];
    sum1 = sum1 + temp;
  }

  for (i = 0; i < dataSize; i++)
  {
    temp = xData[i];
    sum2 = sum2 + temp;
  }

  for (i = 0; i < dataSize; i++)
  {
    temp = yData[i];
    sum3 = sum3 + temp;
  }

  for (i = 0; i < dataSize; i++)
  {
    temp = xData[i] * xData[i];
    sum4 = sum4 + temp;
  }

  m = ((dataSize * sum1) - (sum2 * sum3)) / ((dataSize * sum4) - (sum2 * sum2));

  b = (sum3 - (m * sum2)) / dataSize;
}
How are you calling this function? Are you sure you need double **xData which is a pointer to a pointer to a double, rather than just double *xData which is a pointer to a double. For an ordinary one-dimensional array, the latter would be more usual.
Oh wow. Thanks
Topic archived. No new replies allowed.