public static void TriDiagSolverTest()
        {
            const int numSystems = 512;

            var numbers =
                Enumerable
                .Repeat(numSystems, numSystems)
                .Select(diagonallyDominantSystem)
                .ToArray();

            var l = numbers.SelectMany(s => s.Item1).ToArray();
            var d = numbers.SelectMany(s => s.Item2).ToArray();
            var u = numbers.SelectMany(s => s.Item3).ToArray();
            var b = numbers.SelectMany(s => s.Item4).ToArray();
            var expectedSolution = numbers.SelectMany(s => s.Item5).ToArray();

            var triDiagSolver = new TriDiagSolverModule(GPUModuleTarget.DefaultWorker);

            var x    = triDiagSolver.Apply(numSystems, l, d, u, b);
            var errs = new double[x.Length];

            for (var i = 0; i < x.Length; ++i)
            {
                errs[i] = Math.Abs(expectedSolution[i] - x[i]);
            }
            var err = errs.Max();

            Console.WriteLine("error = {0}", err);
            Assert.LessOrEqual(err, 1e-8);
        }
Exemple #2
0
        public static void TriDiagSolverTest()
        {
            const int numSystems = 512;

            var numbers =
                Enumerable
                .Repeat(numSystems, numSystems)
                .Select(diagonallyDominantSystem)
                .ToArray();

            var l = numbers.SelectMany(s => s.Item1).ToArray();
            var d = numbers.SelectMany(s => s.Item2).ToArray();
            var u = numbers.SelectMany(s => s.Item3).ToArray();
            var b = numbers.SelectMany(s => s.Item4).ToArray();
            var expectedSolution = numbers.SelectMany(s => s.Item5).ToArray();

            var triDiagSolver = new TriDiagSolverModule(GPUModuleTarget.DefaultWorker);

            var x = triDiagSolver.Apply(numSystems, l, d, u, b);
            var errs = new double[x.Length];
            for (var i = 0; i < x.Length; ++i)
                errs[i] = Math.Abs(expectedSolution[i] - x[i]);
            var err = errs.Max();
            Console.WriteLine("error = {0}", err);
            Assert.LessOrEqual(err, 1e-8);
        }