changeset 9353:790ecec405ba octave-forge

control-devel: fix wrappers
author paramaniac
date Wed, 18 Jan 2012 20:29:08 +0000
parents 5e4f4b9c1d31
children 799005b6ae9e
files extra/control-devel/devel/balancmr.m extra/control-devel/devel/balred.m extra/control-devel/devel/bstmr.m extra/control-devel/devel/hankelmr.m extra/control-devel/devel/madievski.m
diffstat 5 files changed, 77 insertions(+), 1095 deletions(-) [+]
line wrap: on
line diff
--- a/extra/control-devel/devel/balancmr.m	Wed Jan 18 19:25:54 2012 +0000
+++ b/extra/control-devel/devel/balancmr.m	Wed Jan 18 20:29:08 2012 +0000
@@ -16,224 +16,12 @@
 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{opt}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{})
-##
-## Model order reduction by frequency weighted Balanced Truncation Approximation (BTA) method.
-## The aim of model reduction is to find an LTI system @var{Gr} of order
-## @var{nr} (nr < n) such that the input-output behaviour of @var{Gr}
-## approximates the one from original system @var{G}.
-##
-## BTA is an absolute error method which tries to minimize
-## @iftex
-## @tex
-## $$ || G - G_r ||_{\\infty} = min $$
-## $$ || V \\ (G - G_r) \\ W ||_{\\infty} = min $$
-## @end tex
-## @end iftex
-## @ifnottex
-## @example
-## ||G-Gr||    = min
-##         inf
-##
-## ||V (G-Gr) W||    = min
-##               inf
-## @end example
-## @end ifnottex
-## where @var{V} and @var{W} denote output and input weightings.
-##
-##
-## @strong{Inputs}
-## @table @var
-## @item G
-## LTI model to be reduced.
-## @item nr
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically according
-## to the description of key @var{'order'}.
-## @item @dots{}
-## Optional pairs of keys and values.  @code{"key1", value1, "key2", value2}.
-## @item opt
-## Optional struct with keys as field names.
-## Struct @var{opt} can be created directly or
-## by command @command{options}.  @code{opt.key1 = value1, opt.key2 = value2}.
-## @end table
-##
-## @strong{Outputs}
-## @table @var
-## @item Gr
-## Reduced order state-space model.
-## @item info
-## Struct containing additional information.
-## @table @var
-## @item info.n
-## The order of the original system @var{G}.
-## @item info.ns
-## The order of the @var{alpha}-stable subsystem of the original system @var{G}.
-## @item info.hsv
-## The Hankel singular values of the @var{alpha}-stable part of
-## the original system @var{G}, ordered decreasingly.
-## @item info.nu
-## The order of the @var{alpha}-unstable subsystem of both the original
-## system @var{G} and the reduced-order system @var{Gr}.
-## @item info.nr
-## The order of the obtained reduced order system @var{Gr}.
-## @end table
-## @end table
-##
-##
-## @strong{Option Keys and Values}
-## @table @var
-## @item 'order', 'nr'
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically such that states with
-## Hankel singular values @var{info.hsv} > @var{tol1} are retained.
-##
-## @item 'left', 'output'
-## LTI model of the left/output frequency weighting @var{V}.
-## Default value is an identity matrix.
-##
-## @item 'right', 'input'
-## LTI model of the right/input frequency weighting @var{W}.
-## Default value is an identity matrix.
-##
-## @item 'method'
-## Approximation method for the L-infinity norm to be used as follows:
-## @table @var
-## @item 'sr', 'b'
-## Use the square-root Balance & Truncate method.
-## @item 'bfsr', 'f'
-## Use the balancing-free square-root Balance & Truncate method.  Default method.
-## @end table
-##
-## @item 'alpha'
-## Specifies the ALPHA-stability boundary for the eigenvalues
-## of the state dynamics matrix @var{G.A}.  For a continuous-time
-## system, ALPHA <= 0 is the boundary value for
-## the real parts of eigenvalues, while for a discrete-time
-## system, 0 <= ALPHA <= 1 represents the
-## boundary value for the moduli of eigenvalues.
-## The ALPHA-stability domain does not include the boundary.
-## Default value is 0 for continuous-time systems and
-## 1 for discrete-time systems.
-##
-## @item 'tol1'
-## If @var{'order'} is not specified, @var{tol1} contains the tolerance for
-## determining the order of the reduced model.
-## For model reduction, the recommended value of @var{tol1} is
-## c*info.hsv(1), where c lies in the interval [0.00001, 0.001].
-## Default value is info.ns*eps*info.hsv(1).
-## If @var{'order'} is specified, the value of @var{tol1} is ignored.
-##
-## @item 'tol2'
-## The tolerance for determining the order of a minimal
-## realization of the ALPHA-stable part of the given
-## model.  TOL2 <= TOL1.
-## If not specified, ns*eps*info.hsv(1) is chosen.
-##
-## @item 'gram-ctrb'
-## Specifies the choice of frequency-weighted controllability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'gram-obsv'
-## Specifies the choice of frequency-weighted observability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'alpha-ctrb'
-## Combination method parameter for defining the
-## frequency-weighted controllability Grammian.
-## abs(alphac) <= 1.
-## If alphac = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphac = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'alpha-obsv'
-## Combination method parameter for defining the
-## frequency-weighted observability Grammian.
-## abs(alphao) <= 1.
-## If alphao = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphao = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'equil', 'scale'
-## Boolean indicating whether equilibration (scaling) should be
-## performed on system @var{G} prior to order reduction.
-## Default value is true if @code{G.scaled == false} and
-## false if @code{G.scaled == true}.
-## @end table
-##
-##
-## UNSTABLE (from bstmodred)
-##
-## MIMO (from bstmodred)
-##
-## Approximation Properties:
-## @itemize @bullet
-## @item
-## Guaranteed stability of reduced models
-## @item
-## Lower guaranteed error bound
-## @item
-## Guaranteed a priori error bound
-## @iftex
-## @tex
-## $$ \\sigma_{r+1} \\leq || (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\sigma_j $$
-## @end tex
-## @end iftex
-## @end itemize
-##
-##
-## @strong{References}@*
-## [1] Enns, D.
-## Model reduction with balanced realizations: An error bound
-## and a frequency weighted generalization.
-## Proc. 23-th CDC, Las Vegas, pp. 127-132, 1984.
-##
-## [2] Lin, C.-A. and Chiu, T.-Y.
-## Model reduction via frequency-weighted balanced realization.
-## Control Theory and Advanced Technology, vol. 8,
-## pp. 341-351, 1992.
-##
-## [3] Sreeram, V., Anderson, B.D.O and Madievski, A.G.
-## New results on frequency weighted balanced reduction
-## technique.
-## Proc. ACC, Seattle, Washington, pp. 4004-4009, 1995.
-##
-## [4] Varga, A. and Anderson, B.D.O.
-## Square-root balancing-free methods for the frequency-weighted
-## balancing related model reduction.
-## (report in preparation)
-##
-##
-## @strong{Algorithm}@*
-## Uses SLICOT AB09ID by courtesy of
-## @uref{http://www.slicot.org, NICONET e.V.}
+## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} balancmr (@var{G}, @dots{})
+## Wrapper for @command{btamodred}.
 ## @end deftypefn
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
-## Created: Januar 2012
+## Created: January 2012
 ## Version: 0.1
 
 function [Gr, info] = balancmr (varargin)
