Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
pawbz committed Apr 3, 2018
1 parent 69cee25 commit 84302bc
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 107 deletions.
2 changes: 2 additions & 0 deletions src/Conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This module is used in DeConv, ConvMix and Coupling
"""
module Conv

using DSP

"""
Model : d = convolution(gf, wav)
d, gf and wav can have arbitary +ve and -ve lags
Expand Down
105 changes: 0 additions & 105 deletions test/Conv.jl

This file was deleted.

104 changes: 102 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,105 @@
using Revise
using Conv
using Base.Test

# write your own tests here
@test 1 == 2
np=1000
n=777
n2=100
x = randn(n,n2); xa = similar(x)
z = zeros(np,n2);

# cover all lags for serial mode
@time for i in [0, 2, 4, n-1]
Conv.pad_truncate!(x, z, n-i-1,i,np,1)
Conv.pad_truncate!(xa, z, n-i-1,i,np,-1)
@test x xa
end

np=1000
n=777
x = randn(n); xa = similar(x)
z = zeros(np);
@time for i in [0, 2, 4, n-1]
Conv.pad_truncate!(x, z, n-i-1,i,np,1)
Conv.pad_truncate!(xa, z, n-i-1,i,np,-1)
@test x xa
end


# fast_filt
# note that this test works for only some delta functions
for nw in [7, 8], nr in [20, 10], ns in [11, 10]

r = zeros(nr); w = zeros(nw); s = zeros(ns);
ra = similar(r); wa = similar(w); sa = similar(s);

r[5]=1.; w[3]=1.;

Conv.mod!(s,r,w,:d)
Conv.mod!(s,r,wa,:wav)
@test w wa

Conv.mod!(s,ra,w,:gf)
@test ra r

Conv.mod!(sa,ra,wa,:d)
@test sa s
end



## dot product test for fast filt

function filt_loop(func, n2; )
nwvec=[101, 100]
nrvec=[1000, 1001]
nsvec=[1500, 901]
np2=2024;
for nw in nwvec, nr in nrvec, ns in nsvec

r=randn(nr, n2...)
s=randn(ns, n2...)
w=randn(nw, n2...)
func(s,r,w,:d)

sa=randn(ns, n2...);
ra=similar(r)
func(sa,ra,w,:gf)

# dot product test
@test dot(s, sa) dot(ra, r)

r=randn(nr, n2...)
s=randn(ns, n2...)
w=zeros(nw, n2...)
func(s,r,w,:wav)


wa=randn(nw, n2...);
ra=similar(r);
func(s,ra,wa,:gf)

# dot product test
@test dot(r, ra) dot(wa, w)
end
end

n2=128
@time filt_loop(Conv.mod!, n2)
@time filt_loop(Conv.mod!, n2)


using BenchmarkTools
# check if mod! will not have any allocations
n=10000
nr=1
println("====================")
s=randn(n,nr)
r=randn(n,nr)
w=randn(n,nr)
pa=Conv.Param(d=s,gf=r,wav=w, ntgf=n, ntd=n, ntwav=n);

@btime Conv.mod!(pa, :d);
@btime Conv.mod!(pa, :d, d=s, gf=r);
@btime Conv.mod!(pa, :gf);
@btime Conv.mod!(pa, :wav);

0 comments on commit 84302bc

Please sign in to comment.