Skip to content

Commit

Permalink
Remove Hermite
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHnt committed Sep 25, 2024
1 parent 83d5868 commit d85785e
Showing 1 changed file with 0 additions and 168 deletions.
168 changes: 0 additions & 168 deletions src/sequence_spaces/special_operators/calculus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1193,174 +1193,6 @@ function _nzval(ℐ::Integral, ::Chebyshev, ::Chebyshev, ::Type{T}, i, j) where
end
end

# Hermite

image(𝒟::Derivative, s::Hermite) = Hermite(order(s)+order(𝒟))

_coeftype(::Derivative, ::Hermite, ::Type{T}) where {T} = float(T)

function _apply!(c::Sequence{Hermite}, 𝒟::Derivative, a)
n = order(𝒟)
if n == 0
coefficients(c) .= coefficients(a)
elseif n == 1
real_CoefType = real(eltype(c))
order_a = order(a)
if order_a 1
@inbounds c[0] = - sqrt(convert(real_CoefType, ExactReal(1)) / ExactReal(2)) * a[1]
end
@inbounds for i 1:order_a+1
c[i] = sqrt(convert(real_CoefType, ExactReal(i)) / ExactReal(2)) * a[i-1]
if i+1 order_a
c[i] -= sqrt(convert(real_CoefType, ExactReal(i+1)) / ExactReal(2)) * a[i+1]
end
end
else # TODO: lift restriction
return throw(DomainError)
end
return c
end

function _apply!(C::AbstractArray{T}, 𝒟::Derivative, space::Hermite, A) where {T}
n = order(𝒟)
if n == 0
C .= A
elseif n == 1
real_T = real(T)
ord = order(space)
if ord 1
@inbounds selectdim(C, 1, 1) .= (-sqrt(convert(real_T, ExactReal(1)) / ExactReal(2))) .* selectdim(A, 1, i+1)
end
@inbounds for i 1:ord+1
Cᵢ = selectdim(C, 1, i+1)
Cᵢ .= (sqrt(convert(real_T, ExactReal(i)) / ExactReal(2))) .* selectdim(A, 1, i)
if i+1 ord
Cᵢ .-= (sqrt(convert(real_T, ExactReal(i+1)) / ExactReal(2))) .* selectdim(A, 1, i+2)
end
end
else # TODO: lift restriction
return throw(DomainError)
end
return C
end

function _apply(𝒟::Derivative, space::Hermite, ::Val{D}, A::AbstractArray{T,N}) where {D,T,N}
n = order(𝒟)
CoefType = _coeftype(𝒟, space, T)
if n == 0
return convert(Array{CoefType,N}, A)
elseif n == 1
real_CoefType = real(CoefType)
ord = order(space)
C = zeros(CoefType, ntuple(i -> i == D ? ord : size(A, i), Val(N)))
if ord 1
@inbounds selectdim(C, D, 1) .= (-sqrt(convert(real_CoefType, ExactReal(1)) / ExactReal(2))) .* selectdim(A, D, i+1)
end
@inbounds for i 1:ord+1
Cᵢ = selectdim(C, D, i+1)
Cᵢ .= (sqrt(convert(real_CoefType, ExactReal(i)) / ExactReal(2))) .* selectdim(A, D, i)
if i+1 ord
Cᵢ .-= (sqrt(convert(real_CoefType, ExactReal(i+1)) / ExactReal(2))) .* selectdim(A, D, i+2)
end
end
return C
else # TODO: lift restriction
return throw(DomainError)
end
end

function _nzind_domain(𝒟::Derivative, domain::Hermite, codomain::Hermite)
if order(𝒟) == 0
return collect(0:min(order(domain), order(codomain)))
elseif order(𝒟) == 1
len = 0
for j 0:order(domain)
if j == 0
len += 1 order(codomain)
else
len += (0 + (j+1 order(codomain))) + (j-1 order(codomain))
end
end
v = Vector{Int}(undef, len)
idx = 1
for j 0:order(domain)
if j == 0
if j+1 order(codomain)
v[1] = 0
idx += 1
end
else
idx2 = (idx-1 + (j+1 order(codomain))) + (j-1 order(codomain))
view(v, idx:idx2) .= j
idx = idx2 + 1
end
end
return v
else # TODO: lift restriction
return throw(DomainError)
end
end

function _nzind_codomain(𝒟::Derivative, domain::Hermite, codomain::Hermite)
if order(𝒟) == 0
return collect(0:min(order(domain), order(codomain)))
elseif order(𝒟) == 1
len = 0
for j 0:order(domain)
if j == 0
len += 1 order(codomain)
else
len += (0 + (j+1 order(codomain))) + (j-1 order(codomain))
end
end
v = Vector{Int}(undef, len)
idx = 1
for j 0:order(domain)
if j == 0
if 1 order(codomain)
v[idx] = 1
idx += 1
end
else
if j+1 order(codomain)
v[idx] = j-1
v[idx+1] = j+1
idx += 2
elseif j-1 order(codomain)
v[idx] = j-1
idx += 1
end
end
end
return v
else # TODO: lift restriction
return throw(DomainError)
end
end

function _nzval(𝒟::Derivative, ::Hermite, ::Hermite, ::Type{T}, i, j) where {T}
n = order(𝒟)
if n == 0
return one(T)
elseif n == 1
if i == 0
if j == 1
return convert(T, -sqrt(convert(real(T), ExactReal(1)) / ExactReal(2)))
else
return zero(T)
end
else
if i+1 == j
return convert(T, -sqrt(convert(real(T), ExactReal(i+1)) / ExactReal(2)))
else # i == j+1
return convert(T, sqrt(convert(real(T), ExactReal(i)) / ExactReal(2)))
end
end
else # TODO: lift restriction
return throw(DomainError)
end
end

# Cartesian spaces

for F (:Derivative, :Integral)
Expand Down

0 comments on commit d85785e

Please sign in to comment.