/*
 *  DSPWINDOW2_RT Helper function for window block.
 *
 *  Copyright (c) 1995-2000 The MathWorks, Inc.
 *  $Revision: 1.1 $  $Date: 2000/07/18 21:40:05 $
 */

#include "dspwindow2_rt.h"

/* NFZ: Non-frame, complex doubles */
void dspwindow2_Apply_NFZ(ArgsCache *args)
{
	real_T *w   = args->winPtr;
	creal_T *u  = (creal_T *)args->inPtr;
	creal_T *y  = (creal_T *)args->outPtr;
	register int_T i = args->nRows;
	while(i-- > 0) {
		register real_T windowSample = *w++;
        y->re     = u->re     * windowSample;
        (y++)->im = (u++)->im * windowSample;
	}
}

void dspwindow2_Apply_NFD(ArgsCache *args)
{
	real_T *w   = args->winPtr;
	 
	/* Real input and output */
    const real_T *u = (real_T *)args->inPtr;
    real_T *y =  (real_T *)args->outPtr; /* apply port */

    /* Since input is a vector, orientation is N/A */
    register int_T i = args->nRows;
    while(i-- > 0) {
		*y++ = (*u++) * (*w++);
	}
}

void dspwindow2_Apply_FZ(ArgsCache *args)
{
	/* ----------------------------------------------------------- */
    /* MULTI-CHANNEL CASE: Input is either FRAME-BASED or is FULL  */
    /* MATRIX and treated as frame-based (but not a 2-D vector).   */
    /* ----------------------------------------------------------- */
    const int_T windowWidth = args->nRows; /* num rows */
    int_T       nchans      = args->nChans; /* num cols */
   
	/* Complex input and output */
    creal_T *u = (creal_T *)args->inPtr;
    creal_T *y = (creal_T *)args->outPtr; /* apply port */
            
    while(nchans-- > 0) {
		real_T *w = args->winPtr;
        register int_T i = windowWidth;
        while(i-- > 0) {
			register real_T windowSample = *w++;
            y->re     = u->re     * windowSample;
            (y++)->im = (u++)->im * windowSample;
		}
	}
}

void dspwindow2_Apply_FD(ArgsCache *args)
{
	const int_T windowWidth = args->nRows; /* num rows */
    int_T       nchans      = args->nChans; /* num cols */
	
	/* Real input and output */
    const real_T *u = (real_T *)args->inPtr;
    real_T *y = (real_T *)args->outPtr; /* apply port */
	
	while(nchans-- > 0) {
		real_T *w = args->winPtr;
        register int_T i = windowWidth;
        while(i-- > 0) {
			*y++ = (*u++) * (*w++);
        }
	}
}

/* [EOF] dspwindow2_rt.c */
