Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

expression?

expression
0
Posted

expression?

0

Yes you can, but not in the way you probably tried first. It is not possible to use a piddle directly in a conditional expression since this is usually poorly defined. Instead PDL has two very useful func- tions: ” any” and ” all” . Use these to test if any or all elements in a piddle fulfils some criterion: perldl> $a=pdl ( 1, -2, 3); perldl> print ’$a has at least one element < 0’ if (any $a < 0); $a has at least one element < 0 perldl> print ’$a is not positive definite’ unless (all $a > 0); $a is not positive definite it is really very simple: Do not use logial operators on multi-element piddles since that really doesn’t make sense, instead write the example as: $mask = which($piddle > 1 & $piddle < 2); which works correctly.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123