1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 1995-2010 - INRIA - Serge Steer
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 = %r_tril(a,k)
14    if argn(2)<2 then
15        k=0
16    else
17        fname = "%r_tril";
18        if type(k)<>1 then
19            msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
20            error(msprintf(msg, fname, 2))
21        end
22        if size(k,"*")<>1 then
23            msg = _("%s: Argument #%d: Scalar (1 element) expected.\n")
24            error(msprintf(msg, fname, 2))
25        end
26        if ~isreal(k) then
27            msg = _("%s: Argument #%d: Decimal number(s) expected.\n")
28            error(msprintf(msg, fname, 2))
29        end
30    end
31
32    d = rlist(tril(a.num,k),tril(a.den,k)+triu(ones(a.den),k+1),a.dt)
33endfunction
34