From 2f8d5cce00d667639dfb331a656c9c9ab399fb8b Mon Sep 17 00:00:00 2001 From: "David K. Zhang" Date: Tue, 27 Aug 2024 12:50:21 -0700 Subject: [PATCH] bump major version --- Project.toml | 3 +- src/RungeKuttaToolKit.jl | 318 --------------------------------------- test/runtests.jl | 2 +- 3 files changed, 3 insertions(+), 320 deletions(-) diff --git a/Project.toml b/Project.toml index 6594944..c223457 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RungeKuttaToolKit" uuid = "5ccfa5ee-da33-4844-afab-33f13f6d8736" authors = ["David K. Zhang "] -version = "1.0.0" +version = "2.0.0" [deps] MultiFloats = "bdf0d083-296b-4888-a5b6-7498122e68a5" @@ -10,4 +10,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] MultiFloats = "2.0" +StatsBase = "^0" julia = "1.0" diff --git a/src/RungeKuttaToolKit.jl b/src/RungeKuttaToolKit.jl index c56f7db..160be8b 100644 --- a/src/RungeKuttaToolKit.jl +++ b/src/RungeKuttaToolKit.jl @@ -1144,322 +1144,4 @@ function reshape_implicit!( end -############################################################## FUNCTOR INTERFACE - - -# function populate_Q!( -# Q::AbstractMatrix{T}, Phi::AbstractMatrix{T}, -# selected_indices::AbstractVector{Int} -# ) where {T} -# t, s = size(Q) -# @assert s == size(Phi, 1) -# @assert (t,) == size(selected_indices) -# for (i, k) in pairs(selected_indices) -# @simd ivdep for j = 1:s -# @inbounds Q[i, j] = Phi[j, k] -# end -# end -# end - - -# function (ev::RKOCEvaluatorAE{T})(x::Vector{T}) where {T} -# reshape_explicit!(ev.A, x) -# compute_Phi!(ev.Phi, ev.A, ev.table.instructions) -# populate_Q!(ev.Q, ev.Phi, ev.table.selected_indices) -# gram_schmidt_qr!(ev.Q) -# compute_residuals!(ev.residuals, ev.Q, ev.inv_gamma) -# return residual_norm_squared(ev.residuals) -# end - - -# function (ev::RKOCEvaluatorAD{T})(x::Vector{T}) where {T} -# reshape_diagonally_implicit!(ev.A, x) -# compute_Phi!(ev.Phi, ev.A, ev.table.instructions) -# populate_Q!(ev.Q, ev.Phi, ev.table.selected_indices) -# gram_schmidt_qr!(ev.Q) -# compute_residuals!(ev.residuals, ev.Q, ev.inv_gamma) -# return residual_norm_squared(ev.residuals) -# end - - -# function (ev::RKOCEvaluatorAI{T})(x::Vector{T}) where {T} -# reshape_implicit!(ev.A, x) -# compute_Phi!(ev.Phi, ev.A, ev.table.instructions) -# populate_Q!(ev.Q, ev.Phi, ev.table.selected_indices) -# gram_schmidt_qr!(ev.Q) -# compute_residuals!(ev.residuals, ev.Q, ev.inv_gamma) -# return residual_norm_squared(ev.residuals) -# end - - -# function (ev::RKOCResidualEvaluatorAE{T})( -# residuals::Vector{T}, x::Vector{T} -# ) where {T} -# reshape_explicit!(ev.A, x) -# compute_Phi!(ev.Phi, ev.A, ev.table.instructions) -# populate_Q!(ev.Q, ev.Phi, ev.table.selected_indices) -# gram_schmidt_qr!(ev.Q) -# compute_residuals!(residuals, ev.Q, ev.inv_gamma) -# return residuals -# end - - -# function (ev::RKOCResidualEvaluatorAD{T})( -# residuals::Vector{T}, x::Vector{T} -# ) where {T} -# reshape_diagonally_implicit!(ev.A, x) -# compute_Phi!(ev.Phi, ev.A, ev.table.instructions) -# populate_Q!(ev.Q, ev.Phi, ev.table.selected_indices) -# gram_schmidt_qr!(ev.Q) -# compute_residuals!(residuals, ev.Q, ev.inv_gamma) -# return residuals -# end - - -# function (ev::RKOCResidualEvaluatorAI{T})( -# residuals::Vector{T}, x::Vector{T} -# ) where {T} -# reshape_implicit!(ev.A, x) -# compute_Phi!(ev.Phi, ev.A, ev.table.instructions) -# populate_Q!(ev.Q, ev.Phi, ev.table.selected_indices) -# gram_schmidt_qr!(ev.Q) -# compute_residuals!(residuals, ev.Q, ev.inv_gamma) -# return residuals -# end - - -# function (adj::RKOCEvaluatorAEAdjoint{T})(g::Vector{T}, x::Vector{T}) where {T} -# reshape_explicit!(adj.ev.A, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# populate_Q!(adj.ev.Q, adj.ev.Phi, adj.ev.table.selected_indices) -# gram_schmidt_qr!(adj.ev.Q, adj.ev.R) -# compute_residuals_and_b!(adj.ev.residuals, adj.ev.b, -# adj.ev.Q, adj.ev.inv_gamma) -# solve_upper_triangular!(adj.ev.b, adj.ev.R) -# pullback_dPhi_from_residual!(adj.ev.dPhi, -# adj.ev.b, adj.ev.residuals, adj.ev.table.source_indices) -# pullback_dPhi!(adj.ev.dPhi, -# adj.ev.A, adj.ev.Phi, adj.ev.table.extension_indices, -# adj.ev.table.rooted_sum_ranges, adj.ev.table.rooted_sum_indices) -# pullback_dA!(adj.ev.dA, -# adj.ev.Phi, adj.ev.dPhi, adj.ev.table.extension_indices) -# reshape_explicit!(g, adj.ev.dA) -# return g -# end - - -# function (adj::RKOCEvaluatorADAdjoint{T})(g::Vector{T}, x::Vector{T}) where {T} -# reshape_diagonally_implicit!(adj.ev.A, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# populate_Q!(adj.ev.Q, adj.ev.Phi, adj.ev.table.selected_indices) -# gram_schmidt_qr!(adj.ev.Q, adj.ev.R) -# compute_residuals_and_b!(adj.ev.residuals, adj.ev.b, -# adj.ev.Q, adj.ev.inv_gamma) -# solve_upper_triangular!(adj.ev.b, adj.ev.R) -# pullback_dPhi_from_residual!(adj.ev.dPhi, -# adj.ev.b, adj.ev.residuals, adj.ev.table.source_indices) -# pullback_dPhi!(adj.ev.dPhi, -# adj.ev.A, adj.ev.Phi, adj.ev.table.extension_indices, -# adj.ev.table.rooted_sum_ranges, adj.ev.table.rooted_sum_indices) -# pullback_dA!(adj.ev.dA, -# adj.ev.Phi, adj.ev.dPhi, adj.ev.table.extension_indices) -# reshape_diagonally_implicit!(g, adj.ev.dA) -# return g -# end - - -# function (adj::RKOCEvaluatorAIAdjoint{T})(g::Vector{T}, x::Vector{T}) where {T} -# reshape_implicit!(adj.ev.A, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# populate_Q!(adj.ev.Q, adj.ev.Phi, adj.ev.table.selected_indices) -# gram_schmidt_qr!(adj.ev.Q, adj.ev.R) -# compute_residuals_and_b!(adj.ev.residuals, adj.ev.b, -# adj.ev.Q, adj.ev.inv_gamma) -# solve_upper_triangular!(adj.ev.b, adj.ev.R) -# pullback_dPhi_from_residual!(adj.ev.dPhi, -# adj.ev.b, adj.ev.residuals, adj.ev.table.source_indices) -# pullback_dPhi!(adj.ev.dPhi, -# adj.ev.A, adj.ev.Phi, adj.ev.table.extension_indices, -# adj.ev.table.rooted_sum_ranges, adj.ev.table.rooted_sum_indices) -# pullback_dA!(adj.ev.dA, -# adj.ev.Phi, adj.ev.dPhi, adj.ev.table.extension_indices) -# reshape_implicit!(g, adj.ev.dA) -# return g -# end - - -# function (adj::RKOCResidualEvaluatorAEAdjoint{T})( -# jacobian::Matrix{T}, x::Vector{T} -# ) where {T} -# @assert length(adj.ev.table.selected_indices) == size(jacobian, 1) -# @assert length(x) == size(jacobian, 2) -# reshape_explicit!(adj.ev.A, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# populate_Q!(adj.ev.Q, adj.ev.Phi, adj.ev.table.selected_indices) -# gram_schmidt_qr!(adj.ev.Q, adj.ev.R) -# compute_residuals_and_b!(adj.ev.residuals, adj.ev.b, -# adj.ev.Q, adj.ev.inv_gamma) -# solve_upper_triangular!(adj.ev.b, adj.ev.R) -# s = length(adj.ev.b) -# k = 1 -# for i = 2:s -# for j = 1:i-1 -# pushforward_dPhi!(adj.ev.dPhi, -# adj.ev.Phi, adj.ev.A, i, j, adj.ev.table.instructions) -# column = view(jacobian, :, k) -# pushforward_db!(adj.ev.db, column, -# adj.ev.residuals, adj.ev.dPhi, adj.ev.b, adj.ev.Q, adj.ev.R, -# adj.ev.table.selected_indices) -# pushforward_dresiduals!(column, -# adj.ev.db, adj.ev.b, adj.ev.dPhi, adj.ev.Phi, -# adj.ev.table.selected_indices) -# k += 1 -# end -# end -# return jacobian -# end - - -# function (adj::RKOCResidualEvaluatorADAdjoint{T})( -# jacobian::Matrix{T}, x::Vector{T} -# ) where {T} -# @assert length(adj.ev.table.selected_indices) == size(jacobian, 1) -# @assert length(x) == size(jacobian, 2) -# reshape_diagonally_implicit!(adj.ev.A, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# populate_Q!(adj.ev.Q, adj.ev.Phi, adj.ev.table.selected_indices) -# gram_schmidt_qr!(adj.ev.Q, adj.ev.R) -# compute_residuals_and_b!(adj.ev.residuals, adj.ev.b, -# adj.ev.Q, adj.ev.inv_gamma) -# solve_upper_triangular!(adj.ev.b, adj.ev.R) -# s = length(adj.ev.b) -# k = 1 -# for i = 1:s -# for j = 1:i -# pushforward_dPhi!(adj.ev.dPhi, -# adj.ev.Phi, adj.ev.A, i, j, adj.ev.table.instructions) -# column = view(jacobian, :, k) -# pushforward_db!(adj.ev.db, column, -# adj.ev.residuals, adj.ev.dPhi, adj.ev.b, adj.ev.Q, adj.ev.R, -# adj.ev.table.selected_indices) -# pushforward_dresiduals!(column, -# adj.ev.db, adj.ev.b, adj.ev.dPhi, adj.ev.Phi, -# adj.ev.table.selected_indices) -# k += 1 -# end -# end -# return jacobian -# end - - -# function (adj::RKOCResidualEvaluatorAIAdjoint{T})( -# jacobian::Matrix{T}, x::Vector{T} -# ) where {T} -# @assert length(adj.ev.table.selected_indices) == size(jacobian, 1) -# @assert length(x) == size(jacobian, 2) -# reshape_implicit!(adj.ev.A, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# populate_Q!(adj.ev.Q, adj.ev.Phi, adj.ev.table.selected_indices) -# gram_schmidt_qr!(adj.ev.Q, adj.ev.R) -# compute_residuals_and_b!(adj.ev.residuals, adj.ev.b, -# adj.ev.Q, adj.ev.inv_gamma) -# solve_upper_triangular!(adj.ev.b, adj.ev.R) -# s = length(adj.ev.b) -# k = 1 -# for i = 1:s -# for j = 1:s -# pushforward_dPhi!(adj.ev.dPhi, -# adj.ev.Phi, adj.ev.A, i, j, adj.ev.table.instructions) -# column = view(jacobian, :, k) -# pushforward_db!(adj.ev.db, column, -# adj.ev.residuals, adj.ev.dPhi, adj.ev.b, adj.ev.Q, adj.ev.R, -# adj.ev.table.selected_indices) -# pushforward_dresiduals!(column, -# adj.ev.db, adj.ev.b, adj.ev.dPhi, adj.ev.Phi, -# adj.ev.table.selected_indices) -# k += 1 -# end -# end -# return jacobian -# end - - -# function (adj::RKOCResidualEvaluatorBEAdjoint{T})( -# jacobian::Matrix{T}, x::Vector{T} -# ) where {T} -# @assert length(adj.ev.table.selected_indices) == size(jacobian, 1) -# @assert length(x) == size(jacobian, 2) -# reshape_explicit!(adj.ev.A, adj.ev.b, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# s = length(adj.ev.b) -# k = 1 -# for i = 2:s -# for j = 1:i-1 -# pushforward_dPhi!(adj.ev.dPhi, -# adj.ev.Phi, adj.ev.A, i, j, adj.ev.table.instructions) -# pushforward_dresiduals!(view(jacobian, :, k), -# adj.ev.b, adj.ev.dPhi, adj.ev.table.selected_indices) -# k += 1 -# end -# end -# return jacobian -# end - - -# function (adj::RKOCResidualEvaluatorBDAdjoint{T})( -# jacobian::Matrix{T}, x::Vector{T} -# ) where {T} -# @assert length(adj.ev.table.selected_indices) == size(jacobian, 1) -# @assert length(x) == size(jacobian, 2) -# reshape_diagonally_implicit!(adj.ev.A, adj.ev.b, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# s = length(adj.ev.b) -# k = 1 -# for i = 1:s -# for j = 1:i -# pushforward_dPhi!(adj.ev.dPhi, -# adj.ev.Phi, adj.ev.A, i, j, adj.ev.table.instructions) -# pushforward_dresiduals!(view(jacobian, :, k), -# adj.ev.b, adj.ev.dPhi, adj.ev.table.selected_indices) -# k += 1 -# end -# end -# for j = 1:s -# for (i, m) in pairs(adj.ev.table.selected_indices) -# @inbounds jacobian[i, k] = adj.ev.Phi[j, m] -# end -# k += 1 -# end -# return jacobian -# end - - -# function (adj::RKOCResidualEvaluatorBIAdjoint{T})( -# jacobian::Matrix{T}, x::Vector{T} -# ) where {T} -# @assert length(adj.ev.table.selected_indices) == size(jacobian, 1) -# @assert length(x) == size(jacobian, 2) -# reshape_implicit!(adj.ev.A, adj.ev.b, x) -# compute_Phi!(adj.ev.Phi, adj.ev.A, adj.ev.table.instructions) -# s = length(adj.ev.b) -# k = 1 -# for i = 1:s -# for j = 1:s -# pushforward_dPhi!(adj.ev.dPhi, -# adj.ev.Phi, adj.ev.A, i, j, adj.ev.table.instructions) -# pushforward_dresiduals!(view(jacobian, :, k), -# adj.ev.b, adj.ev.dPhi, adj.ev.table.selected_indices) -# k += 1 -# end -# end -# for j = 1:s -# for (i, m) in pairs(adj.ev.table.selected_indices) -# @inbounds jacobian[i, k] = adj.ev.Phi[j, m] -# end -# k += 1 -# end -# return jacobian -# end - - end # module RungeKuttaToolKit diff --git a/test/runtests.jl b/test/runtests.jl index 129c7f3..bd5fff2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,7 +7,7 @@ using Test const NUMERIC_TYPES = [ Float16, Float32, Float64, BigFloat, Float64x1, Float64x2, Float64x3, Float64x4, - Float64x5, Float64x6, Float64x7, Float64x8,] + Float64x5, Float64x6, Float64x7, Float64x8] function maximum_relative_difference(