Skip to content

Commit f490983

Browse files
committed
redefine eigvals
1 parent 9f5165e commit f490983

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/particles.jl

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,19 @@ for PT in ParticleSymbols
355355
end
356356
Base.:\(p::Vector{<:$PT}, p2::Vector{<:$PT}) = Matrix(p)\Matrix(p2) # Must be here to be most specific
357357

358+
function LinearAlgebra.eigvals(p::Matrix{$PT{T,N}}; kwargs...) where {T,N} # Special case to propte types differently
359+
individuals = map(1:length(p[1])) do i
360+
eigvals(getindex.(p,i); kwargs...)
361+
end
362+
PRT = Complex{$PT{T,N}}
363+
out = Vector{PRT}(undef, length(individuals[1]))
364+
for i = eachindex(out)
365+
c = getindex.(individuals,i)
366+
out[i] = complex($PT{T,N}(real(c)),$PT{T,N}(imag(c)))
367+
end
368+
out
369+
end
370+
358371
end
359372

360373
# for XT in (:T, :($PT{T,N})), YT in (:T, :($PT{T,N})), ZT in (:T, :($PT{T,N}))
@@ -550,23 +563,6 @@ Base.exp(p::AbstractMatrix{<:AbstractParticles}) = ℝⁿ2ℝⁿ_function(exp, p
550563
LinearAlgebra.lyap(p1::Matrix{<:AbstractParticles}, p2::Matrix{<:AbstractParticles}) = ℝⁿ2ℝⁿ_function(lyap, p1, p2)
551564

552565

553-
# OBS: defining this was a very bad idea, eigvals jump around and get confused with each other etc.
554-
# function LinearAlgebra.eigvals(p::Matrix{$PT{T,N}}) where {T,N} # Special case to propte types differently
555-
# individuals = map(1:length(p[1])) do i
556-
# eigvals(getindex.(p,i))
557-
# end
558-
#
559-
# PRT = Complex{$PT{T,N}}
560-
# out = Vector{PRT}(undef, length(individuals[1]))
561-
# for i = eachindex(out)
562-
# c = getindex.(individuals,i)
563-
# out[i] = complex($PT{T,N}(real(c)),$PT{T,N}(imag(c)))
564-
# end
565-
# out
566-
# end
567-
568-
569-
570566
## Particle BLAS
571567

572568
# pgemv is up to twice as fast as the naive way already for A(2,2)-A(20,20)

0 commit comments

Comments
 (0)