// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Copyright (C) 2012 - 2016 - Scilab Enterprises
+//
+// This file is hereby licensed under the terms of the GNU GPL v2.0,
+// pursuant to article 5.3.4 of the CeCILL v.2.1.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// 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)
[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