 NestingMetrics - Maple Help

SoftwareMetrics

 NestingMetrics Calling Sequence NestingMetrics(prc, dst, sm) Parameters

 prc - Maple procedure, module, or list of procedures or modules dst - (optional) BooleanOpt(distinguish); specifies whether to distinguish between selection and repetition structures sm - (optional) BooleanOpt(summarize); specifies whether to return the output in a tabular format or as an expression sequence containing one (or two) row Vector(s) Description

 • The NestingMetrics routine provides details about nesting depth of selection and repetition structures for each procedure or module contained in the parameter prc.
 Selection structures include if statements and if operators.
 Repetition structures include for-from and for-in statements as well as seq, , map, add, and $\mathrm{mul}$ operators.
 • The distinguish option (dst) controls how selection and repetition structures are treated with regards to nesting depth.
 If omitted (or given as distinguish=false), no distinctions are made between selection and repetition structures, and vice-versa.
 The condition distinguish=true can be abbreviated as distinguish.
 • The summarize option (sm) controls how the result is returned.
 If the summarize option is omitted (or is given as summarize=false), the result returned is an Array which tabulates the details of the nesting depths for each procedure and module contained in prc. Additionally, if prc contains at least two procedures (or a module with more than one export), the routine computes the total nesting depth for of all the procedures and modules combined. This total is included in the last row of the output Array.
 To force the display of large Arrays, you can increase the rtablesize setting using the interface function.
 If given as summarize=true, the result returned is a row Vector (when distinguish=false) or an expression sequence of two row Vectors (when distinguish=true). These row Vectors represent total nesting depth for all of the procedures and modules contained in prc.
 Regardless of the value of summarize, the j-th element of the Vectors contained in the output represent the number of structures for the j-th nesting level.
 The condition summarize=true can be abbreviated as summarize. Examples

 > $\mathrm{with}\left(\mathrm{SoftwareMetrics}\right):$

Example procedure taken from the Maple Programming Guide

 > sieve := proc(n::integer)     local i, k, flags, count, twice_i;     count := 0;     for i from 2 to n do flags[i] := true end do;     for i from 2 to n do         if flags[i] then             twice_i := 2*i;             for k from twice_i by i to n do flags[k] := false end do;             count := count+1;         end if;     end do;     count; end proc:
 > $\mathrm{NestingMetrics}\left('\mathrm{sieve}'\right)$
 $\left[\begin{array}{cc}{\mathrm{sieve}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrr}2& 1& 1\end{array}\right]\right]\right)\end{array}\right]$ (1)
 > $\mathrm{NestingMetrics}\left('\mathrm{sieve}','\mathrm{distinguish}'\right)$
 $\left[\begin{array}{ccc}{}& {\mathrm{Selection Structures}}& {\mathrm{Repetition Structures}}\\ {\mathrm{sieve}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{r}1\end{array}\right]\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}2& 1\end{array}\right]\right]\right)\end{array}\right]$ (2)
 > $\mathrm{NestingMetrics}\left('\mathrm{sieve}','\mathrm{distinguish}','\mathrm{summarize}'\right)$
 $\left[\begin{array}{c}{1}\end{array}\right]{,}\left[\begin{array}{cc}{2}& {1}\end{array}\right]$ (3)

Examples using Maple library code

 > $\mathrm{NestingMetrics}\left(\left['\mathrm{dsolve}','\mathrm{dsolve/numeric}'\right],'\mathrm{distinguish}'=\mathrm{false}\right)$
 $\left[\begin{array}{cc}{\mathrm{dsolve}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrr}4& 12& 11& 6& 3\end{array}\right]\right]\right)\\ {\mathrm{dsolve/numeric}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrrrrr}67& 103& 69& 37& 6& 3& 4& 1\end{array}\right]\right]\right)\\ {\mathrm{TOTAL}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrrrrr}71& 115& 80& 43& 9& 3& 4& 1\end{array}\right]\right]\right)\end{array}\right]$ (4)
 > $\mathrm{NestingMetrics}\left(\left['\mathrm{dsolve}','\mathrm{dsolve/numeric}'\right],'\mathrm{distinguish}'=\mathrm{true}\right)$
 $\left[\begin{array}{ccc}{}& {\mathrm{Selection Structures}}& {\mathrm{Repetition Structures}}\\ {\mathrm{dsolve}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrr}4& 10& 9& 4& 1\end{array}\right]\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{r}8\end{array}\right]\right]\right)\\ {\mathrm{dsolve/numeric}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrrr}68& 72& 50& 9& 1& 3\end{array}\right]\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}82& 5\end{array}\right]\right]\right)\\ {\mathrm{TOTAL}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrrr}72& 82& 59& 13& 2& 3\end{array}\right]\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}90& 5\end{array}\right]\right]\right)\end{array}\right]$ (5)
 > $\mathrm{NestingMetrics}\left('\mathrm{CurveFitting}'\right)$
 $\begin{array}{c}\left[\begin{array}{cc}{\mathrm{CurveFitting}}{:-}{\mathrm{ArrayInterpolation}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrrrrr}23& 28& 44& 23& 11& 1& 2\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{BSpline}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}5& 3\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{BSplineCurve}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}10& 2\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{Interactive}}& \left[\begin{array}{}\end{array}\right]\\ {\mathrm{CurveFitting}}{:-}{\mathrm{LeastSquares}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}10& 7\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{Lowess}}& \left[\begin{array}{}\end{array}\right]\\ {\mathrm{CurveFitting}}{:-}{\mathrm{PolynomialInterpolation}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrr}7& 10& 4\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{RationalInterpolation}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrr}12& 5& 3\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{Spline}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rrrr}22& 26& 9& 2\end{array}\right]\right]\right)\\ {\mathrm{CurveFitting}}{:-}{\mathrm{ThieleInterpolation}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[\left[\begin{array}{rr}8& 1\end{array}\right]\right]\right)\\ {⋮}& {⋮}\end{array}\right]\\ \hfill {\text{11 × 2 Array}}\end{array}$ (6)
 > $\mathrm{NestingMetrics}\left('\mathrm{CurveFitting}','\mathrm{summarize}'\right)$
 $\left[\begin{array}{ccccccc}{97}& {82}& {60}& {25}& {11}& {1}& {2}\end{array}\right]$ (7)