LCOV - code coverage report
Current view: top level - src - implementations.jl (source / functions) Hit Total Coverage
Test: on branch (detached from e33c853) Lines: 68 68 100.0 %
Date: 2025-10-07 08:47:25 Functions: 0 0 -

          Line data    Source code
       1           2 : function _split(xdx::Vector{Tuple{V, V}}) where {V}
       2          10 :     map(v -> v[1], xdx), map(v -> v[2], xdx)
       3             : end
       4             : 
       5           1 : function _split(txdx::Vector{Tuple{S, V, V}}) where {S, V}
       6           7 :     map(v -> v[1], txdx), map(v -> v[2], txdx), map(v -> v[3], txdx)
       7             : end
       8             : 
       9           1 : function _split2(txdx::Vector{Tuple{S, V, V}}) where {S, V}
      10           5 :     map(v -> v[1], txdx), map(v -> (v[2], v[3]), txdx)
      11             : end
      12             : 
      13        9107 : _split(x::Tuple) = x # NOTE: for use with Base.getindex w/ Int or ...
      14             : 
      15             : struct HermiteSpline_t_x_dx{S<:Real, V} <: AbstractHermiteSpline{S, V}
      16             :     t::Vector{S}
      17             :     x::Vector{V}
      18             :     dx::Vector{V}
      19             : 
      20           3 :     HermiteSpline_t_x_dx{S, V}() where {S, V} = new(S[], V[], V[])
      21             : 
      22           3 :     function HermiteSpline_t_x_dx{S, V}(t::Vector{S},
      23             :                                         x::Vector{V},
      24             :                                         dx::Vector{V}) where {S, V}
      25           3 :         @assert length(t) == length(x)
      26           3 :         @assert length(t) == length(dx)
      27           3 :         new(t, x, dx)
      28             :     end
      29             : 
      30           1 :     function HermiteSpline_t_x_dx{S, V}(t::Vector{S},
      31             :                                         xdx::Vector{Tuple{V, V}}) where {S, V}
      32           1 :         @assert length(t) == length(xdx)
      33           1 :         new(t, _split(xdx)...)
      34             :     end
      35             : 
      36           1 :     HermiteSpline_t_x_dx{S, V}(txdx::Vector{Tuple{S, V, V}}) where {S, V} =
      37             :         new(_split(txdx)...)
      38             : end
      39             : 
      40        3788 : Base.getindex(h::HermiteSpline_t_x_dx, i) = tuple(h.t[i], h.x[i], h.dx[i])
      41             : 
      42           1 : function Base.empty!(h::HermiteSpline_t_x_dx)
      43         100 :     empty!(h.t)
      44         100 :     empty!(h.x)
      45         100 :     empty!(h.dx)
      46           1 :     h
      47             : end
      48             : 
      49         102 : function _push!(h::HermiteSpline_t_x_dx{S, V},
      50             :                 t::S, x::V, dx::V) where {S<:Real, V}
      51         102 :     push!(h.t, t)
      52         102 :     push!(h.x, x)
      53         102 :     push!(h.dx, dx)
      54         102 :     h
      55             : end
      56             : 
      57           3 : knots(h::HermiteSpline_t_x_dx{S, V}) where {S, V} = h.t
      58             : 
      59           1 : Base.values(h::HermiteSpline_t_x_dx{S, V}) where {S, V} = h.x
      60           1 : value(h::HermiteSpline_t_x_dx{S, V}, i::Int) where {S, V} = h.x[i]
      61             : 
      62           1 : derivatives(h::HermiteSpline_t_x_dx{S, V}) where {S, V} = h.dx
      63           1 : derivative(h::HermiteSpline_t_x_dx{S, V}, i::Int) where {S, V} = h.dx[i]
      64             : 
      65             : #-----------------------------------------------------------------------------
      66             : 
      67             : struct HermiteSpline_t_xdx{S<:Real, V} <: AbstractHermiteSpline{S, V}
      68             :     t::Vector{S}
      69             :     xdx::Vector{Tuple{V, V}}
      70             : 
      71          15 :     HermiteSpline_t_xdx{S, V}() where {S, V} = new(S[], Tuple{V, V}[])
      72             : 
      73          19 :     function HermiteSpline_t_xdx{S, V}(t::Vector{S},
      74             :                                        xdx::Vector{Tuple{V, V}}) where {S, V}
      75          19 :         @assert length(t) == length(xdx)
      76          19 :         new(t, xdx)
      77             :     end
      78             : 
      79           1 :     function HermiteSpline_t_xdx{S, V}(t::Vector{S},
      80             :                                         x::Vector{V},
      81             :                                         dx::Vector{V}) where {S, V}
      82           1 :         @assert length(t) == length(x)
      83           1 :         @assert length(t) == length(dx)
      84           1 :         new(t, collect(zip(x, dx)))
      85             :     end
      86             : 
      87           1 :     HermiteSpline_t_xdx{S, V}(txdx::Vector{Tuple{S, V, V}}) where {S, V} =
      88             :         new(_split2(txdx)...)
      89             : end
      90             : 
      91        6122 : Base.getindex(h::HermiteSpline_t_xdx, i) = tuple(h.t[i], _split(h.xdx[i])...)
      92             : 
      93           1 : function Base.empty!(h::HermiteSpline_t_xdx)
      94         100 :     empty!(h.t)
      95         100 :     empty!(h.xdx)
      96           1 :     h
      97             : end
      98             : 
      99         128 : function _push!(h::HermiteSpline_t_xdx{S, V},
     100             :                 t::S, x::V, dx::V) where {S<:Real, V}
     101         128 :     push!(h.t, t)
     102         128 :     push!(h.xdx, (x, dx))
     103         128 :     h
     104             : end
     105             : 
     106           7 : knots(h::HermiteSpline_t_xdx) = h.t
     107             : 
     108             : #-----------------------------------------------------------------------------
     109             : 
     110             : struct HermiteSpline_txdx{S<:Real, V} <: AbstractHermiteSpline{S, V}
     111             :     t::Vector{Tuple{S, V, V}}
     112             : 
     113           2 :     HermiteSpline_txdx{S, V}() where {S, V} = new(Tuple{S, V, V}[])
     114             : 
     115           3 :     function HermiteSpline_txdx{S, V}(t::Vector{Tuple{S, V, V}}) where {S, V}
     116           3 :         new(t)
     117             :     end
     118             : 
     119           1 :     function HermiteSpline_txdx{S, V}(t::Vector{S},
     120             :                                       x::Vector{V},
     121             :                                       dx::Vector{V}) where {S, V}
     122           1 :         @assert length(t) == length(x)
     123           1 :         @assert length(t) == length(dx)
     124           1 :         new(collect(zip(t, x, dx)))
     125             :     end
     126             : 
     127           1 :     function HermiteSpline_txdx{S, V}(t::Vector{S},
     128             :                                       xdx::Vector{Tuple{V, V}}) where {S, V}
     129           1 :         @assert length(t) == length(xdx)
     130           3 :         new(collect(map(v -> (v[1], v[2]...), zip(t, xdx))))
     131             :     end
     132             : end
     133             : 
     134        2986 : Base.getindex(h::HermiteSpline_txdx, i) = tuple(_split(h.t[i])...)
     135             : 
     136           1 : function Base.empty!(h::HermiteSpline_txdx)
     137         100 :     empty!(h.t)
     138           1 :     h
     139             : end
     140             : 
     141         100 : function _push!(h::HermiteSpline_txdx{S, V},
     142             :                 t::S, x::V, dx::V) where {S<:Real, V}
     143         100 :     push!(h.t, (t, x, dx))
     144         100 :     h
     145             : end

Generated by: LCOV version 1.16