/* 
 * dsp_ic_rt.c
 *
 *  Author:  R. Firtion
 *  Copyright (c) 1995-2000 The MathWorks, Inc.
 *  $Revision: 1.5 $  $Date: 2000/03/31 19:33:31 $
 *
 * Abstract:
 *   Copy functions for the initial condition handler.
 */

#include "dsp_ic_rt.h"
#include "string.h"    /* For memcpy, etc */

void Copy3DSampleMatrixICsRealToReal(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
	for (j=0; j < args->dWorkRows-1; j++ ) {
            /* args->dataPortWidth == input data port width */
	    memcpy(buffer, prIC +j*args->bytesPerRealElement*args->dataPortWidth, args->bytesPerRealElement);
	    buffer += args->bytesPerRealElement; 
	}
        buffer += args->bytesPerRealElement;
	prIC += args->bytesPerRealElement;
    }
}

void Copy3DSampleMatrixICsRealToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j < args->dWorkRows-1; j++ ) {
            memcpy(buffer, prIC +j*args->bytesPerRealElement*args->dataPortWidth, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement; 

            memset(buffer, 0, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement;
        }
        buffer += 2*args->bytesPerRealElement;
        prIC += args->bytesPerRealElement;
    }
}

void Copy3DSampleMatrixICsComplexToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    const byte_T *piIC   = args->piIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j < args->dWorkRows-1; j++ ) {
            memcpy(buffer, prIC +j*args->bytesPerRealElement*args->dataPortWidth, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement; 

            memcpy(buffer, piIC + j*args->bytesPerRealElement*args->dataPortWidth, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;
        }
        buffer += 2*args->bytesPerRealElement;
        prIC += args->bytesPerRealElement;
        piIC += args->bytesPerRealElement;
    }
}

void Copy3DFrameMatrixICsRealToReal(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
	for (j=0; j < args->dWorkRows-1; j++ ) {
	    memcpy(buffer, prIC + j*args->bytesPerRealElement*args->nChans, args->bytesPerRealElement);
	    buffer += args->bytesPerRealElement; 
        }
        buffer += args->bytesPerRealElement; 
	prIC += args->bytesPerRealElement;
    }
}

void Copy3DFrameMatrixICsRealToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j < args->dWorkRows-1; j++ ) {
            memcpy(buffer, prIC + j*args->bytesPerRealElement*args->nChans, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement; 

            memset(buffer, 0, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement;
        }
        buffer += 2*args->bytesPerRealElement; 
        prIC += args->bytesPerRealElement;
    }
}

void Copy3DFrameMatrixICsComplexToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    const byte_T *piIC   = args->piIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j < args->dWorkRows-1; j++ ) {
            memcpy(buffer, prIC + j*args->bytesPerRealElement*args->nChans, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement; 

            memcpy(buffer, piIC + j*args->bytesPerRealElement*args->nChans, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;
        }
        buffer += 2*args->bytesPerRealElement; 
        prIC += args->bytesPerRealElement;
        piIC += args->bytesPerRealElement;
    }
}

void CopyVectorICsRealToReal(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j++ < args->dWorkRows-1; ) {
	    memcpy(buffer, prIC, args->bytesPerRealElement);                    
	    buffer += args->bytesPerRealElement; 
            prIC += args->bytesPerRealElement;
        }  
	buffer += args->bytesPerRealElement;         
        prIC -= (args->dWorkRows-1)*args->bytesPerRealElement;
    }
}

void CopyVectorICsRealToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j++ < args->dWorkRows-1; ) {
            memcpy(buffer, prIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;
            prIC += args->bytesPerRealElement;

            memset(buffer, 0, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement;
        }
        buffer += 2*args->bytesPerRealElement;
        prIC -= (args->dWorkRows-1)*args->bytesPerRealElement;
    }
}
    
void CopyVectorICsComplexToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    const byte_T *piIC   = args->piIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0;j < args->dWorkRows-1; j++) {
            memcpy(buffer, prIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;
            prIC += args->bytesPerRealElement;

            memcpy(buffer, piIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;
            piIC += args->bytesPerRealElement;
        }
        buffer += 2*args->bytesPerRealElement;

        prIC -= (args->dWorkRows-1)*args->bytesPerRealElement;
        piIC -= (args->dWorkRows-1)*args->bytesPerRealElement;
   }
}
   
void CopyScalarICsRealToReal(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0;j++ < args->dWorkRows; ) {
            if (args->prIC == NULL) memset(buffer, 0, args->bytesPerRealElement);
            else memcpy(buffer, prIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement; 
        }
    }
}

void CopyScalarICsRealToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j++ < args->dWorkRows; ) {
            if (args->prIC == NULL) memset(buffer, 0, args->bytesPerRealElement);
            else memcpy(buffer, prIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;

            memset(buffer, 0, args->bytesPerRealElement);                    
            buffer += args->bytesPerRealElement;
        }
    }
}
    
void CopyScalarICsComplexToComplex(const TMWDSP_CopyICsFcnArgs *args)
{
    const byte_T *prIC   = args->prIC;
    const byte_T *piIC   = args->piIC;
    byte_T       *buffer = args->buffer;
    int_T         i;

    for (i=0; i++ < args->nChans; ) {
        int_T j;
        for (j=0; j++ < args->dWorkRows; ) {
            memcpy(buffer, prIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;

            memcpy(buffer, piIC, args->bytesPerRealElement);
            buffer += args->bytesPerRealElement;
        }
    }
}

/* [EOF] dsp_ic_rt.c */
