Re:Why I often implement things from scratch (2006)
by cochne on Sunday March 08, 2020 @05:27PM
(#22520735)
It might be helpful to have some actual example code of what this looks like. In Python it would be
(This doesn't do any input checking including if the determinant is 0)
[ Parent
| on HN ]
Re:Why I often implement things from scratch (2006)
by SilasX on Sunday March 08, 2020 @06:10PM
(#22520969)
>This doesn't do any input checking including if the determinant is 0
Which seems to me like it assumes away a big part of the difficulty -- you'd need to follow up with: for this problem domain, what am I doing with the answer? How do I need to handle a singular matrix? Should do I throw an exception, and how should the caller handle it?
Re:Why I often implement things from scratch (2006)
by PureParadigm on Sunday March 08, 2020 @09:46PM
(#22522192)
Compared to the library version:
import numpy as np
np.linalg.inv([[1,2],[3,4]])
and this does handle the case where the determinant is 0 (by throwing an error about it being a singular matrix).
Re:Why I often implement things from scratch (2006)
by xaedes on Monday March 09, 2020 @08:50AM
(#22524930)
Avoid np.linalg.inv if you can do it in another way.. It slows the already slow python even more. Recently replaced np.linalg.inv by an affine transformation inverse (what was really needed) in one of our codebases to get a speedup of 100x.