@@ -248,60 +36,3 @@
   [Gr, info] = btamodred (varargin{:});
 
 endfunction
-
-
-%!shared Mo, Me, Info, HSVe
-%! A =  [ -26.4000,    6.4023,    4.3868;
-%!         32.0000,         0,         0;
-%!               0,    8.0000,         0 ];
-%!
-%! B =  [       16
-%!               0
-%!               0 ];
-%!
-%! C =  [   9.2994     1.1624     0.1090 ];
-%!
-%! D =  [        0 ];
-%!
-%! G = ss (A, B, C, D);  % "scaled", false
-%!
-%! AV = [  -1.0000,         0,    4.0000,   -9.2994,   -1.1624,   -0.1090;
-%!               0,    2.0000,         0,   -9.2994,   -1.1624,   -0.1090;
-%!               0,         0,   -3.0000,   -9.2994,   -1.1624,   -0.1090;
-%!         16.0000,   16.0000,   16.0000,  -26.4000,    6.4023,    4.3868;
-%!               0,         0,         0,   32.0000,         0,         0;
-%!               0,         0,         0,         0,    8.0000,         0 ];
-%!
-%! BV = [        1
-%!               1
-%!               1
-%!               0
-%!               0
-%!               0 ];
-%!
-%! CV = [        1          1          1          0          0          0 ];
-%!
-%! DV = [        0 ];
-%!
-%! V = ss (AV, BV, CV, DV);
-%!
-%! [Gr, Info] = btamodred (G, 2, "left", V);
-%! [Ao, Bo, Co, Do] = ssdata (Gr);
-%!
-%! Ae = [  9.1900   0.0000
-%!         0.0000 -34.5297 ];
-%!
-%! Be = [ 11.9593
-%!        16.9329 ];
-%!
-%! Ce = [  2.8955   6.9152 ];
-%!
-%! De = [  0.0000 ];
-%!
-%! HSVe = [  3.8253   0.2005 ].';
-%!
-%! Mo = [Ao, Bo; Co, Do];
-%! Me = [Ae, Be; Ce, De];
-%!
-%!assert (Mo, Me, 1e-4);
-%!assert (Info.hsv, HSVe, 1e-4);
--- a/extra/control-devel/devel/balred.m	Wed Jan 18 19:25:54 2012 +0000
+++ b/extra/control-devel/devel/balred.m	Wed Jan 18 20:29:08 2012 +0000
@@ -16,224 +16,12 @@
 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{opt}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{})
-##
-## Model order reduction by frequency weighted Balanced Truncation Approximation (BTA) method.
-## The aim of model reduction is to find an LTI system @var{Gr} of order
-## @var{nr} (nr < n) such that the input-output behaviour of @var{Gr}
-## approximates the one from original system @var{G}.
-##
-## BTA is an absolute error method which tries to minimize
-## @iftex
-## @tex
-## $$ || G - G_r ||_{\\infty} = min $$
-## $$ || V \\ (G - G_r) \\ W ||_{\\infty} = min $$
-## @end tex
-## @end iftex
-## @ifnottex
-## @example
-## ||G-Gr||    = min
-##         inf
-##
-## ||V (G-Gr) W||    = min
-##               inf
-## @end example
-## @end ifnottex
-## where @var{V} and @var{W} denote output and input weightings.
-##
-##
-## @strong{Inputs}
-## @table @var
-## @item G
-## LTI model to be reduced.
-## @item nr
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically according
-## to the description of key @var{'order'}.
-## @item @dots{}
-## Optional pairs of keys and values.  @code{"key1", value1, "key2", value2}.
-## @item opt
-## Optional struct with keys as field names.
-## Struct @var{opt} can be created directly or
-## by command @command{options}.  @code{opt.key1 = value1, opt.key2 = value2}.
-## @end table
-##
-## @strong{Outputs}
-## @table @var
-## @item Gr
-## Reduced order state-space model.
-## @item info
-## Struct containing additional information.
-## @table @var
-## @item info.n
-## The order of the original system @var{G}.
-## @item info.ns
-## The order of the @var{alpha}-stable subsystem of the original system @var{G}.
-## @item info.hsv
-## The Hankel singular values of the @var{alpha}-stable part of
-## the original system @var{G}, ordered decreasingly.
-## @item info.nu
-## The order of the @var{alpha}-unstable subsystem of both the original
-## system @var{G} and the reduced-order system @var{Gr}.
-## @item info.nr
-## The order of the obtained reduced order system @var{Gr}.
-## @end table
-## @end table
-##
-##
-## @strong{Option Keys and Values}
-## @table @var
-## @item 'order', 'nr'
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically such that states with
-## Hankel singular values @var{info.hsv} > @var{tol1} are retained.
-##
-## @item 'left', 'output'
-## LTI model of the left/output frequency weighting @var{V}.
-## Default value is an identity matrix.
-##
-## @item 'right', 'input'
-## LTI model of the right/input frequency weighting @var{W}.
-## Default value is an identity matrix.
-##
-## @item 'method'
-## Approximation method for the L-infinity norm to be used as follows:
-## @table @var
-## @item 'sr', 'b'
-## Use the square-root Balance & Truncate method.
-## @item 'bfsr', 'f'
-## Use the balancing-free square-root Balance & Truncate method.  Default method.
-## @end table
-##
-## @item 'alpha'
-## Specifies the ALPHA-stability boundary for the eigenvalues
-## of the state dynamics matrix @var{G.A}.  For a continuous-time
-## system, ALPHA <= 0 is the boundary value for
-## the real parts of eigenvalues, while for a discrete-time
-## system, 0 <= ALPHA <= 1 represents the
-## boundary value for the moduli of eigenvalues.
-## The ALPHA-stability domain does not include the boundary.
-## Default value is 0 for continuous-time systems and
-## 1 for discrete-time systems.
-##
-## @item 'tol1'
-## If @var{'order'} is not specified, @var{tol1} contains the tolerance for
-## determining the order of the reduced model.
-## For model reduction, the recommended value of @var{tol1} is
-## c*info.hsv(1), where c lies in the interval [0.00001, 0.001].
-## Default value is info.ns*eps*info.hsv(1).
-## If @var{'order'} is specified, the value of @var{tol1} is ignored.
-##
-## @item 'tol2'
-## The tolerance for determining the order of a minimal
-## realization of the ALPHA-stable part of the given
-## model.  TOL2 <= TOL1.
-## If not specified, ns*eps*info.hsv(1) is chosen.
-##
-## @item 'gram-ctrb'
-## Specifies the choice of frequency-weighted controllability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'gram-obsv'
-## Specifies the choice of frequency-weighted observability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'alpha-ctrb'
-## Combination method parameter for defining the
-## frequency-weighted controllability Grammian.
-## abs(alphac) <= 1.
-## If alphac = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphac = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'alpha-obsv'
-## Combination method parameter for defining the
-## frequency-weighted observability Grammian.
-## abs(alphao) <= 1.
-## If alphao = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphao = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'equil', 'scale'
-## Boolean indicating whether equilibration (scaling) should be
-## performed on system @var{G} prior to order reduction.
-## Default value is true if @code{G.scaled == false} and
-## false if @code{G.scaled == true}.
-## @end table
-##
-##
-## UNSTABLE (from bstmodred)
-##
-## MIMO (from bstmodred)
-##
-## Approximation Properties:
-## @itemize @bullet
-## @item
-## Guaranteed stability of reduced models
-## @item
-## Lower guaranteed error bound
-## @item
-## Guaranteed a priori error bound
-## @iftex
-## @tex
-## $$ \\sigma_{r+1} \\leq || (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\sigma_j $$
-## @end tex
-## @end iftex
-## @end itemize
-##
-##
-## @strong{References}@*
-## [1] Enns, D.
-## Model reduction with balanced realizations: An error bound
-## and a frequency weighted generalization.
-## Proc. 23-th CDC, Las Vegas, pp. 127-132, 1984.
-##
-## [2] Lin, C.-A. and Chiu, T.-Y.
-## Model reduction via frequency-weighted balanced realization.
-## Control Theory and Advanced Technology, vol. 8,
-## pp. 341-351, 1992.
-##
-## [3] Sreeram, V., Anderson, B.D.O and Madievski, A.G.
-## New results on frequency weighted balanced reduction
-## technique.
-## Proc. ACC, Seattle, Washington, pp. 4004-4009, 1995.
-##
-## [4] Varga, A. and Anderson, B.D.O.
-## Square-root balancing-free methods for the frequency-weighted
-## balancing related model reduction.
-## (report in preparation)
-##
-##
-## @strong{Algorithm}@*
-## Uses SLICOT AB09ID by courtesy of
-## @uref{http://www.slicot.org, NICONET e.V.}
+## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} balred (@var{G}, @dots{})
+## Wrapper for @command{spamodred}.
 ## @end deftypefn
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
-## Created: Januar 2012
+## Created: January 2012
 ## Version: 0.1
 
 function [Gr, info] = balred (varargin)
