C polynomial regression for data fitting

Pierre Fromager f168297104 doc : README coverage 3 years ago
doc f168297104 doc : README coverage 3 years ago
src a571dde2d7 fix : sol memory leaks 3 years ago
test 407655ba1e fix : test matcalc 3 years ago
.gitignore a0bb6d5650 cov : add coverage report 3 years ago
Makefile f168297104 doc : README coverage 3 years ago
README.md f168297104 doc : README coverage 3 years ago
buildall.sh 1212d3c174 ref : wip includes + tests 3 years ago
covreport.sh a0bb6d5650 cov : add coverage report 3 years ago

README.md

Polyregress

Polyregress is a c11 portage from initial python polyregress solver.
It provides polynomial equation from a cloud of points.
Higher is the polynomial degree, higher is the accuracy for data fitting.
Keep in mind one degree of polynome represents one inflexion.

Build

to build simply make

make

Doc

to build doc

make doc

Then doc will be generated in the doc/html folder.

Usage

Overview

./polyregress 

Detail

./polyregress -?

The first number of the serie is the higher degree.
The following numbers are XY points and should be paired.
Degree can't be higner than the number of XY points.

echo "4 1 0 2 2 3 1 4 4 5 2" | ./polyregress -

or

./polyregress - <<< "4 1 0 2 2 3 1 4 4 5 2"

or changing instream separator

./polyregress -s ',' - <<< "4,1,0,2,2,3,1,4,4,5,2"

or changing instream separator with debug

./polyregress -d -s ',' - <<< "4,1,0,2,2,3,1,4,4,5,2"

Performance

It can perform from x3 upto x20 faster than the initial script, depending on gcc flags.
Default setup is designed for x20.

time echo "4 1 0 2 2 3 1 4 4 5 2" | ./polyregress -

Removing the # line 14 in Makefile, will enforce security adding sanitizers but downperf to x3.

Read Security-related flags and options for C compilers to know more.

Accuracy

Here we are dealing with double type.
You can change the solution accuracy from the solution.h file.

#define SOL_ACCURACY_FMT "14"

Limitations

Input buffer is limited to 2048 bytes but you can change it in main.

Tests

Tests relied on CUnity/Cunit framework.
Build from source (Release v3.2.7), clone repo and follow the Readme.
Then

make
sudo make install

Build all from root project.

./buildall.sh

Coverage

To generate code coverage

./covreport.sh

Report can be found in doc/covsrc.

covreport

Todo

  • improve tests with coverage

Links