Skip to content

Found a test case where numeric.svd returns an incorrect decomposition #62

Open

Description

@corybarr
//tested with numeric.js version 1.2.6

var countsMatrix = [[0,0,1,1,0,0,0,0,0],[0,0,0,0,0,1,0,0,1],[0,1,0,0,0,0,0,1,0],[0,0,0,0,0,0,1,0,1],[1,0,0,0,0,1,0,0,0],[1,1,1,1,1,1,1,1,1],[1,0,1,0,0,0,0,0,0],[0,0,0,0,0,0,1,0,1],[0,0,0,0,0,2,0,0,1],[1,0,1,0,0,0,0,1,0],[0,0,0,1,1,0,0,0,0]];

var svd = numeric.svd(countsMatrix);

var U = svd.U;
var UTranspose = numeric.transpose(U);

//U should be a unitary matrix, so transpose(U) * U should be the identity matrix:
//http://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm

var shouldBeIdentity = numeric['*'](UTranspose, U);
//However, it isn't the identity matrix:
console.log(JSON.stringify(shouldBeIdentity));

Activity

  1. valette commented on Jan 6, 2016

    @valette

    Same here:
    svd works fine on this matrix:
    M = [
    [5, 0, 0],
    [0, 1, 0],
    [ 0, 0, 1]
    ]
    https://jsfiddle.net/bwrkerqv/

    but fails on that one (which is the same with switched columns/rows):
    M = [
    [1, 0, 0],
    [0, 1, 0],
    [ 0, 0, 5]
    ]
    https://jsfiddle.net/vyvj1o9f/

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions