Closed CodeCs1 closed 2 months ago
you could use jagged arrays instead because multidimensional arrays arent plugged yet
This is what i get:
I use this example code:
int[][] jagged_arr = new int[4][];
jagged_arr[0] = new int[] {1, 2, 3, 4};
jagged_arr[1] = new int[] {11, 34, 67};
jagged_arr[2] = new int[] {89, 23};
jagged_arr[3] = new int[] {0, 45, 78, 53, 99};
Somehow using jagged arrays caused exception.
you might be able to use Multidimensional Indexers (dont know if this is supported in cosmos) to make a wrapper around a d1 array to expose it as 2d
public class MultidimensionalArrary<T> {
T[] data;
int _sizeLevel1;
int _sizeLevel2;
public MultidimensionalArrary<T>(int sizeLevel1, int sizeLevel2)
{
data = new T[sizeLevel1 * sizeLevel2]
_sizeLevel1 = sizeLevel1;
_sizeLevel2 = sizeLevel2;
}
public T this[int index1, int index2]
{
get
{
return data[(index1 * _sizeLevel1) * index2];
}
set
{
data[(index1 * _sizeLevel1) * index2] = value;
}
}
}
note i have not tested this
This is what i get:
I use this example code:
int[][] jagged_arr = new int[4][]; jagged_arr[0] = new int[] {1, 2, 3, 4}; jagged_arr[1] = new int[] {11, 34, 67}; jagged_arr[2] = new int[] {89, 23}; jagged_arr[3] = new int[] {0, 45, 78, 53, 99};
Somehow using jagged arrays caused exception.
jagged arrays are supposed to work in cosmos. are you sure the problem isnt in other regions of your code?
@CodeCs1 You can use Lists, its way better, here is an example :
List<Point> snake;
private class Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y)
{
X = x;
Y = y;
}
}
Issue is already being tracked here https://github.com/CosmosOS/IL2CPU/issues/11
Why i'm open this issue ?
Because i want to know why Cosmos doesn't support matrix array.
What happened ?
When I start to build the project with those code, 'yasm' failed to build.
Error Message:
Cosmos Version
Latest version (dev)
Operating System (in case)
Linux x86_64
So, it there any alternative way to use matrix in Cosmos C#?
--- Sorry for my bad English =| ---