Skip to content

Commit

Permalink
refactor: delete more code
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 28, 2024
1 parent 9025e3e commit 658d5c8
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 163 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
MaybeInplace = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb"
NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
NonlinearSolveQuasiNewton = "9a2c21bd-3a47-402d-9113-8faf9a0ee114"
NonlinearSolveSpectralMethods = "26075421-4e9a-44e1-8bd1-420ed7ad02b2"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Expand Down Expand Up @@ -78,7 +78,6 @@ FixedPointAcceleration = "0.3"
ForwardDiff = "0.10.36"
Hwloc = "3"
InteractiveUtils = "<0.0.1, 1"
LazyArrays = "1.8.2, 2"
LeastSquaresOptim = "0.8.5"
LineSearch = "0.1.4"
LineSearches = "7.3"
Expand Down
4 changes: 0 additions & 4 deletions src/NonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ using CommonSolve: solve, init, solve!
using ConcreteStructs: @concrete
using DiffEqBase: DiffEqBase # Needed for `init` / `solve` dispatches
using FastClosures: @closure
using LazyArrays: LazyArrays, ApplyArray, cache
using LinearAlgebra: LinearAlgebra, Diagonal, I, LowerTriangular, Symmetric,
UpperTriangular, axpy!, cond, diag, diagind, dot, issuccess, istril,
istriu, lu, mul!, norm, pinv, tril!, triu!
Expand Down Expand Up @@ -72,15 +71,12 @@ const DI = DifferentiationInterface
const True = Val(true)
const False = Val(false)

include("abstract_types.jl")
include("timer_outputs.jl")
include("internal/helpers.jl")

include("globalization/trust_region.jl")

include("core/generic.jl")
include("core/generalized_first_order.jl")
include("core/noinit.jl")

include("algorithms/raphson.jl")
include("algorithms/pseudo_transient.jl")
Expand Down
66 changes: 0 additions & 66 deletions src/core/generic.jl

This file was deleted.

37 changes: 0 additions & 37 deletions src/core/noinit.jl

This file was deleted.

54 changes: 0 additions & 54 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,53 +1,3 @@
# Helper Functions
@generated function __getproperty(s::S, ::Val{X}) where {S, X}
hasfield(S, X) && return :(s.$X)
return :(missing)
end

@inline @generated function _vec(v)
hasmethod(vec, Tuple{typeof(v)}) || return :(vec(v))
return :(v)
end
@inline _vec(v::Number) = v
@inline _vec(v::AbstractVector) = v

@inline _restructure(y, x) = restructure(y, x)
@inline _restructure(y::Number, x::Number) = x

@inline __maybe_unaliased(x::Union{Number, SArray}, ::Bool) = x
@inline function __maybe_unaliased(x::AbstractArray, alias::Bool)
# Spend time coping iff we will mutate the array
(alias || !__can_setindex(typeof(x))) && return x
return deepcopy(x)
end
@inline __maybe_unaliased(x::AbstractSciMLOperator, ::Bool) = x

@inline __copy(x::AbstractArray) = copy(x)
@inline __copy(x::Number) = x
@inline __copy(x) = x

# LazyArrays for tracing
__zero(x::AbstractArray) = zero(x)
__zero(x) = x
LazyArrays.applied_eltype(::typeof(__zero), x) = eltype(x)
LazyArrays.applied_ndims(::typeof(__zero), x) = ndims(x)
LazyArrays.applied_size(::typeof(__zero), x) = size(x)
LazyArrays.applied_axes(::typeof(__zero), x) = axes(x)

# Use Symmetric Matrices if known to be efficient
@inline __maybe_symmetric(x) = Symmetric(x)
@inline __maybe_symmetric(x::Number) = x
## LinearSolve with `nothing` doesn't dispatch correctly here
@inline __maybe_symmetric(x::StaticArray) = x
@inline __maybe_symmetric(x::AbstractSparseMatrix) = x
@inline __maybe_symmetric(x::AbstractSciMLOperator) = x

# Simple Checks
@inline __is_present(::Nothing) = false
@inline __is_present(::Missing) = false
@inline __is_present(::Any) = true
@inline __is_present(::NoLineSearch) = false

@inline __is_complex(::Type{ComplexF64}) = true
@inline __is_complex(::Type{ComplexF32}) = true
@inline __is_complex(::Type{Complex}) = true
Expand Down Expand Up @@ -76,10 +26,6 @@ end
return fx_idx, idx
end

@inline __can_setindex(x) = can_setindex(x)
@inline __can_setindex(::Number) = false

@inline __dot(x, y) = dot(_vec(x), _vec(y))

"""
pickchunksize(x) = pickchunksize(length(x))
Expand Down

0 comments on commit 658d5c8

Please sign in to comment.