⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpower.m

📁 GloptiPoly 3: moments, optimization and semidefinite programming. Gloptipoly 3 is intended to so
💻 M
字号:
function z = mpower(x,y)
% @MPOL/MPOWER - Matrix power
%
% MPOWER(X,Y) or X^Y is the Y-th power of X if Y is a non-negative integer
% and X is a square matrix

% D. Henrion, November 30, 2003.

if nargin < 1
 y = 1;
end

if (max(size(y)) > 1) | (y < 0) | (abs(round(y)-y) > 0)
 error('Exponent must be a nonnegative integer')
end

if size(x,1) ~= size(x,2)
 error('Matrix must be square')
end

if y == 0

 % Zero exponent
 z = mpol(eye(size(x)));

elseif (max(size(x)) == 1) & (size(coef(x),1) == 1)

 % Only one scalar monomial
 z = x;
 z.pow = x.pow*y;
 z.coef = z.coef^y;

else

 % Matrix power computed by repeated squarings
 z = x;
 for i = 2:y
   z = mtimes(z,x);
 end
 
end


    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -