Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gummif committed Nov 15, 2015
1 parent 713c3a5 commit b79b079
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/plot.jl
Expand Up @@ -53,7 +53,7 @@ end

# return an array of scaled detail coefficients and unscaled scaling coefficients
# ready to be plotted as an image
function wplotim(x::AbstractArray, L::Integer, wt::Union(DiscreteWavelet,Nothing)=nothing;
function wplotim(x::AbstractArray, L::Integer, wt::Union{DiscreteWavelet,Void}=nothing;
wabs::Bool=true, power::Real=0.7, pnorm::Real=1)
isdyadic(x) || throw(ArgumentError("array must be of dyadic size"))
dim = ndims(x)
Expand Down
18 changes: 9 additions & 9 deletions src/threshold.jl
Expand Up @@ -168,14 +168,14 @@ end
const DEFAULT_WAVELET = wavelet(WT.sym5, WT.Filter) # default wavelet type

# denoise signal x by thresholding in wavelet space
# estnoise is (x::AbstractArray, wt::Union(DiscreteWavelet,Nothing))
# estnoise is (x::AbstractArray, wt::Union{DiscreteWavelet,Void})
function denoise{S<:DNFT}(x::AbstractArray,
wt::Union(DiscreteWavelet,Nothing)=DEFAULT_WAVELET;
wt::Union{DiscreteWavelet,Void}=DEFAULT_WAVELET;
L::Int=min(maxtransformlevels(x),6),
dnt::S=VisuShrink(size(x,1)),
estnoise::Function=noisest,
TI::Bool=false,
nspin::Union(Int,Tuple)=tuple([8 for i=1:ndims(x)]...) )
nspin::Union{Int,Tuple}=tuple([8 for i=1:ndims(x)]...) )
iscube(x) || throw(ArgumentError("array must be square/cube"))
sigma = estnoise(x, wt)

Expand Down Expand Up @@ -241,7 +241,7 @@ end


# estimate the std. dev. of the signal noise, assuming Gaussian distribution
function noisest(x::AbstractArray, wt::Union(DiscreteWavelet,Nothing)=DEFAULT_WAVELET, L::Integer = 1)
function noisest(x::AbstractArray, wt::Union{DiscreteWavelet,Void}=DEFAULT_WAVELET, L::Integer = 1)
if wt == nothing
y = x
else
Expand Down Expand Up @@ -343,23 +343,23 @@ immutable LogEnergyEntropy <: Entropy end
# given x and y, where x has "more concentrated energy" than y
# then coefentropy(x, et, norm) <= coefentropy(y, et, norm) should be satisfied.

function coefentropy{T<:FloatingPoint}(x::T, et::ShannonEntropy, nrm::T)
function coefentropy{T<:AbstractFloat}(x::T, et::ShannonEntropy, nrm::T)
s = (x/nrm)^2
if s == 0.0
return -zero(T)
else
return -s*log(s)
end
end
function coefentropy{T<:FloatingPoint}(x::T, et::LogEnergyEntropy, nrm::T)
function coefentropy{T<:AbstractFloat}(x::T, et::LogEnergyEntropy, nrm::T)
s = (x/nrm)^2
if s == 0.0
return -zero(T)
else
return -log(s)
end
end
function coefentropy{T<:FloatingPoint}(x::AbstractArray{T}, et::Entropy, nrm::T=vecnorm(x))
function coefentropy{T<:AbstractFloat}(x::AbstractArray{T}, et::Entropy, nrm::T=vecnorm(x))
@assert nrm >= 0
sum = zero(T)
nrm == sum && return sum
Expand All @@ -372,10 +372,10 @@ end

# find the best tree that is a subset of the input tree (use :full to find the best tree)
# for wpt
function bestbasistree{T<:FloatingPoint}(y::AbstractVector{T}, wt::DiscreteWavelet, L::Integer=maxtransformlevels(y), et::Entropy=ShannonEntropy())
function bestbasistree{T<:AbstractFloat}(y::AbstractVector{T}, wt::DiscreteWavelet, L::Integer=maxtransformlevels(y), et::Entropy=ShannonEntropy())
bestbasistree(y, wt, maketree(length(y), L, :full), et)
end
function bestbasistree{T<:FloatingPoint}(y::AbstractVector{T}, wt::DiscreteWavelet, tree::BitVector, et::Entropy=ShannonEntropy())
function bestbasistree{T<:AbstractFloat}(y::AbstractVector{T}, wt::DiscreteWavelet, tree::BitVector, et::Entropy=ShannonEntropy())

