@@ -23,10 +23,11 @@ using Printf
2323using DelimitedFiles
2424using StableRNGs
2525using BenchmarkTools
26+ using DoubleFloats
2627using MatrixAlgebraKit
2728using MatrixAlgebraKit: MatrixFunctionViaTaylor, MatrixFunctionViaLA,
28- MatrixFunctionViaEig, MatrixFunctionViaEigh
29- # Loading these makes the generic (BigFloat) eig / eigh drivers available.
29+ MatrixFunctionViaEig, MatrixFunctionViaEigh, QRIteration, GS, GLA
30+ # Loading these makes the generic (BigFloat / Double64 ) eig / eigh drivers available.
3031using GenericSchur
3132using GenericLinearAlgebra
3233
@@ -38,18 +39,28 @@ const CSV_PATH = let i = findfirst(==("--csv"), ARGS)
3839 i === nothing ? joinpath (@__DIR__ , " results.csv" ) : ARGS [i + 1 ]
3940end
4041
41- const ELTYPES = (Float64, ComplexF64, BigFloat, Complex{BigFloat})
42+ # Ordered by increasing precision: hardware BLAS floats, then double-double (~106 bits,
43+ # software but fast), then arbitrary-precision BigFloat.
44+ const ELTYPES = (
45+ Float64, ComplexF64, Double64, Complex{Double64}, BigFloat, Complex{BigFloat},
46+ )
47+
48+ _isblas (:: Type{T} ) where {T} = T <: Union{Float32, Float64, ComplexF32, ComplexF64}
49+ _isdouble (:: Type{T} ) where {T} = T <: Union{Double64, Complex{Double64}}
4250
4351# Sizes for the timing sweep (generic types are far slower, so use fewer / smaller).
52+ # Double64 is software but only ~10-30× slower than BLAS, so it gets an intermediate range;
53+ # BigFloat is far slower still.
4454blas_sizes () = QUICK ? [8 , 16 , 32 ] : [8 , 16 , 32 , 64 , 128 , 256 ]
55+ double_sizes () = QUICK ? [8 , 16 ] : [8 , 16 , 32 , 64 , 128 ]
4556generic_sizes () = QUICK ? [8 , 16 ] : [8 , 16 , 32 , 64 ]
46- perf_sizes (T) = (T <: Union{Float32, Float64, ComplexF32, ComplexF64} ) ? blas_sizes () : generic_sizes ()
57+ perf_sizes (T) = _isblas (T) ? blas_sizes () : ( _isdouble (T ) ? double_sizes () : generic_sizes () )
4758
4859# Sizes for the accuracy sweep (kept small: high-precision reference is expensive).
4960acc_sizes () = QUICK ? [12 ] : [16 , 48 ]
5061
5162# Timing budget per (matrix, algorithm), in seconds.
52- perf_seconds (T) = QUICK ? 0.1 : (T <: Union{Float32, Float64, ComplexF32, ComplexF64} ? 0.3 : 0.8 )
63+ perf_seconds (T) = QUICK ? 0.1 : (_isblas (T) ? 0.3 : 0.8 )
5364
5465# Precision of the analytic reference and its tolerance (must beat the tested precision).
5566const HIGH_BITS = QUICK ? 512 : 1024
@@ -217,16 +228,29 @@ catch
217228 nothing
218229end
219230
231+ # The library only registers default eig / eigh algorithms for BLAS and BigFloat element
232+ # types, but GenericSchur / GenericLinearAlgebra actually drive any `AbstractFloat`. For
233+ # types without a registered default (e.g. Double64) fall back to those drivers directly,
234+ # using the same `QRIteration` the BigFloat default resolves to.
235+ function eig_algorithm_for (A)
236+ eig = _trydefault (MatrixAlgebraKit. default_eig_algorithm, A)
237+ return eig != = nothing ? eig : QRIteration (; driver = GS ())
238+ end
239+ function eigh_algorithm_for (A)
240+ eigh = _trydefault (MatrixAlgebraKit. default_eigh_algorithm, A)
241+ return eigh != = nothing ? eigh : QRIteration (; driver = GLA ())
242+ end
243+
220244function algorithms_for (A, hermitian:: Bool )
221245 T = eltype (A)
222246 algs = Tuple{String, Any}[(" Taylor" , MatrixFunctionViaTaylor ())]
223247 if T <: LinearAlgebra.BlasFloat
224248 push! (algs, (" LA" , MatrixFunctionViaLA ()))
225249 end
226- eig = _trydefault (MatrixAlgebraKit . default_eig_algorithm, A)
250+ eig = eig_algorithm_for ( A)
227251 eig != = nothing && push! (algs, (" Eig" , MatrixFunctionViaEig (eig)))
228252 if hermitian
229- eigh = _trydefault (MatrixAlgebraKit . default_eigh_algorithm, A)
253+ eigh = eigh_algorithm_for ( A)
230254 eigh != = nothing && push! (algs, (" Eigh" , MatrixFunctionViaEigh (eigh)))
231255 end
232256 return algs
0 commit comments