Skip to content

Commit a009aad

Browse files
committed
GetCoordinatesFromAbsoluteIndex calls GetCoordinates for unsliced shape
1 parent 3e4f7b7 commit a009aad

File tree

1 file changed

+1
-44
lines changed

1 file changed

+1
-44
lines changed

src/NumSharp.Core/View/Shape.cs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -938,51 +938,8 @@ public int[] GetCoordinates(int offset)
938938
[MethodImpl((MethodImplOptions)768)]
939939
public int[] GetCoordinatesFromAbsoluteIndex(int offset)
940940
{
941-
int[] coords = null;
942941
if (!IsSliced)
943-
{
944-
if (strides.Length == 1)
945-
coords = new int[] { offset };
946-
else if (layout == 'C')
947-
{
948-
int counter = offset;
949-
coords = new int[strides.Length];
950-
int stride;
951-
for (int i = 0; i < strides.Length; i++)
952-
{
953-
stride = strides[i];
954-
if (stride == 0)
955-
{
956-
coords[i] = 0;
957-
}
958-
else
959-
{
960-
coords[i] = counter / stride;
961-
counter -= coords[i] * stride;
962-
}
963-
}
964-
}
965-
else
966-
{
967-
int counter = offset;
968-
coords = new int[strides.Length];
969-
int stride;
970-
for (int i = strides.Length - 1; i >= 0; i--)
971-
{
972-
stride = strides[i];
973-
if (stride == 0)
974-
{
975-
coords[i] = 0;
976-
}
977-
else
978-
{
979-
coords[i] = counter / stride;
980-
counter -= coords[i] * stride;
981-
}
982-
}
983-
}
984-
return coords;
985-
}
942+
return GetCoordinates(offset);
986943

987944
// handle sliced shape
988945
int[] parent_coords = null;

0 commit comments

Comments
 (0)