/*
 *  DSPPAD_RT Helper function for Pad block.
 *
 *  Copyright 1995-2000 The MathWorks, Inc.
 *  $Revision: 1.1 $  $Date: 2000/08/09 01:02:55 $
 */
#include "dsppad_rt.h"


void padRowsColsDD(ArgsCache *args)
{
    const real_T *u = (const real_T *)args->u;
    real_T *y       = (real_T *)args->y;

    /* Copy and pad each column separately */
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < (args->numInpCols); ) {
        register int_T rowIdx;
        for (rowIdx = 0; rowIdx++ < (args->numInpRows); ) {
            *y++ = *u++;
        }
        for (rowIdx = 0; rowIdx++ < (args->opt1.numExtraRows); ) {
            *y++ = args->padValueRe;
        }
    }
    
    /* Pad the rest of the (fully-padded) output columns */
    for (colIdx = 0; colIdx++ < ((args->opt2.numExtraCols) * (args->numOutRows)); ) {
        *y++ = args->padValueRe;
    }
}


void padColsDD(ArgsCache *args)
{
    real_T *u = (real_T *)args->u;
    real_T *y = (real_T *)args->y;

    /* Extra rows (longer output cols) only */
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < (args->numInpCols); ) {
        register int_T rowIdx;
        for (rowIdx = 0; rowIdx++ < (args->numInpRows); ) {
            *y++ = *u++;
        }
        for (rowIdx = 0; rowIdx++ < (args->opt1.numExtraRows); ) {
            *y++ = args->padValueRe;
        }
    }
}


void padRowsDD(ArgsCache *args)
{
    real_T *u = (real_T *)args->u;
    real_T *y = (real_T *)args->y;

    /* Extra cols (longer output rows) only */
    register int_T idx;
    for (idx = 0; idx++ < ((args->numInpCols) * (args->numOutRows)); ) {
        *y++ = *u++;
    }
    for (idx = 0; idx++ < ((args->opt2.numExtraCols) * (args->numOutRows)); ) {
        *y++ = args->padValueRe;
    }
}


void padRowsColsZZ(ArgsCache *args)
{
    creal_T *u = (creal_T *)args->u;
    creal_T *y = (creal_T *)args->y;

    /* Copy and pad each column separately */
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < (args->numInpCols); ) {
        register int_T rowIdx;
        for (rowIdx = 0; rowIdx++ < (args->numInpRows); ) {
            *y++ = *u++;
        }
        for (rowIdx = 0; rowIdx++ < (args->opt1.numExtraRows); ) {
            *y++ = args->padValueCplx;
        }
    }
    
    /* Pad the rest of the (fully-padded) output columns */
    for (colIdx = 0; colIdx++ < ((args->opt2.numExtraCols) * (args->numOutRows)); ) {
        *y++ = args->padValueCplx;
    }
}


void padColsZZ(ArgsCache *args)
{
    creal_T *u = (creal_T *)args->u;
    creal_T *y = (creal_T *)args->y;

    /* Extra rows (longer output cols) only */
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < (args->numInpCols); ) {
        register int_T rowIdx;
        for (rowIdx = 0; rowIdx++ < (args->numInpRows); ) {
            *y++ = *u++;
        }
        for (rowIdx = 0; rowIdx++ < (args->opt1.numExtraRows); ) {
            *y++ = args->padValueCplx;
        }
    }
}


void padRowsZZ(ArgsCache *args)
{
    creal_T *u = (creal_T *)args->u;
    creal_T *y = (creal_T *)args->y;

    /* Extra cols (longer output rows) only */
    register int_T idx;
    for (idx = 0; idx++ < ((args->numInpCols) * (args->numOutRows)); ) {
        *y++ = *u++;
    }
    for (idx = 0; idx++ < ((args->opt2.numExtraCols) * (args->numOutRows)); ) {
        *y++ = args->padValueCplx;
    }
}


void padRowsColsDZ(ArgsCache *args)
{
    real_T  *u = (real_T *)args->u;
    creal_T *y = (creal_T *)args->y;

    /* Copy and pad each column separately */
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < (args->numInpCols); ) {
        register int_T rowIdx;
        for (rowIdx = 0; rowIdx++ < (args->numInpRows); ) {
            y->re = *u++;
            y++->im = 0.0;
        }
        for (rowIdx = 0; rowIdx++ < (args->opt1.numExtraRows); ) {
            *y++ = args->padValueCplx;
        }
    }
    
    /* Pad the rest of the (fully-padded) output columns */
    for (colIdx = 0; colIdx++ < ((args->opt2.numExtraCols) * (args->numOutRows)); ) {
        *y++ = args->padValueCplx;
    }
}


void padColsDZ(ArgsCache *args)
{
    real_T  *u = (real_T *)args->u;
    creal_T *y = (creal_T *)args->y;

    /* Extra rows (longer output cols) only */
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < (args->numInpCols); ) {
        register int_T rowIdx;
        for (rowIdx = 0; rowIdx++ < (args->numInpRows); ) {
            y->re = *u++;
            y++->im = 0.0;
        }
        for (rowIdx = 0; rowIdx++ < (args->opt1.numExtraRows); ) {
            *y++ = args->padValueCplx;
        }
    }
}


void padRowsDZ(ArgsCache *args)
{
    real_T  *u = (real_T *)args->u;
    creal_T *y = (creal_T *)args->y;

    /* Extra cols (longer output rows) only */
    register int_T idx;
    for (idx = 0; idx++ < ((args->numInpCols) * (args->numOutRows)); ) {
        y->re = *u++;
        y++->im = 0.0;
    }
    for (idx = 0; idx++ < ((args->opt2.numExtraCols) * (args->numOutRows)); ) {
        *y++ = args->padValueCplx;
    }
}


void padCopyOnlyTruncateRows(ArgsCache *args)
{
    memcpy((byte_T *)args->y,
           (byte_T *)args->u,
           args->opt1.bytesPerElement * args->opt2.outputWidth);
}


void padCopyOnlyTruncateCols(ArgsCache *args)
{
    byte_T *u              = (byte_T *)args->u;
    byte_T *y              = (byte_T *)args->y;
    const int_T numOutCols = args->numOutCols;
    register int_T colIdx;
    for (colIdx = 0; colIdx++ < numOutCols; ) {
        memcpy(y, u, args->opt2.bytesPerOutCol);
        y += args->opt2.bytesPerOutCol;
        u += args->opt1.bytesPerInpCol;
    }
}

/* [EOF] dsppad_rt.c */
