shouldn't this throw ? iota(5).sliced(2,2)

Timothee Cour via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 8 20:15:08 PST 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 at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20160108/a0f0e783/attachment.html>


More information about the Digitalmars-d mailing list