Example #1
0
        /// <summary>
        /// Performs the operation: <paramref name="result"/> = generalized_inverse(A) * <paramref name="vector"/>
        /// </summary>
        /// <param name="vector">The vector that will be multiplied. Its <see cref="IIndexable1D.Length"/> must be equal to
        /// <see cref="IIndexable2D.NumRows"/> of the original matrix A.
        /// </param>
        /// <param name="result">
        /// Output vector that will be overwritten with the solution of the linear system. Its <see cref="IIndexable1D.Length"/>
        /// must be equal to <see cref="IIndexable2D.NumColumns"/> of the original matrix A.
        /// </param>
        /// <exception cref="NonMatchingDimensionsException">
        /// Thrown if <paramref name="vector"/> or <paramref name="result"/> violate the described constraints.
        /// </exception>
        /// <exception cref="IndefiniteMatrixException">
        /// Thrown if the original skyline matrix turns out to not be symmetric positive semi-definite.
        /// </exception>
        public void MultiplyGeneralizedInverseMatrixTimesVector(Vector vector, Vector result)
        {
            Preconditions.CheckSystemSolutionDimensions(Order, vector.Length);
            Preconditions.CheckMultiplicationDimensions(Order, result.Length);

            LdlSkyline.Solve(Order, values, diagOffsets, vector.RawData, result.RawData);
        }
        public static Matrix SolveLinearSystems(this LdlSkyline triangulation, Matrix rhsMatrix)
        {
            var solution = Matrix.CreateZero(triangulation.Order, rhsMatrix.NumColumns);

            triangulation.SolveLinearSystems(rhsMatrix, solution);
            return(solution);
        }
Example #3
0
 /// <summary>
 /// Applies the LDL factorization to the independent columns of a symmetric positive semi-definite matrix,
 /// sets the dependent ones equal to columns of the identity matrix and return the nullspace of the matrix. Requires
 /// extra memory for the basis vectors of the nullspace.
 /// </summary>
 /// <param name="order">The number of rows/ columns of the square matrix.</param>
 /// <param name="skyValues">
 /// The non-zero entries of the original <see cref="SkylineMatrix"/>. This array will be overwritten during the
 /// factorization.
 /// </param>
 /// <param name="skyDiagOffsets">
 /// The indexes of the diagonal entries into <paramref name="skyValues"/>. The new
 /// <see cref="SemidefiniteLdlSkyline"/> instance will hold a reference to <paramref name="skyDiagOffsets"/>.
 /// However they do not need copying, since they will not be altered during or after the factorization.
 /// </param>
 /// <param name="pivotTolerance">
 /// If a diagonal entry is &lt;= <paramref name="pivotTolerance"/> it means that the corresponding column is dependent
 /// on the rest. The Cholesky factorization only applies to independent column, while dependent ones are used to compute
 /// the nullspace. Therefore it is important to select a tolerance that will identify small pivots that result from
 /// singularity, but not from ill-conditioning.
 /// </param>
 public static SemidefiniteLdlSkyline Factorize(int order, double[] skyValues, int[] skyDiagOffsets,
                                                double pivotTolerance = SemidefiniteLdlSkyline.PivotTolerance)
 {
     (List <int> dependentColumns, List <double[]> nullSpaceBasis) =
         LdlSkyline.FactorizeInternal(order, skyValues, skyDiagOffsets, pivotTolerance);
     Debug.Assert(dependentColumns.Count == nullSpaceBasis.Count);
     return(new SemidefiniteLdlSkyline(order, skyValues, skyDiagOffsets, dependentColumns, nullSpaceBasis));
 }