Skip to content

Commit 631e537

Browse files
committed
Clarify comment on default_algorithm ambiguity more, make eig test more general
1 parent 01cd6e7 commit 631e537

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/algorithms.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ macro functiondef(f)
201201
# define default algorithm fallbacks for out-of-place functions
202202
# in terms of the corresponding in-place function for types,
203203
# in principle this is covered by the definition above but
204-
# it is necessary to avoid ambiguity errors
204+
# it is necessary to avoid ambiguity errors with the generic definitions:
205+
# ```julia
206+
# default_algorithm(f::F, A; kwargs...) where {F} = default_algorithm(f, typeof(A); kwargs...)
207+
# function default_algorithm(f::F, ::Type{T}; kwargs...) where {F,T}
208+
# throw(MethodError(default_algorithm, (f, T)))
209+
# end
210+
# ```
205211
@inline function default_algorithm(::typeof($f), ::Type{A}; kwargs...) where {A}
206212
return default_algorithm($f!, A; kwargs...)
207213
end

test/eig.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ end
6363
ComplexF64)
6464
rng = StableRNG(123)
6565
m = 4
66-
V = qr_compact(randn(rng, T, m, m))[1]
66+
V = randn(rng, T, m, m)
6767
D = Diagonal([0.9, 0.3, 0.1, 0.01])
68-
A = V * D * V'
68+
A = V * D * inv(V)
6969
alg = TruncatedAlgorithm(LAPACK_Simple(), truncrank(2))
7070
D2, V2 = @constinferred eig_trunc(A; alg)
7171
@test diagview(D2) ≈ diagview(D)[1:2] rtol = sqrt(eps(real(T)))

0 commit comments

Comments
 (0)