Esempio n. 1
0
        internal static double Dot(DoubleArrayVector x, SparseVector y)
        {
            double sum  = 0;
            int    xlen = x.Length;
            int    ylen = y.Length;
            int    i    = 0;
            int    j    = 0;

            while (i < xlen && j < ylen)
            {
                if (i == y.indices[j])
                {
                    sum += x.values[i++] * y.values[j++];
                }
                else
                {
                    if (i > y.indices[j])
                    {
                        ++j;
                    }
                    else
                    {
                        ++i;
                    }
                }
            }
            return(sum);
        }
 internal static double Dot(DoubleArrayVector x, DoubleArrayVector y)
 {
     double sum = 0;
     for (int i = 0; i < x.Length; i++){
         sum += x.values[i]*y.values[i];
     }
     return sum;
 }
Esempio n. 3
0
        internal static double Dot(FloatArrayVector x, DoubleArrayVector y)
        {
            double sum = 0;

            for (int i = 0; i < x.Length; i++)
            {
                sum += x.values[i] * y.values[i];
            }
            return(sum);
        }
Esempio n. 4
0
        internal static double SumSquaredDiffs(FloatArrayVector x, DoubleArrayVector y)
        {
            double sum = 0;

            for (int i = 0; i < x.Length; i++)
            {
                double d = x.values[i] - y.values[i];
                sum += d * d;
            }
            return(sum);
        }
Esempio n. 5
0
        internal static double SumSquaredDiffs(DoubleArrayVector x, SparseVector y)
        {
            double sum  = 0;
            int    xlen = x.Length;
            int    ylen = y.Length;
            int    i    = 0;
            int    j    = 0;

            while (i < xlen && j < ylen)
            {
                if (i == y.indices[j])
                {
                    double d = x.values[i++] - y.values[j++];
                    sum += d * d;
                }
                else if (i > y.indices[j])
                {
                    sum += y.values[j] * y.values[j];
                    ++j;
                }
                else
                {
                    sum += x.values[i] * x.values[i];
                    ++i;
                }
            }
            while (i < xlen)
            {
                sum += x.values[i] * x.values[i];
                ++i;
            }
            while (j < ylen)
            {
                sum += y.values[j] * y.values[j];
                ++j;
            }
            return(sum);
        }
Esempio n. 6
0
 internal static double SumSquaredDiffs(FloatArrayVector x, DoubleArrayVector y)
 {
     double sum = 0;
     for (int i = 0; i < x.Length; i++) {
         double d = x.values[i] - y.values[i];
         sum += d * d;
     }
     return sum;
 }
Esempio n. 7
0
 internal static double SumSquaredDiffs(DoubleArrayVector x, SparseVector y)
 {
     double sum = 0;
     int xlen = x.Length;
     int ylen = y.Length;
     int i = 0;
     int j = 0;
     while (i < xlen && j < ylen){
         if (i == y.indices[j]){
             double d = x.values[i++] - y.values[j++];
             sum += d*d;
         } else if (i > y.indices[j]){
             sum += y.values[j]*y.values[j];
             ++j;
         } else{
             sum += x.values[i]*x.values[i];
             ++i;
         }
     }
     while (i < xlen){
         sum += x.values[i]*x.values[i];
         ++i;
     }
     while (j < ylen){
         sum += y.values[j]*y.values[j];
         ++j;
     }
     return sum;
 }
Esempio n. 8
0
 internal static double Dot(DoubleArrayVector x, SparseVector y)
 {
     double sum = 0;
     int xlen = x.Length;
     int ylen = y.Length;
     int i = 0;
     int j = 0;
     while (i < xlen && j < ylen){
         if (i == y.indices[j]){
             sum += x.values[i++]*y.values[j++];
         } else{
             if (i > y.indices[j]){
                 ++j;
             } else{
                 ++i;
             }
         }
     }
     return sum;
 }