Skip to content

Commit

Permalink
Refactor piecewiselinear.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Oct 28, 2024
1 parent a03907a commit 4078a9d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/theoretical/transiogram/piecewiselinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ obtained from an [`EmpiricalTransiogram`](@ref).
struct PiecewiseLinearTransiogram{ℒ<:Len,M} <: Transiogram
abscissas::Vector{ℒ}
ordinates::Vector{M}
proportion::M
ordinfinity::M
end

function PiecewiseLinearTransiogram(abscissas::AbstractVector, ordinates::AbstractMatrix)
Expand All @@ -38,17 +38,17 @@ function PiecewiseLinearTransiogram(abscissas::AbstractVector, ordinates::Abstra

# proportion matrix
p = normalize(diag(last(O)), 1)
P = SMatrix{m, m}(p[j] for i in 1:m, j in 1:m)
= SMatrix{m, m}(p[j] for i in 1:m, j in 1:m)

PiecewiseLinearTransiogram(a, O, P)
PiecewiseLinearTransiogram(a, O, )
end

function (t::PiecewiseLinearTransiogram)(h)
hs = t.abscissas
if h < first(hs) # left extrapolation
((first(hs) - h) * I + h * first(t.ordinates)) / first(hs)
elseif h > last(hs) # right extrapolation
t.proportion
t.ordinfinity
else # middle interpolation
k = findfirst((h), hs)
((hs[k + 1] - h) * t.ordinates[k] + (h - hs[k]) * t.ordinates[k + 1]) / (hs[k + 1] - hs[k])
Expand Down

0 comments on commit 4078a9d

Please sign in to comment.