@@ -248,60 +36,3 @@
   [Gr, info] = spamodred (varargin{:});
 
 endfunction
-
-
-%!shared Mo, Me, Info, HSVe
-%! A =  [ -26.4000,    6.4023,    4.3868;
-%!         32.0000,         0,         0;
-%!               0,    8.0000,         0 ];
-%!
-%! B =  [       16
-%!               0
-%!               0 ];
-%!
-%! C =  [   9.2994     1.1624     0.1090 ];
-%!
-%! D =  [        0 ];
-%!
-%! G = ss (A, B, C, D);  % "scaled", false
-%!
-%! AV = [  -1.0000,         0,    4.0000,   -9.2994,   -1.1624,   -0.1090;
-%!               0,    2.0000,         0,   -9.2994,   -1.1624,   -0.1090;
-%!               0,         0,   -3.0000,   -9.2994,   -1.1624,   -0.1090;
-%!         16.0000,   16.0000,   16.0000,  -26.4000,    6.4023,    4.3868;
-%!               0,         0,         0,   32.0000,         0,         0;
-%!               0,         0,         0,         0,    8.0000,         0 ];
-%!
-%! BV = [        1
-%!               1
-%!               1
-%!               0
-%!               0
-%!               0 ];
-%!
-%! CV = [        1          1          1          0          0          0 ];
-%!
-%! DV = [        0 ];
-%!
-%! V = ss (AV, BV, CV, DV);
-%!
-%! [Gr, Info] = btamodred (G, 2, "left", V);
-%! [Ao, Bo, Co, Do] = ssdata (Gr);
-%!
-%! Ae = [  9.1900   0.0000
-%!         0.0000 -34.5297 ];
-%!
-%! Be = [ 11.9593
-%!        16.9329 ];
-%!
-%! Ce = [  2.8955   6.9152 ];
-%!
-%! De = [  0.0000 ];
-%!
-%! HSVe = [  3.8253   0.2005 ].';
-%!
-%! Mo = [Ao, Bo; Co, Do];
-%! Me = [Ae, Be; Ce, De];
-%!
-%!assert (Mo, Me, 1e-4);
-%!assert (Info.hsv, HSVe, 1e-4);
--- a/extra/control-devel/devel/bstmr.m	Wed Jan 18 19:25:54 2012 +0000
+++ b/extra/control-devel/devel/bstmr.m	Wed Jan 18 20:29:08 2012 +0000
@@ -16,224 +16,12 @@
 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{opt}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{})
