Hi Guillermo, (I’ve removed the pdl-porters mailing list since that no longer exists)
If I’ve understood you right, I believe a solution to the stated problem is to: * make a PDL::Char from the strings, which will be a (length,n) ndarray * make your mask, a (n) ndarray * use dice_axis with $mask->which to index the char ndarray Example: pdl> p $pchar = PDL::Char->new( ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr'] ) [ 'abc' 'def' 'ghi' 'jkl' 'mno' 'pqr' ] pdl> p $mask = pdl(0,1,1,0,0,0) [0 1 1 0 0 0] pdl> p $pchar->dice_axis(1,$mask->which) [ 'def' 'ghi' ] Note that it may work as well or better in your application to just generate indices directly. A fairly extreme example of this can be seen at https://github.com/wlmb/Photonic/blob/7b79d61f38c7a7a4b1fc7f51caca455f9a588af5/lib/Photonic/Utils.pm#L410-L423 Please also take a look at the new (as of 2.080) vector operations contributed by the mighty Bryan Jurish from PDL::VectorValued, at https://metacpan.org/pod/PDL::Primitive#cmpvec Best regards, Ed From: Guillermo P. Ortiz<mailto:gor...@exa.unne.edu.ar> Sent: 16 June 2022 00:36 To: pdl-general@lists.sourceforge.net<mailto:pdl-general@lists.sourceforge.net>; pdl-de...@lists.sourceforge.net<mailto:pdl-de...@lists.sourceforge.net>; PDL Forum<mailto:pdl-port...@jach.hawaii.edu> Subject: [Pdl-devel] it is possible to mask PDL::Char ndarrays Dear pdl development and pdl friends, I am trying to add a bunch of strings with same length into a pdl in order to may select some of them using a mask, but I do not know if it is possible using PDL::Char for example, or any other usual PDL + some tricks? Thanks in advance for your comments Regards -- Dr. Guillermo P. Ortiz Electromagnetismo Aplicado Dto. Física, Facultad de Ciencias Exactas Universidad Nacional del Nordeste Avda Libertad 5460, W3404AAS Corrientes, Argentina. (+54) 379-4424678 interno 4613 gortiz at unne edu ar
_______________________________________________ pdl-general mailing list pdl-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-general