Ejemplo n.º 1
0
        /// <summary>
        /// Solves a system of linear equations, <c>Ax = b</c>.
        /// </summary>
        /// <param name="input">The right hand side vector, <c>b</c>.</param>
        /// <param name="result">The left hand side vector, <c>x</c>.</param>
        public void Solve(Complex[] input, Complex[] result)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            var x = this.temp;

            Permutation.ApplyInverse(S.pinv, input, x, n); // x = P*b

            SolverHelper.SolveLower(L, x);                 // x = L\x

            SolverHelper.SolveLowerTranspose(L, x);        // x = L'\x

            Permutation.Apply(S.pinv, x, result, n);       // b = P'*x
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Solves a system of linear equations, <c>Ax = b</c>.
        /// </summary>
        /// <param name="input">The right hand side vector, <c>b</c>.</param>
        /// <param name="result">The left hand side vector, <c>x</c>.</param>
        public void Solve(Complex[] input, Complex[] result)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            var x = this.temp;

            Permutation.ApplyInverse(pinv, input, x, n); // x = b(p)

            SolverHelper.SolveLower(L, x);               // x = L\x.

            SolverHelper.SolveUpper(U, x);               // x = U\x.

            Permutation.ApplyInverse(S.q, x, result, n); // b(q) = x
        }