<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App
{
    class InverseIteration
    {
        private Matrix matrixA;
        private Matrix matrixX;
        private Matrix matrixE;

        private float epsilon;

        private int maxIterations = 5;

        private Dictionary<int, Matrix> x;
        Dictionary<int, float> lambda;

        public InverseIteration(Matrix matrixA, Matrix matrixX, float epsilon, float lambda)
        {
            this.matrixA = matrixA;
            this.matrixX = matrixX;

            this.epsilon = epsilon;

            this.x = new Dictionary<int, Matrix>();
            this.lambda = new Dictionary<int, float>();

            this.x.Add(0, matrixX);
            this.lambda.Add(0, lambda);

            createMatrixE();
        }

        public void solve()
        {
            Dictionary<int, Matrix> y = new Dictionary<int, Matrix>();
            Matrix vector;
            SteepestDescentMethod calculations;

            int m = 0;

            do
            {
                calculations = new SteepestDescentMethod(
                    matrixA.substractDiangleBy(lambda[m]),
                    this.x[m],
                    generateMatrixY(),
                    epsilon
                );

                calculations.solve(false);

                y.Add(m + 1, calculations.getResult());

                float norm = y[m + 1].normOfFrobenius();

                Matrix x = new Matrix(y[m + 1].getSize(), 1);

                for (int i = 0; i < y[m + 1].getSize(); i++)
                {
                    x.matrix[i, 0] = y[m + 1].matrix[i, 0] / norm;
                }

                this.x.Add(m + 1, x);

                vector = matrixA.multiplyWithVector(this.x[m + 1]);
                //vector.print();

                lambda[m + 1] = vector.getDotProduct(this.x[m + 1]);

                printIteration(m, y[m + 1]);

                if (isAccurateEnough(m))
                {
                    break;
                }

                if (this.x[m + 1].substractWith(this.x[m]).normOfFrobenius() >= 2)
                {
                    this.x[m + 1] = this.x[m + 1].multiplyBy(-1);
			    }
<commit_msg>Removed unused code<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App
{
    class InverseIteration
    {
        private Matrix matrixA;
        private Matrix matrixX;
        private Matrix matrixE;

        private float epsilon;

        private int maxIterations = 5;

        private Dictionary<int, Matrix> x;
        Dictionary<int, float> lambda;

        public InverseIteration(Matrix matrixA, Matrix matrixX, float epsilon, float lambda)
        {
            this.matrixA = matrixA;
            this.matrixX = matrixX;

            this.epsilon = epsilon;

            this.x = new Dictionary<int, Matrix>();
            this.lambda = new Dictionary<int, float>();

            this.x.Add(0, matrixX);
            this.lambda.Add(0, lambda);

            createMatrixE();
        }

        public void solve()
        {
            Dictionary<int, Matrix> y = new Dictionary<int, Matrix>();
            Matrix vector;
            SteepestDescentMethod calculations;

            int m = 0;

            do
            {
                calculations = new SteepestDescentMethod(
                    matrixA.substractDiangleBy(lambda[m]),
                    this.x[m],
                    generateMatrixY(),
                    epsilon
                );

                calculations.solve(false);

                y.Add(m + 1, calculations.getResult());

                float norm = y[m + 1].normOfFrobenius();

                Matrix x = new Matrix(y[m + 1].getSize(), 1);

                for (int i = 0; i < y[m + 1].getSize(); i++)
                {
                    x.matrix[i, 0] = y[m + 1].matrix[i, 0] / norm;
                }

                this.x.Add(m + 1, x);

                vector = matrixA.multiplyWithVector(this.x[m + 1]);

                lambda[m + 1] = vector.getDotProduct(this.x[m + 1]);

                printIteration(m, y[m + 1]);

                if (isAccurateEnough(m))
                {
                    break;
                }

                if (this.x[m + 1].substractWith(this.x[m]).normOfFrobenius() >= 2)
                {
                    this.x[m + 1] = this.x[m + 1].multiplyBy(-1);
			    }

{'fraction_non_alphanumeric': 0.11145374449339207, 'fraction_numerical': 0.01013215859030837, 'mean_word_length': 1.3467700258397932, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4084116', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1228, 'n_words': 285}