% $Date: 2003/09/15 16:37:45 $ $Author: nthiery $ $Revision: 1.1.1.1 $

\begin{Mhelppage}{Perm2Desc}{V. Prosper}
  \begin{MInfo}
    \eng{computes the list of descents of a permutation}
  \end{MInfo}
  
  \begin{MCalls}
    \Mcall{perm\Mopt{,nb,maj,comaj}}
  \end{MCalls}

  \begin{MParameters}
    \param{perm}
    \eng{any list denoting a permutation} 
    \param{nb}
    \eng{only counts objects} 
    \param{maj}
    \eng{sum of descent positions} 
    \param{comaj}
    \eng{sum of all values} 
  \end{MParameters}

  \begin{MIntro}
    \eng{The {\Mthis} function computes the list of descents of the
      permutation \Mex{perm}, i.e. the list of positions \Mmath{i}{i},
      such that \Mmath{\Mex{perm}[i] >
        \Mex{perm}[i+1]}{\mathtt{perm}_i>\mathtt{perm}_{i+1}}.
 
      When called with the second argument \Mex{maj}, it returns the
      sum of the descent positions.
      
      When called with the second argument \Mex{comaj}, it returns the
      sum of all values (\Mex{n} - descent position), where \Mex{n} is
      equal to \Mex{nops(perm)}. }
  \end{MIntro}

\begin{MExample}{ex1}
\begin{Mexin}
muEC::SG::Perm2Desc( [3,1,4,2,6,5,7] );
\end{Mexin}
\begin{Mexout}
                           [1, 3, 5]
\end{Mexout}
\begin{Mexin}
muEC::SG::Perm2Desc( [3,1,4,2,6,5,7], nb );
\end{Mexin}
\begin{Mexout}
                               3
\end{Mexout}
\begin{Mexin}
muEC::SG::Perm2Desc( [3,1,4,2,6,5,7], maj );
\end{Mexin}
\begin{Mexout}
                               9
\end{Mexout}
\begin{Mexin}
muEC::SG::Perm2Desc( [3,1,4,2,6,5,7], comaj );
\end{Mexin}
\begin{Mexout}
                              12
\end{Mexout}
\end{MExample}

\MRelatedFunctions{Perm2Rise}
\end{Mhelppage}
