Mercurial > hg > octave-nkf
annotate scripts/linear-algebra/vech.m @ 11595:5ec6aa05638d
Prevent doubled quotes around @table items in Info.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 20 Jan 2011 21:29:14 -0800 |
parents | fd0a3ac60b0e |
children | 4d777e05d47c |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1995-2011 Kurt Hornik |
9093 | 2 ## Copyright (C) 2009 VZLU Prague |
3426 | 3 ## |
3922 | 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. | |
3426 | 10 ## |
3922 | 11 ## Octave is distributed in the hope that it will be useful, but |
2540 | 12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3426 | 14 ## General Public License for more details. |
15 ## | |
2540 | 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/>. | |
2540 | 19 |
3369 | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} vech (@var{x}) | |
22 ## Return the vector obtained by eliminating all supradiagonal elements of | |
23 ## the square matrix @var{x} and stacking the result one column above the | |
24 ## other. | |
25 ## @end deftypefn | |
26 | |
2540 | 27 ## See Magnus and Neudecker (1988), Matrix differential calculus with |
28 ## applications in statistics and econometrics. | |
29 | |
5428 | 30 ## Author KH <Kurt.Hornik@wu-wien.ac.at> |
2540 | 31 ## Created: 8 May 1995 |
32 ## Adapted-By: jwe | |
33 | |
34 function v = vech (x) | |
3426 | 35 |
2540 | 36 if (nargin != 1) |
6046 | 37 print_usage (); |
2540 | 38 endif |
3426 | 39 |
4030 | 40 if (! issquare (x)) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
9093
diff
changeset
|
41 error ("vech: X must be square"); |
2540 | 42 endif |
3426 | 43 |
2540 | 44 n = rows (x); |
9093 | 45 slices = cellslices (x(:), (1:n) + n*(0:n-1), n*(1:n)); |
46 v = vertcat (slices{:}); | |
2540 | 47 |
48 endfunction | |
7411 | 49 |
50 %!assert(all (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]) == [1; 4; 7; 5; 8; 9])); | |
51 | |
52 %!error vech (); | |
53 | |
54 %!error vech (1, 2); | |
55 |