%% $RCSfile: sdspm1norm.tlc,v $ %% $Revision: 1.6 $ %% $Date: 2000/06/15 20:37:42 $ %% %% Copyright 1995-2000 The MathWorks, Inc. %% %% Abstract: Matrix 1-Norm %implements sdspm1norm "C" %% Function: Outputs ========================================================== %% %function Outputs(block, system) Output /* DSP Blockset Matrix 1-Norm (%) - % */ %% %assign INPORT = 0 %assign OUTPORT = 0 %assign c0 = LibBlockOutputSignalIsComplex(OUTPORT) %assign M = % %assign N = % %assign contig = IsInputPortContiguous(block, 0) %assign cplx = LibBlockInputSignalIsComplex(INPORT) != 0 %assign dtype = cplx ? "creal_T" : "real_T" %% /* Compute maximum column (absolute value) sum */ %% %if N==1 % = \ %; %else %if contig %% Contiguous { % *u = %; real_T m1norm = 0.0; int_T j; for(j=%; j-- > 0; ) { real_T sumabsAj = 0.0; int_T i; for(i=%; i-- > 0; ) { %if !cplx %% REAL sumabsAj += fabs(*u++); %else %% COMPLEX real_T cabsAij; const creal_T uval = *u++; CABS(uval, cabsAij); sumabsAj += cabsAij; %endif } m1norm = MAX(m1norm, sumabsAj); } % = m1norm; } %else %% Discontiguous { real_T m1norm = 0.0; real_T sumabsAj = 0.0; int_T cnt = 1; %% Start count at 1 %assign rollVars = ["U"] %roll sigIdx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars %% %if !cplx %% REAL sumabsAj += fabs(%); %else %% COMPLEX { real_T cabsAij; CABS(%, cabsAij); sumabsAj += cabsAij; } %endif if ((cnt++ % %) == 0) { m1norm = MAX(m1norm, sumabsAj); cnt = 1; sumabsAj = 0.0; } %endroll % = m1norm; } %endif %endif %endfunction %% [EOF] sdspm1norm.tlc