digitalmars.D - shouldn't this throw ? iota(5).sliced(2,2)
- Timothee Cour via Digitalmars-d (7/7) Jan 06 2016 what's the rationale for:
- Ilya Yaroshenko (6/15) Jan 06 2016 std.ndslice will contain a module or few for allocations, script
- Timothee Cour via Digitalmars-d (24/38) Jan 08 2016 I'm not sure I understand your argument.
- Ilya (4/13) Jan 08 2016 auto a = iota(5).sliced(5);
- Timothee Cour via Digitalmars-d (6/20) Jan 08 2016 ok good, 'reshape' behaves as it should; but what's the rationale for no...
- Ilya (4/30) Jan 08 2016 Agreed. I will add optional exception (by default sliced will
- Timothee Cour via Digitalmars-d (3/34) Jan 08 2016 thanks!! glad we could agree on this!
what's the rationale for: Range length must be greater than or equal to the sum of shift and the product of lengths instead of: Range length must be equal to the sum of shift and the product of lengths ? It seems more lax and bug-prone.
Jan 06 2016
On Thursday, 7 January 2016 at 04:47:16 UTC, Timothee Cour wrote:what's the rationale for: Range length must be greater than or equal to the sum of shift and the product of lengths instead of: Range length must be equal to the sum of shift and the product of lengths ? It seems more lax and bug-prone.std.ndslice will contain a module or few for allocations, script like code, and concatenations. User defined range may not have slicing, but must be able to be used with `sliced` multiple times with different lengths. -- Ilya
Jan 06 2016
I'm not sure I understand your argument. My problem is that iota(5) has 5 elements which is more than 2*2, so I would expect iota(5).sliced(2,2) or iota(7).sliced(2,3).sliced(1,2) to throw, as in pretty much any other tensor library: *matlab:* reshape(0:4, 2,2) Error using reshape To RESHAPE the number of elements must not change. python with numpy: import numpy as np np.arange(5).reshape((2, 2)) ValueError: total size of new array must be unchanged eigen: http://eigen.tuxfamily.org/dox-devel/unsupported/TensorMorphing_8h_source.html eigen_assert(internal::array_prod(m_impl.dimensions()) == internal::array_prod(op.dimensions())); This behavior will 100% cause hard to find bugs. Why not instead allow this behavior only when a template argument is given: ReshapeAllowsDownsize.yes On Wed, Jan 6, 2016 at 10:39 PM, Ilya Yaroshenko via Digitalmars-d < digitalmars-d puremagic.com> wrote:On Thursday, 7 January 2016 at 04:47:16 UTC, Timothee Cour wrote:what's the rationale for: Range length must be greater than or equal to the sum of shift and the product of lengths instead of: Range length must be equal to the sum of shift and the product of lengths ? It seems more lax and bug-prone.std.ndslice will contain a module or few for allocations, script like code, and concatenations. User defined range may not have slicing, but must be able to be used with `sliced` multiple times with different lengths. -- Ilya
Jan 08 2016
On Saturday, 9 January 2016 at 00:15:10 UTC, Timothee Cour wrote:I'm not sure I understand your argument. My problem is that iota(5) has 5 elements which is more than 2*2, so I would expect iota(5).sliced(2,2) or iota(7).sliced(2,3).sliced(1,2) to throw, as in pretty much any other tensor library: [...]auto a = iota(5).sliced(5); auto b = a.reshape(2, 2); // throws ReshapeException --ilya
Jan 08 2016
ok good, 'reshape' behaves as it should; but what's the rationale for not throwing on 'iota(5).sliced(2,2) ' ? in light of what i wrote above, it's surprising behavior and will cause bugs. What are the advantages of allowing it to not throw? On Fri, Jan 8, 2016 at 6:09 PM, Ilya via Digitalmars-d < digitalmars-d puremagic.com> wrote:On Saturday, 9 January 2016 at 00:15:10 UTC, Timothee Cour wrote:I'm not sure I understand your argument. My problem is that iota(5) has 5 elements which is more than 2*2, so I would expect iota(5).sliced(2,2) or iota(7).sliced(2,3).sliced(1,2) to throw, as in pretty much any other tensor library: [...]auto a = iota(5).sliced(5); auto b = a.reshape(2, 2); // throws ReshapeException --ilya
Jan 08 2016
On Saturday, 9 January 2016 at 04:15:08 UTC, Timothee Cour wrote:ok good, 'reshape' behaves as it should; but what's the rationale for not throwing on 'iota(5).sliced(2,2) ' ? in light of what i wrote above, it's surprising behavior and will cause bugs. What are the advantages of allowing it to not throw? On Fri, Jan 8, 2016 at 6:09 PM, Ilya via Digitalmars-d < digitalmars-d puremagic.com> wrote:Agreed. I will add optional exception (by default sliced will trow). --IlyaOn Saturday, 9 January 2016 at 00:15:10 UTC, Timothee Cour wrote:I'm not sure I understand your argument. My problem is that iota(5) has 5 elements which is more than 2*2, so I would expect iota(5).sliced(2,2) or iota(7).sliced(2,3).sliced(1,2) to throw, as in pretty much any other tensor library: [...]auto a = iota(5).sliced(5); auto b = a.reshape(2, 2); // throws ReshapeException --ilya
Jan 08 2016
On Fri, Jan 8, 2016 at 10:07 PM, Ilya via Digitalmars-d < digitalmars-d puremagic.com> wrote:On Saturday, 9 January 2016 at 04:15:08 UTC, Timothee Cour wrote:thanks!! glad we could agree on this!ok good, 'reshape' behaves as it should; but what's the rationale for not throwing on 'iota(5).sliced(2,2) ' ? in light of what i wrote above, it's surprising behavior and will cause bugs. What are the advantages of allowing it to not throw? On Fri, Jan 8, 2016 at 6:09 PM, Ilya via Digitalmars-d < digitalmars-d puremagic.com> wrote: On Saturday, 9 January 2016 at 00:15:10 UTC, Timothee Cour wrote:Agreed. I will add optional exception (by default sliced will trow). --IlyaI'm not sure I understand your argument.My problem is that iota(5) has 5 elements which is more than 2*2, so I would expect iota(5).sliced(2,2) or iota(7).sliced(2,3).sliced(1,2) to throw, as in pretty much any other tensor library: [...]auto a = iota(5).sliced(5); auto b = a.reshape(2, 2); // throws ReshapeException --ilya
Jan 08 2016