Mercurial > hg > octave-lyh
annotate scripts/special-matrix/hankel.m @ 10791:3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
interpreter/doccheck: New directory for spelling/grammar scripts.
interpreter/doccheck/README: Instructions for using scripts.
interpreter/doccheck/spellcheck: Script to spellcheck a Texinfo file.
interpreter/doccheck/aspell.conf: GNU Aspell configuration file for
Octave documentation.
interpreter/doccheck/aspell-octave.en.pws: Private Aspell dictionary.
interpreter/doccheck/add_to_aspell_dict: Script to add new
Octave-specific words to
private Aspell dictionary.
interpreter/octave.texi: New @nospell macro which forces Aspell
to ignore the word marked by the macro.
interpreter/mk_doc_cache.m: Skip new @nospell macro when building
doc_cache.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 17 Jul 2010 19:53:01 -0700 |
parents | f0c3d3fc4903 |
children | 693e22af08ae |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004, |
8920 | 2 ## 2005, 2006, 2007, 2008, 2009 John W. Eaton |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
245 | 19 |
3369 | 20 ## -*- texinfo -*- |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9211
diff
changeset
|
21 ## @deftypefn {Function File} {} hankel (@var{c}) |
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9211
diff
changeset
|
22 ## @deftypefnx {Function File} {} hankel (@var{c}, @var{r}) |
3369 | 23 ## Return the Hankel matrix constructed given the first column @var{c}, and |
24 ## (optionally) the last row @var{r}. If the last element of @var{c} is | |
25 ## not the same as the first element of @var{r}, the last element of | |
4922 | 26 ## @var{c} is used. If the second argument is omitted, it is assumed to |
27 ## be a vector of zeros with the same size as @var{c}. | |
3426 | 28 ## |
3369 | 29 ## A Hankel matrix formed from an m-vector @var{c}, and an n-vector |
30 ## @var{r}, has the elements | |
31 ## @tex | |
32 ## $$ | |
33 ## H (i, j) = \cases{c_{i+j-1},&$i+j-1\le m$;\cr r_{i+j-m},&otherwise.\cr} | |
34 ## $$ | |
35 ## @end tex | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7411
diff
changeset
|
36 ## @ifnottex |
3426 | 37 ## |
3369 | 38 ## @example |
39 ## @group | |
4922 | 40 ## H(i,j) = c(i+j-1), i+j-1 <= m; |
41 ## H(i,j) = r(i+j-m), otherwise | |
3369 | 42 ## @end group |
43 ## @end example | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7411
diff
changeset
|
44 ## @end ifnottex |
5642 | 45 ## @seealso{vander, sylvester_matrix, hilb, invhilb, toeplitz} |
3369 | 46 ## @end deftypefn |
4 | 47 |
2314 | 48 ## Author: jwe |
49 | |
2311 | 50 function retval = hankel (c, r) |
4 | 51 |
52 if (nargin == 1) | |
5731 | 53 r = resize (resize (c, 0), size(c)); |
4 | 54 elseif (nargin != 2) |
6046 | 55 print_usage (); |
4 | 56 endif |
57 | |
58 [c_nr, c_nc] = size (c); | |
59 [r_nr, r_nc] = size (r); | |
60 | |
61 if ((c_nr != 1 && c_nc != 1) || (r_nr != 1 && r_nc != 1)) | |
1518 | 62 error ("hankel: expecting vector arguments"); |
4 | 63 endif |
64 | |
2325 | 65 if (nargin == 1) |
1396 | 66 r (1) = c (length (c)); |
67 endif | |
68 | |
4 | 69 if (c_nc != 1) |
1035 | 70 c = c.'; |
4 | 71 endif |
72 | |
73 if (r_nr != 1) | |
1035 | 74 r = r.'; |
4 | 75 endif |
76 | |
1396 | 77 nc = length (r); |
78 nr = length (c); | |
79 | |
80 if (r (1) != c (nr)) | |
904 | 81 warning ("hankel: column wins anti-diagonal conflict"); |
4 | 82 endif |
83 | |
2303 | 84 ## This should probably be done with the colon operator... |
4 | 85 |
5731 | 86 retval = resize (resize (c, 0), nr, nc); |
4 | 87 |
88 for i = 1:min (nr, nc) | |
89 retval (1:nr-i+1, i) = c (i:nr); | |
90 endfor | |
91 | |
92 tmp = 1; | |
93 if (nc <= nr) | |
94 tmp = nr - nc + 2; | |
95 endif | |
96 | |
97 for i = nr:-1:tmp | |
98 retval (i, 2+nr-i:nc) = r (2:nc-nr+i); | |
99 endfor | |
100 | |
101 endfunction | |
5731 | 102 |
103 %!assert(hankel(1:3),[1,2,3;2,3,0;3,0,0]) | |
104 %!assert(hankel(1),[1]); | |
105 %!assert(hankel(1:3,3:6),[1,2,3,4;2,3,4,5;3,4,5,6]); | |
106 %!assert(hankel(1:3,3:4),[1,2;2,3;3,4]); | |
107 %!assert(hankel(1:3,4:6),[1,2,3;2,3,5;3,5,6]); | |
7411 | 108 |
109 %!assert((hankel (1) == 1 && hankel ([1, 2]) == [1, 2; 2, 0] | |
110 %! && hankel ([1, 2], [2; -1; -3]) == [1, 2, -1; 2, -1, -3])); | |
111 | |
112 %!error hankel ([1, 2; 3, 4], [1, 2; 3, 4]); | |
113 | |
114 %!error hankel (); | |
115 | |
116 %!error hankel (1, 2, 3); | |
117 |