Skip to content

Commit a36d249

Browse files
committed
Format code with JuliaFormatter SciMLStyle
- Applied SciMLStyle formatting to changed files - Ensured consistency with project coding standards
1 parent 1a1e2b7 commit a36d249

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1111
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
1212
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1313
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
14+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
1415
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
1516
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
1617
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
@@ -99,6 +100,7 @@ GPUArraysCore = "0.2"
99100
HYPRE = "1.7"
100101
InteractiveUtils = "1.10"
101102
IterativeSolvers = "0.9.4"
103+
JuliaFormatter = "2.1.6"
102104
KernelAbstractions = "0.9.30"
103105
Krylov = "0.10"
104106
KrylovKit = "0.10"

src/default.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ Get the tuned algorithm preference for the given element type and matrix size.
236236
Returns `nothing` if no preference exists. Uses preloaded constants for efficiency.
237237
Fast path when no preferences are set.
238238
"""
239-
@inline function get_tuned_algorithm(::Type{eltype_A}, ::Type{eltype_b}, matrix_size::Integer) where {eltype_A, eltype_b}
239+
@inline function get_tuned_algorithm(
240+
::Type{eltype_A}, ::Type{eltype_b}, matrix_size::Integer) where {eltype_A, eltype_b}
240241
# Determine the element type to use for preference lookup
241242
target_eltype = eltype_A !== Nothing ? eltype_A : eltype_b
242-
243+
243244
# Determine size category based on matrix size (matching LinearSolveAutotune categories)
244245
size_category = if matrix_size <= 20
245246
:tiny
@@ -252,10 +253,10 @@ Fast path when no preferences are set.
252253
else
253254
:big
254255
end
255-
256+
256257
# Fast path: if no preferences are set, return nothing immediately
257258
AUTOTUNE_PREFS_SET || return nothing
258-
259+
259260
# Look up the tuned algorithm from preloaded constants with type specialization
260261
return _get_tuned_algorithm_impl(target_eltype, size_category)
261262
end
@@ -283,11 +284,10 @@ end
283284

284285
@inline _get_tuned_algorithm_impl(::Type, ::Symbol) = nothing # Fallback for other types
285286

286-
287-
288287
# Convenience method for when A is nothing - delegate to main implementation
289-
@inline get_tuned_algorithm(::Type{Nothing}, ::Type{eltype_b}, matrix_size::Integer) where {eltype_b} =
290-
get_tuned_algorithm(eltype_b, eltype_b, matrix_size)
288+
@inline get_tuned_algorithm(::Type{Nothing},
289+
::Type{eltype_b},
290+
matrix_size::Integer) where {eltype_b} = get_tuned_algorithm(eltype_b, eltype_b, matrix_size)
291291

292292
# Allows A === nothing as a stand-in for dense matrix
293293
function defaultalg(A, b, assump::OperatorAssumptions{Bool})
@@ -301,7 +301,7 @@ function defaultalg(A, b, assump::OperatorAssumptions{Bool})
301301
ArrayInterface.can_setindex(b) &&
302302
(__conditioning(assump) === OperatorCondition.IllConditioned ||
303303
__conditioning(assump) === OperatorCondition.WellConditioned)
304-
304+
305305
# Small matrix override - always use GenericLUFactorization for tiny problems
306306
if length(b) <= 10
307307
DefaultAlgorithmChoice.GenericLUFactorization
@@ -310,7 +310,7 @@ function defaultalg(A, b, assump::OperatorAssumptions{Bool})
310310
matrix_size = length(b)
311311
eltype_A = A === nothing ? Nothing : eltype(A)
312312
tuned_alg = get_tuned_algorithm(eltype_A, eltype(b), matrix_size)
313-
313+
314314
if tuned_alg !== nothing
315315
tuned_alg
316316
elseif appleaccelerate_isavailable() && b isa Array &&

test/basictests.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,23 @@ end
282282
ρ = 0.95
283283
A_tri = SymTridiagonal(ones(k) .+ ρ^2, -ρ * ones(k-1))
284284
b = rand(k)
285-
285+
286286
# Test with explicit LDLtFactorization
287287
prob_tri = LinearProblem(A_tri, b)
288288
sol = solve(prob_tri, LDLtFactorization())
289289
@test A_tri * sol.u b
290-
290+
291291
# Test that default algorithm uses LDLtFactorization for SymTridiagonal
292292
default_alg = LinearSolve.defaultalg(A_tri, b, OperatorAssumptions(true))
293293
@test default_alg isa DefaultLinearSolver
294294
@test default_alg.alg == LinearSolve.DefaultAlgorithmChoice.LDLtFactorization
295-
295+
296296
# Test that the factorization is cached and reused
297297
cache = init(prob_tri, LDLtFactorization())
298298
sol1 = solve!(cache)
299299
@test A_tri * sol1.u b
300300
@test !cache.isfresh # Cache should not be fresh after first solve
301-
301+
302302
# Solve again with same matrix to ensure cache is reused
303303
cache.b = rand(k) # Change RHS
304304
sol2 = solve!(cache)
@@ -602,8 +602,10 @@ end
602602
prob3 = LinearProblem(op1, b1; u0 = x1)
603603
prob4 = LinearProblem(op2, b2; u0 = x2)
604604

605-
@test LinearSolve.defaultalg(op1, x1).alg === LinearSolve.DefaultAlgorithmChoice.DirectLdiv!
606-
@test LinearSolve.defaultalg(op2, x2).alg === LinearSolve.DefaultAlgorithmChoice.DirectLdiv!
605+
@test LinearSolve.defaultalg(op1, x1).alg ===
606+
LinearSolve.DefaultAlgorithmChoice.DirectLdiv!
607+
@test LinearSolve.defaultalg(op2, x2).alg ===
608+
LinearSolve.DefaultAlgorithmChoice.DirectLdiv!
607609
@test LinearSolve.defaultalg(op3, x1).alg ===
608610
LinearSolve.DefaultAlgorithmChoice.KrylovJL_GMRES
609611
@test LinearSolve.defaultalg(op4, x2).alg ===

0 commit comments

Comments
 (0)