Skip to content

Failure to column-wise-concatenate matrix with itself? #1727

@davidmrdavid

Description

@davidmrdavid

The following snippet of code loads a matrix A from disk and attempts to perform a
column-wise concatenation of it with itself. The original dimensions of A are
[ 253120, 1 ] so I expect the output to be [ 253120, 2 ].

const fs = require("fs");
const math = require("mathjs");

function main () {
    contents = fs.readFileSync("A.json");
    json = JSON.parse(contents);
    let A = math.DenseMatrix.fromJSON(json);
    console.log(A.size());
    let A2 = math.concat(A, A, 1); // This will fail
}

main();

Unfortunately, the script fails with the following error trace:

bash-4.2$ node --max-old-space-size=20000 reproducer1.js
[ 253120, 1 ]

/scratch_user/djusto/tester/node_modules/mathjs/lib/function/matrix/concat.js:91
            throw new _IndexError.IndexError(dim, prevDim + 1);
            ^
Error
/...a larger stack trace .../
bash-4.2$

What could this be? The error suggests a dimensionality error but that couldn't be since I'm concatenating a matrix with itself. Thanks!

Files:
reproduce1.zip

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