Skip to content

Commit

Permalink
Change clenshaw!/horner! to mutate first argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Dec 12, 2024
1 parent 368dcb9 commit 6d5b44f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FastTransforms"
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
version = "0.16.6"
version = "0.17"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand All @@ -15,7 +15,6 @@ LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
RecurrenceRelationships = "807425ed-42ea-44d6-a357-6771516d7b2c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24"

Expand All @@ -29,8 +28,7 @@ FastTransforms_jll = "0.6.2"
FillArrays = "0.9, 0.10, 0.11, 0.12, 0.13, 1"
GenericFFT = "0.1"
LazyArrays = "2.2"
RecurrenceRelationships = "0.1"
Reexport = "0.2, 1.0"
RecurrenceRelationships = "0.2"
SpecialFunctions = "0.10, 1, 2"
ToeplitzMatrices = "0.7.1, 0.8"
julia = "1.7"
Expand Down
13 changes: 5 additions & 8 deletions src/FastTransforms.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module FastTransforms

using ArrayLayouts, BandedMatrices, FastGaussQuadrature, FillArrays, LazyArrays, LinearAlgebra,
Reexport, SpecialFunctions, ToeplitzMatrices, RecurrenceRelationships
SpecialFunctions, ToeplitzMatrices, RecurrenceRelationships

@reexport using AbstractFFTs
@reexport using FFTW
@reexport using GenericFFT
using AbstractFFTs
using FFTW
using GenericFFT

import Base: convert, unsafe_convert, eltype, ndims, adjoint, transpose, show,
*, \, inv, length, size, view, getindex, tail, OneTo
Expand Down Expand Up @@ -34,11 +34,8 @@ import LinearAlgebra: cholesky, issymmetric, isposdef, mul!, lmul!, ldiv!

import GenericFFT: interlace # imported in downstream packages

import RecurrenceRelationships: clenshaw!, check_clenshaw_recurrences
import RecurrenceRelationships: check_clenshaw_recurrences

const _forwardrecurrence! = RecurrenceRelationships.forwardrecurrence!
const _clenshaw_next = RecurrenceRelationships.clenshaw_next
const _forwardrecurrence_next = RecurrenceRelationships.forwardrecurrence_next

export leg2cheb, cheb2leg, ultra2ultra, jac2jac,
lag2lag, jac2ultra, ultra2jac, jac2cheb,
Expand Down
12 changes: 6 additions & 6 deletions src/libfasttransforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ function renew!(x::AbstractArray{BigFloat})
return x
end

function horner!(c::StridedVector{Float64}, x::Vector{Float64}, f::Vector{Float64})
function horner!(f::Vector{Float64}, c::StridedVector{Float64}, x::Vector{Float64})
@assert length(x) == length(f)
ccall((:ft_horner, libfasttransforms), Cvoid, (Cint, Ptr{Float64}, Cint, Cint, Ptr{Float64}, Ptr{Float64}), length(c), c, stride(c, 1), length(x), x, f)
f
end

function horner!(c::StridedVector{Float32}, x::Vector{Float32}, f::Vector{Float32})
function horner!(f::Vector{Float32}, c::StridedVector{Float32}, x::Vector{Float32})
@assert length(x) == length(f)
ccall((:ft_hornerf, libfasttransforms), Cvoid, (Cint, Ptr{Float32}, Cint, Cint, Ptr{Float32}, Ptr{Float32}), length(c), c, stride(c, 1), length(x), x, f)
f
Expand All @@ -69,27 +69,27 @@ function check_clenshaw_points(x, f)
length(x) == length(f) || throw(ArgumentError("Dimensions must match"))
end

function clenshaw!(c::StridedVector{Float64}, x::Vector{Float64}, f::Vector{Float64})
function clenshaw!(f::Vector{Float64}, c::StridedVector{Float64}, x::Vector{Float64})
@boundscheck check_clenshaw_points(x, f)
ccall((:ft_clenshaw, libfasttransforms), Cvoid, (Cint, Ptr{Float64}, Cint, Cint, Ptr{Float64}, Ptr{Float64}), length(c), c, stride(c, 1), length(x), x, f)
f
end

function clenshaw!(c::StridedVector{Float32}, x::Vector{Float32}, f::Vector{Float32})
function clenshaw!(f::Vector{Float32}, c::StridedVector{Float32}, x::Vector{Float32})
@boundscheck check_clenshaw_points(x, f)
ccall((:ft_clenshawf, libfasttransforms), Cvoid, (Cint, Ptr{Float32}, Cint, Cint, Ptr{Float32}, Ptr{Float32}), length(c), c, stride(c, 1), length(x), x, f)
f
end

function clenshaw!(c::StridedVector{Float64}, A::Vector{Float64}, B::Vector{Float64}, C::Vector{Float64}, x::Vector{Float64}, ϕ₀::Vector{Float64}, f::Vector{Float64})
function clenshaw!(f::Vector{Float64}, c::StridedVector{Float64}, A::Vector{Float64}, B::Vector{Float64}, C::Vector{Float64}, x::Vector{Float64}, ϕ₀::Vector{Float64})
N = length(c)
@boundscheck check_clenshaw_recurrences(N, A, B, C)
@boundscheck check_clenshaw_points(x, ϕ₀, f)
ccall((:ft_orthogonal_polynomial_clenshaw, libfasttransforms), Cvoid, (Cint, Ptr{Float64}, Cint, Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Cint, Ptr{Float64}, Ptr{Float64}, Ptr{Float64}), N, c, stride(c, 1), A, B, C, length(x), x, ϕ₀, f)
f
end

function clenshaw!(c::StridedVector{Float32}, A::Vector{Float32}, B::Vector{Float32}, C::Vector{Float32}, x::Vector{Float32}, ϕ₀::Vector{Float32}, f::Vector{Float32})
function clenshaw!(f::Vector{Float32}, c::StridedVector{Float32}, A::Vector{Float32}, B::Vector{Float32}, C::Vector{Float32}, x::Vector{Float32}, ϕ₀::Vector{Float32})
N = length(c)
@boundscheck check_clenshaw_recurrences(N, A, B, C)
@boundscheck check_clenshaw_points(x, ϕ₀, f)
Expand Down

0 comments on commit 6d5b44f

Please sign in to comment.