bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Matrix Permanents: Episode 1


From: Juergen Sauermann
Subject: Re: [Bug-apl] Matrix Permanents: Episode 1
Date: Sat, 29 Aug 2015 18:04:19 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hi Mike,

thanks, fixed in SVN 669.

/// Jürgen


On 08/26/2015 05:14 AM, Mike Duvos wrote:
Here's a simple little recursive function to compute matrix permanents. 

    ∇
[0]   Z←PERM X;⎕IO;N
[1]   Z←1 ⋄ ⎕IO←0
[2]   →(0=⍴N←⍳↑⍴X)/0
[3]   Z←+/X[0;]×PERM¨N {⍵[N~0;N~⍺]}¨⊂X
    ∇

       ⎕←A←10 10⍴11↑1
1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1

      PERM A

[I get tired of waiting, and hit ATTENTION]

^CATTENTION
PERM[1]  ⎕IO←0
         ^
      )si
PERM[1]
PERM[3]
PERM[3]
PERM[3]
PERM[3]
PERM[3]
PERM[3]
PERM[3]
PERM[3]
PERM[3]
PERM[3]



      )reset
VALUE ERROR
PERM[1]  ⎕IO←0
         ^

      )reset
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
            →
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
[Isn't reset supposed to clear the whole state indicator, and not just pop one function call at a time off it?]

      )load perm
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
[I don't understand this at all]

      )clear
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
[nor this]

       →
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
      →
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
      →
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
      →
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
      )si
PERM[3]
PERM[3]
PERM[3]


     
[almost there]

      )reset
VALUE ERROR
PERM[3]  Z←+/X[0;]×PERM¨N λ1¨⊂X
                   ^
      )reset
     
      )si
     
[finally]

      PERM 3 3⍴⍳9
ATTENTION
PERM[1]  ⎕IO←0
         ^

[I didn't hit attention this time.  It apparently remembered the last attention.]

      PERM 3 3⍴1 2 3 4 5 6 7 8 9
450
     
[Which is the correct answer, on a smaller matrix that takes less time.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]