% $Date: 2004/10/04 17:25:12 $ $Author: nthiery $ $Revision: 1.1.1.3 $

\begin{Mhelppage}{SpSpecialize}{S. Veigneau}

  \begin{MInfo}
    \eng{specializes a set of variables}
  \end{MInfo}

\begin{MCalls}
 \Mcall{expr,gname,f,args}
\end{MCalls}
%
\begin{MParameters}
  \param{expr}
  \eng{any expression}
  \param{gname}
  \eng{any string or indexed}
  \param{f}
  \eng{any procedure}
  \param{args}
  \eng{any (extra) parameters for \Mex{f}} 
\end{MParameters}
%
\begin{MIntro}
  \eng{

The {\Mthis} function is devoted to specialize a set of variables.
This can be all variables generated by the generic name gname in such a
way that the variable \Mex{gname.i} is sent onto \Mex{f(i, args)}.
This function can also be used to specialize indexed variables named
\Mex{gname[}sequence\Mex{]} onto \Mex{f([}sequence\Mex{], args)}.
}
\end{MIntro}
%
\begin{MExample}{ex1}
%
\begin{Mexin}
muEC::SP::SpSpecialize(x1 + y3 + xx2 + x3^3, x, i->y.i);
\end{Mexin}
\begin{Mexout}
                        3
                      y3  + y3 + xx2 + y1
\end{Mexout}
% \begin{Mexout}[hide]
                    % y1 + y3 + xx2 + y3^3
% \end{Mexout}
%
\begin{Mexin}
deg:=3: // you should use a map to specialize a table...
map(muEC::SP::TableX(deg), muEC::SP::SpSpecialize, x,
    proc(i,d) begin q^(d-i) end_proc, deg);
\end{Mexin}
\begin{Mexout}
                     table(
                                    5
                       [3, 2, 1] = q ,
                                    3
                       [2, 3, 1] = q ,
                                    2
                       [2, 1, 3] = q ,
                                    4
                       [3, 1, 2] = q ,
                                    2
                       [1, 3, 2] = q  + q,
                       [1, 2, 3] = 1
                     )
\end{Mexout}
% \begin{Mexout}[hide]
% table([1, 2, 3]=1,[1, 3, 2]=q + q^2,[3, 1, 2]=q^4,[2, 1, 3]=q^2,
% [2, 3, 1]=q^3,[3, 2, 1]=q^5)
% \end{Mexout}
%
\begin{Mexin}
// specialization of the yi's as  the permutation [3,1,2] of the  xi's...
map(muEC::SP::TableXX(3), muEC::SP::SpSpecialize, y,
    (i,perm)->x.(perm[i]), [3,1,2]);
\end{Mexin}
\begin{Mexout}
              table(
                [3, 2, 1] = 0,
                [2, 3, 1] = (x1 - x3) (x2 - x3),
                [2, 1, 3] = x1 - x3,
                [3, 1, 2] = 0,
                [1, 3, 2] = x2 - x3,
                [1, 2, 3] = 1
              )
\end{Mexout}
% \begin{Mexout}[hide]
% table([1, 2, 3]=1,[1, 3, 2]=x2 + x3*(-1),[3, 1, 2]=0,[2, 1, 3]=x1 + x3*(-1),
% [2, 3, 1]=(x1 + x3*(-1))*(x2 + x3*(-1)),[3, 2, 1]=0)
% \end{Mexout}
\end{MExample}
%
\MRelatedFunctions{SG::Perm2Code,TableX,TableXX}
\end{Mhelppage}
