%%HP: T(3)F(.);
@ by Ted A Smith
DIR
  Eigen
    \<< DUP IDN SWAP
        DUP SIZE 1 GET \-> d
      \<<
        DO OVER
          SWAP 1 d 1 -
          FOR i i 1 + d
            FOR j
              DUP { j j } GET OVER { i i } GET -
              OVER { i j } GET 3 PICK { j i } GET +
              IF DUP
              THEN
                /
                IF DUP
                THEN
                  DUP SIGN SWAP ABS DUP SQ 1 + \v/ + /
                ELSE
                  DROP 1
                END
                DUP SQ 1 + \v/ INV SWAP OVER * DUP NEG 4 PICK IDN
                { j i } ROT PUT { i j } ROT PUT { i i }
                3 PICK PUT { j j } ROT PUT
                ROT OVER * OVER TRN 4 ROLL * ROT *
              ELSE
                DROP2
              END
            NEXT
          NEXT
        UNTIL
          ROT 3 PICK SAME
        END 1 d
        FOR i 1 d
          FOR j
            IF i j SAME NOT
            THEN
              { i j } 0 PUT
            END
          NEXT
        NEXT
      \>>
    \>>
  EFun
    \<< \-> f
      \<< Eigen 1 OVER SIZE 1 GET
        FOR i
          { i i } DUP2 GET f EVAL PUT
        NEXT
        OVER TRN * *
      \>>
    \>>
  EClr
    \<< DUP SIZE 1 GET \-> d
      \<< 1 d
        FOR i 1 d
          FOR j
            IF i j SAME NOT
            THEN
              { i j } 0 PUT
            END
          NEXT
        NEXT
      \>>
    \>>
END
