matrix operator with variable precison

If we don't know about 'em, we can't fix 'em.

matrix operator with variable precison

PostPosted by drab » Mon Sep 18, 2017 6:37 am

The new matrix operator is very cool, but it does not work on numbers with variable precision.

⌹ 2 2⍴1 2 3 5
¯5 2
3 ¯1
÷⌻ 2 2⍴1 2 3 5
¯5 2
3 ¯1

⌹ 2 2⍴1 2 3 5v
¯5 2
3 ¯1
÷⌻ 2 2⍴1 2 3 5v
DOMAIN ERROR
drab
 
Posts: 315
Joined: Thu Oct 09, 2014 6:23 am

Re: matrix operator with variable precison

PostPosted by drab » Mon Sep 18, 2017 6:46 am

It doesn't work with rational numbers either -- which not a surprise.
But maybe a rational argument should be automatically converted.
drab
 
Posts: 315
Joined: Thu Oct 09, 2014 6:23 am

Re: matrix operator with variable precison

PostPosted by forummaster » Mon Sep 18, 2017 7:00 pm

drab wrote:It doesn't work with rational numbers either -- which not a surprise.
But maybe a rational argument should be automatically converted.
This behavior represents the current behavior of the current Alpha release. When I get around to it, I plan to extend the Matrix Operator to support MP numbers, but first I need to find C code which implements calculations of Eigenvalues and Eigenvectors so I can convert it to MP code and thus support MP numbers in the Matrix Operator.
forummaster
 
Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm

Re: matrix operator with variable precison

PostPosted by drab » Tue Sep 19, 2017 6:23 am

Consider these ...

∘⌻ 1 (2 2⍴⍳4)
1 0 0
0 1 2
0 3 4
∘⌻ 1 (3 3↑2 3⍴⍳6)
1 0 0 0
0 1 2 3
0 4 5 6
0 0 0 0

∘⌻ 1 ( 2 3⍴⍳6)
LENGTH ERROR

Why not do an automatic "squaring" of the sub-matrices if necessary, so as to make the last expression work?
drab
 
Posts: 315
Joined: Thu Oct 09, 2014 6:23 am

Re: matrix operator with variable precison

PostPosted by drab » Fri Sep 22, 2017 7:39 am

Just curious ...

Please describe the algorithm this uses.

I tried

F ⌻ 2 2⍴1 2 3 5

where F is a defined function which traces it use.

It called F once with a complex vector argument.

Is it using eigenvectors?
drab
 
Posts: 315
Joined: Thu Oct 09, 2014 6:23 am

Re: matrix operator with variable precison

PostPosted by drab » Fri Sep 22, 2017 7:42 am

Another question ...

Is there already a way to get eigenvectors and eigenvalues?
If so, I missed it.
drab
 
Posts: 315
Joined: Thu Oct 09, 2014 6:23 am

Re: matrix operator with variable precison

PostPosted by forummaster » Sat Sep 23, 2017 2:24 am

drab wrote:Another question ...

Is there already a way to get eigenvectors and eigenvalues?
If so, I missed it.
This is yet another well-hidden documentation which can be found in Eigenvalues and Eigenvectors. The short of it is that

(Eval Evec)←⌹⍠3 M where M is a square matrix. The Magic Function

    ⎕VR'#MatOpr'
∇ Z←{L} (LO #MatOpr) R;Eval Evec T
[1] ⎕PRO:
[2] :if 0=⎕NC 'L' ⋄ L←⊢ ⋄ :endif
[3] (Eval Evec)←⌹⍠3 R
[4] ⎕ERROR ((⍴Eval)≠⍴∪Eval)/'EIGENVALUES NOT DISTINCT'
[5] Z←Evec+.×(∘⌻L LO Eval)+.×⌹Evec

shows how the Matrix Operator works. That is, given Eval andEvec have been calculated from M as above, then

M≡Evec+.×(∘⌻Eval)+.×⌹Evec

which shows the inverse operation to calculating Eval and Evec. The Matrix Operator inserts its left operand into the above expression between ∘⌻ and Eval. For example, the above expression can be expressed as the identity M≡⊢⌻M. Another surprising identity is (⌹M)≡÷⌻M. Squaring a matrix (M+.×M) can be expressed as 2*⍨⌻M. Given the right matrix, you can express various identities such as I≡(2*⍨⌻1○⌻M)+2*⍨⌻2○⌻M where I is the appropriately shaped identity matrix and the values of M are such that both 1>⌈/|⌹⍠1 M and ∧/1>|,M hold. However, even with that restriction, the identity doesn't hold because the off-diagonal elements of the right hand side aren't exactly zero (as they are in the identity matrix I) and so they don't compare because ⎕CT doesn't apply to comparisons against zero. More on fixing that later from an idea I had at the recent Minnowbrook workshop.

The recent paper A Matrix Operator in APL explains a bit more, but it is very preliminary.
Last edited by forummaster on Sat Sep 23, 2017 3:58 pm, edited 1 time in total.
forummaster
 
Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm

Re: matrix operator with variable precison

PostPosted by drab » Sat Sep 23, 2017 3:40 pm

Excellent. Thanks.

But if that's the third function of the new operator, then what are the first two?
drab
 
Posts: 315
Joined: Thu Oct 09, 2014 6:23 am

Re: matrix operator with variable precison

PostPosted by forummaster » Sat Sep 23, 2017 4:04 pm

drab wrote:Excellent. Thanks.

But if that's the third function of the new operator, then what are the first two?

If you are referring to the four flavors of the Variant operator on the Domino function of which the third one (⌹⍠3) returns both Eigenvalues and Eigenvectors, take a look at Eigenvalues and Eigenvectors.
forummaster
 
Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 2 guests

cron