toop_project.src.Matrix.DiagonalMatrix.USolve C# (CSharp) Method

USolve() public method

public USolve ( Vector x, bool UseDiagonal ) : Vector
x toop_project.src.Vector_.Vector
UseDiagonal bool
return toop_project.src.Vector_.Vector
        public override Vector USolve(Vector x, bool UseDiagonal)
        {
            if (di.Length == x.Size)
            {
                Vector result = (Vector)x.Clone();

                if (UseDiagonal)
                {
                    int n = di.Length - shift_u[shift_u.Length - 1];

                    result[di.Length - 1] /= di[di.Length - 1];
                    for (int i = di.Length - 1; i >= n; i--)
                    {
                        for (int j = 0; j < shift_u.Length; j++)
                            result[i - shift_u[j]] -= au[i][j] * result[i];
                        result[i] /= di[i];
                    }
                }
                else
                {
                    int n = di.Length - shift_u[shift_u.Length - 1];

                    for (int i = di.Length - 1; i >= n; i--)
                        for (int j = 0; j < shift_u.Length; j++)
                            result[i - shift_u[j]] -= au[i][j] * result[i];
                }
                return result;
            }
            else
                throw new Exception("Диагональный формат: Несовпадение размерностей матрицы и вектора в обратном ходе");
        }