GraphBLAS / LAGraph

This is a library plus a test harness for collecting algorithms that use the GraphBLAS. For test coverage reports, see https://graphblas.org/LAGraph/ . Documentation: https://lagraph.readthedocs.org
Other
229 stars 61 forks source link

Utility functions for diagonal and inverse diagonal #96

Closed szarnyasg closed 2 years ago

szarnyasg commented 4 years ago

Related to #94, it would be useful to have functions for diag (for turning a vector into a diagonal matrix) and diag^{-1} (for extracting the diagonal elements of a matrix). These could be called LAGraph_diag(GrB_Matrix* A, GrB_Vector d) and LAGraph_inv_diag(GrB_Vector &d, GrB_Matrix A, boolean diagonal_only) (diagonal_only denoting whether matrix A only has diagonal elements, which makes the extraction trivial).

DrTimothyAldenDavis commented 2 years ago

One of these is now in the spec (GrB_Matrix_diag, to build a matrix from a diagonal). The opposite, GxB_Vector_diag, to extract a diagonal from a matrix, is in SuiteSparse as a GxB method, but is not in the spec.