OK this time I have a really weird mistake that does not always appear. Here is the function that actually contains problems. All it does is literally summing elements of a vector. It works in most cases but in a few cases it tend to become highly problematic.
int sumvec(vect v) {
int i = 0;
int sum = 0;
int l = v.length();
std::cout << "Sum of vector " << v.tostring(3) << std::endl;
for (; i < l; i++) {
sum += v[i];
std::cout << v[i] << " " << sum << " ";
};
std::cout << std::endl;
return sum;
}
Here vect
is defined using typedef alglib::real_1d_array vect;
. OK so what do I get? Huh..
Sum of vector [1.000,1.000,0.000,1.000,1.000,1.000]
1 0 1 0 0 0 1 0 1 0 1 1
What?!!!!!