Skip to content

Commit 4e7465f

Browse files
lkdvosclaude
andcommitted
refactor: build Diagonal copies via map_diagonal
`map_diagonal(f, src)` is exactly `diagonal(f.(diagview(src)))`, so the three `copy_input` methods can use it instead of constructing a `Diagonal` directly. This keeps them consistent with the rest of the package, which routes diagonal construction through `diagonal` rather than the `LinearAlgebra` type. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1d5d8be commit 4e7465f

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/implementations/logarithm.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function copy_input(::typeof(logarithm), A::AbstractMatrix)
44
return copy!(similar(A, float(eltype(A))), A)
55
end
6-
copy_input(::typeof(logarithm), A::Diagonal) = Diagonal(float.(diagview(A)))
6+
copy_input(::typeof(logarithm), A::Diagonal) = map_diagonal(float, A)
77

88
function check_input(::typeof(logarithm!), A::AbstractMatrix, logA, alg::AbstractAlgorithm)
99
m = LinearAlgebra.checksquare(A)

src/implementations/power.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function copy_input(::typeof(power), A::AbstractMatrix, p::Real)
44
return copy!(similar(A, float(eltype(A))), A), p
55
end
6-
copy_input(::typeof(power), A::Diagonal, p::Real) = Diagonal(float.(diagview(A))), p
6+
copy_input(::typeof(power), A::Diagonal, p::Real) = map_diagonal(float, A), p
77

88
function check_input(::typeof(power!), A::AbstractMatrix, p::Real, powA, alg::AbstractAlgorithm)
99
m = LinearAlgebra.checksquare(A)

src/implementations/squareroot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function copy_input(::typeof(squareroot), A::AbstractMatrix)
44
return copy!(similar(A, float(eltype(A))), A)
55
end
6-
copy_input(::typeof(squareroot), A::Diagonal) = Diagonal(float.(diagview(A)))
6+
copy_input(::typeof(squareroot), A::Diagonal) = map_diagonal(float, A)
77

88
function check_input(::typeof(squareroot!), A::AbstractMatrix, sqrtA, alg::AbstractAlgorithm)
99
m = LinearAlgebra.checksquare(A)

0 commit comments

Comments
 (0)