Mercurial > hg > octave-lyh
annotate scripts/linear-algebra/vech.m @ 16505:ff061068a66c
move dialog files to separate directory
* scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m,
scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m,
scripts/ui/warndlg.m: Move here from scripts/java.
* scripts/java/module.mk (java_FCN_FILES): Update list.
* scripts/ui/module.mk: New file.
* scripts/Makefile.am: Include it.
(ui/PKG_ADD, $(ui_GEN_FCN_FILES), ui/$(octave_dirstamp)): New targets.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 12 Apr 2013 14:51:51 -0400 |
parents | f3d52523cde1 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12639
diff
changeset
|
1 ## Copyright (C) 1995-2012 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 | |
12639
4d777e05d47c
doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
24 ## other. This has uses in matrix calculus where the underlying matrix |
4d777e05d47c
doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
25 ## is symmetric and it would be pointless to keep values above the main |
4d777e05d47c
doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 ## diagonal. |
4d777e05d47c
doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 ## @seealso{vec} |
3369 | 28 ## @end deftypefn |
29 | |
2540 | 30 ## See Magnus and Neudecker (1988), Matrix differential calculus with |
31 ## applications in statistics and econometrics. | |
32 | |
5428 | 33 ## Author KH <Kurt.Hornik@wu-wien.ac.at> |
2540 | 34 ## Created: 8 May 1995 |
35 ## Adapted-By: jwe | |
36 | |
37 function v = vech (x) | |
3426 | 38 |
2540 | 39 if (nargin != 1) |
6046 | 40 print_usage (); |
2540 | 41 endif |
3426 | 42 |
4030 | 43 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
|
44 error ("vech: X must be square"); |
2540 | 45 endif |
3426 | 46 |
2540 | 47 n = rows (x); |
9093 | 48 slices = cellslices (x(:), (1:n) + n*(0:n-1), n*(1:n)); |
49 v = vertcat (slices{:}); | |
2540 | 50 |
51 endfunction | |
7411 | 52 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
53 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 %!assert (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]), [1; 4; 7; 5; 8; 9]) |
7411 | 55 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 %!error vech () |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 %!error vech (1, 2) |
7411 | 58 |