📄 power.m
字号:
function r = power(obj1,obj2)% POSYNOMIAL/POWER Implements '.^' for posynomials.%if( ~isnumeric(obj2) ) error('The exponent in the power must be a numerical value.');endsz1 = size(obj1); sz2 = size(obj2);if( length(obj2) ~= 1 ) % the exponent is not a scalar if( sz1(1) ~= sz2(1) || sz1(2) ~= sz2(2)) error(['Cannot apply pointwise power to vectors or matrices ' ... 'with incompatible dimensions' char(10) ... '(if the power is not scalar).']) endend% take the pointwise power with a posynomial and a scalar (to get a gposy)if( length(obj1) == 1 & length(obj2) == 1 ) r = obj1^obj2; return;end% pointwise power of a posynomial vector (or matrix) and scalar powerif( length(obj2) == 1 ) for i = 1:sz1(1) for j = 1:sz1(2) r(i,j) = obj1(i,j)^obj2; end end return;end% pointwise power of a posynomial vector and a scalar vectorif( sz1(1) == 1 & sz2(1) == 1 ) for k = 1:sz1(2) r(1,k) = obj1(1,k)^obj2(1,k); end return;endif( sz1(2) == 1 & sz2(2) == 1 ) for k = 1:sz1(1) r(k,1) = obj1(k,1)^obj2(k,1); end return;end% pointwise power of matrices (one has posynomials and the other scalars)for i = 1:sz1(1) for j = 1:sz1(2) r(i,j) = obj1(i,j)^obj2(i,j); endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -