Esempio n. 1
0
    static int Main(string[] args)
    {
        int N;

        if (args.Length > 0)
        {
            N = int.Parse(args[0]);
        }
        else
        {
            N = 3;
        }
        int    nm = N;
        matrix A1 = randmatrix_sym(nm, nm);
        matrix V  = new matrix(nm, nm);
        //vector e=jac_dia_red(A1,V,1);

        jac_clas ja = new jac_clas(A1);
        int      nr = ja.n_rot;

        WriteLine($"{nm} {nr}");



        return(0);
    }
Esempio n. 2
0
    static int Main()
    {
        int    nm = 5;
        matrix A1 = randmatrix_sym(nm, nm);
        //matrix V= new matrix(nm,nm);
        jac_dia jd = new jac_dia(A1);
        vector  ed = jd.e;
        //matrix Ad=jd.A;
        jac_clas jc = new jac_clas(A1);
        vector   ec = jc.e;
        matrix   Ac = jc.A;

        WriteLine($"Part C:");
        WriteLine("i) Test that calculated eigenvalues with classic Jacobi are the same as the ones calulated by the cyclic sweep for a given random matrix A:");
        WriteLine($"Classic:	cyclic:");
        for (int n2 = 0; n2 < nm; n2++)
        {
            WriteLine($"{ec[n2]}	{ed[n2]}");
        }

        WriteLine("That the clissic method diagonalize a given matrix A:");
        for (int n1 = 0; n1 < nm; n1++)
        {
            for (int n2 = 0; n2 < nm; n2++)
            {
                Write($"{Ac[n1,n2]}	");
            }
            Write("\n");
        }

        WriteLine($"");
        WriteLine($"ii) Does classic improve the number of rotation and the time?");
        WriteLine($"In plot_rotations.svg and plot_time.svg is the number of rotations and the time used by the classic and the cyclic sweep methods compared.");
        WriteLine($"The result indicate that classic Jacobi is slower then the cyclic sweep, but use fewer rotations.");


        return(0);
    }