forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayHelper.cs
More file actions
41 lines (36 loc) · 1.13 KB
/
ArrayHelper.cs
File metadata and controls
41 lines (36 loc) · 1.13 KB
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
35
36
37
38
39
40
41
using System;
using System.Linq;
namespace NumSharp.UnitTest.Shared
{
internal static class ArrayHelper
{
internal static bool CompareTwoJaggedArrays<T>(T[][] np1, T[][] np2 )
{
bool arraysSame = true;
for(int idx = 0; idx < np1.Length;idx++)
{
for (int jdx = 0; jdx < np2[0].Length;jdx++)
{
if (!np1[idx][jdx].Equals(np2[idx][jdx]))
{
arraysSame = false;
}
else
{
// pass
}
}
}
return arraysSame;
}
internal static T[][] CreateJaggedArrayByMatrix<T>(T[,] np)
{
int dim0 = np.GetLength(0);
int dim1 = np.GetLength(1);
var returnResult = new T[dim0][];
returnResult = returnResult.Select(x => new T[dim1]).ToArray();
returnResult = returnResult.Select((x,idx) => x.Select((y,jdx) => np[idx,jdx]).ToArray()).ToArray();
return returnResult;
}
}
}