public class Converters
{
public static TOutput[,] ConvertAll<TInput, TOutput>(TInput[,] array, Converter<TInput, TOutput> converter)
{
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
if (converter is null)
{
throw new ArgumentNullException(nameof(converter));
}
var output = new TOutput[array.GetLengthGetLongLength(0), array.GetLengthGetLongLength(1)];
for (intlong row = 0; row < array.GetLengthGetLongLength(0); row++)
{
for (intlong column = 0; column < array.GetLengthGetLongLength(1); column++)
{
output[row, column] = converter(array[row, column]);
}
}
return output;
}
public static TOutput[,,] ConvertAll<TInput, TOutput>(TInput[,,] array, Converter<TInput, TOutput> converter)
{
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
if (converter is null)
{
throw new ArgumentNullException(nameof(converter));
}
var output = new TOutput[array.GetLengthGetLongLength(0), array.GetLengthGetLongLength(1), array.GetLengthGetLongLength(2)];
for (intlong dim1 = 0; dim1 < array.GetLengthGetLongLength(0); dim1++)
{
for (intlong dim2 = 0; dim2 < array.GetLengthGetLongLength(1); dim2++)
{
for (intlong dim3 = 0; dim3 < array.GetLengthGetLongLength(2); dim3++)
{
output[dim1, dim2, dim3] = converter(array[dim1, dim2, dim3]);
}
}
}
return output;
}
public static TOutput[,,,] ConvertAll<TInput, TOutput>(TInput[,,,] array, Converter<TInput, TOutput> converter)
{
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
if (converter is null)
{
throw new ArgumentNullException(nameof(converter));
}
var output = new TOutput[array.GetLengthGetLongLength(0), array.GetLengthGetLongLength(1), array.GetLengthGetLongLength(2), array.GetLengthGetLongLength(3)];
for (intlong dim1 = 0; dim1 < array.GetLengthGetLongLength(0); dim1++)
{
for (intlong dim2 = 0; dim2 < array.GetLengthGetLongLength(1); dim2++)
{
for (intlong dim3 = 0; dim3 < array.GetLengthGetLongLength(2); dim3++)
{
for (intlong dim4 = 0; dim4 < array.GetLengthGetLongLength(3); dim4++)
{
output[dim1, dim2, dim3, dim4] = converter(array[dim1, dim2, dim3, dim4]);
}
}
}
}
return output;
}
public static TOutput[,,,,] ConvertAll<TInput, TOutput>(TInput[,,,,] array, Converter<TInput, TOutput> converter)
{
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
if (converter is null)
{
throw new ArgumentNullException(nameof(converter));
}
var output = new TOutput[array.GetLengthGetLongLength(0), array.GetLengthGetLongLength(1), array.GetLengthGetLongLength(2), array.GetLengthGetLongLength(3), array.GetLengthGetLongLength(4)];
for (intlong dim1 = 0; dim1 < array.GetLengthGetLongLength(0); dim1++)
{
for (intlong dim2 = 0; dim2 < array.GetLengthGetLongLength(1); dim2++)
{
for (intlong dim3 = 0; dim3 < array.GetLengthGetLongLength(2); dim3++)
{
for (intlong dim4 = 0; dim4 < array.GetLengthGetLongLength(3); dim4++)
{
for (intlong dim5 = 0; dim5 < array.GetLengthGetLongLength(4); dim5++)
{
output[dim1, dim2, dim3, dim4, dim5] = converter(array[dim1, dim2, dim3, dim4, dim5]);
}
}
}
}
}
return output;
}
public static TOutput[,,,,,] ConvertAll<TInput, TOutput>(TInput[,,,,,] array, Converter<TInput, TOutput> converter)
{
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
if (converter is null)
{
throw new ArgumentNullException(nameof(converter));
}
var output = new TOutput[array.GetLengthGetLongLength(0), array.GetLengthGetLongLength(1), array.GetLengthGetLongLength(2), array.GetLengthGetLongLength(3), array.GetLengthGetLongLength(4), array.GetLengthGetLongLength(5)];
for (intlong dim1 = 0; dim1 < array.GetLengthGetLongLength(0); dim1++)
{
for (intlong dim2 = 0; dim2 < array.GetLengthGetLongLength(1); dim2++)
{
for (intlong dim3 = 0; dim3 < array.GetLengthGetLongLength(2); dim3++)
{
for (intlong dim4 = 0; dim4 < array.GetLengthGetLongLength(3); dim4++)
{
for (intlong dim5 = 0; dim5 < array.GetLengthGetLongLength(4); dim5++)
{
for (intlong dim6 = 0; dim6 < array.GetLengthGetLongLength(5); dim6++)
{
output[dim1, dim2, dim3, dim4, dim5, dim6] = converter(array[dim1, dim2, dim3, dim4, dim5, dim6]);
}
}
}
}
}
}
return output;
}
}