I try to make a grep like on a PDL matrix or array of Vector :
my @toto;
push(@toto, pdl(1,2,3));
push(@toto, pdl(4,5,6));
my $titi=pdl(1,2,3);
print("OK") if (grep { $_ eq $titi} @toto);
I also tried
my @toto;
push(@toto, pdl(1,2,3));
push(@toto, pdl(4,5,6));
my $titi=pdl(1,2,3);
print("OK") if (grep { $_ eq $titi} PDL::Matrix->pdl(\@toto));
None works.
Any help Please
Disclaimer: I don't know anything about PDL. I've read the source to figure this one out.
There's a function PDL::all()
that you can use in conjunction with the overloaded comparison operator ==
.
use PDL;
my $foo = pdl(1,2,3);
my $bar = pdl(4,5,6);
my $qrr = pdl(1,2,3);
print "OK 1" if PDL::all( $foo == $bar );
print "OK 2" if PDL::all( $foo == $qrr );
I'm still looking for the documentation.