reimplement matrix inverse algo, pending debugging
fix bugs with inverse
fix more bugs with inverse