Hi Chris. Yes $i should have been $idx.
Thanks for the bitwise & hint. I had read that a while back but had forgotten it. Regards Vikas. On 09/26/2014 02:41 PM, Chris Marshall wrote: > I'm not sure what $i is ($idx?) but the warning is > from this expression: > > $a > 0 && $a->index($i) < 0 > > And the problem is that you are using the perl logical > && rather than the overloaded bitwise & to combine the > masks. Change to > > ($a > 0) & ($a->index($i) < 0) > > and things should work better. I've added some parens > to avoid warning about possible precedence issues.... > > > Cheers, > Chris > > On Fri, Sep 26, 2014 at 2:16 PM, Vikas N Kumar <[email protected]> wrote: >> Hi >> >> I am stumped by the problems I face with simple conditionals in using >> the which() function. I have tried many different ways in trying to >> solve it but none of them give me the result I want. >> >> Here is a sample: >> >> use PDL; >> # a random list of values that are above and below 0 >> my $a = randsym(100) - 0.5; >> >> # create a lag of 1 >> my $idx = xvals($a->dims) - 1; >> $i = $i->setbadif($i < 0)->setbadtoval(0); # can this be more elegant ? >> >> # find all the positions where $a[i] > 0 and $a[i - 1] < 0 >> # in essence where $a crosses the zero line >> my $b = zeroes($a->dims); >> my $b_idx = which($a > 0 && $a->index($i) < 0); >> >> # set those points as 1 >> $b->index($b_idx) .= 1; >> >> Everytime I run this I get "multielement piddle in conditional >> expression" errors. >> >> I have not been able to find an elegant solution to this problem. I >> cannot seem to create a mask that has more than 1 piddle comparisons. >> >> Please help. >> >> Thanks >> Vikas >> >> >> _______________________________________________ >> Perldl mailing list >> [email protected] >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
