Skip to content

Commit

Permalink
Fix initialization of y and make conditional tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Aug 15, 2017
1 parent e3b8a3f commit a6c0147
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ToeplitzMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ function A_mul_B!{T}(α::T, A::AbstractToeplitz{T}, x::StridedVector, β::T,
throw(DimensionMismatch(""))
end

# In any case, scale/initialize y
if iszero(β)
fill!(y, 0)
else
scale!(y, β)
end

@inbounds begin
# Small case: don't use FFT
if N < 512
if iszero(β)
fill!(y, 0)
else
scale!(y, β)
end
for j in 1:n
tmp = α * x[j]
for i in 1:m
Expand All @@ -82,8 +84,7 @@ function A_mul_B!{T}(α::T, A::AbstractToeplitz{T}, x::StridedVector, β::T,
end
A.dft \ A.tmp
for i in 1:m
yi = ifelse(iszero(β), zero(β), y[i]*β)
y[i] = yi + α * (T <: Real ? real(A.tmp[i]) : A.tmp[i])
y[i] += α * (T <: Real ? real(A.tmp[i]) : A.tmp[i])
end
return y
end
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ end

if isdir(Pkg.dir("FastTransforms"))
using FastTransforms
end
if isdir(Pkg.dir("FastTransforms"))
@testset "BigFloat" begin
T = Toeplitz(BigFloat[1,2,3,4,5], BigFloat[1,6,7,8,0])
@test T*ones(BigFloat,5) [22,24,19,16,15]
Expand Down

0 comments on commit a6c0147

Please sign in to comment.