multiply got error for different shape
see my project: https://github.com/RexHuang/GaussNewton.js
I want to get result of following: Jf = nj.array([[1.3009595627444526,9.007230966684432],[1.6924957839670183,23.436086522021778],[2.201868575113508,45.734101316607926],[2.8645419789086186,79.33095528080969],[3.726653280367031,129.00795614214644],[4.848225222175984,201.4009610995515],[6.30734496560592,305.6835907468525],[8.205600748567576,454.4937036239815]]); Jf.T.multiply(Jf)
but got error:
Uncaught Error: cwise: Arrays do not all have the same shape!
at muleq_cwise_thunk (eval at n.exports (numjs.min.js:3),
I had use matrixjs to solve the problem, pls study from https://github.com/Airblader/matrixjs
Here's some of my implementation: // var delta = (Jf.T.multiply(Jf)).inv().multiply(Jf.T).multiply(r); var Mat_Jf=Jf.flatten().tolist().toMatrix(Jf.shape[0],Jf.shape[1]); var Mat_r=r.flatten().tolist().toMatrix(r.shape[0],r.shape[1]); var Mat_delta = Mat_Jf.transpose().multiply(Mat_Jf).inverse().multiply(Mat_Jf.transpose()).multiply(Mat_r); delta=nj.array(Mat_delta.toArray()).reshape(params.shape[0],params.shape[1]);
We also need the implement of inv() I like numjs, hope we can improve:)