Skip to content

Commit f57ecda

Browse files
committed
Changed NDOffsetIncrementor to accept only Shape.
1 parent 189c07f commit f57ecda

17 files changed

Lines changed: 61 additions & 68 deletions

src/NumSharp.Core/Backends/Iterators/NDIterator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected void setDefaults_NoCast()
235235

236236
case IteratorType.Matrix:
237237
case IteratorType.Tensor:
238-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
238+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
239239
MoveNext = () => *((TOut*)localBlock.Address + iterator.Next());
240240
MoveNextReference = () => ref Unsafe.AsRef<TOut>(((TOut*)localBlock.Address + iterator.Next()));
241241
Reset = () => iterator.Reset();
@@ -356,7 +356,7 @@ protected void autoresetDefault_NoCast()
356356
break;
357357
case IteratorType.Matrix:
358358
case IteratorType.Tensor:
359-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
359+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
360360
MoveNext = () => *((TOut*)localBlock.Address + iterator.Next());
361361
MoveNextReference = () => ref Unsafe.AsRef<TOut>(((TOut*)localBlock.Address + iterator.Next()));
362362
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIterator.template.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected void setDefaults___1__() //__1__ is the input type
128128

129129
case IteratorType.Matrix:
130130
case IteratorType.Tensor:
131-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
132132
MoveNext = () => convert(*((__1__*)localBlock.Address + iterator.Next()));
133133
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
134134
Reset = () => iterator.Reset();
@@ -241,7 +241,7 @@ protected void autoresetDefault___1__()
241241
break;
242242
case IteratorType.Matrix:
243243
case IteratorType.Tensor:
244-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
245245
MoveNext = () => convert(*((__1__*)localBlock.Address + iterator.Next()));
246246
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
247247
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Boolean.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Boolean() //Boolean is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Boolean*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Boolean()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Boolean*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Byte.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Byte() //Byte is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Byte*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Byte()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Byte*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Char.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Char() //Char is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Char*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Char()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Char*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Decimal.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Decimal() //Decimal is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Decimal*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Decimal()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Decimal*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Double.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Double() //Double is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Double*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Double()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Double*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Int16.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Int16() //Int16 is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Int16*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Int16()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Int16*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Int32.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Int32() //Int32 is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Int32*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Int32()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Int32*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

src/NumSharp.Core/Backends/Iterators/NDIteratorCasts/NDIterator.Cast.Int64.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generated by Regex Templating Engine at 27/07/2019 17:32:10 UTC
1+
//Generated by Regex Templating Engine at 03/08/2019 15:03:34 UTC
22
//template source: C:\Users\Eli-PC\Desktop\SciSharp\NumSharp\src\NumSharp.Core\Backends\Iterators\NDIterator.template.cs
33

44
using System;
@@ -127,7 +127,7 @@ protected void setDefaults_Int64() //Int64 is the input type
127127

128128
case IteratorType.Matrix:
129129
case IteratorType.Tensor:
130-
var iterator = new NDOffsetIncrementor(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
130+
var iterator = new NDOffsetIncrementor(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
131131
MoveNext = () => convert(*((Int64*)localBlock.Address + iterator.Next()));
132132
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
133133
Reset = () => iterator.Reset();
@@ -240,7 +240,7 @@ protected void autoresetDefault_Int64()
240240
break;
241241
case IteratorType.Matrix:
242242
case IteratorType.Tensor:
243-
var iterator = new NDOffsetIncrementorAutoresetting(Shape.dimensions, Shape.strides); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
243+
var iterator = new NDOffsetIncrementorAutoresetting(Shape); //we do not copy the dimensions because there is not risk for the iterator's shape to change.
244244
MoveNext = () => convert(*((Int64*)localBlock.Address + iterator.Next()));
245245
MoveNextReference = () => throw new NotSupportedException("Unable to return references during iteration when casting is involved.");
246246
HasNext = () => true;

0 commit comments

Comments
 (0)