@@ -62,6 +62,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
62
62
Debug . Assert ( size > 0 ) ;
63
63
#if _REGEN
64
64
#region Compute
65
+ Func < int [ ] , int > getOffset = x . Shape . GetOffset ;
65
66
switch ( x . typecode ) {
66
67
% foreach supported_dtypes, supported_dtypes_lowercase %
67
68
case NPTypeCode. #1 : {
@@ -71,7 +72,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
71
72
int offset;
72
73
do
73
74
{
74
- offset = x . Shape . GetOffset ( coords ) ;
75
+ offset = getOffset ( coords ) ;
75
76
if ( ! ( src [ offset ] == default ( #2 ) ) )
76
77
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
77
78
} while ( incr . Next ( ) != null ) ;
@@ -83,8 +84,8 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
83
84
}
84
85
#endregion
85
86
#else
86
-
87
87
#region Compute
88
+ Func < int [ ] , int > getOffset = x. Shape. GetOffset;
88
89
switch ( x . typecode ) {
89
90
case NPTypeCode . Boolean : {
90
91
var incr = new NDCoordinatesIncrementor ( x . shape ) ;
@@ -93,8 +94,8 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
93
94
int offset ;
94
95
do
95
96
{
96
- offset = x . Shape . GetOffset ( coords ) ;
97
- if ( src [ offset ] )
97
+ offset = getOffset ( coords ) ;
98
+ if ( ! ( src [ offset ] == default ( bool ) ) )
98
99
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
99
100
} while ( incr . Next ( ) != null ) ;
100
101
@@ -107,7 +108,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
107
108
int offset ;
108
109
do
109
110
{
110
- offset = x . Shape . GetOffset ( coords ) ;
111
+ offset = getOffset ( coords ) ;
111
112
if ( ! ( src [ offset ] == default ( byte ) ) )
112
113
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
113
114
} while ( incr . Next ( ) != null ) ;
@@ -121,7 +122,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
121
122
int offset;
122
123
do
123
124
{
124
- offset = x . Shape . GetOffset ( coords ) ;
125
+ offset = getOffset ( coords ) ;
125
126
if ( ! ( src [ offset ] == default ( short ) ) )
126
127
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
127
128
} while ( incr . Next ( ) != null ) ;
@@ -135,7 +136,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
135
136
int offset;
136
137
do
137
138
{
138
- offset = x . Shape . GetOffset ( coords ) ;
139
+ offset = getOffset ( coords ) ;
139
140
if ( ! ( src [ offset ] == default ( ushort ) ) )
140
141
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
141
142
} while ( incr . Next ( ) != null ) ;
@@ -149,7 +150,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
149
150
int offset;
150
151
do
151
152
{
152
- offset = x . Shape . GetOffset ( coords ) ;
153
+ offset = getOffset ( coords ) ;
153
154
if ( ! ( src [ offset ] == default ( int ) ) )
154
155
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
155
156
} while ( incr . Next ( ) != null ) ;
@@ -163,7 +164,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
163
164
int offset;
164
165
do
165
166
{
166
- offset = x . Shape . GetOffset ( coords ) ;
167
+ offset = getOffset ( coords ) ;
167
168
if ( ! ( src [ offset ] == default ( uint ) ) )
168
169
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
169
170
} while ( incr . Next ( ) != null ) ;
@@ -177,7 +178,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
177
178
int offset;
178
179
do
179
180
{
180
- offset = x . Shape . GetOffset ( coords ) ;
181
+ offset = getOffset ( coords ) ;
181
182
if ( ! ( src [ offset ] == default ( long ) ) )
182
183
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
183
184
} while ( incr . Next ( ) != null ) ;
@@ -191,7 +192,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
191
192
int offset ;
192
193
do
193
194
{
194
- offset = x . Shape . GetOffset ( coords ) ;
195
+ offset = getOffset ( coords ) ;
195
196
if ( ! ( src [ offset ] == default ( ulong ) ) )
196
197
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
197
198
} while ( incr . Next ( ) != null ) ;
@@ -205,7 +206,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
205
206
int offset ;
206
207
do
207
208
{
208
- offset = x . Shape . GetOffset ( coords ) ;
209
+ offset = getOffset ( coords ) ;
209
210
if ( ! ( src [ offset ] == default ( char ) ) )
210
211
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
211
212
} while ( incr . Next ( ) != null ) ;
@@ -219,7 +220,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
219
220
int offset ;
220
221
do
221
222
{
222
- offset = x . Shape . GetOffset ( coords ) ;
223
+ offset = getOffset ( coords ) ;
223
224
if ( ! ( src [ offset ] == default ( double ) ) )
224
225
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
225
226
} while ( incr . Next ( ) != null ) ;
@@ -233,7 +234,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
233
234
int offset ;
234
235
do
235
236
{
236
- offset = x . Shape . GetOffset ( coords ) ;
237
+ offset = getOffset ( coords ) ;
237
238
if ( ! ( src [ offset ] == default ( float ) ) )
238
239
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
239
240
} while ( incr . Next ( ) != null ) ;
@@ -247,7 +248,7 @@ private static unsafe NDArray<int>[] nonzeros<T>(NDArray<T> x) where T : unmanag
247
248
int offset ;
248
249
do
249
250
{
250
- offset = x . Shape . GetOffset ( coords ) ;
251
+ offset = getOffset ( coords ) ;
251
252
if ( ! ( src [ offset ] == default ( decimal ) ) )
252
253
nonzeroCoords. Add ( coords . CloneArray ( ) ) ;
253
254
} while ( incr . Next ( ) != null ) ;
0 commit comments