Skip to content

Eidos should allow matrices and arrays with zero elements #562

@bhaller

Description

@bhaller

In R you can do:

> y = matrix(integer(0), nrow=3, ncol=0)
> y

[1,]
[2,]
[3,]

In Eidos you cannot:

> y = matrix(integer(0), nrow=3, ncol=0)
ERROR (Eidos_ExecuteFunction_matrix): dimension <= 0 requested, which is not allowed.

This is arbitrarily limiting, and should be fixed; it will get in the way of algorithms that generate a result matrix with an unknown N number of rows, where N could be 0, for example. It forces the user to check for the zero case and avoid the error, rather than simply making the matrix with 0 rows.

Unfortunately I wrote all the existing matrix code in Eidos on the assumption that dimensions are always non-zero, so I will have to vet the existing code very carefully to fix this, and add new unit tests for this case for every existing function/method/operator that takes a matrix parameter/operand. So this is a rainy-week project.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions