Skip to content

SVD outputs NaN for certain inputs #75

Open

Description

@dllu

Example input:

IN> numeric.svd([[         1.2314470096270005,         -8.927990819795772],
 [         0.0710192233504547,        -0.5148893692907976]])

OUT> {U: [[ NaN, NaN], [ NaN, NaN]], S: [ 0, NaN], V: [[ 0.9906, 0.1366], [ 0.1366, -0.9906]]}

Tested on both Chromium and Firefox.

image

However, GNU Octave manages to compute a correct SVD without outputting NaN.

octave:23> A = [[         1.2314470096270005,         -8.927990819795772],
>  [         0.0710192233504547,        -0.5148893692907976]]
A =

   1.231447  -8.927991
   0.071019  -0.514889

octave:24> [U, S, V] = svd(A)
U =

  -0.998341  -0.057576
  -0.057576   0.998341

S =

Diagonal Matrix

   9.0275e+00            0
            0   3.0340e-17

V =

  -0.13664  -0.99062
   0.99062  -0.13664

octave:25> U * S * V'
ans =

   1.231447  -8.927991
   0.071019  -0.514889

Activity

  1. cladelpino commented on Apr 25, 2017

    @cladelpino

    can reproduce:
    x=[[1,2],[2,4]]

    numeric.svd(x).S
    [0, NaN]

    x=[[1,2],[3,6]]

    numeric.svd(x).S
    [7.071067811865476, 0]

  2. sloisel commented on Apr 26, 2017

    @sloisel
    Owner
  3. cladelpino commented on Apr 26, 2017

    @cladelpino

    Thanks to you for this piece of software. Do you have this bug located or do you need help locating it ?

  4. sloisel commented on Apr 26, 2017

    @sloisel
    Owner
  5. ankitrohatgi commented on Dec 26, 2018

    @ankitrohatgi

    For a 3x2 matrix (e.g. numeric.svd([[1,4],[2,5],[3,6]])), I get U as a 3x2 matrix instead of a 3x3 as I was expecting. Any ideas why that might be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions