function ZTemp = mysympower(vartable,Z);
% MYSYMPOWER --- Fast symbolic power.
%
% ZSYM = mysympower(VARTABLE,ZNUM)
%

% This file is part of SOSTOOLS - Sum of Squares Toolbox ver 3.00.
%
% Copyright (C)2002, 2004, 2013  A. Papachristodoulou (1), J. Anderson (1),
%                                G. Valmorbida (1), S. Prajna (2), 
%                                P. Seiler (3), P. A. Parrilo (4)
% (1) Department of Engineering Science, University of Oxford, Oxford, U.K.
% (2) Control and Dynamical Systems - California Institute of Technology,
%     Pasadena, CA 91125, USA.
% (3) Aerospace and Engineering Mechanics Department, University of
%     Minnesota, Minneapolis, MN 55455-0153, USA.
% (4) Laboratory for Information and Decision Systems, M.I.T.,
%     Massachusetts, MA 02139-4307
%
% Send bug reports and feedback to: sostools@cds.caltech.edu
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%

% 03/01/02 - SP

ZTemp = '[';
for j = 1:size(Z,1)
    idx = find(Z(j,:));
    charexpr = [];
    for i = idx
        if Z(j,i)>1
            charexpr = [charexpr,char(vartable(i)),'^',int2str(Z(j,i)),'*'];
        else
            charexpr = [charexpr,char(vartable(i)),'*'];    
        end;
    end;
    if isempty(idx)
        charexpr = '1*';
    end;
    charexpr = [charexpr(1:end-1),';'];
    ZTemp = [ZTemp,charexpr];
end;    
ZTemp = [ZTemp(1:end-1),']'];
ZTemp = sym(ZTemp);