-##
-## Model order reduction by frequency weighted Balanced Truncation Approximation (BTA) method.
-## The aim of model reduction is to find an LTI system @var{Gr} of order
-## @var{nr} (nr < n) such that the input-output behaviour of @var{Gr}
-## approximates the one from original system @var{G}.
-##
-## BTA is an absolute error method which tries to minimize
-## @iftex
-## @tex
-## $$ || G - G_r ||_{\\infty} = min $$
-## $$ || V \\ (G - G_r) \\ W ||_{\\infty} = min $$
-## @end tex
-## @end iftex
-## @ifnottex
-## @example
-## ||G-Gr||    = min
-##         inf
-##
-## ||V (G-Gr) W||    = min
-##               inf
-## @end example
-## @end ifnottex
-## where @var{V} and @var{W} denote output and input weightings.
-##
-##
-## @strong{Inputs}
-## @table @var
-## @item G
-## LTI model to be reduced.
-## @item nr
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically according
-## to the description of key @var{'order'}.
-## @item @dots{}
-## Optional pairs of keys and values.  @code{"key1", value1, "key2", value2}.
-## @item opt
-## Optional struct with keys as field names.
-## Struct @var{opt} can be created directly or
-## by command @command{options}.  @code{opt.key1 = value1, opt.key2 = value2}.
-## @end table
-##
-## @strong{Outputs}
-## @table @var
-## @item Gr
-## Reduced order state-space model.
-## @item info
-## Struct containing additional information.
-## @table @var
-## @item info.n
-## The order of the original system @var{G}.
-## @item info.ns
-## The order of the @var{alpha}-stable subsystem of the original system @var{G}.
-## @item info.hsv
-## The Hankel singular values of the @var{alpha}-stable part of
-## the original system @var{G}, ordered decreasingly.
-## @item info.nu
-## The order of the @var{alpha}-unstable subsystem of both the original
-## system @var{G} and the reduced-order system @var{Gr}.
-## @item info.nr
-## The order of the obtained reduced order system @var{Gr}.
-## @end table
-## @end table
-##
-##
-## @strong{Option Keys and Values}
-## @table @var
-## @item 'order', 'nr'
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically such that states with
-## Hankel singular values @var{info.hsv} > @var{tol1} are retained.
-##
-## @item 'left', 'output'
-## LTI model of the left/output frequency weighting @var{V}.
-## Default value is an identity matrix.
-##
-## @item 'right', 'input'
-## LTI model of the right/input frequency weighting @var{W}.
-## Default value is an identity matrix.
-##
-## @item 'method'
-## Approximation method for the L-infinity norm to be used as follows:
-## @table @var
-## @item 'sr', 'b'
-## Use the square-root Balance & Truncate method.
-## @item 'bfsr', 'f'
-## Use the balancing-free square-root Balance & Truncate method.  Default method.
-## @end table
-##
-## @item 'alpha'
-## Specifies the ALPHA-stability boundary for the eigenvalues
-## of the state dynamics matrix @var{G.A}.  For a continuous-time
-## system, ALPHA <= 0 is the boundary value for
-## the real parts of eigenvalues, while for a discrete-time
-## system, 0 <= ALPHA <= 1 represents the
-## boundary value for the moduli of eigenvalues.
-## The ALPHA-stability domain does not include the boundary.
-## Default value is 0 for continuous-time systems and
-## 1 for discrete-time systems.
-##
-## @item 'tol1'
-## If @var{'order'} is not specified, @var{tol1} contains the tolerance for
-## determining the order of the reduced model.
-## For model reduction, the recommended value of @var{tol1} is
-## c*info.hsv(1), where c lies in the interval [0.00001, 0.001].
-## Default value is info.ns*eps*info.hsv(1).
-## If @var{'order'} is specified, the value of @var{tol1} is ignored.
-##
-## @item 'tol2'
-## The tolerance for determining the order of a minimal
-## realization of the ALPHA-stable part of the given
-## model.  TOL2 <= TOL1.
-## If not specified, ns*eps*info.hsv(1) is chosen.
-##
-## @item 'gram-ctrb'
-## Specifies the choice of frequency-weighted controllability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'gram-obsv'
-## Specifies the choice of frequency-weighted observability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'alpha-ctrb'
-## Combination method parameter for defining the
-## frequency-weighted controllability Grammian.
-## abs(alphac) <= 1.
-## If alphac = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphac = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'alpha-obsv'
-## Combination method parameter for defining the
-## frequency-weighted observability Grammian.
-## abs(alphao) <= 1.
-## If alphao = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphao = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'equil', 'scale'
-## Boolean indicating whether equilibration (scaling) should be
-## performed on system @var{G} prior to order reduction.
-## Default value is true if @code{G.scaled == false} and
-## false if @code{G.scaled == true}.
-## @end table
-##
-##
-## UNSTABLE (from bstmodred)
-##
-## MIMO (from bstmodred)
-##
-## Approximation Properties:
-## @itemize @bullet
-## @item
-## Guaranteed stability of reduced models
-## @item
-## Lower guaranteed error bound
-## @item
-## Guaranteed a priori error bound
-## @iftex
-## @tex
-## $$ \\sigma_{r+1} \\leq || (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\sigma_j $$
-## @end tex
-## @end iftex
-## @end itemize
-##
-##
-## @strong{References}@*
-## [1] Enns, D.
-## Model reduction with balanced realizations: An error bound
-## and a frequency weighted generalization.
-## Proc. 23-th CDC, Las Vegas, pp. 127-132, 1984.
-##
-## [2] Lin, C.-A. and Chiu, T.-Y.
-## Model reduction via frequency-weighted balanced realization.
-## Control Theory and Advanced Technology, vol. 8,
-## pp. 341-351, 1992.
-##
-## [3] Sreeram, V., Anderson, B.D.O and Madievski, A.G.
-## New results on frequency weighted balanced reduction
-## technique.
-## Proc. ACC, Seattle, Washington, pp. 4004-4009, 1995.
-##
-## [4] Varga, A. and Anderson, B.D.O.
-## Square-root balancing-free methods for the frequency-weighted
-## balancing related model reduction.
-## (report in preparation)
-##
-##
-## @strong{Algorithm}@*
-## Uses SLICOT AB09ID by courtesy of
-## @uref{http://www.slicot.org, NICONET e.V.}
+## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} bstmr (@var{G}, @dots{})
+## Wrapper for @command{bstmodred}.
 ## @end deftypefn
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
-## Created: Januar 2012
+## Created: January 2012
 ## Version: 0.1
 
 function [Gr, info] = bstmr (varargin)
@@ -248,60 +36,3 @@
   [Gr, info] = bstmodred (varargin{:});
 
 endfunction
-
-
-%!shared Mo, Me, Info, HSVe
-%! A =  [ -26.4000,    6.4023,    4.3868;
-%!         32.0000,         0,         0;
-%!               0,    8.0000,         0 ];
-%!
-%! B =  [       16
-%!               0
-%!               0 ];
-%!
-%! C =  [   9.2994     1.1624     0.1090 ];
-%!
-%! D =  [        0 ];
-%!
-%! G = ss (A, B, C, D);  % "scaled", false
-%!
-%! AV = [  -1.0000,         0,    4.0000,   -9.2994,   -1.1624,   -0.1090;
-%!               0,    2.0000,         0,   -9.2994,   -1.1624,   -0.1090;
-%!               0,         0,   -3.0000,   -9.2994,   -1.1624,   -0.1090;
-%!         16.0000,   16.0000,   16.0000,  -26.4000,    6.4023,    4.3868;
-%!               0,         0,         0,   32.0000,         0,         0;
-%!               0,         0,         0,         0,    8.0000,         0 ];
-%!
-%! BV = [        1
-%!               1
-%!               1
-%!               0
-%!               0
-%!               0 ];
-%!
-%! CV = [        1          1          1          0          0          0 ];
-%!
-%! DV = [        0 ];
-%!
-%! V = ss (AV, BV, CV, DV);
-%!
-%! [Gr, Info] = btamodred (G, 2, "left", V);
-%! [Ao, Bo, Co, Do] = ssdata (Gr);
-%!
-%! Ae = [  9.1900   0.0000
-%!         0.0000 -34.5297 ];
-%!
-%! Be = [ 11.9593
-%!        16.9329 ];
-%!
-%! Ce = [  2.8955   6.9152 ];
-%!
-%! De = [  0.0000 ];
-%!
-%! HSVe = [  3.8253   0.2005 ].';
-%!
-%! Mo = [Ao, Bo; Co, Do];
-%! Me = [Ae, Be; Ce, De];
-%!
-%!assert (Mo, Me, 1e-4);
-%!assert (Info.hsv, HSVe, 1e-4);
--- a/extra/control-devel/devel/hankelmr.m	Wed Jan 18 19:25:54 2012 +0000
+++ b/extra/control-devel/devel/hankelmr.m	Wed Jan 18 20:29:08 2012 +0000
@@ -16,224 +16,12 @@
 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{opt}, @dots{})
-## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{})
-##
-## Model order reduction by frequency weighted Balanced Truncation Approximation (BTA) method.
-## The aim of model reduction is to find an LTI system @var{Gr} of order
-## @var{nr} (nr < n) such that the input-output behaviour of @var{Gr}
-## approximates the one from original system @var{G}.
-##
-## BTA is an absolute error method which tries to minimize
-## @iftex
-## @tex
-## $$ || G - G_r ||_{\\infty} = min $$
-## $$ || V \\ (G - G_r) \\ W ||_{\\infty} = min $$
-## @end tex
-## @end iftex
-## @ifnottex
-## @example
-## ||G-Gr||    = min
-##         inf
-##
-## ||V (G-Gr) W||    = min
-##               inf
-## @end example
-## @end ifnottex
-## where @var{V} and @var{W} denote output and input weightings.
-##
-##
-## @strong{Inputs}
-## @table @var
-## @item G
-## LTI model to be reduced.
-## @item nr
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically according
-## to the description of key @var{'order'}.
-## @item @dots{}
-## Optional pairs of keys and values.  @code{"key1", value1, "key2", value2}.
-## @item opt
-## Optional struct with keys as field names.
-## Struct @var{opt} can be created directly or
-## by command @command{options}.  @code{opt.key1 = value1, opt.key2 = value2}.
-## @end table
-##
-## @strong{Outputs}
-## @table @var
-## @item Gr
-## Reduced order state-space model.
-## @item info
-## Struct containing additional information.
-## @table @var
-## @item info.n
-## The order of the original system @var{G}.
-## @item info.ns
-## The order of the @var{alpha}-stable subsystem of the original system @var{G}.
-## @item info.hsv
-## The Hankel singular values of the @var{alpha}-stable part of
-## the original system @var{G}, ordered decreasingly.
-## @item info.nu
-## The order of the @var{alpha}-unstable subsystem of both the original
-## system @var{G} and the reduced-order system @var{Gr}.
-## @item info.nr
-## The order of the obtained reduced order system @var{Gr}.
-## @end table
-## @end table
-##
-##
-## @strong{Option Keys and Values}
-## @table @var
-## @item 'order', 'nr'
-## The desired order of the resulting reduced order system @var{Gr}.
-## If not specified, @var{nr} is chosen automatically such that states with
-## Hankel singular values @var{info.hsv} > @var{tol1} are retained.
-##
-## @item 'left', 'output'
-## LTI model of the left/output frequency weighting @var{V}.
-## Default value is an identity matrix.
-##
-## @item 'right', 'input'
-## LTI model of the right/input frequency weighting @var{W}.
-## Default value is an identity matrix.
-##
-## @item 'method'
-## Approximation method for the L-infinity norm to be used as follows:
-## @table @var
-## @item 'sr', 'b'
-## Use the square-root Balance & Truncate method.
-## @item 'bfsr', 'f'
-## Use the balancing-free square-root Balance & Truncate method.  Default method.
-## @end table
-##
-## @item 'alpha'
-## Specifies the ALPHA-stability boundary for the eigenvalues
-## of the state dynamics matrix @var{G.A}.  For a continuous-time
-## system, ALPHA <= 0 is the boundary value for
-## the real parts of eigenvalues, while for a discrete-time
-## system, 0 <= ALPHA <= 1 represents the
-## boundary value for the moduli of eigenvalues.
-## The ALPHA-stability domain does not include the boundary.
-## Default value is 0 for continuous-time systems and
-## 1 for discrete-time systems.
-##
-## @item 'tol1'
-## If @var{'order'} is not specified, @var{tol1} contains the tolerance for
-## determining the order of the reduced model.
-## For model reduction, the recommended value of @var{tol1} is
-## c*info.hsv(1), where c lies in the interval [0.00001, 0.001].
-## Default value is info.ns*eps*info.hsv(1).
-## If @var{'order'} is specified, the value of @var{tol1} is ignored.
-##
-## @item 'tol2'
-## The tolerance for determining the order of a minimal
-## realization of the ALPHA-stable part of the given
-## model.  TOL2 <= TOL1.
-## If not specified, ns*eps*info.hsv(1) is chosen.
-##
-## @item 'gram-ctrb'
-## Specifies the choice of frequency-weighted controllability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'gram-obsv'
-## Specifies the choice of frequency-weighted observability
-## Grammian as follows:
-## @table @var
-## @item 'standard'
-## Choice corresponding to a combination method [4]
-## of the approaches of Enns [1] and Lin-Chiu [2,3].  Default method.
-## @item 'enhanced'
-## Choice corresponding to the stability enhanced
-## modified combination method of [4].
-## @end table
-##
-## @item 'alpha-ctrb'
-## Combination method parameter for defining the
-## frequency-weighted controllability Grammian.
-## abs(alphac) <= 1.
-## If alphac = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphac = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'alpha-obsv'
-## Combination method parameter for defining the
-## frequency-weighted observability Grammian.
-## abs(alphao) <= 1.
-## If alphao = 0, the choice of
-## Grammian corresponds to the method of Enns [1], while if
-## alphao = 1, the choice of Grammian corresponds
-## to the method of Lin and Chiu [2,3].
-## Default value is 0.
-##
-## @item 'equil', 'scale'
-## Boolean indicating whether equilibration (scaling) should be
-## performed on system @var{G} prior to order reduction.
-## Default value is true if @code{G.scaled == false} and
-## false if @code{G.scaled == true}.
-## @end table
-##
-##
-## UNSTABLE (from bstmodred)
-##
-## MIMO (from bstmodred)
-##
-## Approximation Properties:
-## @itemize @bullet
-## @item
-## Guaranteed stability of reduced models
-## @item
-## Lower guaranteed error bound
-## @item
-## Guaranteed a priori error bound
-## @iftex
-## @tex
-## $$ \\sigma_{r+1} \\leq || (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\sigma_j $$
-## @end tex
-## @end iftex
-## @end itemize
-##
-##
-## @strong{References}@*
-## [1] Enns, D.
-## Model reduction with balanced realizations: An error bound
-## and a frequency weighted generalization.
-## Proc. 23-th CDC, Las Vegas, pp. 127-132, 1984.
-##
-## [2] Lin, C.-A. and Chiu, T.-Y.
-## Model reduction via frequency-weighted balanced realization.
-## Control Theory and Advanced Technology, vol. 8,
-## pp. 341-351, 1992.
-##
-## [3] Sreeram, V., Anderson, B.D.O and Madievski, A.G.
-## New results on frequency weighted balanced reduction
-## technique.
-## Proc. ACC, Seattle, Washington, pp. 4004-4009, 1995.
-##
-## [4] Varga, A. and Anderson, B.D.O.
-## Square-root balancing-free methods for the frequency-weighted
-## balancing related model reduction.
-## (report in preparation)
-##
-##
-## @strong{Algorithm}@*
-## Uses SLICOT AB09ID by courtesy of
-## @uref{http://www.slicot.org, NICONET e.V.}
+## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} hankelmr (@var{G}, @dots{})
+## Wrapper for @command{hnamodred}.
 ## @end deftypefn
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
-## Created: Januar 2012
+## Created: January 2012
 ## Version: 0.1
 
 function [Gr, info] = hankelmr (varargin)
@@ -248,60 +36,3 @@
   [Gr, info] = hnamodred (varargin{:});
 
 endfunction
