public static void Bench() { int n = 100; foreach (var iteration in Benchmark.Iterations) { double a = 0; using (iteration.StartMeasurement()) { for (int i = 0; i < Iterations; i++) { SpectralNorm s = new SpectralNorm(); a += s.Approximate(n); } } double norm = a / Iterations; double expected = 1.274219991; bool valid = Math.Abs(norm - expected) < 1e-4; if (!valid) { throw new Exception("Benchmark failed to validate"); } } }
public static int Main(String[] args) { int n = 100; if (args.Length > 0) n = Int32.Parse(args[0]); double norm = new SpectralNorm().Approximate(n); Console.WriteLine("Norm={0:f9}", norm); double expected = 1.274219991; bool result = Math.Abs(norm - expected) < 1e-4; return (result ? 100 : -1); }
public static int Main(String[] args) { int n = 100; if (args.Length > 0) { n = Int32.Parse(args[0]); } double norm = new SpectralNorm().Approximate(n); Console.WriteLine("Norm={0:f9}", norm); double expected = 1.274219991; bool result = Math.Abs(norm - expected) < 1e-4; return(result ? 100 : -1); }