This file is indexed.

/usr/share/octave/packages/control-2.6.2/@lti/prescale.m is in octave-control 2.6.2-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
## Copyright (C) 2009-2014   Lukas F. Reichlin
##
## This file is part of LTI Syncope.
##
## LTI Syncope is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## LTI Syncope is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {[@var{scaledsys}, @var{info}] =} prescale (@var{sys})
## Scale state-space model.  The scaled model @var{scaledsys} is equivalent to
## @var{sys}, but the state vector is scaled by diagonal transformation matrices
## in order to increase the accuracy of subsequent numerical computations.
## Frequency response commands perform automatic scaling unless model property
## @var{scaled} is set to @var{true}.
##
## @strong{Inputs}
## @table @var
## @item sys
## @acronym{LTI} model.
## @end table
##
## @strong{Outputs}
## @table @var
## @item scaledsys
## Scaled state-space model.
## @item info
## Structure containing additional information.
## @item info.SL
## Left scaling factors.  @code{Tl = diag (info.SL)}.
## @item info.SR
## Right scaling factors.  @code{Tr = diag (info.SR)}.
## @end table
##
## @strong{Equations}
## @example
## @group
## Es = Tl * E * Tr
## As = Tl * A * Tr
## Bs = Tl * B
## Cs =      C * Tr
## Ds =      D
## @end group
## @end example
##
## For proper state-space models, @var{Tl} and @var{Tr} are inverse of each other.
##
## @strong{Algorithm}@*
## Uses SLICOT TB01ID and TG01AD by courtesy of
## @uref{http://www.slicot.org, NICONET e.V.}.
## @end deftypefn

## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: June 2011
## Version: 0.2

function [retsys, varargout] = prescale (sys)

  if (nargin != 1)
    print_usage ();
  endif

  if (! isa (sys, "ss"))
    warning ("prescale: system not in state-space form");
    sys = ss (sys);
  endif

  [retsys, lscale, rscale] = __prescale__ (sys);
  
  if (nargout > 1)
    varargout{1} = struct ("SL", lscale, "SR", rscale);
  endif

endfunction


## Scaling of state-space models, direct access to TB01ID
%!shared Ao, Bo, Co, SCALEo, MAXREDo, Ae, Be, Ce, SCALEe, MAXREDe
%! A = [          0.0  1.0000e+000          0.0          0.0          0.0
%!       -1.5800e+006 -1.2570e+003          0.0          0.0          0.0
%!        3.5410e+014          0.0 -1.4340e+003          0.0 -5.3300e+011
%!                0.0          0.0          0.0          0.0  1.0000e+000
%!                0.0          0.0          0.0 -1.8630e+004 -1.4820e+000 ];
%!
%! B = [          0.0          0.0
%!        1.1030e+002          0.0
%!                0.0          0.0
%!                0.0          0.0
%!                0.0  8.3330e-003 ];
%!
%! C = [  1.0000e+000          0.0          0.0          0.0          0.0
%!                0.0          0.0  1.0000e+000          0.0          0.0
%!                0.0          0.0          0.0  1.0000e+000          0.0
%!        6.6640e-001          0.0 -6.2000e-013          0.0          0.0
%!                0.0          0.0 -1.0000e-003  1.8960e+006  1.5080e+002 ];
%!
%! MAXRED = 0.0;
%!
%! [Ao, Bo, Co, MAXREDo, SCALEo] = __sl_tb01id__ (A, B, C, MAXRED);
%!
%! Ae = [    0.0000000D+00  0.1000000D+05  0.0000000D+00  0.0000000D+00  0.0000000D+00
%!          -0.1580000D+03 -0.1257000D+04  0.0000000D+00  0.0000000D+00  0.0000000D+00
%!           0.3541000D+05  0.0000000D+00 -0.1434000D+04  0.0000000D+00 -0.5330000D+03
%!           0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.1000000D+03
%!           0.0000000D+00  0.0000000D+00  0.0000000D+00 -0.1863000D+03 -0.1482000D+01 ];
%!
%! Be = [    0.0000000D+00  0.0000000D+00
%!           0.1103000D+04  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.8333000D+02 ];
%!
%! Ce = [    0.1000000D-04  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00  0.1000000D+06  0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00  0.0000000D+00  0.1000000D-05  0.0000000D+00
%!           0.6664000D-05  0.0000000D+00 -0.6200000D-07  0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00 -0.1000000D+03  0.1896000D+01  0.1508000D-01 ];
%!
%! SCALEe = [0.1000000D-04  0.1000000D+00  0.1000000D+06  0.1000000D-05  0.1000000D-03 ];
%!
%! MAXREDe = 0.3488E+10;
%!
%!assert (Ao, Ae, 1e-4);
%!assert (Bo, Be, 1e-4);
%!assert (Co, Ce, 1e-4);
%!assert (MAXREDo, MAXREDe, 1e6);
%!assert (SCALEo, SCALEe.', 1e-4);


## Scaling of descriptor state-space models, direct access to TG01AD
%!shared Ao, Eo, Bo, Co, LSCALEo, RSCALEo, Ae, Ee, Be, Ce, LSCALEe, RSCALEe
%! A = [   -1         0         0    0.003
%!          0         0    0.1000    0.02
%!        100        10         0    0.4
%!          0         0         0    0.0];
%!
%! E = [    1       0.2         0    0.0
%!          0         1         0    0.01
%!        300        90         6    0.3
%!          0         0        20    0.0];
%!
%! B = [   10         0
%!          0         0
%!          0      1000
%!      10000     10000];
%!
%! C = [ -0.1      0.0    0.001    0.0
%!        0.0      0.01  -0.001    0.0001];
%!
%! TRESH = 0.0;
%!
%! [Ao, Eo, Bo, Co, LSCALEo, RSCALEo] = __sl_tg01ad__ (A, E, B, C, TRESH);
%!
%! Ae = [ -1.0000    0.0000    0.0000    0.3000
%!         0.0000    0.0000    1.0000    2.0000
%!         1.0000    0.1000    0.0000    0.4000
%!         0.0000    0.0000    0.0000    0.0000];
%!
%! Ee = [  1.0000    0.2000    0.0000    0.0000
%!         0.0000    1.0000    0.0000    1.0000
%!         3.0000    0.9000    0.6000    0.3000
%!         0.0000    0.0000    0.2000    0.0000 ];
%!
%! Be = [100.0000    0.0000
%!         0.0000    0.0000
%!         0.0000  100.0000
%!       100.0000  100.0000 ];
%!
%! Ce = [ -0.0100    0.0000    0.0010    0.0000
%!         0.0000    0.0010   -0.0010    0.0010];
%!
%! LSCALEe = [ 10.0000   10.0000    0.1000    0.0100 ];
%!
%! RSCALEe = [  0.1000    0.1000    1.0000   10.0000 ];
%!
%!assert (Ao, Ae, 1e-4);
%!assert (Eo, Ee, 1e-4);
%!assert (Bo, Be, 1e-4);
%!assert (Co, Ce, 1e-4);
%!assert (LSCALEo, LSCALEe.', 1e-4);
%!assert (RSCALEo, RSCALEe.', 1e-4);


## Scaling of state-space models, user function
%!shared Ao, Bo, Co, INFOo, Ae, Be, Ce, SCALEe
%! A = [          0.0  1.0000e+000          0.0          0.0          0.0
%!       -1.5800e+006 -1.2570e+003          0.0          0.0          0.0
%!        3.5410e+014          0.0 -1.4340e+003          0.0 -5.3300e+011
%!                0.0          0.0          0.0          0.0  1.0000e+000
%!                0.0          0.0          0.0 -1.8630e+004 -1.4820e+000 ];
%!
%! B = [          0.0          0.0
%!        1.1030e+002          0.0
%!                0.0          0.0
%!                0.0          0.0
%!                0.0  8.3330e-003 ];
%!
%! C = [  1.0000e+000          0.0          0.0          0.0          0.0
%!                0.0          0.0  1.0000e+000          0.0          0.0
%!                0.0          0.0          0.0  1.0000e+000          0.0
%!        6.6640e-001          0.0 -6.2000e-013          0.0          0.0
%!                0.0          0.0 -1.0000e-003  1.8960e+006  1.5080e+002 ];
%!
%! SYS = ss (A, B, C);
%!
%! [SYSo, INFOo] = prescale (SYS);
%!
%! [Ao, Bo, Co] = ssdata (SYSo);
%!
%! Ae = [    0.0000000D+00  0.1000000D+05  0.0000000D+00  0.0000000D+00  0.0000000D+00
%!          -0.1580000D+03 -0.1257000D+04  0.0000000D+00  0.0000000D+00  0.0000000D+00
%!           0.3541000D+05  0.0000000D+00 -0.1434000D+04  0.0000000D+00 -0.5330000D+03
%!           0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.1000000D+03
%!           0.0000000D+00  0.0000000D+00  0.0000000D+00 -0.1863000D+03 -0.1482000D+01 ];
%!
%! Be = [    0.0000000D+00  0.0000000D+00
%!           0.1103000D+04  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.8333000D+02 ];
%!
%! Ce = [    0.1000000D-04  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00  0.1000000D+06  0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00  0.0000000D+00  0.1000000D-05  0.0000000D+00
%!           0.6664000D-05  0.0000000D+00 -0.6200000D-07  0.0000000D+00  0.0000000D+00
%!           0.0000000D+00  0.0000000D+00 -0.1000000D+03  0.1896000D+01  0.1508000D-01 ];
%!
%! SCALEe = [0.1000000D-04  0.1000000D+00  0.1000000D+06  0.1000000D-05  0.1000000D-03 ];
%!
%!assert (Ao, Ae, 1e-4);
%!assert (Bo, Be, 1e-4);
%!assert (Co, Ce, 1e-4);
%!assert (INFOo.SL.^-1, SCALEe.', 1e-4);
%!assert (INFOo.SR, SCALEe.', 1e-4);


## Scaling of descriptor state-space models, user function
%!shared Ao, Eo, Bo, Co, INFOo, Ae, Ee, Be, Ce, LSCALEe, RSCALEe
%! A = [   -1         0         0    0.003
%!          0         0    0.1000    0.02
%!        100        10         0    0.4
%!          0         0         0    0.0];
%!
%! E = [    1       0.2         0    0.0
%!          0         1         0    0.01
%!        300        90         6    0.3
%!          0         0        20    0.0];
%!
%! B = [   10         0
%!          0         0
%!          0      1000
%!      10000     10000];
%!
%! C = [ -0.1      0.0    0.001    0.0
%!        0.0      0.01  -0.001    0.0001];
%!
%! SYS = dss (A, B, C, [], E);
%!
%! [SYSo, INFOo] = prescale (SYS);
%!
%! [Ao, Bo, Co, ~, Eo] = dssdata (SYSo); 
%!
%! Ae = [ -1.0000    0.0000    0.0000    0.3000
%!         0.0000    0.0000    1.0000    2.0000
%!         1.0000    0.1000    0.0000    0.4000
%!         0.0000    0.0000    0.0000    0.0000];
%!
%! Ee = [  1.0000    0.2000    0.0000    0.0000
%!         0.0000    1.0000    0.0000    1.0000
%!         3.0000    0.9000    0.6000    0.3000
%!         0.0000    0.0000    0.2000    0.0000 ];
%!
%! Be = [100.0000    0.0000
%!         0.0000    0.0000
%!         0.0000  100.0000
%!       100.0000  100.0000 ];
%!
%! Ce = [ -0.0100    0.0000    0.0010    0.0000
%!         0.0000    0.0010   -0.0010    0.0010];
%!
%! LSCALEe = [ 10.0000   10.0000    0.1000    0.0100 ];
%!
%! RSCALEe = [  0.1000    0.1000    1.0000   10.0000 ];
%!
%!assert (Ao, Ae, 1e-4);
%!assert (Eo, Ee, 1e-4);
%!assert (Bo, Be, 1e-4);
%!assert (Co, Ce, 1e-4);
%!assert (INFOo.SL, LSCALEe.', 1e-4);
%!assert (INFOo.SR, RSCALEe.', 1e-4);