From b86e88413d4c6ec428aaedb147f7675f28882fe4 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 14 Jul 2023 12:36:50 +0930 Subject: clang-format -i applied to src unittest misc --- src/linreg.c | 87 ++++++++++++++++++++++++++++-------------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) (limited to 'src/linreg.c') diff --git a/src/linreg.c b/src/linreg.c index f37634d..4e985df 100644 --- a/src/linreg.c +++ b/src/linreg.c @@ -34,73 +34,68 @@ along with this program; if not, see . */ +#include "linreg.h" + +#include #include #include -#include -#include "linreg.h" #include "comp_prim.h" +void linreg(COMP *m, COMP *b, float x[], COMP y[], int n) { + float sumx = 0.0; /* sum of x */ + float sumx2 = 0.0; /* sum of x^2 */ + COMP sumxy = {0.0, 0.0}; /* sum of x * y */ + COMP sumy = {0.0, 0.0}; /* sum of y */ + COMP sumy2 = {0.0, 0.0}; /* sum of y**2 */ + float denom; + COMP zero; + int i; + + for (i = 0; i < n; i++) { + sumx += x[i]; + sumx2 += x[i] * x[i]; + sumxy = cadd(sumxy, fcmult(x[i], y[i])); + sumy = cadd(sumy, y[i]); + sumy2 = cadd(sumy2, cmult(y[i], y[i])); + } -void linreg(COMP *m, COMP *b, float x[], COMP y[], int n) -{ - float sumx = 0.0; /* sum of x */ - float sumx2 = 0.0; /* sum of x^2 */ - COMP sumxy = {0.0,0.0}; /* sum of x * y */ - COMP sumy = {0.0,0.0}; /* sum of y */ - COMP sumy2 = {0.0,0.0}; /* sum of y**2 */ - float denom; - COMP zero; - int i; - - for (i=0; i