%% $Revision: 1.8 $ %% $RCSfile: scumsum.tlc,v $ %% $Date: 2000/06/15 20:37:38 $ %% %% Copyright 1995-2000 The MathWorks, Inc. %% %% Abstract: Target file for the S-Function scumsum.c %% %implements "scumsum" "C" %% Function: Outputs ========================================================== %% %% Compute cumulative sum of input elements %% %function Outputs(block, system) Output /* DSP Blockset Cumulative Sum (%) - % */ %% %assign INPORT = 0 %assign OUTPORT = 0 %assign c0 = LibBlockOutputSignalIsComplex(OUTPORT) %assign inplace = (LibBlockInputSignalBufferDstPort(INPORT) == OUTPORT) %assign N = LibDataInputPortWidth(INPORT) %% %if N==1 /* Scalar input - no code required */ %% %elseif(inplace) %if !c0 /* Real in-place algorithm: */ { real_T *y = %; real_T *yprev = y++; /* Skip over first element */ int_T width = %; while(--width > 0) { *y++ += *yprev++; } } %else { creal_T *y = %; creal_T *yprev = y++; /* Skip over first element */ int_T width = %; while(--width > 0) { y->re += yprev->re; (y++)->im += (yprev++)->im; } } %endif %else %if !c0 { %% real_T *y = %; real_T *yprev = y; *y++ = %; %% %assign rollRegions1 = LibClipRollRegions(RollRegions, 2, -1) %assign rollVars = ["U"] %roll sigIdx = rollRegions1, lcv = RollThreshold, block, ... "Roller", rollVars *y++ = *yprev++ + %; %endroll } %else { creal_T *y = %; creal_T *yprev = y; *y++ = %; %% %assign rollRegions1 = LibClipRollRegions(RollRegions, 2, -1) %assign rollVars = ["U"] %roll sigIdx = rollRegions1, lcv = RollThreshold, block, ... "Roller", rollVars %assign ur = LibBlockInputSignal(INPORT, "", lcv, "%%") %assign ui = LibBlockInputSignal(INPORT, "", lcv, "%%") y->re = yprev->re + %; (y++)->im = (yprev++)->im + %; %endroll } %endif %endif %endfunction %% Outputs %% EOF: scumsum.tlc