%% $RCSfile: sdspflip.tlc,v $ %% $Revision: 1.4 $ $Date: 2000/06/15 20:37:41 $ %% %% Copyright 1995-2000 The MathWorks, Inc. %% %% Abstract: Target file for the S-Function sdspflip.c %% %implements "sdspflip" "C" %% Function: BlockInstanceSetup =============================================== %% %function BlockInstanceSetup(block, system) void %assign INPORT = 0 %assign OUTPORT = 0 %assign numDims = LibBlockInputSignalNumDimensions(INPORT) %assign inDims = LibBlockInputSignalDimensions(INPORT) %assign inCols = (numDims == 2) ? inDims[1] : 1 %assign inRows = inDims[0] %assign cmplx = LibBlockOutputSignalIsComplex(OUTPORT) %assign DType = cmplx ? "creal_T" : "real_T" %assign block = block + INPORT + OUTPORT + numDims + ... inCols + inRows + cmplx + DType %endfunction %% BlockInstanceSetup %% Function: Outputs ========================================================== %% %% Abstract: %% %function Outputs(block, system) Output /* DSP Blockset Flip (%) - % */ %% %assign inplace = (LibBlockInputSignalBufferDstPort(INPORT) == OUTPORT) %assign direction = SFcnParamSettings.Direction %assign RowFlip = (direction == 1) && (numDims==2) %assign ColumnFlip = (direction == 2) && (numDims==2) %% %% Certain cases don't require any code %% - Flip Cols of a row %% - Flip Rows of a col %% - Scalar %% %if (ColumnFlip && inRows==1) || ... (RowFlip && inCols==1) || ... (inRows==1 && inCols==1) %% %if inplace /* No code gnerated for flip block because input is not modified. */ %else %assign u = LibBlockInputSignal(INPORT,"i","",0) %assign y = LibBlockOutputSignal(OUTPORT,"i","",0) %assign width = LibDataInputPortWidth(INPORT) %% { /* Copy input to output. */ int i; for(i=0; i<%; i++) { % = %; } } %endif %% %else { %if numDims == 1 %if inplace /* Flip vector using in-place algorithm */ % \ %else /* Flip vector */ % \ %endif %elseif ColumnFlip %% %if inplace /* Flip columns using in-place algorithm */ % \ %else /* Flip columns */ % \ %endif %% %elseif RowFlip %% %if inplace /* Flip rows using in-place algorithm */ % \ %else /* Flip rows */ % \ %endif %endif } %endif %endfunction %% Outputs %% Function: FlipColInPlace ========================================================== %% %function FlipColInPlace() Output %% %if inCols > 1 %% %% Matrix code %% % *y = %; int_T rows = %; %% int_T cols = %; int_T c; for(c=0; c *top = y + (c * rows); /* top of next column */ % *bottom = top + rows-1; int_T i = rows / 2; /* if odd, = floor(width/2) */ while(i-- > 0) { % tmp = *top; *top++ = *bottom; *bottom-- = tmp; } } %else % \ %endif %% %endfunction %% FlipColInPlace %% Function: FlipCol ========================================================== %% %function FlipCol() Output %% %if inCols > 1 %% %% Matrix code %% % *y = %; % *u = %; int_T rows = %; %% int_T cols = %; int_T c; for(c=0; c *ycol = y + ((c+1) * rows - 1); /* Bottom of next column */ int_T i; for(i=0; i \ %endif %% %endfunction %% FlipCol %% Function: FlipRowInPlace ========================================================== %% %function FlipRowInPlace() Output %% %if inRows > 1 %% %% Matrix code %% % *y = %; int_T cols = %; int_T c; int_T rows = %; int_T r; for(r=0; r tmp = *(y+bak); *(y+bak) = *(y+fwd); *(y+fwd) = tmp; } y++; /* next output row */ } %else % \ %endif %% %endfunction %% FlipRowInPlace %% Function: FlipRow ========================================================== %% %function FlipRow() Output %% %if inRows > 1 %% %% Matrix code %% % *y = %; % *u = %; int_T cols = %; int_T c; %% int_T rows = %; int_T r; for(r=0; r \ %endif %% %endfunction %% FlipRow %% Function: FlipVectorInPlace ========================================================== %% %function FlipVectorInPlace(width) Output %% % *top = %; % *bottom = %; int_T halfwidth = %; /* if odd, = floor(width/2) */ while(halfwidth-- > 0) { % tmp = *top; *top++ = *bottom; *bottom-- = tmp; } %% %endfunction %% FlipVector %% Function: FlipVector ========================================================== %% %function FlipVector(width) Output %% % *u = %; % *yend = %; int_T width = %; while(width-- > 0) { *yend-- = *u++; } %% %endfunction %% FlipVector %% [EOF: sdspflip.tlc]