示例#1
0
        /// <summary>
        /// See <see cref="ITriangulation.SolveLinearSystem(Vector, Vector)"/>.
        /// </summary>
        /// <exception cref="LapackException">Thrown if the call to LAPACK fails due to invalid arguments.</exception>
        public void SolveLinearSystem(Vector rhs, Vector solution)
        {
            CheckOverwritten();
            Preconditions.CheckSystemSolutionDimensions(Order, rhs.Length);
            Preconditions.CheckMultiplicationDimensions(Order, solution.Length);

            // Back & forward substitution using LAPACK
            solution.CopyFrom(rhs);
            int numRhs      = 1;     // rhs is a n x nRhs matrix, stored in b
            int leadingDimB = Order; // column major ordering: leading dimension of b is n

            LapackLinearEquations.Dpotrs(StoredTriangle.Upper, Order, numRhs, data, 0, Order, solution.RawData, 0,
                                         leadingDimB);
        }
示例#2
0
        /// <summary>
        /// Solves a series of linear systems L * L^T * x = b (or L * D * L^T * x = b), where L is the lower triangular factor
        /// (and D the diagonal factor) of the Cholesky factorization: A = L * L^T (or A = L * D * L^T).
        /// </summary>
        /// <param name="rhsVectors">
        /// A matrix whose columns are the right hand side vectors b of the linear systems. Constraints:
        /// <paramref name="rhsVectors"/>.<see cref="IIndexable2D.NumRows"/> == this.<see cref="Order"/>.
        /// </param>
        /// <exception cref="NonMatchingDimensionsException">
        /// Thrown if <paramref name="rhsVectors"/> violates the described constraints.
        /// </exception>
        /// <exception cref="AccessViolationException">
        /// Thrown if the unmanaged memory that holds the factorization data has been released.
        /// </exception>
        /// <exception cref="SuiteSparseException">Thrown if the call to SuiteSparse library fails.</exception>
        public Matrix SolveLinearSystems(Matrix rhs)
        {
            CheckOverwritten();
            Preconditions.CheckSystemSolutionDimensions(Order, rhs.NumRows);
            //Preconditions.CheckMultiplicationDimensions(Order, solution.NumColumns);

            // Back & forward substitution using LAPACK
            Matrix solution    = rhs.Copy();
            int    numRhs      = rhs.NumColumns; // rhs is a n x nRhs matrix, stored in b
            int    leadingDimB = Order;          // column major ordering: leading dimension of b is n

            LapackLinearEquations.Dpotrs(StoredTriangle.Upper, Order, numRhs, data, 0, Order, solution.RawData, 0,
                                         leadingDimB);
            return(solution);
        }