Exemplo n.º 1
0
        public Matrix Calculate()
        {
            Matrix last    = new Matrix(Vector.rows, 1);
            Matrix current = new Matrix(Vector.rows, 1);

            double value;
            int    iterations = 0;


            do
            {
                iterations++;
                for (int i = 0; i < Matrix.rows; i++)
                {
                    double sum = 0;
                    sum += Vector.values[i, 0];

                    for (int j = 0; j < Matrix.cols; j++)
                    {
                        if (i != j)
                        {
                            sum -= Matrix.values[i, j] * last.values[j, 0];
                        }
                    }

                    current.values[i, 0] = sum / Matrix.values[i, i];
                }
                value = (current - last).GetNorm();
                last  = DeepCopy.Copy(current);
            }while (value > 0.001);

            return(current);
        }
Exemplo n.º 2
0
        public Matrix EliminationPG(Matrix _matrix, Matrix _vector)
        {
            var result1 = DeepCopy.Copy(_matrix);
            var result2 = DeepCopy.Copy(_vector);

            for (int i = 0; i < result1.rows - 1; i++)
            {
                PartialPivot(result1, result2, i);
                ZeroColumn(result1, result2, i);
            }
            return(CalculateResult(result1, result2));
        }
Exemplo n.º 3
0
 public Jacobi(Matrix matrix, Matrix vector)
 {
     Matrix = DeepCopy.Copy(matrix);
     Vector = DeepCopy.Copy(vector);
 }
Exemplo n.º 4
0
 public GaussSeidel(Matrix matrix, Matrix vector)
 {
     Matrix = DeepCopy.Copy(matrix);
     Vector = DeepCopy.Copy(vector);
 }