X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=blobdiff_plain;f=scilab%2Fmodules%2Felementary_functions%2Fmacros%2F%25sp_diag.sci;h=d388c0987c2cff302650841159858eae78c77d61;hp=32a08784bf72b9a6c0826af799b94b15836d91de;hb=f8ff9927f796d2c03a03becb11a240a2f98242d2;hpb=18e9fd43fc2a5d034e5ff7a8f79e9c6a55e195cf diff --git a/scilab/modules/elementary_functions/macros/%sp_diag.sci b/scilab/modules/elementary_functions/macros/%sp_diag.sci index 32a0878..d388c09 100644 --- a/scilab/modules/elementary_functions/macros/%sp_diag.sci +++ b/scilab/modules/elementary_functions/macros/%sp_diag.sci @@ -10,7 +10,7 @@ // For more information, see the COPYING file which you should have received // along with this program. -function d=%sp_diag(a,k) +function d = %sp_diag(a,k) // %sp_diag - implement diag function for sparse matrix, rational matrix ,.. [lhs,rhs]=argn(0) @@ -19,7 +19,11 @@ function d=%sp_diag(a,k) [ij,v,sz]=spget(a) m=sz(1);n=sz(2) if m>1&n>1 then - l=find(ij(:,1)==(ij(:,2)-k)) + if ij<>[] + l = find(ij(:,1)==(ij(:,2)-k)) + else + l = [] + end if k<=0 then mn=min(m+k,n) i0=-k