News for hackers. Stuff that matters.
Re:Why I often implement things from scratch (2006) by NohatCoder on Monday March 09, 2020 @04:14AM (#22523798)
You have already got floating point inaccuracy on the input, even if the library somehow avoid inaccuracy when computing the determinant, it can't tell the reason for a zero or almost-zero arising. What is the library supposed to do? You will have to deal with the issue of either a very big numbers matrix, or no matrix at all, in any case.

This is a great example of the fallacy of believing that a library automatically solves arbitrary issues.

Re:Why I often implement things from scratch (2006) by SilasX on Monday March 09, 2020 @07:59AM (#22524674)
>You have already got floating point inaccuracy on the input,

Not if they come in as integers that have to be coerced at some point.

>What is the library supposed to do?

Compare ad to bc instead of ad - bc to zero, for one.

>This is a great example of the fallacy of believing that a library automatically solves arbitrary issues.

I didn’t say that and don’t believe it. My point only depends on he library having avoided more domain-specific rookie mistakes than I would have caught in five minutes, when it comes to computational linear algebra. Like the sibling commenter, I don’t think libraries are a panacea, and the answer depends on the specifics of the case.

Re:Why I often implement things from scratch (2006) by NohatCoder on Monday March 09, 2020 @02:52PM (#22528465)
>Not if they come in as integers that have to be coerced at some point.

In which case you can calculate the determinant exactly with your own roll, but a library will likely force you to convert everything to doubles.

>Compare ad to bc instead of ad - bc to zero, for one.

That is the same thing, a compare instruction is basically just a subtract that doesn't write the output, so you get zero/equality in exactly the same cases. Most compilers will probably turn your code into doing just one subtract and then check the flags, no matter which version you write.