예제 #1
0
        //[/GenericReduceSumInts]

        //[GenericReduceSumDoubles]
        public static void SumDoubles()
        {
            foreach (var n in Nums)
            {
                var values = Gen(Rng.NextDouble, n);
                var dr     = ReduceApi.Sum(values);
                var hr     = cpuReduce((x, y) => x + y, values);
                Assert.AreEqual(hr, dr, 1e-11);
            }
        }
예제 #2
0
        //[/GenericReduceMaxDoubles]

        //[GenericReduceMinDoubles]
        public static void MinDoubles()
        {
            foreach (var n in Nums)
            {
                var values = Gen(Rng.NextDouble, n);
                //var dr = ReduceApi.Reduce(() => double.PositiveInfinity, Math.Min, values);
                var dr = ReduceApi.Reduce(LibDevice.__posinf <double>, Math.Min, values);
                var hr = cpuReduce(Math.Min, values);
                Assert.AreEqual(hr, dr, 1e-11);
            }
        }
예제 #3
0
        //[/GenericReduceSumDoubles]

        //[GenericReduceScalarProdDoubles]
        public static void ScalarProdDoubles()
        {
            foreach (var n in Nums)
            {
                var values1 = Gen(Rng.NextDouble, n);
                var values2 = Gen(Rng.NextDouble, n);
                var dr      = ReduceApi.ScalarProd(values1, values2);
                var hr      = cpuScalarProd((x, y) => x + y, (x, y) => x * y, values1, values2);
                Assert.AreEqual(hr, dr, 1e-11);
            }
        }