Help us shape the future of Go! Take the 2026 Go Developer Survey

order

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package order computes sparse-matrix orderings and measures their quality.

  • RCM: reverse Cuthill-McKee with a George-Liu pseudo-peripheral start (bandwidth and profile reduction; MATLAB symrcm, scipy csgraph.reverse_cuthill_mckee).
  • AMD: approximate minimum degree on the pattern of A+Aᵀ, written from Amestoy, Davis and Duff, SIAM J. Matrix Anal. Appl. 17(4), 1996, doi:10.1137/S0895479894278952 (MATLAB amd, symamd).
  • COLAMD: approximate minimum degree on the column intersection graph of A, never forming AᵀA, written from Davis, Gilbert, Larimore and Ng, ACM TOMS 30(3), 2004, doi:10.1145/1024074.1024079 (MATLAB colamd).

Provenance: the implementations are written from the papers. SuiteSparse AMD and COLAMD are BSD-3-Clause and are credited as the reference algorithms; CHOLMOD, UMFPACK and CSparse (GPL/LGPL) were not consulted. Tie-breaking differs from SuiteSparse, so permutations are not expected to be identical; quality is compared through Bandwidth, Profile and CholeskyNNZ.

A permutation p lists, for each new position i, the original index p[i], so the reordered matrix is B[i][j] = A[p[i]][p[j]] (CSR.Permute(p, p)).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSquare = errors.New("order: matrix is not square")

ErrNotSquare is returned for orderings that need a square matrix.

Functions

func AMD

func AMD[T sparse.Scalar](a *sparse.CSR[T]) ([]int, error)

AMD returns an approximate minimum degree ordering of the pattern of A + Aᵀ for a square matrix. Rows denser than max(16, 10 sqrt(n)) are ordered last, as in SuiteSparse AMD.

func Bandwidth

func Bandwidth[T sparse.Scalar](a *sparse.CSR[T]) int

Bandwidth returns max |i-j| over the stored entries of A.

func COLAMD

func COLAMD[T sparse.Scalar](a *sparse.CSR[T]) ([]int, error)

COLAMD returns a column ordering of the m x n matrix A for sparse LU or QR (an approximate minimum degree ordering of AᵀA computed from A alone). Rows with more than max(16, 10 sqrt(n)) entries are ignored and columns with more than max(16, 10 sqrt(m)) entries are ordered last, the default thresholds of SuiteSparse COLAMD.

func CholeskyNNZ

func CholeskyNNZ[T sparse.Scalar](a *sparse.CSR[T], perm []int) (int, error)

CholeskyNNZ returns the number of nonzeros (diagonal included) of the Cholesky factor L of P A Pᵀ for the pattern of A + Aᵀ, computed symbolically from the elimination tree (Liu 1990). perm nil is the natural order.

func Inverse

func Inverse(p []int) []int

Inverse returns the inverse permutation.

func IsPermutation

func IsPermutation(p []int) bool

IsPermutation reports whether p is a permutation of 0..len(p)-1.

func Profile

func Profile[T sparse.Scalar](a *sparse.CSR[T]) int

Profile returns the (lower) envelope size: the sum over rows of i - (smallest column index in row i), for entries on or below the diagonal.

func QRFillNNZ

func QRFillNNZ[T sparse.Scalar](a *sparse.CSR[T], perm []int) (int, error)

QRFillNNZ returns the nonzeros of the Cholesky factor of the pattern of AᵀA under the column permutation perm: the size of R in the QR factorisation (and a bound on the fill of LU) for a COLAMD-type ordering.

func RCM

func RCM[T sparse.Scalar](a *sparse.CSR[T]) ([]int, error)

RCM returns the reverse Cuthill-McKee ordering of the pattern of A + Aᵀ. Each connected component is started from a pseudo-peripheral vertex.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL