From: <par...@us...> - 2011-03-05 00:08:47
|
Revision: 8155 http://octave.svn.sourceforge.net/octave/?rev=8155&view=rev Author: paramaniac Date: 2011-03-05 00:08:39 +0000 (Sat, 05 Mar 2011) Log Message: ----------- control: fixed gain for dss models. need to fix makefiles later. Modified Paths: -------------- trunk/octave-forge/main/control/devel/zeromake.m trunk/octave-forge/main/control/inst/@lti/zero.m trunk/octave-forge/main/control/inst/@ss/__zero__.m trunk/octave-forge/main/control/src/TG04BX.f trunk/octave-forge/main/control/src/slag08bd.cc Added Paths: ----------- trunk/octave-forge/main/control/devel/zerotest.m trunk/octave-forge/main/control/doc/NEWS trunk/octave-forge/main/control/src/sltg04bx.cc Modified: trunk/octave-forge/main/control/devel/zeromake.m =================================================================== --- trunk/octave-forge/main/control/devel/zeromake.m 2011-03-04 23:55:52 UTC (rev 8154) +++ trunk/octave-forge/main/control/devel/zeromake.m 2011-03-05 00:08:39 UTC (rev 8155) @@ -1 +1,9 @@ -mkoctfile TG04BX.f MB02RD.f MB02SD.f \ No newline at end of file +homedir = pwd (); +develdir = fileparts (which ("makefile_zero")); +srcdir = [develdir, "/../src"]; +cd (srcdir); + +## gain of descriptor state-space models +mkoctfile "-Wl,-framework" "-Wl,vecLib" \ + sltg04bx.cc \ + TG04BX.f MB02RD.f MB02SD.f \ No newline at end of file Added: trunk/octave-forge/main/control/devel/zerotest.m =================================================================== --- trunk/octave-forge/main/control/devel/zerotest.m (rev 0) +++ trunk/octave-forge/main/control/devel/zerotest.m 2011-03-05 00:08:39 UTC (rev 8155) @@ -0,0 +1,16 @@ +P = ss (-2, 3, 4, 0) + +Pi = inv (P) + +p = pole (P) +[z, k] = zero (P) + +pi = pole (Pi) +[zi, ki] = zero (Pi) + + +%{ +P = dss (-2, 3, 4, 5, 1) +[z, k] = zero (P) +[z, k] = zero (ss (-2, 3, 4, 5)) +%} \ No newline at end of file Added: trunk/octave-forge/main/control/doc/NEWS =================================================================== --- trunk/octave-forge/main/control/doc/NEWS (rev 0) +++ trunk/octave-forge/main/control/doc/NEWS 2011-03-05 00:08:39 UTC (rev 8155) @@ -0,0 +1,17 @@ +=============================================================================== +control-2.0.1 Release Date: 2011-mm-dd Maintainer: luk...@gm... +=============================================================================== + +** lsim.m + -- Support time vectors not starting at zero. (Thanks to Rob Frohne) + -- Improved help text. + +** @lti/zero.m + -- The gain of descriptor state-space models is now computed correctly. + + +=============================================================================== +control-2.0.0 Release Date: 2011-02-08 Maintainer: luk...@gm... +=============================================================================== + +** First official release. \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@lti/zero.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/zero.m 2011-03-04 23:55:52 UTC (rev 8154) +++ trunk/octave-forge/main/control/inst/@lti/zero.m 2011-03-05 00:08:39 UTC (rev 8155) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -23,7 +23,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.1.1 function [zer, gain] = zero (sys) @@ -31,6 +31,6 @@ print_usage (); endif - [zer, gain] = __zero__ (sys); + [zer, gain] = __zero__ (sys, nargout); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@ss/__zero__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__zero__.m 2011-03-04 23:55:52 UTC (rev 8154) +++ trunk/octave-forge/main/control/inst/@ss/__zero__.m 2011-03-05 00:08:39 UTC (rev 8155) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -22,15 +22,21 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.2 +## Version: 0.3 -function [zer, gain] = __zero__ (sys) +function [zer, gain] = __zero__ (sys, argc) if (isempty (sys.e)) [zer, gain] = slab08nd (sys.a, sys.b, sys.c, sys.d); else - [zer, gain] = slag08bd (sys.a, sys.e, sys.b, sys.c, sys.d); - ## FIXME: I'm not sure whether the gain is always correct + zer = slag08bd (sys.a, sys.e, sys.b, sys.c, sys.d); + if (argc > 1 && issiso (sys)) + pol = pole (sys); + gain = sltg04bx (sys.a, sys.e, sys.b, sys.c, sys.d, \ + real (pol), imag (pol), real (zer), imag (zer)); + else + gain = []; + endif endif endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/src/TG04BX.f =================================================================== --- trunk/octave-forge/main/control/src/TG04BX.f 2011-03-04 23:55:52 UTC (rev 8154) +++ trunk/octave-forge/main/control/src/TG04BX.f 2011-03-05 00:08:39 UTC (rev 8155) @@ -1,4 +1,4 @@ - SUBROUTINE TG04BX( IP, IZ, E, A, LDA, B, C, D, PR, PI, ZR, ZI, + SUBROUTINE TG04BX( IP, IZ, A, LDA, E, B, C, D, PR, PI, ZR, ZI, $ GAIN, IWORK ) C C WARNING @@ -148,7 +148,7 @@ DOUBLE PRECISION D, GAIN INTEGER IP, IZ, LDA C .. Array Arguments .. - DOUBLE PRECISION E(LDA,*), A(LDA,*), B(*), C(*), PI(*), PR(*), + DOUBLE PRECISION A(LDA,*), E(LDA,*), B(*), C(*), PI(*), PR(*), $ ZI(*), ZR(*) INTEGER IWORK(*) C .. Local Scalars .. @@ -168,10 +168,10 @@ C C Quick return if possible. C - IF( IP.EQ.0 ) THEN - GAIN = ZERO - RETURN - END IF +C IF( IP.EQ.0 ) THEN +C GAIN = ZERO +C RETURN +C END IF C C Compute a suitable value for S0 . C @@ -197,8 +197,8 @@ C C Form A - S0*E . C - DO 30 J = 1, IP - DO 25 I = 1, IP + DO 30 J = 1, LDA + DO 25 I = 1, LDA A(I,J) = A(I,J) - S0*E(I,J) 25 CONTINUE 30 CONTINUE @@ -206,15 +206,19 @@ C Compute the LU factorization of the matrix A - S0*E C (guaranteed to be nonsingular). C - CALL MB02SD( IP, A, LDA, IWORK, INFO ) +C CALL MB02SD( IP, A, LDA, IWORK, INFO ) + CALL MB02SD( LDA, A, LDA, IWORK, INFO ) C C Solve the linear system (A - S0*E)*x = b . C - CALL MB02RD( 'No Transpose', IP, 1, A, LDA, IWORK, B, IP, INFO ) +C CALL MB02RD( 'No Transpose', IP, 1, A, LDA, IWORK, B, IP, INFO ) +C CALL MB02RD( 'No Transpose', IP, 1, A, LDA, IWORK, B, LDA, INFO ) + CALL MB02RD( 'No Transpose', LDA, 1, A, LDA, IWORK, B, LDA, INFO ) C -1 C Compute c*(S0*E - A) *b + d . C - GAIN = D - DDOT( IP, C, 1, B, 1 ) +C GAIN = D - DDOT( IP, C, 1, B, 1 ) + GAIN = D - DDOT( LDA, C, 1, B, 1 ) C C Multiply by the products in terms of poles and zeros in (1). C Modified: trunk/octave-forge/main/control/src/slag08bd.cc =================================================================== --- trunk/octave-forge/main/control/src/slag08bd.cc 2011-03-04 23:55:52 UTC (rev 8154) +++ trunk/octave-forge/main/control/src/slag08bd.cc 2011-03-05 00:08:39 UTC (rev 8155) @@ -1,6 +1,6 @@ /* -Copyright (C) 2010 Lukas F. Reichlin +Copyright (C) 2010, 2011 Lukas F. Reichlin This file is part of LTI Syncope. @@ -23,7 +23,7 @@ Author: Lukas Reichlin <luk...@gm...> Created: September 2010 -Version: 0.1 +Version: 0.2 */ @@ -195,22 +195,6 @@ if (info2 != 0) error ("dss: zero: slag08bd: DGGEV returned info = %d", info2); - // calculate gain - octave_value gain = Matrix (0, 0);; - - if (m == 1 && p == 1) // FIXME: I'm not sure of this - { - if (nfz < n) - gain = args(3).matrix_value () * (args(1).matrix_value ()).inverse () * xpow (args(0).matrix_value (), double (n-1-nfz)) * args(2).matrix_value (); - // gain = args(3).matrix_value () * xpow (args(0).matrix_value (), double (n-1-nfz)) * (args(1).matrix_value ()).inverse () * args(2).matrix_value (); - // NOTE: content of matrices has changed - // c * inv (e) * a^(n-1-nfz) * b ? - // c * a^(n-1-nfz) * inv (e) * b ? - // good examples needed where a^(n-1-nfz) != eye (n) - else - gain = d; - } - // assemble complex vector - adapted from DEFUN complex in data.cc // LAPACK DGGEV.f says: // @@ -236,7 +220,6 @@ // return values retval(0) = zero; - retval(1) = gain; } return retval; Added: trunk/octave-forge/main/control/src/sltg04bx.cc =================================================================== --- trunk/octave-forge/main/control/src/sltg04bx.cc (rev 0) +++ trunk/octave-forge/main/control/src/sltg04bx.cc 2011-03-05 00:08:39 UTC (rev 8155) @@ -0,0 +1,117 @@ +/* + +Copyright (C) 2011 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/>. + +Gain of descriptor state-space models. Based on SLICOT TB04BX.f. + +Author: Lukas Reichlin <luk...@gm...> +Created: March 2011 +Version: 0.1 + +*/ + +#include <octave/oct.h> +#include <f77-fcn.h> +#include "common.cc" +#include <complex> +#include <xpow.h> + +extern "C" +{ + int F77_FUNC (tg04bx, TG04BX) + (int& IP, int& IZ, + double* A, int& LDA, + double* E, + double* B, + double* C, + double* D, + double* PR, double* PI, + double* ZR, double* ZI, + double& GAIN, + int* IWORK); +} + +DEFUN_DLD (sltg04bx, args, nargout, + "-*- texinfo -*-\n\ +Slicot TG04BX Release 5.0\n\ +No argument checking.\n\ +For internal use only.") +{ + int nargin = args.length (); + octave_value_list retval; + + if (nargin != 9) + { + print_usage (); + } + else + { + // arguments in + Matrix a = args(0).matrix_value (); + Matrix e = args(1).matrix_value (); + Matrix b = args(2).matrix_value (); + Matrix c = args(3).matrix_value (); + Matrix d = args(4).matrix_value (); + + ColumnVector pr = args(5).column_vector_value (); + ColumnVector pi = args(6).column_vector_value (); + + ColumnVector zr = args(7).column_vector_value (); + ColumnVector zi = args(8).column_vector_value (); + + int n = a.rows (); // n: number of states + int ip = pr.length (); // ip: number of finite poles + int iz = zr.length (); // iz: number of zeros + + // For ss, IP = n is always true. + // However, dss models with poles at infinity + // (filtered by pole.m) may have IP <= n + + // Take pr.length == pi.length == ip for granted, + // and the same for iz, zr and zi. + + int lda = max (1, n); + + // arguments out + double gain; + + // workspace + OCTAVE_LOCAL_BUFFER (int, iwork, lda); + + + F77_XFCN (tg04bx, TG04BX, + (ip, iz, + a.fortran_vec (), lda, + e.fortran_vec (), + b.fortran_vec (), + c.fortran_vec (), + d.fortran_vec (), + pr.fortran_vec (), pi.fortran_vec (), + zr.fortran_vec (), zi.fortran_vec (), + gain, + iwork)); + + if (f77_exception_encountered) + error ("dss: zero: sltg04bx: exception in TG04BX"); + + // return values + retval(0) = octave_value (gain); + } + + return retval; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |