Post Reply 
(49g 50g) Narayana Transform
01-22-2020, 10:48 PM
Post: #1
(49g 50g) Narayana Transform
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.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)