Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart constructors are transposed #35

Closed
gilgamec opened this issue Nov 8, 2019 · 5 comments
Closed

Smart constructors are transposed #35

gilgamec opened this issue Nov 8, 2019 · 5 comments

Comments

@gilgamec
Copy link

gilgamec commented Nov 8, 2019

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 
@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

@gilgamec what do you suggest then ? Would it be more convenient for the end user if we force her user to specify everything in column-major order ?

@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

I think it might be good to support both, tbh. Row / Column-oriented interfaces for all of the smart constructors, that is.

@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

#37

@gilgamec this should provide a fix so that matrix can be used correctly.

example shown below:

> 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                                                                                                                                                                                                                         

@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

@gilgamec this should be fixed, please re-open if you think otherwise.

@dmjio dmjio closed this as completed Nov 9, 2019
@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

we're converging upon Array perfection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants