📄 norm.sci
字号:
function y=norm(x,choice)
// Copyright Aldo I Maalouf
[lhs,rhs]=argn()
if rhs<2 ,
y=max(svd(x));
elseif rhs>2
error('warning:the number of the input is error!');
else
temp=size(x);
if temp(1)>1 & temp(2)>1
select choice,
case choice==1 then y= max(sum(abs(x))),
case choice==inf then y= max(sum(abs(x'))),
case choice=='fro' then y=sqrt(sum(diag(x'*x))),
else error('incorrect input');
end
end
if temp(1)==1 | temp(2)==1
select choice,
case choice==inf then y=max(abs(x)),
case choice==-inf then y=min(abs(x)),
else y=sum(abs(x).^choice)^(1/choice),
end
end
if temp(1)==0 | temp(2)==0
y=0;
end
end
endfunction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -