I'm confused by variations of the following program:
use v5.36;
use PDL;
use PDL::NiceSlice;
my $v=sequence(2);
my $m=pdl($v->slice(":,*2"), $v->slice("*2,:"));
say $m;

The output is

   [
    [
     [0 1]
     [0 1]
    ]
    [
     [0 0]
     [1 1]
    ]
   ]

which is what I expected. But after a small change:

use v5.36;
use PDL;
use PDL::NiceSlice;
my $v=sequence(2);
my $m=pdl($v->slice(":,*"), $v->slice("*,:"));
say $m;

the output becomes


[
 [
  [0 1]
  [0 0]
 ]
 [
  [0 0]
  [1 0]
 ]
]

The same if I replace * by *1. Was I wrong to expect the same output?
I expected the dummy dimension of size 1 (or unspecified size) would
lead to  the initial array [0 1] being replicated as many times as
required by the actual dimensions of the other arrays.

Best regards,
Luis



-- 

                                                                  o
W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
Av. Universidad s/n CP 62210         |                           (*)/\/  \
Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB


_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to