1
1
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2
2
// Copyright (C) INRIA
3
// Copyright (C) Scilab Enterprises - Adeline CARNIS
4
5
// This file must be used under the terms of the CeCILL.
5
6
// This source file is licensed as described in the file COPYING, which
10
11
function res=%sp_norm(S,flag)
13
if rhs==1 then flag=2;end //norm(S)=norm(S,2)
16
if m==1|n==1 then //vector norm
24
res=max(ones(1,m)*abs(S))
34
if res==0 then return,end
36
while abs(res-res0) > tol*res
37
res0 = res; Sx = S*x; res = norm(Sx);
41
if m<>n then res=sqrt(res),end
43
res=max(abs(S)*ones(n,1))
45
res=max(abs(S)*ones(n,1))
48
res=sqrt(sum(abs(v.*v)))
14
if rhs==1 then flag=2;end //norm(S)=norm(S,2)
17
if m==1|n==1 then //vector norm
25
res=max(ones(1,m)*abs(S))
38
if res==0 then return,end
40
while abs(res-res0) > tol*res
41
res0 = res; Sx = S1*x;
43
// Bug #10178: norm failed for some sparse matrix
44
// If Sx = 0, we had "division by zero" with x/norm(x)
45
// So, use to sum(abs(S).^2).^(1/2)
47
res = sum(abs(S).^2).^(1/2);
56
if m<>n then res=sqrt(res),end
58
res=max(abs(S)*ones(n,1))
60
res=max(abs(S)*ones(n,1))
63
res=sqrt(sum(abs(v.*v)))