*! 1.0.4 18Jun1997 Jeroen Weesie/ICS STB-39 dm49 program define matnorm version 5.0 * scratch tempname A B nrm * parse input parse "`*'", parse(",") local A0 "`1'" capt mat `A' = `A0' if _rc { di in red "`A0' is undefined or an illegal matrix expression" exit 198 } local nc = colsof(`A') local nr = rowsof(`A') mac shift local options "Display Norm(str) Format(str)" if `nr' > `nc' { mat `B' = `A'' * `A' } else { mat `B' = `A' * `A'' } scalar `nrm' = sqrt(trace(`B')) if "`display'" != "" | "`norm'" == "" { if "`format'" == "" { local format "%10.2g" } di in gr "L2-norm of `A0'[`nc',`nr'] = " /* */ in ye `format' scalar(`nrm') } if "`norm'" != "" { scalar `norm' = `nrm' } end exit Returns the norm of a matrix expression. currently, we only implement a 2-norm = square-root of the sum of the squares of the elements later version should add * true L-x norms. * operator norms * ...