News for hackers. Stuff that matters.
Re:Why I often implement things from scratch (2006) by enriquto on Sunday March 08, 2020 @11:24AM (#22518450)
> 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.

Re:Why I often implement things from scratch (2006) by crispyambulance on Sunday March 08, 2020 @03:43PM (#22520079)
Sure, 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.

Re:Why I often implement things from scratch (2006) by NohatCoder on Sunday March 08, 2020 @04:56PM (#22520563)
If 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.
Re:Why I often implement things from scratch (2006) by crispyambulance on Monday March 09, 2020 @08:55AM (#22524961)
I 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.
Re:Why I often implement things from scratch (2006) by SilasX on Sunday March 08, 2020 @06:15PM (#22520993)
I 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".

Re:Why I often implement things from scratch (2006) by heisenbit on Sunday March 08, 2020 @12:04PM (#22518715)
I 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.

Re:Why I often implement things from scratch (2006) by ci5er on Sunday March 08, 2020 @09:06PM (#22522001)
And, 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.