Hello!
1. situation with std::string is something specific for C++ Builder. Unfortunately, we have not tested ALGLIB with newer versions of C++ Builder. string class must be part of std, and I think that it can be fixed by including appropriate files - I just do not have a copy of C++ Builder to experiment with.
2. regarding division by zero. It occurs when all Y[] are same, and total sum-of-squares is zero. Most C++ and C# compilers are compliant with IEEE 754 standard and handle it by returning NAN as result (that's why it was not caught), but C++ Builder raises an exception (I think that it is NOT correct behavior) unless you manually mask floating-point exceptions.
As I told, IEEE 754 compliant should handle it gracefully, but I decided to regard it as a minor bug. It was added to issues tracker http://bugs.alglib.net/view.php?id=524 and will be fixed in upcoming 3.8.0
As for you, you may: (a) manually mask FP exceptions when your program starts (recommended) (b) replace "rep->r2 = 1.0 - rss/tss;" by "rep->r2 = tss>0 ? 1.0 - rss/tss : 1.0;"
|