Skip to content

Smart constructors are transposed #35

Closed
@gilgamec

Description

@gilgamec

This was mentioned in #22, but I'll make an Issue for it here. The data provided to the smart constructors matrix, cube, and tensor is validated (in terms of row and column sizes) in row-major order, but the constructors all flatten the input lists and use mkArray, which enters the data in the column-major order. This leads to, first, properly arranged rows and columns being invalid:

λ> A.matrix (3,2) [[1,2,3],[4,5,6]]
*** Exception: AFException {afExceptionType = SizeError, afExceptionCode = 203, afExceptionMsg = "Invalid elements provided. Expected 6 elements received 4"}

and, second, if the input lists are transposed so they validate OK, the data in the Array doesn't even follow the rows and columns provided:

λ> A.matrix (3,2) [[1,2],[3,4],[5,6]]
ArrayFire Array
[3 2 1 1]
    1.0000     4.0000 
    2.0000     5.0000 
    3.0000     6.0000 

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