%% $RCSfile: sdspmtrnsp.tlc,v $ %% $Revision: 1.8 $ %% $Date: 2000/06/15 20:37:46 $ %% %% Copyright 1995-2000 The MathWorks, Inc. %% %% Abstract: Matrix transpose %implements sdspmtrnsp "C" %% Function: BlockInstanceSetup =============================================== %% %% Abstract: %% Rename the S-Function parameter for easy reference. %% %function BlockInstanceSetup(block, system) void %% % % %% %endfunction %% Function: Outputs ========================================================== %% %function Outputs(block, system) Output /* DSP Blockset Matrix Transpose (%) - % */ %% %assign INPORT = 0 %assign OUTPORT = 0 %assign need_copy = (LibBlockInputSignalBufferDstPort(INPORT) != OUTPORT) %assign cplx = LibBlockInputSignalIsComplex(INPORT) != 0 %assign dtype = cplx ? "creal_T" : "real_T" %assign hermit = cplx ? LibBlockParameterValue(Hermit,0) : 0 %assign cols = CAST("Number",LibBlockParameterValue(Cols,0)) %assign width = CAST("Number",LibDataInputPortWidth(0)) %assign rows = CAST("Number",width/cols) %% %if need_copy %if cols == 1 || rows == 1 %% %% Vector input %% %assign rollVars = ["U","Y"] %roll sigIdx = RollRegions, lcv = RollThreshold, \ block, "Roller", rollVars %if !hermit %assign u = LibBlockInputSignal(INPORT, "", lcv, sigIdx) %assign y = LibBlockOutputSignal(OUTPORT, "", lcv, sigIdx) % = %; %else %assign u_re = LibBlockInputSignal(INPORT, "", lcv, "%%") %assign u_im = LibBlockInputSignal(INPORT, "", lcv, "%%") %assign y_re = LibBlockOutputSignal(OUTPORT, "", lcv, "%%") %assign y_im = LibBlockOutputSignal(OUTPORT, "", lcv, "%%") % = %; % = -%; %endif %endroll %else %% %% Matrix input %% %if !IsInputPortContiguous(block,INPORT) % %endif %% { /* * Transpose matrix: Walk the inputs in order down * the columns and write the outputs across the rows */ % *u = %; % *y = %; int_T j = %; while(j-- > 0) { % *yy = y++; int_T i = %; while(i-- > 0) { %if !hermit *yy = *u++; %else yy->re = u->re; yy->im = -(u++)->im; %endif yy += %; } } } %endif %else /* Output is identical to input. No code needed. */ %endif %% need_copy %endfunction %% [EOF] sdspmtrnsp.tlc