HP Forums

Full Version: (49g 50g) Narayana Transform
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
Reference URL's