moretticb / ML-Implementations

Implementations of Machine Learning algorithms
http://www.moretticb.com/tags/#machine-learning
10 stars 2 forks source link

A bug in data read index #1

Open demo-acct opened 5 months ago

demo-acct commented 5 months ago

I think there is a bug here:

sample[c][0] = -1.0;   
   for(i=1;i<=inputs;i++)
    scanf("%lf", &sample[c][i]);

since you started i=1, then scanf should use ("%lf", &sample[c][i-1]). Otherwise the last item will be read unknown memory space.

moretticb commented 5 months ago

Good catch! I should have allocated one more position, as I did at line 171. Feel free to contribute 😎. Perhaps the compiler I used at the time let this one slip without the classic segmentation fault. Thanks!