1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12
13function d=%c_triu(a,k)
14    // g_triu - implement triu function for sparse matrix, rationnal matrix ,..
15    [lhs,rhs]=argn(0)
16    if rhs==1 then k=0,end
17
18    [m,n]=size(a)
19    if k<=0 then
20        mn=min(m,n-k)
21    else
22        mn=min(m+k,n)
23    end
24    a=matrix(a,m*n,1)
25    i=(1:mn)+((1:mn)+(k-1))*m
26    d=emptystr(m*n,1)
27    d(i)=a(i)
28    d=matrix(d,m,n)
29endfunction
30