示例#1
0
        /// <summary>
        /// Generate a fill-reducing ordering using the CCOLAMD algorithm.
        /// </summary>
        /// <param name="A">The matrix.</param>
        /// <param name="constraints">Constraint set of A (of size ncol).</param>
        /// <returns>The permutation vector or NULL, if an error occurred.</returns>
        public static int[] Generate <T>(CompressedColumnStorage <T> A, int[] constraints)
            where T : struct, IEquatable <T>, IFormattable
        {
            int rows = A.RowCount;
            int cols = A.ColumnCount;

            var p = new int[cols + 1];

            A.ColumnPointers.CopyTo(p, 0);

            var amd = new COLAMD();

            var info = amd.Order(rows, cols, A.RowIndices, p, constraints);

            if (info.Status < COLAMD_OK)
            {
                // error
                return(null);
            }

            return(p);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="n">Number of rows and columns in the symmetrix matrix A.</param>
        /// <param name="A">Row indices of A (of size nnz).</param>
        /// <param name="p">Column pointers of A (of size n+1).</param>
        /// <param name="perm">The permutation vector (of size n+1).</param>
        /// <param name="cmember">Constraint set of A (of size n).</param>
        /// <param name="stype">0: use both parts, &gt;0: upper, &lt;0: lower.</param>
        /// <returns></returns>
        /// <remarks>
        /// The array <paramref name="perm"/> is used as a workspace during the ordering,
        /// which is why it must be of length n+1, not just n.
        ///
        /// If <paramref name="stype"/> &lt; 0, then only the strictly lower triangular
        /// part of A is accessed. The upper triangular part is assumed to be the transpose
        /// of the lower triangular part.  This is the same as SYMAMD, which did not have
        /// an stype parameter.
        ///
        /// If <paramref name="stype"/> &gt; 0, only the strictly upper triangular part
        /// of A is accessed. The lower triangular part is assumed to be the transpose
        /// of the upper triangular part.
        ///
        /// If <paramref name="stype"/> == 0, then the nonzero pattern of A+A' is ordered.
        /// </remarks>
        public COLAMD.Info Order(int n, int[] A, int[] p, int[] perm, int[] cmember, int stype)
        {
            var amd = new COLAMD();

            return(amd.SymOrder(n, A, p, perm, GetControl(), cmember, stype));
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="n">Number of rows and columns in the symmetrix matrix A.</param>
        /// <param name="A">Row indices of A (of size nnz).</param>
        /// <param name="p">Column pointers of A (of size n+1).</param>
        /// <param name="perm">The permutation vector (of size n+1).</param>
        /// <returns></returns>
        /// <remarks>
        /// The array <paramref name="perm"/> is used as a workspace during the ordering,
        /// which is why it must be of length n+1, not just n.
        /// </remarks>
        public COLAMD.Info Order(int n, int[] A, int[] p, int[] perm)
        {
            var amd = new COLAMD();

            return(amd.SymOrder(n, A, p, perm, GetControl()));
        }