forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon_regens.txt
More file actions
53 lines (44 loc) · 2 KB
/
common_regens.txt
File metadata and controls
53 lines (44 loc) · 2 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
42
43
44
45
46
47
48
49
50
51
52
53
//This is a bank for commonly used regen template
#if _REGEN_GLOBAL
%all_dtypes = ["NDArray","Complex","Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Char","Double","Single","Decimal","String"]
%all_dtypes_lowercase = ["NDArray","Complex","bool","byte","short","ushort","int","uint","long","ulong","char","double","float","decimal","string"]
%supported_primitives = ["Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Char","Double","Single","Decimal","String"]
%supported_primitives_lowercase = ["bool","byte","short","ushort","int","uint","long","ulong","char","double","float","decimal","string"]
#endif
#if _REGEN
%foreach all_dtypes, all_dtypes_lowercase%
/// <summary>
/// Retrieves value of type <see cref="#2"/> from internal storage.
/// </summary>
/// <param name="indices">The shape's indices to get.</param>
/// <returns></returns>
/// <exception cref="NullReferenceException">When <see cref="DType"/> is not <see cref="#2"/></exception>
public #2 Get#1(params int[] indices)
=> _array#1[Shape.GetOffset(Slice, indices)];
%
#else
#endif
switch (_typecode)
{
#if _REGEN
//Since it is a single assignment, we do not use 'as' casting but rather explicit casting that'll also type-check.
%foreach all_dtypes,all_dtypes_lowercase%
case NPTypeCode.#1:
{
_array#1 = (#2[]) array;
break;
}
%
default:
throw new NotImplementedException();
#else
}
#if _REGEN
%all_dtypes = ["Complex","Boolean","Byte","Int16","UInt16","Int32","UInt32","Int64","UInt64","Char","Double","Single","Decimal","String"]
%vals = ["3","false","1","1","1","1","1","1","1","'c'","1d","2f","3","3"]
[DataTestMethod]
%foreach all_dtypes, vals%
[DataRow(typeof(#1),(#1)#2)]
%
#else
#endif