Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 类型为';int';和';双精度(双精度*,双精度*,整数)和#x27;到二进制运算符_C++_Types_Binary_Operator Keyword_Operands - Fatal编程技术网

C++ 类型为';int';和';双精度(双精度*,双精度*,整数)和#x27;到二进制运算符

C++ 类型为';int';和';双精度(双精度*,双精度*,整数)和#x27;到二进制运算符,c++,types,binary,operator-keyword,operands,C++,Types,Binary,Operator Keyword,Operands,我们在课堂上为一个项目做线性回归。我必须写一个函数。我尝试过静态施法和其他方法将这个“int n”改为双精度,这样它就不会抛出错误了?还是我的思路完全错了 作用 void linear_regression(double x[], double y[], int n, double *slope, double *y_int) { double sum_x, sum_y, sum_x_Squared, sum_Squared_x, produ

我们在课堂上为一个项目做线性回归。我必须写一个函数。我尝试过静态施法和其他方法将这个“int n”改为双精度,这样它就不会抛出错误了?还是我的思路完全错了

作用

void linear_regression(double x[], double y[], int n,
                   double *slope, double *y_int)
{    
    double sum_x, sum_y, sum_x_Squared, sum_Squared_x, product_x_y;
    double m = *slope, b = *y_int;

    sum_x = sum_array(x, n);
    sum_y = sum_array(y, n);

    sum_Squared_x = sum_square_array(x, n);
    sum_x_Squared = sum_array(x, n) * sum_array(x, n);

    product_x_y = sum_product_of_arrays(x, y, n);

    //I'm getting an error on the next statement, about the n
    m = ((sum_x * sum_y) - (n * sum_product_of_arrays)) /
            ((sum_x_Squared) - (n * sum_Squared_x));
    b = ((sum_y - (m * sum_x))/(n));

    return;
}
错误消息

Invalid operands of types 'int' and 'double(double*, double*, int)' to
binary operator.

n*sum\u product\u of_array
中,
sum\u product\u of_array
是一个调用以获取
product\u x\u y
的函数。您是否打算使用
product\u x\u y

n*sum\u-product\u of\u-arrays
中,
sum\u-product\u of-arrays
是您调用以获取
product\u-y
的函数。你是不是想用
product\u x\u y

好主意,+1,但为什么这应该成为一个社区维基问题?谢谢。似乎睡眠不足。很好的回答,+1,但为什么这应该成为一个社区维基问题?谢谢。似乎睡眠不足。注意:
double(double*,double*,int)
是一个函数,而不是
double
。注意:
double(double*,double*,int)
是一个函数,而不是
double