Perhaps I'm completely wrong, but did you mean
        even =.(<<oddkey){y
or should that be 
        even =.(<<<oddkey){y
?

And, much more important, shouldn't 
        s1 =.even+(C2*.d1)+C3*_1|.d1
be
        s1 =.even+(C2*d1)+C3*_1|.d1
?

Especially the last change has quite some impact:

   ts'D4_Transform d'[d=:(2^12)[EMAIL PROTECTED]                NB. with 
+(C2*.d1)+
0.11440561 394752
   ts'D4_Transform d'[d=:(2^14)[EMAIL PROTECTED]
0.4459374 1527808

versus

   ts'D4_Transform d'[d=:(2^12)[EMAIL PROTECTED]                NB. with 
+(C2*d1)+
0.0013655373 394752
   ts'D4_Transform d'[d=:(2^14)[EMAIL PROTECTED]
0.0041350176 1528192


R.E. Boss



-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Xu Zuoqian
Verzonden: vrijdag 22 december 2006 10:31
Aan: [email protected]
Onderwerp: [Jprogramming] J vs Matlab vs NumPy for speed by wavelet
computing

Just read a post(
http://mail.python.org/pipermail/python-list/2006-November/414270.html),whic
hcompare
the speed of matlab and numpy for wavelet
computing.On my machine(P4 2.8G,Debian sid)the results are:matlab --
26.268899 seconds,numpy -- 1.72 seconds.
I translate the code to J as:

D4_Transform=:3 :0
NB. D4 Wavelet transform in Matlab
NB. (C) Sturla Molden
C1 =.  1.7320508075688772
C2 =.  0.4330127018922193
C3 =. -0.066987298107780702
C4 =.  0.51763809020504137
C5 =.  1.9318516525781364
n=.>.-:#y

r =. (#y)$0
oddkey=.2*i.n
odd =.oddkey{y
even =.(<<oddkey){y

d1 =. odd - C2*even
s1 =.even+(C2*.d1)+C3*_1|.d1
d2=.d1+_1|.s1

if.2<#y do.
r=.(D4_Transform odd) oddkey}r
else.
r=.(C4*s1)oddkey}r
end.
r=.(C5*d2)(<<oddkey)}r
r
)

And the timing is:
  d=.?(2^23)$0
  ts 'D4_Transform d'
150.59277 7.718007e8

How to improve?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to