Hey, I'm working with a buddy on making this Linear and quadratic regression program and we hit a bug that we both can't seem to figure out. I'm looking for any help I can get, it is greatly appreciated.
Ah... almost forgot to list the error.... The error reads as..Code:// Gary Marosy // CMPSC 201C- 001 // HW5 // Inputs: Points Red from File // Outputs: Equation of the fitted line #include <iostream> #include <cmath> #include <iomanip> #include <fstream> using namespace std; const int SIZE = 20; void getData (double x[], double y[], int& size) { ifstream input; input.open("linear.txt"); size = 0; while (!input.eof()) { input >> x[size] >> y[size]; size++; } input.close(); } void displayResults ( double x[], double y[], double z[], int size) { int i = 0; while (i < SIZE) { cout << "Measured X" << fixed << 5 << "Measured Y" << fixed << 5 << right << endl; cout << x[i] << left << y[i] << right << endl; i++; } } void linearRegress ( double x[], double y[], int size, double &m, double &b ) { int i = 0; while (i < size) { int m; int b; int sumX = 0; int sumY = 0; int sumXY = 0; int sumX2 = 0; int denom; for ( i; i < size; i++) { sumX += x[i]; sumY += y[i]; sumXY += x[i] + y[i]; sumX2 += x[i] * x[i]; denom = (size * sumX2) - (sumX * sumX); m = ((size * sumXY) - (sumX * sumY)) / denom; b = ((sumX2 * sumY) - (sumXY * sumX)) / denom; } } } void quadRegress ( double x[], double y[], int size, double &m, double &b, double &c ); int main () { double x[SIZE]; double y[SIZE]; double z[SIZE]; int numlines = 0; double m = 0; double b = 0; double size = 0; getData(x, y, size); linearRegress (x, y, size, m, b); displayResults (x, y, z, size); return 0; }
1>c:\homeworkfiles.cpp\homework5\homework5.cpp(88 ) : error C2664: 'getData' : cannot convert parameter 3 from 'double' to 'int &'
I've never seen an error like this before.
Thanks again to anyone who can help.



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.