Skip to content

A bug for the transpose of ImmutableDenseMatrix #2032

@bingao

Description

@bingao

Hi,

The bug is at line 83 of the file symengine/matrices/transpose.cpp:

t[j * x.ncols() + i] = x.get(i, j);

which should be

t[j * x.nrows() + i] = x.get(i, j);

This bug is not found by symengine/tests/matrix/test_matrixexpr.cpp due to a square ImmutableDenseMatrix being used in the test. See lines 308-312:

    auto A1 = immutable_dense_matrix(
        2, 2, {integer(2), integer(23), integer(5), integer(9)});
    auto A1T = immutable_dense_matrix(
        2, 2, {integer(2), integer(5), integer(23), integer(9)});
    REQUIRE(eq(*transpose(A1), *A1T));

I suggest a non-square matrix for this test.

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