Skip to content

GetData gives incorrect results #29

Description

@shanedidona

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

Activity

  1. shanedidona commented on Feb 5, 2020

    @shanedidona
    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

  2. changed the title [-]Incorrect Transpose[/-] [+]GetData gives incorrect results[/+] on Feb 5, 2020
  3. shanedidona commented on Feb 5, 2020

    @shanedidona
    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

  4. umar456 commented on Feb 5, 2020

    @umar456
    Member

    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

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