Duncan Murdoch a écrit :
On 22/01/2010 12:52 PM, Christophe Genolini wrote:
Thanks both of you.
>
> > Inf - Inf
> [1] NaN
So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev
will be NA and !ISNAN(dev) will detect it...
Sothe loop cool be
8.for(i = 0 ; i < taille ; i++)
On 22/01/2010 12:52 PM, Christophe Genolini wrote:
Thanks both of you.
>
> > Inf - Inf
> [1] NaN
So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev
will be NA and !ISNAN(dev) will detect it...
Sothe loop cool be
8.for(i = 0 ; i < taille ; i++) {
10.dev = (x[i] -
A side note: The NA vs NaN does not seem to play a role here, because:
#define both_non_NA(a,b) (!ISNAN(a) && !ISNAN(b))
So, it is the same type of test used in line 9 and in line 11.
/Henrik
On Fri, Jan 22, 2010 at 9:52 AM, Christophe Genolini
wrote:
> Thanks both of you.
>
>>
>> > Inf - Inf
Thanks both of you.
> Inf - Inf
[1] NaN
So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev
will be NA and !ISNAN(dev) will detect it...
Sothe loop cool be
8.for(i = 0 ; i < taille ; i++) {
10.dev = (x[i] - y[i]);
11.if(!ISNAN(dev)) {
12. dist +
Christophe Genolini wrote:
Hi the list,
I need to write some efficient distances function, so I read the code
for the Euclidean distance.
I do not understand the purpose of the line 11 : if x[i] and y[i] are
not NA (line 9), can dev be NA ?
As Romain said, the test is for NaN as well as N
Bonjour Christophe,
NA and NaN are different things... Actually this is tricky because NA is
implemented as a special kind of NaN :
See this extract of R_ext/Arith.h :
int R_IsNA(double); /* True for R's NA only */
int R_IsNaN(double);/* True for special NaN, *not* for
Hi the list,
I need to write some efficient distances function, so I read the code
for the Euclidean distance.
I do not understand the purpose of the line 11 : if x[i] and y[i] are
not NA (line 9), can dev be NA ?
Christophe
#define both_FINITE(a,b) (R_FINITE(a) && R_FINITE(b))
#define both
7 matches
Mail list logo