Prior Click here
NaN means Not A Number

if (s1.length()!=s2.length()) return double.NaN;
               int len=s1.length();
               double sum_mul=0;
               for (int i=0;i<=len-1;i++)
                        sum_mul+=(s1.list[i]*s2.list[i]);
               return (sum_mul-len*s1.mean()*s2.mean())/(len-1);

To move code like this from something destined to run on one or more
CPUs and cores to a GPU requires that a separate module be built
with the same code but with the kernel keyword added and a separate
compile be done.

Then we have a three way choice - run the code or something like it in
the cloud; run the same multi-threaded code on a local CPU or  attach
the compiled kernel module and run somewhat different code on the
GPU.  
Chronology Click here