2024-05-23 20:37:44 +02:00
|
|
|
|
using System;
|
2024-05-23 13:53:03 +02:00
|
|
|
|
|
2024-05-23 20:37:44 +02:00
|
|
|
|
namespace AioNet.DataStructures
|
2024-05-23 13:53:03 +02:00
|
|
|
|
{
|
2024-05-23 20:37:44 +02:00
|
|
|
|
public static class Matrix
|
|
|
|
|
|
{
|
|
|
|
|
|
public static int NumberOfRows<T>(this T[,] source)
|
|
|
|
|
|
{
|
|
|
|
|
|
return source.GetLength(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int NumberOfColumns<T>(this T[,] source)
|
|
|
|
|
|
{
|
|
|
|
|
|
return source.GetLength(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static T[][] ToJaggedArray<T>(this T[,] source)
|
|
|
|
|
|
{
|
|
|
|
|
|
int rows = source.NumberOfRows();
|
|
|
|
|
|
int columns = source.NumberOfColumns();
|
|
|
|
|
|
|
|
|
|
|
|
T[][] jaggedArray = new T[rows][];
|
|
|
|
|
|
|
|
|
|
|
|
for (int row = 0; row < rows; row++)
|
|
|
|
|
|
{
|
|
|
|
|
|
T[] currentRow = new T[columns];
|
|
|
|
|
|
|
|
|
|
|
|
for (int column = 0; column < columns; column++)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentRow[column] = source[row, column];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jaggedArray[row] = currentRow;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return jaggedArray;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-23 13:53:03 +02:00
|
|
|
|
}
|