Esempio n. 1
0
        /// <summary>
        /// Solves Ax=b where A is symmetric positive definite; b is overwritten with
        /// solution.
        /// </summary>
        /// <param name="b">right hand side, b is overwritten with solution</param>
        /// <returns>true if successful, false on error</returns>
        public bool Solve(Complex[] b)
        {
            if (b == null || numFactor == null)
            {
                return(false);                                // check inputs
            }
            Complex[] x = new Complex[n];

            Common.InversePermute(symFactor.pinv, b, x, n); // x = P*b
            Triangular.SolveL(numFactor.L, x);              // x = L\x
            Triangular.SolveLt(numFactor.L, x);             // x = L'\x
            Common.Permute(symFactor.pinv, x, b, n);        // b = P'*x

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Solves Ax=b, where A is square and nonsingular. b overwritten with
        /// solution. Partial pivoting if tol = 1.
        /// </summary>
        /// <param name="b">size n, b on input, x on output</param>
        /// <returns>true if successful, false on error</returns>
        public bool Solve(Complex[] b)
        {
            if (b == null || numFactor == null)
            {
                return(false);                              // check inputs
            }
            Complex[] x = new Complex[n];                   // get workspace

            Common.InversePermute(numFactor.pinv, b, x, n); // x = b(p)
            Triangular.SolveL(numFactor.L, x);              // x = L\x
            Triangular.SolveU(numFactor.U, x);              // x = U\x
            Common.InversePermute(symFactor.q, x, b, n);    // b(q) = x

            return(true);
        }