2

I have been porting old APL*PLUS PC functions that run on DOS to Dyalog and have had great success. But one function runs fine on APL*PLUS PC but gave me a DOMAIN ERROR on Dyalog. I traced the problem to a matrix invertion using ⌹.

Here is an example of what I am seeing:

      F←6.91E9 5.655E9
      I←¯0.0144722 ¯0.01897385

      Z←I⌹2 2⍴F[1],(÷-F[1]),F[2],÷-F[2]
DOMAIN ERROR
      Z←I⌹2 2⍴F[1],(÷-F[1]),F[2],÷-F[2]
         ∧

This error was also observed on GNU_64 APL.

I created my own DIVIDE function to work with 2x2 arrays:

 Z←I2 DIVIDE M22;A;B;C;D
 A←M22[1;1] ⋄ B←M22[1;2] ⋄ C←M22[2;1] ⋄ D←M22[2;2]
 Z←÷(A×D)-B×C
 Z←Z×(2 2)⍴D,(-B),(-C),A
 Z←Z+.×I2
      Z←I DIVIDE 2 2⍴F[1],(÷-F[1]),F[2],÷-F[2]
      Z
4.625648461E¯13 122089494.5

Check answer:

    (2 2⍴F[1],(÷-F[1]),F[2],÷-F[2])+.×Z
¯0.0144722 ¯0.01897385

DIVIDE gives the correct answer

Adám
  • 6,573
  • 20
  • 37
MLS
  • 41
  • 1

0 Answers0