isvalidtree(y, tree) || throw(ArgumentError("invalid tree"))

Expand Down
28 changes: 14 additions & 14 deletions src/transforms.jl
Expand Up @@ -16,26 +16,26 @@ for (Xwt, Xwt!, _Xwt!, fw) in ((:dwt, :dwt!, :_dwt!, true),
(:idwt, :idwt!, :_dwt!, false))
@eval begin
# filter
function ($Xwt){T<:FloatingPoint}(x::DWTArray{T},
function ($Xwt){T<:AbstractFloat}(x::DWTArray{T},
filter::OrthoFilter,
L::Integer=maxtransformlevels(x))
y = Array(T, size(x))
return ($_Xwt!)(y, x, filter, L, $fw)
end
function ($Xwt!){T<:FloatingPoint}(y::DWTArray{T}, x::DWTArray{T},
function ($Xwt!){T<:AbstractFloat}(y::DWTArray{T}, x::DWTArray{T},
filter::OrthoFilter,
L::Integer=maxtransformlevels(x))
return ($_Xwt!)(y, x, filter, L, $fw)
end
# lifting
function ($Xwt){T<:FloatingPoint}(x::DWTArray{T},
function ($Xwt){T<:AbstractFloat}(x::DWTArray{T},
scheme::GLS,
L::Integer=maxtransformlevels(x))
y = Array(T, size(x))
copy!(y, x)
return ($_Xwt!)(y, scheme, L, $fw)
end
function ($Xwt!){T<:FloatingPoint}(y::DWTArray{T},
function ($Xwt!){T<:AbstractFloat}(y::DWTArray{T},
scheme::GLS,
L::Integer=maxtransformlevels(x))
return ($_Xwt!)(y, scheme, L, $fw)
Expand Down Expand Up @@ -101,42 +101,42 @@ The inverse of `dwt!`.
for (Xwt, Xwt!, _Xwt!, fw) in ((:wpt, :wpt!, :_wpt!, true),
(:iwpt, :iwpt!, :_wpt!, false))
@eval begin
function ($Xwt){T<:FloatingPoint}(x::WPTArray{T},
function ($Xwt){T<:AbstractFloat}(x::WPTArray{T},
wt::DiscreteWavelet,
L::Integer=maxtransformlevels(x))
return ($Xwt)(x, wt, maketree(length(x), L, :full))
end
# filter
function ($Xwt){T<:FloatingPoint}(x::WPTArray{T},
function ($Xwt){T<:AbstractFloat}(x::WPTArray{T},
filter::OrthoFilter,
tree::BitVector=maketree(x, :full))
y = Array(T, size(x))
return ($_Xwt!)(y, x, filter, tree, $fw)
end
function ($Xwt!){T<:FloatingPoint}(y::WPTArray{T}, x::WPTArray{T},
function ($Xwt!){T<:AbstractFloat}(y::WPTArray{T}, x::WPTArray{T},
filter::OrthoFilter,
tree::BitVector=maketree(x, :full))
return ($_Xwt!)(y, x, filter, tree, $fw)
end
function ($Xwt!){T<:FloatingPoint}(y::WPTArray{T}, x::WPTArray{T},
function ($Xwt!){T<:AbstractFloat}(y::WPTArray{T}, x::WPTArray{T},
filter::OrthoFilter,
L::Integer=maxtransformlevels(x))
return ($Xwt!)(y, x, filter, maketree(length(x), L, :full))
end
# lifting
function ($Xwt){T<:FloatingPoint}(x::WPTArray{T},
function ($Xwt){T<:AbstractFloat}(x::WPTArray{T},
scheme::GLS,
tree::BitVector=maketree(x, :full))
y = Array(T, size(x))
copy!(y, x)
return ($_Xwt!)(y, scheme, tree, $fw)
end
function ($Xwt!){T<:FloatingPoint}(y::WPTArray{T},
function ($Xwt!){T<:AbstractFloat}(y::WPTArray{T},
scheme::GLS,
tree::BitVector=maketree(y, :full))
return ($_Xwt!)(y, scheme, tree, $fw)
end
function ($Xwt!){T<:FloatingPoint}(y::WPTArray{T},
function ($Xwt!){T<:AbstractFloat}(y::WPTArray{T},
scheme::GLS,
L::Integer=maxtransformlevels(x))
return ($Xwt!)(y, scheme, maketree(length(x), L, :full))
Expand Down Expand Up @@ -177,13 +177,13 @@ end
for (Xwt_oop!, Xwt!) in ((:dwt_oop!, :dwt!), (:idwt_oop!, :idwt!))
@eval begin
# filter
function ($Xwt_oop!){T<:FloatingPoint}(y::DWTArray{T}, x::DWTArray{T},
function ($Xwt_oop!){T<:AbstractFloat}(y::DWTArray{T}, x::DWTArray{T},
filter::OrthoFilter,
L::Integer=maxtransformlevels(x))
return ($Xwt!)(y, x, filter, L)
end
# lifting
function ($Xwt_oop!){T<:FloatingPoint}(y::DWTArray{T}, x::DWTArray{T},
function ($Xwt_oop!){T<:AbstractFloat}(y::DWTArray{T}, x::DWTArray{T},
scheme::GLS,
L::Integer=maxtransformlevels(x))
copy!(y, x)
Expand All @@ -198,7 +198,7 @@ end # for
# or transform each x[:,...,i,:,...] separately at dim td
for (Xwtc, Xwt) in ((:dwtc, :dwt!), (:idwtc, :idwt!))
@eval begin
function $Xwtc{T<:FloatingPoint}(x::AbstractArray{T}, wt::DiscreteWavelet, L::Integer, td::Integer=ndims(x))
function $Xwtc{T<:AbstractFloat}(x::AbstractArray{T}, wt::DiscreteWavelet, L::Integer, td::Integer=ndims(x))
dim = ndims(x)
(1 <= td <= dim) || throw(BoundsError())
sizex = size(x)
Expand Down
26 changes: 13 additions & 13 deletions src/transforms_filter.jl
Expand Up @@ -10,13 +10,13 @@
# DWT
# 1-D
# writes to y
function _dwt!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVector{T},
function _dwt!{T<:AbstractFloat}(y::AbstractVector{T}, x::AbstractVector{T},
filter::OrthoFilter, L::Integer, fw::Bool)
si = Array(T, length(filter)-1) # tmp filter vector
scfilter, dcfilter = WT.makereverseqmfpair(filter, fw, T)
return _dwt!(y, x, filter, L, fw, dcfilter, scfilter, si)
end
function _dwt!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVector{T},
function _dwt!{T<:AbstractFloat}(y::AbstractVector{T}, x::AbstractVector{T},
filter::OrthoFilter, L::Integer, fw::Bool,
dcfilter::Vector{T}, scfilter::Vector{T},
si::Vector{T}, snew::Vector{T} = Array(T, ifelse(L>1, length(x)>>1, 0)))
Expand Down Expand Up @@ -59,7 +59,7 @@ function _dwt!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVector{T},
end
return y
end
function unsafe_dwt1level!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVector{T},
function unsafe_dwt1level!{T<:AbstractFloat}(y::AbstractVector{T}, x::AbstractVector{T},
filter::OrthoFilter, fw::Bool,
dcfilter::Vector{T}, scfilter::Vector{T},
si::Vector{T})
Expand All @@ -82,7 +82,7 @@ function unsafe_dwt1level!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVe
end


function dwt_transform_strided!{T<:FloatingPoint}(y::Array{T}, x::AbstractArray{T},
function dwt_transform_strided!{T<:AbstractFloat}(y::Array{T}, x::AbstractArray{T},
nsub::Int, stride::Int, idx_func::Function,
tmpvec::Vector{T}, tmpvec2::Vector{T},
filter::OrthoFilter, fw::Bool,
Expand All @@ -95,7 +95,7 @@ function dwt_transform_strided!{T<:FloatingPoint}(y::Array{T}, x::AbstractArray{
end
end

function dwt_transform_cols!{T<:FloatingPoint}(y::Array{T}, x::AbstractArray{T},
function dwt_transform_cols!{T<:AbstractFloat}(y::Array{T}, x::AbstractArray{T},
nsub::Int, idx_func::Function,
tmpvec::Vector{T},
filter::OrthoFilter, fw::Bool,
Expand All @@ -110,7 +110,7 @@ end

# 2-D
# writes to y
function _dwt!{T<:FloatingPoint}(y::Matrix{T}, x::AbstractMatrix{T},
function _dwt!{T<:AbstractFloat}(y::Matrix{T}, x::AbstractMatrix{T},
filter::OrthoFilter, L::Integer, fw::Bool)
n = size(x,1)
si = Array(T, length(filter)-1) # tmp filter vector
Expand All @@ -119,7 +119,7 @@ function _dwt!{T<:FloatingPoint}(y::Matrix{T}, x::AbstractMatrix{T},

return _dwt!(y, x, filter, L, fw, dcfilter, scfilter, si, tmpbuffer)
end
function _dwt!{T<:FloatingPoint}(y::Matrix{T}, x::AbstractMatrix{T},
function _dwt!{T<:AbstractFloat}(y::Matrix{T}, x::AbstractMatrix{T},
filter::OrthoFilter, L::Integer, fw::Bool,
dcfilter::Vector{T}, scfilter::Vector{T},
si::Vector{T}, tmpbuffer::Vector{T})
Expand Down Expand Up @@ -186,7 +186,7 @@ end

# 3-D
# writes to y
function _dwt!{T<:FloatingPoint}(y::Array{T, 3}, x::AbstractArray{T, 3},
function _dwt!{T<:AbstractFloat}(y::Array{T, 3}, x::AbstractArray{T, 3},
filter::OrthoFilter, L::Integer, fw::Bool)
n = size(x,1)
si = Array(T, length(filter)-1) # tmp filter vector
Expand All @@ -195,7 +195,7 @@ function _dwt!{T<:FloatingPoint}(y::Array{T, 3}, x::AbstractArray{T, 3},

return _dwt!(y, x, filter, L, fw, dcfilter, scfilter, si, tmpbuffer)
end
function _dwt!{T<:FloatingPoint}(y::Array{T, 3}, x::AbstractArray{T, 3},
function _dwt!{T<:AbstractFloat}(y::Array{T, 3}, x::AbstractArray{T, 3},
filter::OrthoFilter, L::Integer, fw::Bool,
dcfilter::Vector{T}, scfilter::Vector{T},
si::Vector{T}, tmpbuffer::Vector{T})
Expand Down Expand Up @@ -287,15 +287,15 @@ end
# WPT
# 1-D
# writes to y
function _wpt!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVector{T}, filter::OrthoFilter, tree::BitVector, fw::Bool)
function _wpt!{T<:AbstractFloat}(y::AbstractVector{T}, x::AbstractVector{T}, filter::OrthoFilter, tree::BitVector, fw::Bool)
si = Array(T, length(filter)-1)
ns = ifelse(fw, length(x)>>1, length(x))
snew = Array(T, ns)
scfilter, dcfilter = WT.makereverseqmfpair(filter, fw, T)

return _wpt!(y, x, filter, tree, fw, dcfilter, scfilter, si, snew)
end
function _wpt!{T<:FloatingPoint}(y::AbstractVector{T}, x::AbstractVector{T}, filter::OrthoFilter, tree::BitVector, fw::Bool, dcfilter::Vector{T}, scfilter::Vector{T}, si::Vector{T}, snew::Vector{T})
function _wpt!{T<:AbstractFloat}(y::AbstractVector{T}, x::AbstractVector{T}, filter::OrthoFilter, tree::BitVector, fw::Bool, dcfilter::Vector{T}, scfilter::Vector{T}, si::Vector{T}, snew::Vector{T})

size(x) == size(y) ||
throw(DimensionMismatch("in and out array size must match"))
Expand Down Expand Up @@ -373,7 +373,7 @@ end
# x : filter convolved with x[ix:ix+nx-1], where nx=nout*2 (shifted by shift)
# ss : shift downsampling
# based on Base.filt
function filtdown!{T<:FloatingPoint}(f::Vector{T}, si::Vector{T},
function filtdown!{T<:AbstractFloat}(f::Vector{T}, si::Vector{T},
out::AbstractVector{T}, iout::Integer, nout::Integer,
x::AbstractVector{T}, ix::Integer, shift::Integer=0, ss::Bool=false)
nx = nout<<1
Expand Down Expand Up @@ -452,7 +452,7 @@ end
# x : filter convolved with x[ix:ix+nx-1] upsampled, where nout==nx*2 (then shifted by shift)
# ss : shift upsampling
# based on Base.filt
function filtup!{T<:FloatingPoint}(add2out::Bool, f::Vector{T}, si::Vector{T},
function filtup!{T<:AbstractFloat}(add2out::Bool, f::Vector{T}, si::Vector{T},
out::AbstractVector{T}, iout::Integer, nout::Integer,
x::AbstractVector{T}, ix::Integer, shift::Integer=0, ss::Bool=false)
nx = nout>>1
Expand Down

0 comments on commit b79b079

Please sign in to comment.