3 ms·
> I am in the camp that says calling the library is (in the general case) You misunderstood the question. The question is not about the general case. It is a
by enriquto 7y ago
> I am in the camp that says calling the library is (in the general case)
You misunderstood the question. The question is not about the general case. It is about solving a linear system of two equations and two variables. The solution is not found by "an algorithm", it is a simple formula that fits in one line.
- heisenbit 7y agoI was tending to go in your direction, but then the formula contains a division and we could be faced with a division by zero error. Which makes me a bit uncertain whether it is so simple. If we are guaranteed the matrix is invertible then doing it by hand is something I would prefer. And likely if it is not then as well since... The invertibility issue also plagues any library and while it may not blow up by a division by zero we likely still would need to handle that case. This requires to understand the libraries handling of corner cases and how it affects the results.
- crispyambulance 7y agoSure, if you're solving a 2x2 in ONE place in a piece of software, it makes sense to just perform the computation directly without using a library. Realistically speaking, though, if you're doing one 2x2 computation, you're probably going to end up doing a bunch of other linear algebra as well. If you don't do linear algebra in your everyday work, the threshold from rolling-your-own solution to grabbing a library is going to come up very quickly. The Armstrong example is perhaps a bit mis-titled. He's talking about "implementing from scratch" only insofar as he can use the facilities of his platform to perform exactly the task he needs to do rather than bringing in a huge dependency, in this case, an FTP server that does a lot more than the one task at hand.
- NohatCoder 7y agoIf you don't know how to do linear algebra, a library is unlikely to help you. Rote stuff like matrix inversion is the easy part, figuring that that is what you need is where things tend to get hairy.
- crispyambulance 7y agoI think also that people can "know" linear algebra but not be skilled it's practical implementation and usage in software. That's partly why computation libraries are among the longest-lived pieces of software in existence.
- SilasX 7y agoI hate to nitpick like this, but... The question asked about inverting a 2x2 matrix, nothing about solving a linear system of equations. The latter is certainnly one common use of inverting a matrix, sure, but from the problem as given, the use-case could just as well be "report to the end user what the inverse is".
- ci5er 7y agoAnd, now, we know why we have an explosion of libraries that do the job badly OR end up with bloated binaries by including LINPACK when a one-liner would have done the trick. You triggered a conversation thread that made me understand the ecosystem dynamics a bit better. Thank you.