%% $Revision: 1.8 $ %% $RCSfile: sdspconv.tlc,v $ %% $Date: 1999/03/24 14:53:41 $ %% %% J. Faneuff, April 22, 1998 %% Copyright (c) 1995-1999 The MathWorks, Inc. All Rights Reserved. %% %% Abstract: Target file for the S-Function sdsp2norm.c %% %implements "sdspconv" "C" %% Function: Outputs ========================================================== %% %% Abstract: %% %function Outputs(block, system) Output /* DSP Blockset Convolution (%) - % */ %% %assign INPORT0 = 0 %assign INPORT1 = 1 %assign OUTPORT = 0 %assign M = LibDataInputPortWidth(INPORT0) %assign N = LibDataInputPortWidth(INPORT1) %assign L = LibDataOutputPortWidth(OUTPORT) %assign c0 = LibBlockInputSignalIsComplex(INPORT0) %assign c1 = LibBlockInputSignalIsComplex(INPORT1) %assign contig0 = IsInputPortContiguous(block,INPORT0) %assign contig1 = IsInputPortContiguous(block,INPORT1) %% %if !contig0 || !contig1 % %endif %% %if !c0 && !c1 %% Both ports are real: { real_T *u0 = %; real_T *u1 = %; real_T *y = %; int_T i; for (i = 0; i < %; i++) { const int_T j_end = MIN(i, %); real_T sum = 0.0; int_T j; for (j = MAX(0, i-%); j <= j_end; j++) { sum += u0[j] * u1[i-j]; } *y++ = sum; } } %% %elseif c0 && c1 %% %% Both ports are complex: { creal_T *u0 = %; creal_T *u1 = %; creal_T *y = %; int_T i; for (i = 0; i < %; i++) { const int_T j_end = MIN(i, %); creal_T sum = {0.0, 0.0}; int_T j; for (j = MAX(0, i-%); j <= j_end; j++) { const creal_T val0 = u0[j]; const creal_T val1 = u1[i-j]; sum.re += CMULT_RE(val0, val1); sum.im += CMULT_IM(val0, val1); } *y++ = sum; } } %else { %% Mixed case (one port is complex, the other port is real) %% %% Two possible cases here: %% if c0 -> First port complex, second port real %% if c1 -> First port real, second port complex %% %% uptr0 will always point to the complex input %% uptr1 will always point to the real input %% %if c0 creal_T *u0 = %; real_T *u1 = %; %assign MM = M %assign NN = N %else creal_T *u0 = %; real_T *u1 = %; %assign MM = N %assign NN = M %endif %% creal_T *y = %; int_T i; for (i = 0; i < %; i++) { const int_T j_end = MIN(i, %); creal_T sum = {0.0, 0.0}; int_T j; for (j = MAX(0, i-%); j <= j_end; j++) { const creal_T *uu0 = u0+j; const real_T uv1 = u1[i-j]; sum.re += uu0->re * uv1; sum.im += uu0->im * uv1; } *y++ = sum; } } %endif %endfunction %% Outputs %% EOF: sdspconv.tlc