Perl 6 - the future is here, just unevenly distributed

IRC log for #pdl, 2015-07-13

| Channels | #pdl index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
05:32 chm sivoais: I built sf390 branch and tried $s=1 with badvalue=0 and badflag=1.  $s<0 seems to
05:32 chm compare as if $s<pdl(0)->badvalue(0)->badflag(1)
05:33 chm Is that the intended result.  It seems like the problem results.
05:33 chm I'm going back to look at the mailing list discussion for context.
06:02 sivoais chm: for when you see this:
06:02 sivoais that's because doing
06:02 sivoais $s = pdl(1)
06:02 sivoais ;
06:03 sivoais $s->badvalue(0);  # when not using BADVAL_PER_PDL, sets 0 to be bad for all double PDLs
06:03 sivoais double->badvalue; # gives 0
06:04 sivoais since 1 < 0 is 0
06:04 sivoais AND
06:04 sivoais the badflag from $s is propagated to the output
06:05 sivoais thus $c = $s < 0; # BAD
06:05 sivoais set the badvalue to something else like 5
06:06 sivoais there is no way around this --- badvalues are supposed to be values that don't come up from a computation
06:06 sivoais and when they can't be set per-PDL, that means that all computations are affected
06:13 sivoais this is unfortunately the semantics of badvalues.
06:13 sivoais Unless the comparison code can change double->badvalue to something other than 0 or 1, there is no way for it to give the correct answer
06:14 sivoais it can't both give the correct answer and return BAD when needed
06:17 sivoais This is similar to how Perl5 has the $ARRAY_BASE / $[ variable to change the index of the first element of arrays
06:17 sivoais Sure, you can do it (it's deprecated), but don't expect other code to handle it. It breaks a lot of assumptions.
06:18 sivoais So is setting badvalues to values that are possible outputs of a computation
06:23 sivoais Another example to show that it is more than just the comparison ops
06:23 sivoais use PDL; $s = pdl([0, 1]); $s->badvalue(1); $s->badflag(1); $s->cos
06:23 sivoais gives
06:24 sivoais # [BAD BAD]
06:25 sivoais and
06:25 sivoais use PDL; $s = pdl([0, 1]); $s->badvalue(1); $s->badflag(0); $s->cos
06:25 sivoais gives
06:25 sivoais # [1 0.54030231]
06:25 sivoais the only difference is that badflag was set on the input PDL
06:33 sivoais joined #pdl
06:34 osfameron joined #pdl
06:34 jberger joined #pdl
14:19 vicash chm,sivoais: shouldn't the default BAD value for double be NAN ?
14:19 vicash that way all calculations will return NAN and all logical comparisons will return false
14:23 vicash 0 cannot be a bad value for double, it is a good value.. you can use HUGE_VAL macro if you do not want to use NAN. on Linux, "man NAN" will give you more info.
14:27 sivoais vicash: it is when the BADVAL_USE_NAN option is enabled (but only for floats and doubles)
14:27 vicash yes but my point is that if you write a PDL script and ship it to someone who doesn't have BADVAL_USE_NAN enabled then the PDL results will not be reproducible..
14:28 vicash NAN is available on almost every system for more than a decade now . the 90s option of making it optional should go away
14:28 vicash and for those embedded systems (?) for which it isnt available, you can use HUGE_VAL which is the largest double that can be represented.. which is also fine
14:29 vicash 0 can be a valid value and calculations can go wrong if it is also a bad value
14:30 sivoais yep, I agree
15:42 sivoais the only problem might be back-compat

| Channels | #pdl index | Today | | Search | Google Search | Plain-Text | summary