Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon06.news.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail
From: "Filip Wasilewski" <filipwasilewski@gmail.com>
Newsgroups: comp.soft-sys.matlab,comp.lang.python
Subject: Re: About alternatives to Matlab
Date: 19 Nov 2006 12:33:27 -0800
Organization: http://groups.google.com
Lines: 45
Message-ID: <1163968407.464913.196640@k70g2000cwa.googlegroups.com>
References: <1161613941.550194.204870@e3g2000cwe.googlegroups.com>
NNTP-Posting-Host: 83.26.227.121
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1163968412 7815 127.0.0.1 (19 Nov 2006 20:33:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 19 Nov 2006 20:33:32 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: k70g2000cwa.googlegroups.com; posting-host=83.26.227.121;
Xref: news.mathworks.com comp.soft-sys.matlab:379473 comp.lang.python:437570


sturlamolden wrote:
>
> Actually, there was a typo in the original code. I used d1[l-1] where I
> should have used d1[l+1]. Arrgh. Here is the corrected version, the
> Matlab code must be changed similarly. It has no relevance for the
> performance timings though.
>
>
> def D4_Transform(x, s1=None, d1=None, d2=None):
>     """
>     D4 Wavelet transform in NumPy
>     (C) Sturla Molden
>     """
>     C1 = 1.7320508075688772
>     C2 = 0.4330127018922193
>     C3 = -0.066987298107780702
>     C4 = 0.51763809020504137
>     C5 = 1.9318516525781364
>     if d1 == None:
>        d1 = numpy.zeros(x.size/2)
>        s1 = numpy.zeros(x.size/2)
>        d2 = numpy.zeros(x.size/2)
>     odd = x[1::2]
>     even = x[:-1:2]
>     d1[:] = odd[:] - C1*even[:]
>     s1[:-1] = even[:-1] + C2*d1[:-1] + C3*d1[1:]
>     s1[-1] = even[-1] + C2*d1[-1] + C3*d1[0]
>     d2[0] = d1[0] + s1[-1]
>     d2[1:] = d1[1:] + s1[:-1]
>     even[:] = C4 * s1[:]
>     odd[:] = C5 * d2[:]

If you swap C4 with C5 then our solutions give identical results and
both match the classic dwt approach:

    even[:] = C5 * s1[:]
    odd[:] = C4 * d2[:]

>     if x.size > 2:
>     D4_Transform(even,s1[0:even.size/2],
>             d1[0:even.size/2],d2[0:even.size/2])

cheers,
fw