//[/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); } }
//[/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); } }
//[/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); } }