Re: Excluding NAN entries when summing an array by RS
RS
Thu Sep 21 09:30:56 CDT 2006
Abdo Haji-Ali wrote:
> "RS" <rsina_no.ssppaamm@comcast.net> wrote in message
> news:oMWdnczBh4sQBo_YnZ2dnUVZ_vidnZ2d@comcast.com...
>> Hi all, what is a safe and efficient way to sum the contents of an array
>> or a matrix, skipping any possible NANs or INFs?
>
> What type/container of array/matrix are you using? How are you summing the
> entries up?
>
Hi Abdo,
I am using the Blitz class arrays. But never mind that. How about just
sums on simple arrays, something similar to
double mysum(double *my_array,int n)
{
double sum=0;
for(int i=0;i<n;i++)
sum+=my_array[i]; //modify this to skip possible NANs and INFs
return sum;
}
I am new to VC7 (2003). Is there an "is_nan" utility or function that we
can test the contents of a number with?
Thanks,
RS