7017
|
1 ## Copyright (C) 1996, 2000, 2002, 2004, 2005, 2007 |
|
2 ## Auburn University. All rights reserved. |
3430
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3430
|
10 ## |
7016
|
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. |
3430
|
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/>. |
3430
|
19 |
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {@var{pv} =} sysreorder (@var{vlen}, @var{list}) |
3430
|
22 ## |
|
23 ## @strong{Inputs} |
5016
|
24 ## @table @var |
|
25 ## @item vlen |
|
26 ## Vector length. |
|
27 ## @item list |
|
28 ## A subset of @code{[1:vlen]}. |
|
29 ## @end table |
3430
|
30 ## |
5016
|
31 ## @strong{Output} |
|
32 ## @table @var |
|
33 ## @item pv |
|
34 ## A permutation vector to order elements of @code{[1:vlen]} in |
3430
|
35 ## @code{list} to the end of a vector. |
5016
|
36 ## @end table |
3430
|
37 ## |
|
38 ## Used internally by @code{sysconnect} to permute vector elements to their |
|
39 ## desired locations. |
|
40 ## @end deftypefn |
|
41 |
|
42 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
43 ## Created: August 1995 |
|
44 |
|
45 function pv = sysreorder (vlen, list) |
|
46 |
7125
|
47 if (nargin != 2) |
|
48 print_usage (); |
|
49 endif |
|
50 |
3430
|
51 ## disp('sysreorder: entry') |
|
52 |
|
53 pv = 1:vlen; |
|
54 ## make it a row vector |
|
55 list = reshape(list,1,length(list)); |
7136
|
56 A = pv' * ones (size (list)); |
|
57 B = ones (size (pv')) * list; |
3430
|
58 X = (A != B); |
7136
|
59 if (! isvector (X)) |
|
60 y = min (X'); |
3430
|
61 else |
|
62 y = X'; |
|
63 endif |
7136
|
64 z = find (y == 1); |
|
65 if (! isempty (z)) |
3430
|
66 pv = [z, list]; |
|
67 else |
|
68 pv = list; |
|
69 endif |
|
70 |
|
71 endfunction |