Пример #1
0
        public void SumUTest(int test, float expected)
        {
            float[] src    = (float[])testArrays[test].Clone();
            var     actual = CpuMathUtils.Sum(src, src.Length);

            Assert.Equal(expected, actual, 2);
        }
Пример #2
0
 /// <summary>
 /// Returns sum of elements in array
 /// </summary>
 public static Float Sum(Float[] a)
 {
     if (a == null || a.Length == 0)
     {
         return(0);
     }
     return(CpuMathUtils.Sum(a));
 }
Пример #3
0
 private static Float Mean(Float[] src, int count, int length)
 {
     if (length == 0 || count == 0)
     {
         return(0);
     }
     return(CpuMathUtils.Sum(src, 0, count) / length);
 }
Пример #4
0
        public void SumTest(string mode, string test, Dictionary <string, string> environmentVariables)
        {
            RemoteExecutor.RemoteInvoke((arg0, arg1) =>
            {
                CheckProperFlag(arg0);
                float[] src    = (float[])_testArrays[int.Parse(arg1)].Clone();
                float expected = 0;
                for (int i = 0; i < src.Length; i++)
                {
                    expected += src[i];
                }

                var actual = CpuMathUtils.Sum(src);
                Assert.Equal(expected, actual, 2);
                return(RemoteExecutor.SuccessExitCode);
            }, mode, test, new RemoteInvokeOptions(environmentVariables));
        }
Пример #5
0
        /// <summary>
        /// Compute Standard Deviation. In case of both subMean and useStd are true, we technically need to compute variance
        /// based on centered values (i.e. after subtracting the mean). But since the centered
        /// values mean is approximately zero, we can use variance of non-centered values.
        /// </summary>
        private static Float StdDev(Float[] values, int count, int length)
        {
            Contracts.Assert(0 <= count && count <= length);
            if (count == 0)
            {
                return(0);
            }
            // We need a mean to compute variance.
            Float tmpMean = CpuMathUtils.Sum(values, 0, count) / length;
            Float sumSq   = 0;

            if (count != length && tmpMean != 0)
            {
                // Sparse representation.
                Float meanSq = tmpMean * tmpMean;
                sumSq = (length - count) * meanSq;
            }
            sumSq += CpuMathUtils.SumSq(tmpMean, values, 0, count);
            return(MathUtils.Sqrt(sumSq / length));
        }
Пример #6
0
 public float Simple() => CpuMathUtils.Sum(Enumerable.Range(0, 1024).Select(Convert.ToSingle).ToArray());
Пример #7
0
 public float Sum()
 => CpuMathUtils.Sum(new Span <float>(src, 0, _smallInputLength));
Пример #8
0
 public float ManagedSumUPerf() => CpuMathUtils.Sum(src, LEN);