error in "xtimes" dfun in dfns.dyalog.com (Complex.numbers)

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...
Post Reply
Stu
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

error in "xtimes" dfun in dfns.dyalog.com (Complex.numbers)

Post by Stu »

Has anyone tried using "xtimes"? The code is extremely compact and aesthetically pleasing, but the examples given produce this error:

RANK ERROR: Invalid axis
floop[0] floop←{(⊣/⍺)∇⍣(×m)⊢(+⌿⍵),[m-0.5]⍺×[⍳m←≢⍴⍺]-⌿⍵}

Did anyone encounter this, and, if so, were you able to fix it?
JohnS|Dyalog

Re: error in "xtimes" dfun in dfns.dyalog.com (Complex.numbe

Post by JohnS|Dyalog »

Hi Stu,
Which example goes wrong?
You can see more examples in the test script: http://dfns.dyalog.com/s_xtimes.htm
John
Stu
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: error in "xtimes" dfun in dfns.dyalog.com (Complex.numbe

Post by Stu »

I tried this example because I was mainly interested in just the FFT and iFFT:
x
9 3 5 8 1 0 5
y
6 2 3 7 4

iFFT (FFT 16↑x) × (FFT 16↑y)
54J¯9.32587E¯15 36J¯3.51108E¯15 63J¯6.38378E¯15 ...

floop seems to be the problem. I assumed I could take the definitions of FFT and iFFT out of the definition of xtimes and use them independently.
JohnS|Dyalog

Re: error in "xtimes" dfun in dfns.dyalog.com (Complex.numbe

Post by JohnS|Dyalog »

I think the code is assuming an index origin of 0. Try:
      ⎕IO ← 0
Stu
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: error in "xtimes" dfun in dfns.dyalog.com (Complex.numbe

Post by Stu »

⎕IO←0 did the trick, so now I can use FFT and iFFT. Cool!

I tried a couple of examples from the webpage you sent me to. I get "VALUE ERROR" on the final expression here:

x←¯50+?23⍴100
y←¯50+?17⍴100
(¯1+(⍴x)+⍴y)≡⍴x rconvolve y ⍝ OK
(x rconvolve y)≡x rconvolve⍨y ⍝ OK
(x convolve y)≡⌊0.5+9○x rconvolve y ⍝ PRODUCES VALUE ERROR
JohnS|Dyalog

Re: error in "xtimes" dfun in dfns.dyalog.com (Complex.numbe

Post by JohnS|Dyalog »

I can't see anything wrong with your last line - and if I copy/paste it into my session, it works. Could you copy the output from a whole session, from starting up Dyalog - to getting the VALUE ERROR into an email please and send it to support at dyalog dot com? A bit like this:

      Dyalog APL/W Version 15.0.27638
Serial No : 000000
Unicode Edition
Thu Jul 7 10:13:52 2016
clear ws
)load dfns
C:\15.0.dss\svn\misc\ws\unicode\dfns.dws saved Wed Jul 6 17:51:28 2016

An assortment of D Functions and Operators (unicode).

tree # ⍝ Workspace map.
↑¯10↑↓attrib ⎕nl 3 4 ⍝ What's new?
⍕notes find 'Word' ⍝ Apropos "Word".
⎕ed'notes.contents' ⍝ Workspace overview.

⎕io←0
roots ← {×\1,1↓(⍵÷2)⍴¯1*2÷⍵}
cube ← {⍵⍴⍨2⍴⍨2⍟⍴⍵}
extend ← {(2*⌈2⍟¯1+(⍴⍺)+⍴⍵)↑¨⍺ ⍵}
floop ← {(⊣/⍺)∇⍣(×m)⊢(+⌿⍵),[m-0.5]⍺×[⍳m←≢⍴⍺]-⌿⍵}
FFT ← { ,(cube roots ⍴⍵)floop cube ⍵}
iFFT ← {(⍴⍵)÷⍨,(cube +roots ⍴⍵)floop cube ⍵}
⍝ ... etc
Stu
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: error in "xtimes" dfun in dfns.dyalog.com (Complex.numbe

Post by Stu »

I tried again, this time in a clean workspace. It works fine. I don't know why that last expression wouldn't work in my original workspace. Sorry for the trouble!
Post Reply