HP Forums
(49g 50g) Narayana Transform - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49g 50g) Narayana Transform (/thread-14401.html)



(49g 50g) Narayana Transform - John Keith - 01-22-2020 10:48 PM

This program computes the Narayana transform of a list of integers. The Narayana transform is a variation of the binomial transform. Examples can be found by searching for "narayana transform" on http://oeis.org/.

This program employs an updated version of the ConvOffs transform explained in this post.

Code:

\<< DUP SIZE \-> n
  \<< DUP 1. 2. SUB EVAL OVER + ROT n 1. - R\->I LSEQ :: + Scanl1 3. n
    FOR k 1 OVER 1. k 1. - SUB DUP REV 2.
      \<< PICK3 * SWAP /
      \>> DOLIST + PICK3 1. k SUB * \GSLIST UNROT
    NEXT DROP2 n \->LIST
  \>>
\>>

Next, the inverse Narayana transform:

Code:

\<< DUP SIZE \-> b n
  \<< b 1. 2. SUB EVAL OVER - 2 2 n 1. -
R\->I LASEQ 0 :: + Scanl { -1 1 } 3. n
    FOR k OVER k GET * OVER 2. k SUB / DUP \GSLIST
NEG SWAP + DUP b 1. k SUB * \GSLIST UNROT
    NEXT DROP2 n \->LIST
  \>>
\>>

Both programs require the ListExt and GoferLists libraries.