private void assemble(IElementalAccessMatrix A, IElementalAccessVector b, double K, double f)
        {
            int    n = b.Length - 1;
            double h = 1.0 / ((double)n);

            double[,] Ae = new double[, ] {
                { K / h, (-K) / h }, { (-K) / h, K / h }
            };
            double[] be = new double[] { f *h / 2.0, f *h / 2.0 };

            for (int i = 0; i < n; ++i)
            {
                int[] ind = new int[] { i, i + 1 };
                A.AddValues(ind, ind, Ae);
                b.AddValues(ind, be);
                //Console.WriteLine(i+" ind " + ind + " Ae " + Ae + " be " + be);
            }
        }
        private void Helper2(IElementalAccessMatrix A, IElementalAccessVector b,
                             IElementalAccessVector x, ILinearSolver solver, IPreconditioner M, ILinearIteration iter)
        {
            Random r = new Random();
            double K = r.NextDouble(), f = r.NextDouble(), gl = r.NextDouble(), gr = r.NextDouble();

            assemble(A, b, K, f);
            boundary(A, b, x, gl, gr);
            double[] ans         = solve(A, b, x, solver, M, iter);
            double[] ref_Renamed = reference(b.Length - 1, K, f, gl, gr);

            checkEqual(ans, ref_Renamed);

            Console.WriteLine("TT hej");

            Blas.Default.Zero(A);
            Blas.Default.Zero(b);
            Blas.Default.Zero(x);
        }
Example #3
0
 private static void Check(IElementalAccessVector x, double[] real)
 {
     AreEqual(TesterUtilities.getElVector(x), real);
     AreEqual(TesterUtilities.getVector(x), real);
     AreEqual(TesterUtilities.getVectorCopy(x), real);
 }
Example #4
0
 private static void transColumnCheck(IElementalAccessMatrix A, IElementalAccessVector x,
                                      IElementalAccessVector y, IElementalAccessVector z, int nu)
 {
     double[,] Ad = TesterUtilities.setAssembleColumnMatrix(A, nu);
     transCheck(A, x, y, z, Ad);
 }
Example #5
0
 private static void rowCheck(IElementalAccessMatrix A, IElementalAccessVector x,
                              IElementalAccessVector y, IElementalAccessVector z, int nu)
 {
     double[,] Ad = TesterUtilities.SetAssembleRowMatrix(A, nu);
     check(A, x, y, z, Ad);
 }