Skip to content

num::diagonal_similarity

Defined in header <linear/sparse/sparse.hpp>

mat<real> diagonal_similarity(const spmat &A, view<const real> weights);

Scale the rows and columns of a sparse matrix, returning a dense one: \(D^{-1} A D\), \(D = \mathrm{diag}(w)\).

Exceptions

  • std::invalid_argument: If the dimensions disagree or a weight is not positive.