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

GetData gives incorrect results #29

Open
shanedidona opened this issue Feb 5, 2020 · 3 comments
Open

GetData gives incorrect results #29

shanedidona opened this issue Feb 5, 2020 · 3 comments

Comments

@shanedidona
Copy link

The Matrix.Transpose method seems to be broken for nonsquare arrays.

Example code to produce the error is shown below. It seems that transpose assumes that the incoming matrix dimensions are switched perhaps.
Program.txt

@shanedidona
Copy link
Author

change main to

    static void Main(string[] args)
    {
        ArrayFire.Array ArrayIn = Data.CreateArray(IndexMatrix(5, 7));

        Console.WriteLine("In:");
        Console.WriteLine(ArrayToString(Data.GetData2D<int>(ArrayIn)));

        Util.Print(ArrayIn);

        ArrayFire.Array ArrayOut = Matrix.Transpose(ArrayIn, false);

        Console.WriteLine("");
        Console.WriteLine("Out:");
        Console.WriteLine(ArrayToString(Data.GetData2D<int>(ArrayOut)));

        Util.Print(ArrayOut);

        Thread.Sleep(100000);
    }

and you see that GetData2D may be the issue

@shanedidona shanedidona changed the title Incorrect Transpose GetData gives incorrect results Feb 5, 2020
@shanedidona shanedidona reopened this Feb 5, 2020
@shanedidona
Copy link
Author

Command line output:

In:
0,1,2,3,4,5,6
7,8,9,10,11,12,13
14,15,16,17,18,19,20
21,22,23,24,25,26,27
28,29,30,31,32,33,34
No Name Array
[5 7 1 1]
0 5 10 15 20 25 30
1 6 11 16 21 26 31
2 7 12 17 22 27 32
3 8 13 18 23 28 33
4 9 14 19 24 29 34

Out:
0,5,10,15,20
25,30,1,6,11
16,21,26,31,2
7,12,17,22,27
32,3,8,13,18
23,28,33,4,9
14,19,24,29,34
No Name Array
[7 5 1 1]
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
25 26 27 28 29
30 31 32 33 34

@umar456
Copy link
Member

umar456 commented Feb 5, 2020

ArrayFire is a column major library so consecutive values across the column are going to be represented as consecutive values in memory. The values returned by the array seems correct but the shape seems to be off. I think the IndexArray and ArrayToString need to be reworked to take this into account. If you look at the In array, the values already seem to be transposed.

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