the expr works fine with expr (isnan($f1), 0, $f1). The route f method doesn't work since NaN is treated as a valid floating point "number".
thanks for the help, David Brynjar
On Sat, Sep 13, 2008 at 11:05 AM, tim info@timvets.net wrote:
[expr] contains a function 'isnan'. Not sure how to use it though. can someone give an example ?
Tim
On Sat, 2008-09-13 at 10:36 -0400, David Brynjar Franzson wrote:
Hi,
is there any simple way to replace all NaN values with Zeros or
to filter them out?
thanks, David Brynjar
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-- ................................... www.timvets.net info@timvets.net, timvets@gmail.com 0032 474 89 66 86 skype: tim167_ ...................................
David Brynjar Franzson wrote:
the expr works fine with expr (isnan($f1), 0, $f1). The route f method doesn't work since NaN is treated as a valid floating point "number".
on pd-0.40-3-extended (osx intel) trying to use this i get :
expr: syntax error: illegal comma
, 0 , $f1
error: expr: syntax error expr (isnan($f1) , 0 , $f1) ... couldn't create
Hallo, Damian Stewart hat gesagt: // Damian Stewart wrote:
David Brynjar Franzson wrote:
the expr works fine with expr (isnan($f1), 0, $f1). The route f method doesn't work since NaN is treated as a valid floating point "number".
on pd-0.40-3-extended (osx intel) trying to use this i get :
expr: syntax error: illegal comma
, 0 , $f1
error: expr: syntax error expr (isnan($f1) , 0 , $f1) ... couldn't create
There's an "if" missing. Try: "expr if(isnan($f1) , 0 , $f1)" instead.
Frank
is there a pure Pd way to remove NaNs? i can't use expr with rjdj..
damian stewart | skype: damiansnz | damian@frey.co.nz frey | live art with machines | http://www.frey.co.nz
Damian Stewart wrote:
is there a pure Pd way to remove NaNs? i can't use expr with rjdj..
i thought expr is part of the RjDj distro... but then: you can test while i cannot. and this might be one of the "later this week" licensing things.
fgmasdr IOhannes
Hallo, IOhannes m zmoelnig hat gesagt: // IOhannes m zmoelnig wrote:
Damian Stewart wrote:
is there a pure Pd way to remove NaNs? i can't use expr with rjdj..
i thought expr is part of the RjDj distro...
Only the BSD parts of Pd are included in RjDj at the moment, so you cannot use expr - which is tricky, as in fact there are several math functions missing now in RjDj's Pd, for example no [pow~] yet - but this will come as a builtin as soon as RjDj jumps to 0.42.
Frank
Frank Barknecht wrote:
Hallo, IOhannes m zmoelnig hat gesagt: // IOhannes m zmoelnig wrote:
Damian Stewart wrote:
is there a pure Pd way to remove NaNs? i can't use expr with rjdj..
i thought expr is part of the RjDj distro...
Only the BSD parts of Pd are included in RjDj at the moment, so you cannot use expr - which is tricky, as in fact there are several math functions missing now in RjDj's Pd, for example no [pow~] yet - but this will come as a builtin as soon as RjDj jumps to 0.42.
and judging from the lack of replies i assume detecting NaNs is one of these things as well...
Damian Stewart wrote:
Frank Barknecht wrote:
Hallo, IOhannes m zmoelnig hat gesagt: // IOhannes m zmoelnig wrote:
Damian Stewart wrote:
is there a pure Pd way to remove NaNs? i can't use expr with rjdj..
i thought expr is part of the RjDj distro...
Only the BSD parts of Pd are included in RjDj at the moment, so you cannot use expr - which is tricky, as in fact there are several math functions missing now in RjDj's Pd, for example no [pow~] yet - but this will come as a builtin as soon as RjDj jumps to 0.42.
and judging from the lack of replies i assume detecting NaNs is one of these things as well...
Adding this functionality would be trivial, if you want you can add a ticket on track regarding the issue. In the long run the correct solution would be to try to figure out why there are NaN's ... and fix it there.
Günter
On Wed, 29 Oct 2008 17:55:00 +0100 Gunter Geiger geiger@xdv.org wrote:
Only the BSD parts of Pd are included in RjDj at the moment, so you cannot use expr - which is tricky, as in fact there are several math functions missing now in RjDj's Pd, for example no [pow~] yet - but this will come as a builtin as soon as RjDj jumps to 0.42.
Just a quick but important note: Please make sure [pow~] is compatible with latest vanilla versions and not the broken (reversed parameter) version from cyclone.
cheers,
Andy
On Wed, Oct 29, 2008 at 11:55 AM, Gunter Geiger geiger@xdv.org wrote:
Adding this functionality would be trivial, if you want you can add a ticket on track regarding the issue. In the long run the correct solution would be to try to figure out why there are NaN's ... and fix it there.
Günter
My best guess is that NaN's come from underflow, under normal circumstances. I wish there would be an easy way to change this behavior via a compiler flag, but I don't think there is.
It seems to be a more pervasive problem, and it's unreasonable to expect to add NaN handlers in application code. Thank the IEEE standards for this gem.
Chuck
My best guess is that NaN's come from underflow, under normal circumstances. I wish there would be an easy way to change this behavior via a compiler flag, but I don't think there is.
It seems to be a more pervasive problem, and it's unreasonable to expect to add NaN handlers in application code. Thank the IEEE standards for this gem.
I did some more searching around to find that someone has written just such a handler for underflow here: http://www.cenapad.unicamp.br/parque/manuais/Ibmcxx/complink/tasks/tutrapex....
The code uses the sigcontext struct when a floating point exception occurs, to set the result to zero, once an underflow is created.
Underflow traps are enabled by (gcc) compiler flag -mfp-trap-mode=u
I'm really not sure about how all of this can be applied successfully. Has anyone implemented this kind of handler before?
Charles Henry wrote:
My best guess is that NaN's come from underflow, under normal circumstances. I wish there would be an easy way to change this behavior via a compiler flag, but I don't think there is.
It seems to be a more pervasive problem, and it's unreasonable to expect to add NaN handlers in application code. Thank the IEEE standards for this gem.
I did some more searching around to find that someone has written just such a handler for underflow here: http://www.cenapad.unicamp.br/parque/manuais/Ibmcxx/complink/tasks/tutrapex....
The code uses the sigcontext struct when a floating point exception occurs, to set the result to zero, once an underflow is created.
Underflow traps are enabled by (gcc) compiler flag -mfp-trap-mode=u
I'm really not sure about how all of this can be applied successfully. Has anyone implemented this kind of handler before?
In the perform routine of sqosc~, I used: if (finite(sample))*out++ = sample; else *out++ = 0.0; to get rid of denormals.
For MSW builds that required adding: #include <float.h> /* for _finite */ #define finite _finite
Seems like the simplest solution to me...
Martin
On Wed, Oct 29, 2008 at 2:03 PM, Martin Peach martin.peach@sympatico.ca wrote:
In the perform routine of sqosc~, I used: if (finite(sample))*out++ = sample; else *out++ = 0.0; to get rid of denormals.
For MSW builds that required adding: #include <float.h> /* for _finite */ #define finite _finite
Seems like the simplest solution to me...
It might be simplest, but it's very inefficient. Consider if all pd objects had to check every sample to see that it's a number....
NaN and inf should be fairly rare occurrences. No sense adding more instructions to cover the mere possibility of something going wrong--an interrupt/signal based solution would add less cost to the program, if it's possible.
But where would such a signal handler be declared (my guess is m_pd.h)? Would everything need to be compiled with the added flag(s) (my guess is yes)? Would there be variations across platforms (no clue here)?
Chuck
Damian Stewart wrote:
David Brynjar Franzson wrote:
the expr works fine with expr (isnan($f1), 0, $f1). The route f method doesn't work since NaN is treated as a valid floating point "number".
on pd-0.40-3-extended (osx intel) trying to use this i get :
expr: syntax error: illegal comma
... which is because it needs to be expr ( if(isnan($f1), 0, $f1) )