Project DelphiTensors Workshop
Knowledge

Diagonal and symmetric matrices

A diagonal matrix has nonzero entries only on the main diagonal: Dᵢ,ⱼ = 0 whenever i ≠ j. diag(v) is the square diagonal matrix with the vector v along its diagonal. Diagonal matrices are cheap to work with:

  • diag(v)x = v ⊙ x just scales each xᵢ by vᵢ.
  • The inverse exists only if every diagonal entry is nonzero, and then diag(v)⁻¹ = diag([1/v₁, …, 1/vₙ]ᵀ).
  • Diagonal matrices can also be rectangular. Those have no inverse, but multiplying by them is still cheap.

A symmetric matrix equals its own transpose: A = Aᵀ. Symmetric matrices arise when the entries come from a function of two arguments that does not depend on their order, such as a table of distances between points, where Aᵢ,ⱼ = Aⱼ,ᵢ.