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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
5016
|
20 ## @deftypefn {Function File} {@var{pv} =} sysreorder (@var{vlen}, @var{list}) |
3430
|
21 ## |
|
22 ## @strong{Inputs} |
5016
|
23 ## @table @var |
|
24 ## @item vlen |
|
25 ## Vector length. |
|
26 ## @item list |
|
27 ## A subset of @code{[1:vlen]}. |
|
28 ## @end table |
3430
|
29 ## |
5016
|
30 ## @strong{Output} |
|
31 ## @table @var |
|
32 ## @item pv |
|
33 ## A permutation vector to order elements of @code{[1:vlen]} in |
3430
|
34 ## @code{list} to the end of a vector. |
5016
|
35 ## @end table |
3430
|
36 ## |
|
37 ## Used internally by @code{sysconnect} to permute vector elements to their |
|
38 ## desired locations. |
|
39 ## @end deftypefn |
|
40 |
|
41 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
42 ## Created: August 1995 |
|
43 |
|
44 function pv = sysreorder (vlen, list) |
|
45 |
|
46 ## disp('sysreorder: entry') |
|
47 |
|
48 pv = 1:vlen; |
|
49 ## make it a row vector |
|
50 list = reshape(list,1,length(list)); |
|
51 A = pv'*ones(size(list)); |
|
52 B = ones(size(pv'))*list; |
|
53 X = (A != B); |
4030
|
54 if(!isvector(X)) |
3430
|
55 y = min(X'); |
|
56 else |
|
57 y = X'; |
|
58 endif |
|
59 z = find(y == 1); |
|
60 if(!isempty(z)) |
|
61 pv = [z, list]; |
|
62 else |
|
63 pv = list; |
|
64 endif |
|
65 |
|
66 endfunction |