-
-
-%!shared Mo, Me, Info, HSVe
-%! A =  [ -26.4000,    6.4023,    4.3868;
-%!         32.0000,         0,         0;
-%!               0,    8.0000,         0 ];
-%!
-%! B =  [       16
-%!               0
-%!               0 ];
-%!
-%! C =  [   9.2994     1.1624     0.1090 ];
-%!
-%! D =  [        0 ];
-%!
-%! G = ss (A, B, C, D);  % "scaled", false
-%!
-%! AV = [  -1.0000,         0,    4.0000,   -9.2994,   -1.1624,   -0.1090;
-%!               0,    2.0000,         0,   -9.2994,   -1.1624,   -0.1090;
-%!               0,         0,   -3.0000,   -9.2994,   -1.1624,   -0.1090;
-%!         16.0000,   16.0000,   16.0000,  -26.4000,    6.4023,    4.3868;
-%!               0,         0,         0,   32.0000,         0,         0;
-%!               0,         0,         0,         0,    8.0000,         0 ];
-%!
-%! BV = [        1
-%!               1
-%!               1
-%!               0
-%!               0
-%!               0 ];
-%!
-%! CV = [        1          1          1          0          0          0 ];
-%!
-%! DV = [        0 ];
-%!
-%! V = ss (AV, BV, CV, DV);
-%!
-%! [Gr, Info] = btamodred (G, 2, "left", V);
-%! [Ao, Bo, Co, Do] = ssdata (Gr);
-%!
-%! Ae = [  9.1900   0.0000
-%!         0.0000 -34.5297 ];
-%!
-%! Be = [ 11.9593
-%!        16.9329 ];
-%!
-%! Ce = [  2.8955   6.9152 ];
-%!
-%! De = [  0.0000 ];
-%!
-%! HSVe = [  3.8253   0.2005 ].';
-%!
-%! Mo = [Ao, Bo; Co, Do];
-%! Me = [Ae, Be; Ce, De];
-%!
-%!assert (Mo, Me, 1e-4);
-%!assert (Info.hsv, HSVe, 1e-4);
--- a/extra/control-devel/devel/madievski.m	Wed Jan 18 19:25:54 2012 +0000
+++ b/extra/control-devel/devel/madievski.m	Wed Jan 18 20:29:08 2012 +0000
@@ -1,3 +1,5 @@
+%clear all, close all, clc;
+
 Ap1 = [  0.0         1.0
          0.0         0.0     ];
 
@@ -52,7 +54,7 @@
 
 K = ss (Ac, Bc, Cc, Dc);
 
-Kr = btaconred (P, K, 4, 'weight', 'both', 'feedback', '-')
+Kr = btaconred (P, K, 4, 'feedback', '-')
 
 
 tau = 0.1;
@@ -63,22 +65,78 @@
 F = 5 / (s + 5);
 
 L = P * K;
-Ld = Pd * Kd;
+%Ld = Pd * Kd;
+Lr = P * Kr;
 
 T = feedback (L);
-Td = feedback (Ld);
+%Td = feedback (Ld);
+Tr = feedback (Lr);
+
+w = {1e-2, 1e1};
 
 figure (1)
 step (T, 100)
 
 figure (2)
-bode (L)
+%bode (L)
+bode (K, w)
 
 figure (3)
-step (Td, 100)
+%step (Td, 100)
+step (Tr, 100)
 
 figure (4)
-bode (Ld)
+%bode (Ld)
+bode (Kr, w)
 
 figure (5)
-step (feedback (P*Kr), 100)
+%step (feedback (P*Kr), 100)
+
+
+
+[mag, pha, w] = bode (K, w);
+[magr, phar, wr] = bode (Kr, w);
+
+mag = 20 * log10 (mag);
+magr = 20 * log10 (magr);
+
+
+%figure (6)
+
+
+      xl_str = "Frequency [rad/s]";
+
+
+    subplot (2, 1, 1)
+    semilogx (w, mag, "b", wr, magr, "r")
+    axis ("tight")
+    ylim (__axis_margin__ (ylim))
+    grid ("on")
+    title ("Bode Diagrams of K and Kr")
+    ylabel ("Magnitude [dB]")
+
+    subplot (2, 1, 2)
+    semilogx (w, pha, "b", wr, phar, "r")
+    axis ("tight")
+    ylim (__axis_margin__ (ylim))
+    grid ("on")
+    xlabel (xl_str)
+    ylabel ("Phase [deg]")
+    legend ("K (8 states)", "Kr (4 states)", "location", "southwest")
+    
+    print -depsc2 madievski-bode.eps
+
+
+[y, t] = step (T, 100);
+[yr, tr] = step (Tr, 100);
+
+figure (6)
+plot (t, y, 'b', tr, yr, 'r')
+grid ('on')
+title ('Step Response of Closed Loop')
+xlabel ('Time [s]')
+ylabel ('Output [-]')
+legend ('K (8 states)', 'Kr (4 states)', 'Location', 'SouthEast')
+
+print -depsc2 madievski-step.eps
+