Skip to content

Commit

Permalink
Add diagonal
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Jan 9, 2025
1 parent 43fc9d6 commit 0186526
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/diaginterface/diaginterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,11 @@ function setdiagindices!(a::AbstractArray, v, i::Colon)
diagview(a) .= v
return a
end

"""
diagonal(v::AbstractVector) -> AbstractMatrix
Return a diagonal matrix from a vector `v`. This is a replacement of `LinearAlgebra.Diagonal`
that does not imply an output type. Defaults to `Diagonal(v)`.
"""
diagonal(A::AbstractVector) = LinearAlgebra.Diagonal(A)

Check warning on line 98 in src/diaginterface/diaginterface.jl

View check run for this annotation

Codecov / codecov/patch

src/diaginterface/diaginterface.jl#L98

Added line #L98 was not covered by tests

0 comments on commit 0186526

Please sign in to comment.