3430
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
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 |
|
47 ## disp('sysreorder: entry') |
|
48 |
|
49 pv = 1:vlen; |
|
50 ## make it a row vector |
|
51 list = reshape(list,1,length(list)); |
|
52 A = pv'*ones(size(list)); |
|
53 B = ones(size(pv'))*list; |
|
54 X = (A != B); |
4030
|
55 if(!isvector(X)) |
3430
|
56 y = min(X'); |
|
57 else |
|
58 y = X'; |
|
59 endif |
|
60 z = find(y == 1); |
|
61 if(!isempty(z)) |
|
62 pv = [z, list]; |
|
63 else |
|
64 pv = list; |
|
65 endif |
|
66 |
|
67 endfunction |