-
Notifications
You must be signed in to change notification settings - Fork 134
Adding Moore-Penrose pseudo-inverse of a matrix as per issue #463 #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@Arafatk I do believe there are more economical ways to get an accurate pseudo inverse than gesvd, it certainly was the most common way before but newer algorithms have been around. EDIT : Most of these methods aren't available to nmatrix right now. |
fd2cba0 to
b8b7f1f
Compare
|
I think it's fine to merge this, even if it's not the most efficient implementation possible. If someone else wants to make it more efficient later, then they can submit a new pull request. @Arafatk is this patch otherwise ready to be reviewed and merged? |
|
@wlevine Yes, it is fit for review and merging. |
|
@MohawkJohn Thanks for the review. |
|
@wlevine, didn't you see an error like this at some point? |
1b2c9b5 to
6930c7c
Compare
|
Is this okay? |
f17061f to
9c04728
Compare
|
Okay, that's a small improvement, but not the one I'm getting at. Sorry for my delayed response. Was getting surgery. |
|
How did it work after replacing with a constant! This is weird. I'll investigate this further as soon as I get a breather from college. I remember getting an error of this sort at some point too. Can exactly place it. |
|
No, no. I'm asking you to help him rearrange his test code so it makes more sense. Right now it's written really redundantly. |
lib/nmatrix/math.rb
Outdated
| largest_singular_value = s[0] | ||
| (0...s.shape[0]).each do |i| | ||
| largest_singular_value = s[i] if largest_singular_value < s[i] | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need this loop? Is s[0] not always the largest singular value?
Otherwise, can't you just do largest_singular_value = s.max.to_f instead of lines 167-170?
|
@MohawkJohn oh lol. Ok will do that tonight. |
Squashed commit of the following: commit a773004 Author: Arafatk <arafat@iitkpg.ac.in> Date: Wed Mar 23 13:33:47 2016 +0530 removing loop commit 9c04728 Author: Arafatk <arafat@iitkpg.ac.in> Date: Fri Mar 11 10:32:24 2016 +0530 Adding Moore pseudo inverse Squashed commit of the following: commit 2d335f84de81032811b840cbabb1cb58adbbc294 Author: Arafatk <arafat@iitkpg.ac.in> Date: Fri Mar 11 10:31:07 2016 +0530 Improving tests commit f17061f Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Mar 5 12:25:59 2016 +0530 Removing un-necessary spaces commit fa908ac Author: Arafatk <arafat@iitkpg.ac.in> Date: Fri Mar 4 10:33:23 2016 +0530 Corrections to spec tests commit 9d9ab35 Author: Arafatk <arafat@iitkpg.ac.in> Date: Tue Mar 1 20:40:33 2016 +0530 Adding Moore-Penrose pseudo-inverse of a matrix Squashed commit of the following: commit 8c02601d5cd065071c4378c16a5a525477033b87 Author: Arafatk <arafat@iitkpg.ac.in> Date: Tue Mar 1 20:39:17 2016 +0530 correcting Docs commit b8b7f1f Author: Arafatk <arafat@iitkpg.ac.in> Date: Mon Feb 29 23:55:14 2016 +0530 Squashed commit of the following: commit fd2cba0 Author: Arafatk <arafat@iitkpg.ac.in> Date: Mon Feb 29 23:52:33 2016 +0530 correcting docs commit 87eeaae Author: Arafatk <arafat@iitkpg.ac.in> Date: Mon Feb 29 23:26:17 2016 +0530 Adding complex data type commit f3950b1 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sun Feb 28 09:39:05 2016 +0530 Adding Moore-Penrose pseudo-inverse of a matrix Squashed commit of the following: commit dbba0c1 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 23:20:31 2016 +0530 Adding Pseudo inverse commit 32a49e6 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 22:24:19 2016 +0530 correcting error in docs commit 8031cc8 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 21:06:55 2016 +0530 Correcting load error commit 4b0b375 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 18:59:25 2016 +0530 Correcting Load error in Spec Tests commit 2fffafc Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 17:22:08 2016 +0530 Improving Docs Adding Tests commit 6e0ab74 Author: Arafatk <arafat@iitkpg.ac.in> Date: Wed Feb 24 22:28:21 2016 +0530 Adding Moore-Penrose pseudo-inverse of a matrix
|
Replaced with #574. |
* Adding pseudo inverse Squashed commit of the following: commit a773004 Author: Arafatk <arafat@iitkpg.ac.in> Date: Wed Mar 23 13:33:47 2016 +0530 removing loop commit 9c04728 Author: Arafatk <arafat@iitkpg.ac.in> Date: Fri Mar 11 10:32:24 2016 +0530 Adding Moore pseudo inverse Squashed commit of the following: commit 2d335f84de81032811b840cbabb1cb58adbbc294 Author: Arafatk <arafat@iitkpg.ac.in> Date: Fri Mar 11 10:31:07 2016 +0530 Improving tests commit f17061f Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Mar 5 12:25:59 2016 +0530 Removing un-necessary spaces commit fa908ac Author: Arafatk <arafat@iitkpg.ac.in> Date: Fri Mar 4 10:33:23 2016 +0530 Corrections to spec tests commit 9d9ab35 Author: Arafatk <arafat@iitkpg.ac.in> Date: Tue Mar 1 20:40:33 2016 +0530 Adding Moore-Penrose pseudo-inverse of a matrix Squashed commit of the following: commit 8c02601d5cd065071c4378c16a5a525477033b87 Author: Arafatk <arafat@iitkpg.ac.in> Date: Tue Mar 1 20:39:17 2016 +0530 correcting Docs commit b8b7f1f Author: Arafatk <arafat@iitkpg.ac.in> Date: Mon Feb 29 23:55:14 2016 +0530 Squashed commit of the following: commit fd2cba0 Author: Arafatk <arafat@iitkpg.ac.in> Date: Mon Feb 29 23:52:33 2016 +0530 correcting docs commit 87eeaae Author: Arafatk <arafat@iitkpg.ac.in> Date: Mon Feb 29 23:26:17 2016 +0530 Adding complex data type commit f3950b1 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sun Feb 28 09:39:05 2016 +0530 Adding Moore-Penrose pseudo-inverse of a matrix Squashed commit of the following: commit dbba0c1 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 23:20:31 2016 +0530 Adding Pseudo inverse commit 32a49e6 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 22:24:19 2016 +0530 correcting error in docs commit 8031cc8 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 21:06:55 2016 +0530 Correcting load error commit 4b0b375 Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 18:59:25 2016 +0530 Correcting Load error in Spec Tests commit 2fffafc Author: Arafatk <arafat@iitkpg.ac.in> Date: Sat Feb 27 17:22:08 2016 +0530 Improving Docs Adding Tests commit 6e0ab74 Author: Arafatk <arafat@iitkpg.ac.in> Date: Wed Feb 24 22:28:21 2016 +0530 Adding Moore-Penrose pseudo-inverse of a matrix * Added pendings for jruby. Also made sure pendings were marked for object dtypes (instead of just using `next`)
I have used Singular Value decomposition from Atlas to make the pinv function.It is very similar to pinv.