comparison scripts/general/tril.m @ 3369:f37ca3017116

[project @ 1999-11-21 16:26:02 by jwe]
author jwe
date Sun, 21 Nov 1999 16:26:08 +0000
parents e6d14959bea9
children 5e0a0b1cba43
comparison
equal deleted inserted replaced
3368:a4cd1e9d9962 3369:f37ca3017116
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, write to the Free 16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
18 ## 02111-1307, USA. 18 ## 02111-1307, USA.
19 19
20 ## usage: tril (x, k) 20 ## -*- texinfo -*-
21 ## 21 ## @deftypefn {Function File} {} tril (@var{a}, @var{k})
22 ## Return the lower triangular part of x above the k-th diagonal. If 22 ## @deftypefnx {Function File} {} triu (@var{a}, @var{k})
23 ## the second argument is omitted, k = 0 is assumed. 23 ## Return a new matrix formed by extracting extract the lower (@code{tril})
24 ## 24 ## or upper (@code{triu}) triangular part of the matrix @var{a}, and
25 ## setting all other elements to zero. The second argument is optional,
26 ## and specifies how many diagonals above or below the main diagonal should
27 ## also be set to zero.
28 ##
29 ## The default value of @var{k} is zero, so that @code{triu} and
30 ## @code{tril} normally include the main diagonal as part of the result
31 ## matrix.
32 ##
33 ## If the value of @var{k} is negative, additional elements above (for
34 ## @code{tril}) or below (for @code{triu}) the main diagonal are also
35 ## selected.
36 ##
37 ## The absolute value of @var{k} must not be greater than the number of
38 ## sub- or super-diagonals.
39 ##
40 ## For example,
41 ##
42 ## @example
43 ## @group
44 ## tril (ones (3), -1)
45 ## @result{} 0 0 0
46 ## 1 0 0
47 ## 1 1 0
48 ## @end group
49 ## @end example
50 ##
51 ## @noindent
52 ## and
53 ##
54 ## @example
55 ## @group
56 ## tril (ones (3), 1)
57 ## @result{} 1 1 0
58 ## 1 1 1
59 ## 1 1 1
60 ## @end group
61 ## @end example
62 ## @end deftypefn
63
25 ## See also: triu, diag 64 ## See also: triu, diag
26 65
27 ## Author: jwe 66 ## Author: jwe
28 67
29 function retval = tril (x, k) 68 function retval = tril (x, k)