Skip to content

Conversation

@arafatkatze
Copy link

I have used Singular Value decomposition from Atlas to make the pinv function.It is very similar to pinv.

@gtamba
Copy link

gtamba commented Feb 27, 2016

@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.

@arafatkatze arafatkatze force-pushed the pinv branch 2 times, most recently from fd2cba0 to b8b7f1f Compare February 29, 2016 18:24
@wlevine
Copy link

wlevine commented Mar 1, 2016

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?

@arafatkatze
Copy link
Author

@wlevine Yes, it is fit for review and merging.

@arafatkatze
Copy link
Author

@MohawkJohn Thanks for the review.
I am not sure why the build is failing because of this should properly calculate floor for complex128 FAILED (0.01s)

@translunar
Copy link
Member

@wlevine, didn't you see an error like this at some point?

@arafatkatze arafatkatze force-pushed the pinv branch 2 times, most recently from 1b2c9b5 to 6930c7c Compare March 9, 2016 15:27
@arafatkatze
Copy link
Author

[:float32, :float64, :complex64, :complex128].each do |dtype|
might be replaced by this

  NON_INTEGER_DTYPES.each do |dtype|
    next if dtype == :object

Is this okay?

@arafatkatze arafatkatze force-pushed the pinv branch 2 times, most recently from f17061f to 9c04728 Compare March 11, 2016 04:56
@translunar
Copy link
Member

Okay, that's a small improvement, but not the one I'm getting at.

Sorry for my delayed response. Was getting surgery.

@translunar
Copy link
Member

@v0dro Maybe you could give @Arafatk a tip on this one?

@v0dro
Copy link
Member

v0dro commented Mar 18, 2016

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.

@translunar
Copy link
Member

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.

largest_singular_value = s[0]
(0...s.shape[0]).each do |i|
largest_singular_value = s[i] if largest_singular_value < s[i]
end
Copy link

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?

@v0dro
Copy link
Member

v0dro commented Mar 19, 2016

@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
translunar added a commit that referenced this pull request Mar 4, 2017
@translunar
Copy link
Member

Replaced with #574.

@translunar translunar closed this Mar 4, 2017
translunar added a commit that referenced this pull request Mar 12, 2017
* 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`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants