%% $RCSfile: sdspdiff2.tlc,v $ %% $Revision: 1.9 $ $Date: 2000/08/15 22:34:53 $ %% %% Copyright 1995-2000 The MathWorks, Inc. %% %% Abstract: Element-to-element difference along a vector %implements sdspdiff2 "C" %% Function: BlockInstanceSetup =============================================== %% %function BlockInstanceSetup(block, system) void %assign INPORT = 0 %assign OUTPORT = 0 %% %assign inDims = LibBlockInputSignalDimensions(INPORT) %assign inRows = inDims[0] %% %assign numDims = LibBlockOutputSignalNumDimensions(OUTPORT) %assign outDims = LibBlockOutputSignalDimensions(OUTPORT) %assign outCols = (numDims == 2) ? outDims[1] : 1 %assign outRows = outDims[0] %% %assign cmplx = LibBlockOutputSignalIsComplex(OUTPORT) %assign DType = cmplx ? "creal_T" : "real_T" %% %assign direction = SFcnParamSettings.Direction %assign ColumnDiff = (direction == 2) && (numDims==2) %assign framebased = LibBlockInputSignalIsFrameData(INPORT) %assign frameColRunningMode = (framebased && ColumnDiff) %% %assign block = block + INPORT + OUTPORT + numDims + ... outCols + outRows + inRows + cmplx + ... DType + frameColRunningMode + ColumnDiff %endfunction %% BlockInstanceSetup %% Function: Start ============================================================= %% Abstract: %% %function Start(block, system) Output %if !LibIsEqual(TID, "constant") %if frameColRunningMode { /* For the first step the previous input equals ZERO */ % *prev = %; %if (% > 1) const int_T outCols = %; int_T c; for(c=0; c++re = 0; prev++->im = 0; %endif } %else %if !cmplx *prev = 0; %else prev->re = 0; prev->im = 0; %endif %endif } %endif %endif %endfunction %% Start %% Function: Outputs ========================================================== %% %function Outputs(block, system) Output /* DSP Blockset Difference (%) - % */ { %if numDims == 1 /* Difference along vector */ % \ %elseif frameColRunningMode /* Framebased running difference */ % \ %elseif ColumnDiff /* Difference along columns */ % \ %else /* Difference along rows */ % \ %endif } %endfunction %% Outputs %% Function: DiffFrame ========================================= %% %function DiffFrame() Output % *prev = %; % *y = %; % *u = %; % *v = u+1; /* next */ const int_T outRows = %; const int_T outCols = %; int_T c; for(c=0; c++re = u->re - prev->re; y++->im = u->im - prev->im; %endif %% for(r=1; r++re = v->re - u->re; y++->im = v++->im - u++->im; %endif } *prev++ = *u++; /* Save last sample in frame */ v++; /* Skip first sample of next frame */ } %endfunction %% Function: DiffCol ========================================================== %% %function DiffCol() Output %if outCols > 1 % *y = %; % *u = %; % *v = u+1; int_T outRows = %; int_T outCols = %; int_T c; for(c=0; c++re = v->re - u->re; (y++)->im = (v++)->im - (u++)->im; %else *y++ = *v++ - *u++; %endif } u++; v++; /* top of next input column */ } %else % \ %endif %endfunction %% DiffCol %% Function: DiffRow ========================================================== %% %function DiffRow() Output %if outRows > 1 % *y = %; % *u = %; int_T inRows = %; int_T outCols = %; int_T outRows = %; int_T r; for(r=0; r \ %endif %endfunction %% DiffRow %% Function: DiffVector ========================================================== %% %function DiffVector(outWidth) Output % *y = %; % *u = %; % *v = u+1; int_T outWidth = %; while(outWidth-- > 0) { %if cmplx y->re = v->re - u->re; (y++)->im = (v++)->im - (u++)->im; %else *y++ = *v++ - *u++; %endif } %endfunction %% DiffVector %% [EOF] $RCSfile: sdspdiff2.tlc,v $