Open shanedidona opened 4 years ago
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
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
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.
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