View Raw SPL
/*****************************************************************************
*                                                                            *
*   IDST.SPL     Copyright (C) 2012 DSP Development Corporation              *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Calculates the Inverse Discrete Sine Transform              *
*                                                                            *
*   Revisions:   26 Apr 2012  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/


#if @HELP_IDST

    IDST

    Purpose: Calculates the Inverse Discrete Sine Transform

    Syntax:  IDST(s, n)

              s - input series or array

              n - optional integer, transform length (defaults to length
                  of input)

    Returns: A series or array.

    Example:
             idst(dst(gsin(100, 1/100, 20)))

             returns a 20 Hz cosine wave.

    Remarks:
             The transform is applied to each column if the input is an
             array.

    See Also:
             Dct
             Dst
             Fft
             Idct
             Ifft
#endif


/* inverse discrete sine transform */
ITERATE idst(b, n)
{
        local a;

        if (argc < 2)
        {
                if (argc < 1) error("idst - input series required");

                n = length(b);
        }

        a = 2 * dst(b, n) / (n + 1);

        /* set correct deltax */
        setdeltax(a, 1 / (2 * n * deltax(b)));

        return(a);
}