%% %% $RCSfile: sdspsctest.tlc,v $ %% Abstract: %% Target file for the Schur-Cohn Stability Test block %% S-Function in the DSP Blockset. %% %% Copyright 1995-2000 The MathWorks, Inc. %% $Revision: 1.3 $ $Date: 2000/06/15 20:37:48 $ %implements "sdspsctest" "C" %include "dsplib.tlc" %% Function: Outputs ========================================================== %% %% Abstract: Determine if roots are all inside unit circle %% %function Outputs(block, system) Output /* Schur-Cohn Stability Test (%) - % */ %% %\ %% %assign INPORT = 0 %assign OUTPORT = 0 %% %assign c0 = LibBlockInputSignalIsComplex(INPORT) %assign in_dtype = LibBlockInputSignalDataTypeName(INPORT,"") %assign IS_BOOLEAN = (LibBlockOutputSignalDataTypeId(OUTPORT) == tSS_BOOLEAN) %assign dTrue = IS_BOOLEAN ? "TRUE" : "1.0" %assign dFalse = IS_BOOLEAN ? "FALSE" : "0.0" %assign nRows = CAST("Number", SFcnParamSettings.nRows) %assign nChans = CAST("Number", SFcnParamSettings.nChans) %% %if nRows == 1 %% %% Scalar input %% /* Scalar input - root is always inside unit circle: */ %if nChans > 1 { int_T j = %; /* # of channels */ while(--j > 0) % = %; } %else % = %; %endif %else %% %% Vector/matrix input %% { %if nChans > 1 const int_T nChans = %; int_T j = nChans; while(--j >= 0) % = %; %else %% Defer to after variables are declared below: %% % = %; %endif %if nChans > 1 %assign jN = "j*N" %assign jout = "j" %% for(j=0; j < nChans; j++) { %else %assign jN = "" %assign jout = "" %endif % *p1 = %; % *p2 = %; int_T N = %; /* # of coeffs in polynomial */ %if nChans == 1 % = %; %endif %% memcpy(p1, /* Copy all elements to temp storage */ %, N * sizeof(%)); while(--N > 0) { const % k1 = p1[0]; const % k2 = p1[N]; %if c0 if (CMAGSQ(k1) <= CMAGSQ(k2)) { %else if (k1*k1 <= k2*k2) { %endif % = %; break; } { int_T i; for(i=0; i *tmp=p1; p1=p2; p2=tmp;} /* Swap p1 and p2 pointers */ } %if nChans > 1 } %endif } %endif %endfunction %% Outputs %% EOF: sdspsctest.tlc