%% $RCSfile: sdsptri.tlc,v $ %% $Revision: 1.8 $ %% $Date: 2000/06/15 20:37:50 $ %% %% Copyright 1995-2000 The MathWorks, Inc. %% %% Abstract: extract lower/upper triangular part %implements sdsptri "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 %% %assign UPPER = 1 %assign LOWER = 2 %% %assign INPORT = 0 %assign OUTPORT = 0 %assign extract = LibBlockParameterValue(Extract,0) %assign cols = CAST("Number", LibBlockParameterValue(Cols,0)) %assign width = CAST("Number", LibDataInputPortWidth(0)) %assign rows = CAST("Number", width/cols) %assign cplx = LibBlockInputSignalIsComplex(INPORT) != 0 %assign dtype = cplx ? "creal_T" : "real_T" %assign need_copy = (LibBlockInputSignalBufferDstPort(INPORT) != OUTPORT) %assign uplow = (extract == UPPER) ? "Upper" : "Lower" %% %% /* DSP Blockset Extract % Triangular Matrix (%) - % */ %% %if !IsInputPortContiguous(block,INPORT) % %endif %if need_copy %% %assign compare = (extract == UPPER) ? ">" : "<" { % *u = %; % *y = %; int_T nc; for(nc=0; nc++ < %; ) { int_T nr; for (nr=0; nr++ < %; ) { %if !cplx *y++ = (nr % nc) ? 0.0 : *u; u++; %else if(nr % nc) { y->re = 0.0; (y++)->im = 0.0; u++; } else { *y++ = *u++; } %endif } } } %else %% /* In-place algorithm. */ %% %if width !=1 %% %if extract == UPPER { % *y = %; int_T c; %assign mincols = MIN(cols,rows) for(c=0; c < %; c++) { int_T r; y += c+1; for (r=c+1; r++ < %; ) { %if !cplx *y++ = 0.0; %else y->re = 0.0; (y++)->im = 0.0; %endif } } } %else %% extract == LOWER { % *y = %; int_T c; for(c=1; c < %; c++) { int_T r; int_T cc = MIN(c, %); for (r=0; r++ < cc; ) { %if !cplx *y++ = 0.0; %else y->re = 0.0; (y++)->im = 0.0; %endif } y += (%-cc); } } %endif %else %% /* Scalar output equals input. No code needed. */ %% %endif %endif %endfunction %% [EOF] sdsptri.tlc