Exemplo 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
        }
Exemplo n.º 2
0
        /// <summary>
        /// Solves a system of linear equations, <c>A'x = 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 SolveTranspose(Complex[] input, Complex[] result)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

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

            var x = this.temp;

            Permutation.Apply(S.q, input, x, n);    // x = Q'*b

            SolverHelper.SolveUpperTranspose(U, x); // x = U'\x.

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

            Permutation.Apply(pinv, x, result, n);  // b = P'*x
        }