Skip to content

math.size and Matrix.size are inconsistent #1771

@cshaa

Description

@cshaa

The .size() method on matrices always returns number[]. The math.size(x) method, which should be more robust, can take not only Matrix instances, but also array matrices and scalars. For arrays it returns number[], but for matrices it returns an instance of Matrix.

let a = [ [1], [2] ]
let m = math.matrix(a)
math.size(a) // [1,2]
m.size() // [1,2]
math.size(m) // Matrix([1,2])

This is unexpected and useless. Size is usefull when one can read the dimensions rightaway, with matrix, you have to convert it to array first.

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