8920
|
1 ## Copyright (C) 1995, 1996, 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008 |
7017
|
2 ## Kurt Hornik |
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} {} vec (@var{x}) |
|
22 ## Return the vector obtained by stacking the columns of the matrix @var{x} |
2540
|
23 ## one above the other. |
3369
|
24 ## @end deftypefn |
|
25 |
2540
|
26 ## See Magnus and Neudecker (1988), Matrix differential calculus with |
|
27 ## applications in statistics and econometrics. |
|
28 |
5428
|
29 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
2540
|
30 ## Created: 8 May 1995 |
|
31 ## Adapted-By: jwe |
|
32 |
|
33 function v = vec (x) |
3426
|
34 |
2540
|
35 if (nargin != 1) |
6046
|
36 print_usage (); |
3426
|
37 endif |
|
38 |
4890
|
39 v = x(:); |
2540
|
40 |
|
41 endfunction |
7411
|
42 |
|
43 %!assert(vec ([1, 2; 3, 4]) == [1; 3; 2; 4] && vec ([1, 3, 2, 4]) == [1; 3; 2; 4]); |
|
44 |
|
45 %!error vec (); |
|
46 |
|
47 %!error vec (1, 2); |
|
48 |