From: <par...@us...> - 2011-11-03 18:49:17
|
Revision: 8956 http://octave.svn.sourceforge.net/octave/?rev=8956&view=rev Author: paramaniac Date: 2011-11-03 18:49:11 +0000 (Thu, 03 Nov 2011) Log Message: ----------- control-devel: fix layout of error and warning messages Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/slab09hd.cc trunk/octave-forge/extra/control-devel/src/slab09id.cc trunk/octave-forge/extra/control-devel/src/slab09jd.cc Modified: trunk/octave-forge/extra/control-devel/src/slab09hd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09hd.cc 2011-11-03 17:21:17 UTC (rev 8955) +++ trunk/octave-forge/extra/control-devel/src/slab09hd.cc 2011-11-03 18:49:11 UTC (rev 8956) @@ -185,35 +185,33 @@ { switch (info) { - // FIXME: The code below looks nice, but the error message does not - // because there is much white space after each line break case 1: - error ("bstmodred: 1: the computation of the ordered real Schur form of A\ - failed"); + error ("bstmodred: 1: the computation of the ordered real Schur form of A " + "failed"); case 2: - error ("bstmodred: 2: the reduction of the Hamiltonian matrix to real\ - Schur form failed"); + error ("bstmodred: 2: the reduction of the Hamiltonian matrix to real " + "Schur form failed"); case 3: - error ("bstmodred: 3: the reordering of the real Schur form of the\ - Hamiltonian matrix failed"); + error ("bstmodred: 3: the reordering of the real Schur form of the " + "Hamiltonian matrix failed"); case 4: - error ("bstmodred: 4: the Hamiltonian matrix has less than N stable\ - eigenvalues"); + error ("bstmodred: 4: the Hamiltonian matrix has less than N stable " + "eigenvalues"); case 5: - error ("bstmodred: 5: the coefficient matrix U11 in the linear system\ - X*U11 = U21 to determine X is singular to working\ - precision"); + error ("bstmodred: 5: the coefficient matrix U11 in the linear system " + "X*U11 = U21 to determine X is singular to working " + "precision"); case 6: error ("bstmodred: 6: BETA = 0 and D has not a maximal row rank"); case 7: error ("bstmodred: 7: the computation of Hankel singular values failed"); case 8: - error ("bstmodred: 8: the separation of the ALPHA-stable/unstable diagonal\ - blocks failed because of very close eigenvalues"); + error ("bstmodred: 8: the separation of the ALPHA-stable/unstable diagonal " + "blocks failed because of very close eigenvalues"); case 9: - error ("bstmodred: 9: the resulting order of reduced stable part is less\ - than the number of unstable zeros of the stable\ - part"); + error ("bstmodred: 9: the resulting order of reduced stable part is less " + "than the number of unstable zeros of the stable " + "part"); default: error ("bstmodred: unknown error, info = %d", info); } @@ -225,26 +223,26 @@ switch (iwarn) { case 1: - warning ("bstmodred: 1: with ORDSEL = 'F', the selected order NR is greater\ - than NSMIN, the sum of the order of the\ - ALPHA-unstable part and the order of a minimal\ - realization of the ALPHA-stable part of the given\ - system; in this case, the resulting NR is set equal\ - to NSMIN."); + warning ("bstmodred: 1: with ORDSEL = 'F', the selected order NR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "system; in this case, the resulting NR is set equal " + "to NSMIN."); break; case 2: - warning ("bstmodred: 2: with ORDSEL = 'F', the selected order NR corresponds\ - to repeated singular values for the ALPHA-stable\ - part, which are neither all included nor all\ - excluded from the reduced model; in this case, the\ - resulting NR is automatically decreased to exclude\ - all repeated singular values."); + warning ("bstmodred: 2: with ORDSEL = 'F', the selected order NR corresponds " + "to repeated singular values for the ALPHA-stable " + "part, which are neither all included nor all " + "excluded from the reduced model; in this case, the " + "resulting NR is automatically decreased to exclude " + "all repeated singular values."); break; case 3: - warning ("bstmodred: 3: with ORDSEL = 'F', the selected order NR is less\ - than the order of the ALPHA-unstable part of the\ - given system; in this case NR is set equal to the\ - order of the ALPHA-unstable part."); + warning ("bstmodred: 3: with ORDSEL = 'F', the selected order NR is less " + "than the order of the ALPHA-unstable part of the " + "given system; in this case NR is set equal to the " + "order of the ALPHA-unstable part."); break; default: warning ("bstmodred: unknown warning, iwarn = %d", info); Modified: trunk/octave-forge/extra/control-devel/src/slab09id.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09id.cc 2011-11-03 17:21:17 UTC (rev 8955) +++ trunk/octave-forge/extra/control-devel/src/slab09id.cc 2011-11-03 18:49:11 UTC (rev 8956) @@ -326,41 +326,39 @@ { switch (info) { - // FIXME: The code below looks nice, but the error message does not - // because there is much white space after each line break case 1: - error ("modred: 1: the computation of the ordered real Schur form of A\ - failed"); + error ("modred: 1: the computation of the ordered real Schur form of A " + "failed"); case 2: - error ("modred: 2: the separation of the ALPHA-stable/unstable\ - diagonal blocks failed because of very close\ - eigenvalues"); + error ("modred: 2: the separation of the ALPHA-stable/unstable " + "diagonal blocks failed because of very close " + "eigenvalues"); case 3: - error ("modred: 3: the reduction to a real Schur form of the state\ - matrix of a minimal realization of V failed"); + error ("modred: 3: the reduction to a real Schur form of the state " + "matrix of a minimal realization of V failed"); case 4: - error ("modred: 4: a failure was detected during the ordering of the\ - real Schur form of the state matrix of a minimal\ - realization of V or in the iterative process to\ - compute a left coprime factorization with inner\ - denominator"); + error ("modred: 4: a failure was detected during the ordering of the " + "real Schur form of the state matrix of a minimal " + "realization of V or in the iterative process to " + "compute a left coprime factorization with inner " + "denominator"); case 5: - error ("modred: 5: if DICO = 'C' and the matrix AV has an observable\ - eigenvalue on the imaginary axis, or DICO = 'D' and\ - AV has an observable eigenvalue on the unit circle"); + error ("modred: 5: if DICO = 'C' and the matrix AV has an observable " + "eigenvalue on the imaginary axis, or DICO = 'D' and " + "AV has an observable eigenvalue on the unit circle"); case 6: - error ("modred: 6: the reduction to a real Schur form of the state\ - matrix of a minimal realization of W failed"); + error ("modred: 6: the reduction to a real Schur form of the state " + "matrix of a minimal realization of W failed"); case 7: - error ("modred: 7: a failure was detected during the ordering of the\ - real Schur form of the state matrix of a minimal\ - realization of W or in the iterative process to\ - compute a right coprime factorization with inner\ - denominator"); + error ("modred: 7: a failure was detected during the ordering of the " + "real Schur form of the state matrix of a minimal " + "realization of W or in the iterative process to " + "compute a right coprime factorization with inner " + "denominator"); case 8: - error ("modred: 8: if DICO = 'C' and the matrix AW has a controllable\ - eigenvalue on the imaginary axis, or DICO = 'D' and\ - AW has a controllable eigenvalue on the unit circle"); + error ("modred: 8: if DICO = 'C' and the matrix AW has a controllable " + "eigenvalue on the imaginary axis, or DICO = 'D' and " + "AW has a controllable eigenvalue on the unit circle"); case 9: error ("modred: 9: the computation of eigenvalues failed"); case 10: @@ -376,31 +374,31 @@ switch (iwarn) { case 1: - warning ("modred: 1: with ORDSEL = 'F', the selected order NR is greater\ - than NSMIN, the sum of the order of the\ - ALPHA-unstable part and the order of a minimal\ - realization of the ALPHA-stable part of the given\ - system; in this case, the resulting NR is set equal\ - to NSMIN."); + warning ("modred: 1: with ORDSEL = 'F', the selected order NR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "system; in this case, the resulting NR is set equal " + "to NSMIN."); break; case 2: - warning ("modred: 2: with ORDSEL = 'F', the selected order NR corresponds\ - to repeated singular values for the ALPHA-stable\ - part, which are neither all included nor all\ - excluded from the reduced model; in this case, the\ - resulting NR is automatically decreased to exclude\ - all repeated singular values."); + warning ("modred: 2: with ORDSEL = 'F', the selected order NR corresponds " + "to repeated singular values for the ALPHA-stable " + "part, which are neither all included nor all " + "excluded from the reduced model; in this case, the " + "resulting NR is automatically decreased to exclude " + "all repeated singular values."); break; case 3: - warning ("modred: 3: with ORDSEL = 'F', the selected order NR is less\ - than the order of the ALPHA-unstable part of the\ - given system; in this case NR is set equal to the\ - order of the ALPHA-unstable part."); + warning ("modred: 3: with ORDSEL = 'F', the selected order NR is less " + "than the order of the ALPHA-unstable part of the " + "given system; in this case NR is set equal to the " + "order of the ALPHA-unstable part."); break; default: - warning ("modred: 10+%d: %d violations of the numerical stability condition\ - occured during the assignment of eigenvalues in the\ - SLICOT Library routines SB08CD and/or SB08DD.", info, info); + warning ("modred: 10+%d: %d violations of the numerical stability condition " + "occured during the assignment of eigenvalues in the " + "SLICOT Library routines SB08CD and/or SB08DD.", info, info); } } Modified: trunk/octave-forge/extra/control-devel/src/slab09jd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09jd.cc 2011-11-03 17:21:17 UTC (rev 8955) +++ trunk/octave-forge/extra/control-devel/src/slab09jd.cc 2011-11-03 18:49:11 UTC (rev 8956) @@ -302,71 +302,69 @@ { switch (info) { - // FIXME: The code below looks nice, but the error message does not - // because there is much white space after each line break case 1: - error ("hnamodred: 1: the computation of the ordered real Schur form of A\ - failed"); + error ("hnamodred: 1: the computation of the ordered real Schur form of A " + "failed"); case 2: - error ("hnamodred: 2: the separation of the ALPHA-stable/unstable\ - diagonal blocks failed because of very close eigenvalues"); + error ("hnamodred: 2: the separation of the ALPHA-stable/unstable " + "diagonal blocks failed because of very close eigenvalues"); case 3: error ("hnamodred: 3: the reduction of AV to a real Schur form failed"); case 4: error ("hnamodred: 4: the reduction of AW to a real Schur form failed"); case 5: - error ("hnamodred: 5: the reduction to generalized Schur form of the\ - descriptor pair corresponding to the inverse of V\ - failed"); + error ("hnamodred: 5: the reduction to generalized Schur form of the " + "descriptor pair corresponding to the inverse of V " + "failed"); case 6: - error ("hnamodred: 6: the reduction to generalized Schur form of the\ - descriptor pair corresponding to the inverse of W\ - failed"); + error ("hnamodred: 6: the reduction to generalized Schur form of the " + "descriptor pair corresponding to the inverse of W " + "failed"); case 7: error ("hnamodred: 7: the computation of Hankel singular values failed"); case 8: - error ("hnamodred: 8: the computation of stable projection in the\ - Hankel-norm approximation algorithm failed"); + error ("hnamodred: 8: the computation of stable projection in the " + "Hankel-norm approximation algorithm failed"); case 9: - error ("hnamodred: 9: the order of computed stable projection in the\ - Hankel-norm approximation algorithm differs\ - from the order of Hankel-norm approximation"); + error ("hnamodred: 9: the order of computed stable projection in the " + "Hankel-norm approximation algorithm differs " + "from the order of Hankel-norm approximation"); case 10: - error ("hnamodred: 10: the reduction of AV-BV*inv(DV)*CV to a\ - real Schur form failed"); + error ("hnamodred: 10: the reduction of AV-BV*inv(DV)*CV to a " + "real Schur form failed"); case 11: - error ("hnamodred: 11: the reduction of AW-BW*inv(DW)*CW to a\ - real Schur form failed"); + error ("hnamodred: 11: the reduction of AW-BW*inv(DW)*CW to a " + "real Schur form failed"); case 12: - error ("hnamodred: 12: the solution of the Sylvester equation failed\ - because the poles of V (if JOBV = 'V') or of\ - conj(V) (if JOBV = 'C') are not distinct from\ - the poles of G1 (see METHOD)"); + error ("hnamodred: 12: the solution of the Sylvester equation failed " + "because the poles of V (if JOBV = 'V') or of " + "conj(V) (if JOBV = 'C') are not distinct from " + "the poles of G1 (see METHOD)"); case 13: - error ("hnamodred: 13: the solution of the Sylvester equation failed\ - because the poles of W (if JOBW = 'W') or of\ - conj(W) (if JOBW = 'C') are not distinct from\ - the poles of G1 (see METHOD)"); + error ("hnamodred: 13: the solution of the Sylvester equation failed " + "because the poles of W (if JOBW = 'W') or of " + "conj(W) (if JOBW = 'C') are not distinct from " + "the poles of G1 (see METHOD)"); case 14: - error ("hnamodred: 14: the solution of the Sylvester equation failed\ - because the zeros of V (if JOBV = 'I') or of\ - conj(V) (if JOBV = 'R') are not distinct from\ - the poles of G1sr (see METHOD)"); + error ("hnamodred: 14: the solution of the Sylvester equation failed " + "because the zeros of V (if JOBV = 'I') or of " + "conj(V) (if JOBV = 'R') are not distinct from " + "the poles of G1sr (see METHOD)"); case 15: - error ("hnamodred: 15: the solution of the Sylvester equation failed\ - because the zeros of W (if JOBW = 'I') or of\ - conj(W) (if JOBW = 'R') are not distinct from\ - the poles of G1sr (see METHOD)"); + error ("hnamodred: 15: the solution of the Sylvester equation failed " + "because the zeros of W (if JOBW = 'I') or of " + "conj(W) (if JOBW = 'R') are not distinct from " + "the poles of G1sr (see METHOD)"); case 16: - error ("hnamodred: 16: the solution of the generalized Sylvester system\ - failed because the zeros of V (if JOBV = 'I') or\ - of conj(V) (if JOBV = 'R') are not distinct from\ - the poles of G1sr (see METHOD)"); + error ("hnamodred: 16: the solution of the generalized Sylvester system " + "failed because the zeros of V (if JOBV = 'I') or " + "of conj(V) (if JOBV = 'R') are not distinct from " + "the poles of G1sr (see METHOD)"); case 17: - error ("hnamodred: 17: the solution of the generalized Sylvester system\ - failed because the zeros of W (if JOBW = 'I') or\ - of conj(W) (if JOBW = 'R') are not distinct from\ - the poles of G1sr (see METHOD)"); + error ("hnamodred: 17: the solution of the generalized Sylvester system " + "failed because the zeros of W (if JOBW = 'I') or " + "of conj(W) (if JOBW = 'R') are not distinct from " + "the poles of G1sr (see METHOD)"); case 18: error ("hnamodred: 18: op(V) is not antistable"); case 19: @@ -386,18 +384,18 @@ switch (iwarn) { case 1: - warning ("hnamodred: 1: with ORDSEL = 'F', the selected order NR is greater\ - than NSMIN, the sum of the order of the\ - ALPHA-unstable part and the order of a minimal\ - realization of the ALPHA-stable part of the given\ - system. In this case, the resulting NR is set equal\ - to NSMIN."); + warning ("hnamodred: 1: with ORDSEL = 'F', the selected order NR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "system. In this case, the resulting NR is set equal " + "to NSMIN."); break; case 2: - warning ("hnamodred: 2: with ORDSEL = 'F', the selected order NR is less\ - than the order of the ALPHA-unstable part of the\ - given system. In this case NR is set equal to the\ - order of the ALPHA-unstable part."); + warning ("hnamodred: 2: with ORDSEL = 'F', the selected order NR is less " + "than the order of the ALPHA-unstable part of the " + "given system. In this case NR is set equal to the " + "order of the ALPHA-unstable part."); break; default: warning ("hnamodred: unknown warning, iwarn = %d", info); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-09 20:27:08
|
Revision: 9347 http://octave.svn.sourceforge.net/octave/?rev=9347&view=rev Author: paramaniac Date: 2011-12-09 20:27:01 +0000 (Fri, 09 Dec 2011) Log Message: ----------- control-devel: cleaner C++ code for warning and error messages (Thanks to Hans Buchmann) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/common.cc trunk/octave-forge/extra/control-devel/src/slab09hd.cc Modified: trunk/octave-forge/extra/control-devel/src/common.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/common.cc 2011-12-09 19:19:00 UTC (rev 9346) +++ trunk/octave-forge/extra/control-devel/src/common.cc 2011-12-09 20:27:01 UTC (rev 9347) @@ -21,7 +21,7 @@ Author: Lukas Reichlin <luk...@gm...> Created: April 2010 -Version: 0.2 +Version: 0.3 */ @@ -56,3 +56,27 @@ else return b; } + +void error_msg (const char name[], int index, int max, const char* msg[]) +{ + if (index == 0) + return; + + if (index < 0) + error ("%s: the %d-th argument had an invalid value", name, index); + else if (index <= max) + error ("%s: %s", name, msg[index]); + else + error ("%s: unknown error, info = %d", name, index); +} + +void warning_msg (const char name[], int index, int max, const char* msg[]) +{ + if (index == 0) + return; + + if (index > 0 && index <= max) + warning ("%s: %s", name, msg[index]); + else + warning ("%s: unknown warning, iwarn = %d", name, index); +} Modified: trunk/octave-forge/extra/control-devel/src/slab09hd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09hd.cc 2011-12-09 19:19:00 UTC (rev 9346) +++ trunk/octave-forge/extra/control-devel/src/slab09hd.cc 2011-12-09 20:27:01 UTC (rev 9347) @@ -176,79 +176,51 @@ if (f77_exception_encountered) error ("bstmodred: exception in SLICOT subroutine AB09HD"); - - if (info != 0) - { - if (info < 0) - error ("bstmodred: the %d-th argument had an invalid value", info); - else - { - switch (info) - { - case 1: - error ("bstmodred: 1: the computation of the ordered real Schur form of A " - "failed"); - case 2: - error ("bstmodred: 2: the reduction of the Hamiltonian matrix to real " - "Schur form failed"); - case 3: - error ("bstmodred: 3: the reordering of the real Schur form of the " - "Hamiltonian matrix failed"); - case 4: - error ("bstmodred: 4: the Hamiltonian matrix has less than N stable " - "eigenvalues"); - case 5: - error ("bstmodred: 5: the coefficient matrix U11 in the linear system " - "X*U11 = U21 to determine X is singular to working " - "precision"); - case 6: - error ("bstmodred: 6: BETA = 0 and D has not a maximal row rank"); - case 7: - error ("bstmodred: 7: the computation of Hankel singular values failed"); - case 8: - error ("bstmodred: 8: the separation of the ALPHA-stable/unstable diagonal " - "blocks failed because of very close eigenvalues"); - case 9: - error ("bstmodred: 9: the resulting order of reduced stable part is less " - "than the number of unstable zeros of the stable " - "part"); - default: - error ("bstmodred: unknown error, info = %d", info); - } - } - } - if (iwarn != 0) - { - switch (iwarn) - { - case 1: - warning ("bstmodred: 1: with ORDSEL = 'F', the selected order NR is greater " - "than NSMIN, the sum of the order of the " - "ALPHA-unstable part and the order of a minimal " - "realization of the ALPHA-stable part of the given " - "system; in this case, the resulting NR is set equal " - "to NSMIN."); - break; - case 2: - warning ("bstmodred: 2: with ORDSEL = 'F', the selected order NR corresponds " - "to repeated singular values for the ALPHA-stable " - "part, which are neither all included nor all " - "excluded from the reduced model; in this case, the " - "resulting NR is automatically decreased to exclude " - "all repeated singular values."); - break; - case 3: - warning ("bstmodred: 3: with ORDSEL = 'F', the selected order NR is less " - "than the order of the ALPHA-unstable part of the " - "given system; in this case NR is set equal to the " - "order of the ALPHA-unstable part."); - break; - default: - warning ("bstmodred: unknown warning, iwarn = %d", info); - } - } + static const char* err_msg[] = { + "0: OK", + "1: the computation of the ordered real Schur form of A " + "failed", + "2: the reduction of the Hamiltonian matrix to real " + "Schur form failed", + "3: the reordering of the real Schur form of the " + "Hamiltonian matrix failed", + "4: the Hamiltonian matrix has less than N stable " + "eigenvalues", + "5: the coefficient matrix U11 in the linear system " + "X*U11 = U21 to determine X is singular to working " + "precision", + "6: BETA = 0 and D has not a maximal row rank", + "7: the computation of Hankel singular values failed", + "8: the separation of the ALPHA-stable/unstable diagonal " + "blocks failed because of very close eigenvalues", + "9: the resulting order of reduced stable part is less " + "than the number of unstable zeros of the stable " + "part"}; + + static const char* warn_msg[] = { + "0: OK", + "1: with ORDSEL = 'F', the selected order NR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "system; in this case, the resulting NR is set equal " + "to NSMIN.", + "2: with ORDSEL = 'F', the selected order NR corresponds " + "to repeated singular values for the ALPHA-stable " + "part, which are neither all included nor all " + "excluded from the reduced model; in this case, the " + "resulting NR is automatically decreased to exclude " + "all repeated singular values.", + "3: with ORDSEL = 'F', the selected order NR is less " + "than the order of the ALPHA-unstable part of the " + "given system; in this case NR is set equal to the " + "order of the ALPHA-unstable part."}; + + error_msg ("bstmodred", info, 9, err_msg); + warning_msg ("bstmodred", iwarn, 3, warn_msg); + // resize a.resize (nr, nr); b.resize (nr, m); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-09 21:28:11
|
Revision: 9348 http://octave.svn.sourceforge.net/octave/?rev=9348&view=rev Author: paramaniac Date: 2011-12-09 21:28:04 +0000 (Fri, 09 Dec 2011) Log Message: ----------- control-devel: convert to new error/warning format Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/slab09id.cc trunk/octave-forge/extra/control-devel/src/slab09jd.cc Modified: trunk/octave-forge/extra/control-devel/src/slab09id.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09id.cc 2011-12-09 20:27:01 UTC (rev 9347) +++ trunk/octave-forge/extra/control-devel/src/slab09id.cc 2011-12-09 21:28:04 UTC (rev 9348) @@ -317,91 +317,65 @@ if (f77_exception_encountered) error ("modred: exception in SLICOT subroutine AB09ID"); - - if (info != 0) - { - if (info < 0) - error ("modred: the %d-th argument had an invalid value", info); - else - { - switch (info) - { - case 1: - error ("modred: 1: the computation of the ordered real Schur form of A " - "failed"); - case 2: - error ("modred: 2: the separation of the ALPHA-stable/unstable " - "diagonal blocks failed because of very close " - "eigenvalues"); - case 3: - error ("modred: 3: the reduction to a real Schur form of the state " - "matrix of a minimal realization of V failed"); - case 4: - error ("modred: 4: a failure was detected during the ordering of the " - "real Schur form of the state matrix of a minimal " - "realization of V or in the iterative process to " - "compute a left coprime factorization with inner " - "denominator"); - case 5: - error ("modred: 5: if DICO = 'C' and the matrix AV has an observable " - "eigenvalue on the imaginary axis, or DICO = 'D' and " - "AV has an observable eigenvalue on the unit circle"); - case 6: - error ("modred: 6: the reduction to a real Schur form of the state " - "matrix of a minimal realization of W failed"); - case 7: - error ("modred: 7: a failure was detected during the ordering of the " - "real Schur form of the state matrix of a minimal " - "realization of W or in the iterative process to " - "compute a right coprime factorization with inner " - "denominator"); - case 8: - error ("modred: 8: if DICO = 'C' and the matrix AW has a controllable " - "eigenvalue on the imaginary axis, or DICO = 'D' and " - "AW has a controllable eigenvalue on the unit circle"); - case 9: - error ("modred: 9: the computation of eigenvalues failed"); - case 10: - error ("modred: 10: the computation of Hankel singular values failed"); - default: - error ("modred: unknown error, info = %d", info); - } - } - } - - if (iwarn != 0) - { - switch (iwarn) - { - case 1: - warning ("modred: 1: with ORDSEL = 'F', the selected order NR is greater " - "than NSMIN, the sum of the order of the " - "ALPHA-unstable part and the order of a minimal " - "realization of the ALPHA-stable part of the given " - "system; in this case, the resulting NR is set equal " - "to NSMIN."); - break; - case 2: - warning ("modred: 2: with ORDSEL = 'F', the selected order NR corresponds " - "to repeated singular values for the ALPHA-stable " - "part, which are neither all included nor all " - "excluded from the reduced model; in this case, the " - "resulting NR is automatically decreased to exclude " - "all repeated singular values."); - break; - case 3: - warning ("modred: 3: with ORDSEL = 'F', the selected order NR is less " - "than the order of the ALPHA-unstable part of the " - "given system; in this case NR is set equal to the " - "order of the ALPHA-unstable part."); - break; - default: - warning ("modred: 10+%d: %d violations of the numerical stability condition " - "occured during the assignment of eigenvalues in the " - "SLICOT Library routines SB08CD and/or SB08DD.", info, info); - } - } + + static const char* err_msg[] = { + "0: OK", + "1: the computation of the ordered real Schur form of A " + "failed", + "2: the separation of the ALPHA-stable/unstable " + "diagonal blocks failed because of very close " + "eigenvalues", + "3: the reduction to a real Schur form of the state " + "matrix of a minimal realization of V failed", + "4: a failure was detected during the ordering of the " + "real Schur form of the state matrix of a minimal " + "realization of V or in the iterative process to " + "compute a left coprime factorization with inner " + "denominator", + "5: if DICO = 'C' and the matrix AV has an observable " + "eigenvalue on the imaginary axis, or DICO = 'D' and " + "AV has an observable eigenvalue on the unit circle", + "6: the reduction to a real Schur form of the state " + "matrix of a minimal realization of W failed", + "7: a failure was detected during the ordering of the " + "real Schur form of the state matrix of a minimal " + "realization of W or in the iterative process to " + "compute a right coprime factorization with inner " + "denominator", + "8: if DICO = 'C' and the matrix AW has a controllable " + "eigenvalue on the imaginary axis, or DICO = 'D' and " + "AW has a controllable eigenvalue on the unit circle", + "9: the computation of eigenvalues failed", + "10: the computation of Hankel singular values failed"}; + + static const char* warn_msg[] = { + "0: OK", + "1: with ORDSEL = 'F', the selected order NR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "system; in this case, the resulting NR is set equal " + "to NSMIN.", + "2: with ORDSEL = 'F', the selected order NR corresponds " + "to repeated singular values for the ALPHA-stable " + "part, which are neither all included nor all " + "excluded from the reduced model; in this case, the " + "resulting NR is automatically decreased to exclude " + "all repeated singular values.", + "3: with ORDSEL = 'F', the selected order NR is less " + "than the order of the ALPHA-unstable part of the " + "given system; in this case NR is set equal to the " + "order of the ALPHA-unstable part.", + "10+%d: %d violations of the numerical stability condition " + "occured during the assignment of eigenvalues in the " + "SLICOT Library routines SB08CD and/or SB08DD."};//, info, info); + + // TODO: handle case 10+info + + error_msg ("modred", info, 10, err_msg); + warning_msg ("modred", iwarn, 4, warn_msg); + // resize a.resize (nr, nr); b.resize (nr, m); Modified: trunk/octave-forge/extra/control-devel/src/slab09jd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09jd.cc 2011-12-09 20:27:01 UTC (rev 9347) +++ trunk/octave-forge/extra/control-devel/src/slab09jd.cc 2011-12-09 21:28:04 UTC (rev 9348) @@ -292,116 +292,97 @@ if (f77_exception_encountered) error ("hnamodred: exception in SLICOT subroutine AB09JD"); - - if (info != 0) - { - //error ("hsvd: slab09jd: AB09JD returned info = %d", info); - if (info < 0) - error ("hnamodred: the %d-th argument had an invalid value", info); - else - { - switch (info) - { - case 1: - error ("hnamodred: 1: the computation of the ordered real Schur form of A " - "failed"); - case 2: - error ("hnamodred: 2: the separation of the ALPHA-stable/unstable " - "diagonal blocks failed because of very close eigenvalues"); - case 3: - error ("hnamodred: 3: the reduction of AV to a real Schur form failed"); - case 4: - error ("hnamodred: 4: the reduction of AW to a real Schur form failed"); - case 5: - error ("hnamodred: 5: the reduction to generalized Schur form of the " - "descriptor pair corresponding to the inverse of V " - "failed"); - case 6: - error ("hnamodred: 6: the reduction to generalized Schur form of the " - "descriptor pair corresponding to the inverse of W " - "failed"); - case 7: - error ("hnamodred: 7: the computation of Hankel singular values failed"); - case 8: - error ("hnamodred: 8: the computation of stable projection in the " - "Hankel-norm approximation algorithm failed"); - case 9: - error ("hnamodred: 9: the order of computed stable projection in the " - "Hankel-norm approximation algorithm differs " - "from the order of Hankel-norm approximation"); - case 10: - error ("hnamodred: 10: the reduction of AV-BV*inv(DV)*CV to a " - "real Schur form failed"); - case 11: - error ("hnamodred: 11: the reduction of AW-BW*inv(DW)*CW to a " - "real Schur form failed"); - case 12: - error ("hnamodred: 12: the solution of the Sylvester equation failed " - "because the poles of V (if JOBV = 'V') or of " - "conj(V) (if JOBV = 'C') are not distinct from " - "the poles of G1 (see METHOD)"); - case 13: - error ("hnamodred: 13: the solution of the Sylvester equation failed " - "because the poles of W (if JOBW = 'W') or of " - "conj(W) (if JOBW = 'C') are not distinct from " - "the poles of G1 (see METHOD)"); - case 14: - error ("hnamodred: 14: the solution of the Sylvester equation failed " - "because the zeros of V (if JOBV = 'I') or of " - "conj(V) (if JOBV = 'R') are not distinct from " - "the poles of G1sr (see METHOD)"); - case 15: - error ("hnamodred: 15: the solution of the Sylvester equation failed " - "because the zeros of W (if JOBW = 'I') or of " - "conj(W) (if JOBW = 'R') are not distinct from " - "the poles of G1sr (see METHOD)"); - case 16: - error ("hnamodred: 16: the solution of the generalized Sylvester system " - "failed because the zeros of V (if JOBV = 'I') or " - "of conj(V) (if JOBV = 'R') are not distinct from " - "the poles of G1sr (see METHOD)"); - case 17: - error ("hnamodred: 17: the solution of the generalized Sylvester system " - "failed because the zeros of W (if JOBW = 'I') or " - "of conj(W) (if JOBW = 'R') are not distinct from " - "the poles of G1sr (see METHOD)"); - case 18: - error ("hnamodred: 18: op(V) is not antistable"); - case 19: - error ("hnamodred: 19: op(W) is not antistable"); - case 20: - error ("hnamodred: 20: V is not invertible"); - case 21: - error ("hnamodred: 21: W is not invertible"); - default: - error ("hnamodred: unknown error, info = %d", info); - } - } - } - - if (iwarn != 0) - { - switch (iwarn) - { - case 1: - warning ("hnamodred: 1: with ORDSEL = 'F', the selected order NR is greater " - "than NSMIN, the sum of the order of the " - "ALPHA-unstable part and the order of a minimal " - "realization of the ALPHA-stable part of the given " - "system. In this case, the resulting NR is set equal " - "to NSMIN."); - break; - case 2: - warning ("hnamodred: 2: with ORDSEL = 'F', the selected order NR is less " - "than the order of the ALPHA-unstable part of the " - "given system. In this case NR is set equal to the " - "order of the ALPHA-unstable part."); - break; - default: - warning ("hnamodred: unknown warning, iwarn = %d", info); - } - } + + static const char* err_msg[] = { + "0: OK", + "1: the computation of the ordered real Schur form of A " + "failed", + + "2: the separation of the ALPHA-stable/unstable " + "diagonal blocks failed because of very close eigenvalues", + + "3: the reduction of AV to a real Schur form failed", + + "4: the reduction of AW to a real Schur form failed", + + "5: the reduction to generalized Schur form of the " + "descriptor pair corresponding to the inverse of V " + "failed", + + "6: the reduction to generalized Schur form of the " + "descriptor pair corresponding to the inverse of W " + "failed", + + "7: the computation of Hankel singular values failed", + + "8: the computation of stable projection in the " + "Hankel-norm approximation algorithm failed", + + "9: the order of computed stable projection in the " + "Hankel-norm approximation algorithm differs " + "from the order of Hankel-norm approximation", + + "10: the reduction of AV-BV*inv(DV)*CV to a " + "real Schur form failed", + + "11: the reduction of AW-BW*inv(DW)*CW to a " + "real Schur form failed", + + "12: the solution of the Sylvester equation failed " + "because the poles of V (if JOBV = 'V') or of " + "conj(V) (if JOBV = 'C') are not distinct from " + "the poles of G1 (see METHOD)", + + "13: the solution of the Sylvester equation failed " + "because the poles of W (if JOBW = 'W') or of " + "conj(W) (if JOBW = 'C') are not distinct from " + "the poles of G1 (see METHOD)", + + "14: the solution of the Sylvester equation failed " + "because the zeros of V (if JOBV = 'I') or of " + "conj(V) (if JOBV = 'R') are not distinct from " + "the poles of G1sr (see METHOD)", + + "15: the solution of the Sylvester equation failed " + "because the zeros of W (if JOBW = 'I') or of " + "conj(W) (if JOBW = 'R') are not distinct from " + "the poles of G1sr (see METHOD)", + + "16: the solution of the generalized Sylvester system " + "failed because the zeros of V (if JOBV = 'I') or " + "of conj(V) (if JOBV = 'R') are not distinct from " + "the poles of G1sr (see METHOD)", + + "17: the solution of the generalized Sylvester system " + "failed because the zeros of W (if JOBW = 'I') or " + "of conj(W) (if JOBW = 'R') are not distinct from " + "the poles of G1sr (see METHOD)", + + "18: op(V) is not antistable", + + "19: op(W) is not antistable", + + "20: V is not invertible", + + "21: W is not invertible"}; + + static const char* warn_msg[] = { + "0: OK", + "1: with ORDSEL = 'F', the selected order NR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "system. In this case, the resulting NR is set equal " + "to NSMIN.", + "2: with ORDSEL = 'F', the selected order NR is less " + "than the order of the ALPHA-unstable part of the " + "given system. In this case NR is set equal to the " + "order of the ALPHA-unstable part."}; + + error_msg ("hnamodred", info, 21, err_msg); + warning_msg ("hnamodred", iwarn, 2, warn_msg); + // resize a.resize (nr, nr); b.resize (nr, m); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-09 21:49:22
|
Revision: 9350 http://octave.svn.sourceforge.net/octave/?rev=9350&view=rev Author: paramaniac Date: 2011-12-09 21:49:15 +0000 (Fri, 09 Dec 2011) Log Message: ----------- control-devel: convert to new error/warning format (2) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/slsb16ad.cc trunk/octave-forge/extra/control-devel/src/slsb16bd.cc trunk/octave-forge/extra/control-devel/src/slsb16cd.cc Modified: trunk/octave-forge/extra/control-devel/src/slsb16ad.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slsb16ad.cc 2011-12-09 21:35:20 UTC (rev 9349) +++ trunk/octave-forge/extra/control-devel/src/slsb16ad.cc 2011-12-09 21:49:15 UTC (rev 9350) @@ -263,71 +263,45 @@ if (f77_exception_encountered) error ("conred: exception in SLICOT subroutine SB16AD"); - - if (info != 0) - { - if (info < 0) - error ("conred: the %d-th argument had an invalid value", info); - else - { - switch (info) - { - case 1: - error ("conred: 1: the closed-loop system is not well-posed; " - "its feedthrough matrix is (numerically) singular"); - case 2: - error ("conred: 2: the computation of the real Schur form of the " - "closed-loop state matrix failed"); - case 3: - error ("conred: 3: the closed-loop state matrix is not stable"); - case 4: - error ("conred: 4: the solution of a symmetric eigenproblem failed"); - case 5: - error ("conred: 5: the computation of the ordered real Schur form " - "of Ac failed"); - case 6: - error ("conred: 6: the separation of the ALPHA-stable/unstable " - "diagonal blocks failed because of very close eigenvalues"); - case 7: - error ("conred: 7: the computation of Hankel singular values failed"); - default: - error ("conred: unknown error, info = %d", info); - } - } - } - - if (iwarn != 0) - { - switch (iwarn) - { - case 1: - warning ("conred: 1: with ORDSEL = 'F', the selected order NCR is greater " - "than NSMIN, the sum of the order of the " - "ALPHA-unstable part and the order of a minimal " - "realization of the ALPHA-stable part of the given " - "controller; in this case, the resulting NCR is set " - "equal to NSMIN."); - break; - case 2: - warning ("conred: 2: with ORDSEL = 'F', the selected order NCR " - "corresponds to repeated singular values for the " - "ALPHA-stable part of the controller, which are " - "neither all included nor all excluded from the " - "reduced model; in this case, the resulting NCR is " - "automatically decreased to exclude all repeated " - "singular values."); - break; - case 3: - warning ("conred: 3: with ORDSEL = 'F', the selected order NCR is less " - "than the order of the ALPHA-unstable part of the " - "given controller. In this case NCR is set equal to " - "the order of the ALPHA-unstable part."); - break; - default: - warning ("conred: unknown warning, iwarn = %d", iwarn); - } - } + static const char* err_msg[] = { + "0: OK", + "1: the closed-loop system is not well-posed; " + "its feedthrough matrix is (numerically) singular", + "2: the computation of the real Schur form of the " + "closed-loop state matrix failed", + "3: the closed-loop state matrix is not stable", + "4: the solution of a symmetric eigenproblem failed", + "5: the computation of the ordered real Schur form " + "of Ac failed", + "6: the separation of the ALPHA-stable/unstable " + "diagonal blocks failed because of very close eigenvalues", + "7: the computation of Hankel singular values failed"}; + + static const char* warn_msg[] = { + "0: OK", + "1: with ORDSEL = 'F', the selected order NCR is greater " + "than NSMIN, the sum of the order of the " + "ALPHA-unstable part and the order of a minimal " + "realization of the ALPHA-stable part of the given " + "controller; in this case, the resulting NCR is set " + "equal to NSMIN.", + "2: with ORDSEL = 'F', the selected order NCR " + "corresponds to repeated singular values for the " + "ALPHA-stable part of the controller, which are " + "neither all included nor all excluded from the " + "reduced model; in this case, the resulting NCR is " + "automatically decreased to exclude all repeated " + "singular values.", + "3: with ORDSEL = 'F', the selected order NCR is less " + "than the order of the ALPHA-unstable part of the " + "given controller. In this case NCR is set equal to " + "the order of the ALPHA-unstable part."}; + + error_msg ("conred", info, 7, err_msg); + warning_msg ("conred", iwarn, 3, warn_msg); + + // resize ac.resize (ncr, ncr); bc.resize (ncr, p); // p: number of plant outputs Modified: trunk/octave-forge/extra/control-devel/src/slsb16bd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slsb16bd.cc 2011-12-09 21:35:20 UTC (rev 9349) +++ trunk/octave-forge/extra/control-devel/src/slsb16bd.cc 2011-12-09 21:49:15 UTC (rev 9350) @@ -226,50 +226,30 @@ if (f77_exception_encountered) - error ("conred: exception in SLICOT subroutine SB16BD"); - - if (info != 0) - { - if (info < 0) - error ("conred: the %d-th argument had an invalid value", info); - else - { - switch (info) - { - case 1: - error ("conred: 1: the reduction of A+G*C to a real Schur form " - "failed"); - case 2: - error ("conred: 2: the matrix A+G*C is not stable (if DICO = 'C'), " - "or not convergent (if DICO = 'D')"); - case 3: - error ("conred: 3: the computation of Hankel singular values failed"); - case 4: - error ("conred: 4: the reduction of A+B*F to a real Schur form " - "failed"); - case 5: - error ("conred: 5: the matrix A+B*F is not stable (if DICO = 'C'), " - "or not convergent (if DICO = 'D')"); - default: - error ("conred: unknown error, info = %d", info); - } - } - } - - if (iwarn != 0) - { - switch (iwarn) - { - case 1: - warning ("conred: 1: with ORDSEL = 'F', the selected order NCR is " - "greater than the order of a minimal " - "realization of the controller."); - break; - default: - warning ("conred: unknown warning, iwarn = %d", iwarn); - } - } + error ("cfconred: exception in SLICOT subroutine SB16BD"); + static const char* err_msg[] = { + "0: OK", + "1: the reduction of A+G*C to a real Schur form " + "failed", + "2: the matrix A+G*C is not stable (if DICO = 'C'), " + "or not convergent (if DICO = 'D')", + "3: the computation of Hankel singular values failed", + "4: the reduction of A+B*F to a real Schur form " + "failed", + "5: the matrix A+B*F is not stable (if DICO = 'C'), " + "or not convergent (if DICO = 'D')"}; + + static const char* warn_msg[] = { + "0: OK", + "1: with ORDSEL = 'F', the selected order NCR is " + "greater than the order of a minimal " + "realization of the controller."}; + + error_msg ("cfconred", info, 5, err_msg); + warning_msg ("cfconred", iwarn, 1, warn_msg); + + // resize a.resize (ncr, ncr); // Ac g.resize (ncr, p); // Bc Modified: trunk/octave-forge/extra/control-devel/src/slsb16cd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slsb16cd.cc 2011-12-09 21:35:20 UTC (rev 9349) +++ trunk/octave-forge/extra/control-devel/src/slsb16cd.cc 2011-12-09 21:49:15 UTC (rev 9350) @@ -191,58 +191,35 @@ if (f77_exception_encountered) - error ("conred: exception in SLICOT subroutine SB16CD"); - - if (info != 0) - { - if (info < 0) - error ("conred: the %d-th argument had an invalid value", info); - else - { - switch (info) - { - case 1: - error ("conred: 1: eigenvalue computation failure"); - case 2: - error ("conred: 2: the matrix A+G*C is not stable"); - case 3: - error ("conred: 3: the matrix A+B*F is not stable"); - case 4: - error ("conred: 4: the Lyapunov equation for computing the " - "observability Grammian is (nearly) singular"); - case 5: - error ("conred: 5: the Lyapunov equation for computing the " - "controllability Grammian is (nearly) singular"); - case 6: - error ("conred: 6: the computation of Hankel singular values failed"); - default: - error ("conred: unknown error, info = %d", info); - } - } - } - - if (iwarn != 0) - { - switch (iwarn) - { - case 1: - warning ("conred: 1: with ORDSEL = 'F', the selected order NCR is " - "greater than the order of a minimal realization " - "of the controller."); - break; - case 2: - warning ("conred: 2: with ORDSEL = 'F', the selected order NCR " - "corresponds to repeated singular values, which are " - "neither all included nor all excluded from the " - "reduced controller. In this case, the resulting NCR " - "is set automatically to the largest value such that " - "HSV(NCR) > HSV(NCR+1)."); - break; - default: - warning ("conred: unknown warning, iwarn = %d", iwarn); - } - } + error ("fwcfconred: exception in SLICOT subroutine SB16CD"); + static const char* err_msg[] = { + "0: OK", + "1: eigenvalue computation failure", + "2: the matrix A+G*C is not stable", + "3: the matrix A+B*F is not stable", + "4: the Lyapunov equation for computing the " + "observability Grammian is (nearly) singular", + "5: the Lyapunov equation for computing the " + "controllability Grammian is (nearly) singular", + "6: the computation of Hankel singular values failed"}; + + static const char* warn_msg[] = { + "0: OK", + "1: with ORDSEL = 'F', the selected order NCR is " + "greater than the order of a minimal realization " + "of the controller.", + "2: with ORDSEL = 'F', the selected order NCR " + "corresponds to repeated singular values, which are " + "neither all included nor all excluded from the " + "reduced controller. In this case, the resulting NCR " + "is set automatically to the largest value such that " + "HSV(NCR) > HSV(NCR+1)."}; + + error_msg ("fwcfconred", info, 6, err_msg); + warning_msg ("fwcfconred", iwarn, 2, warn_msg); + + // resize a.resize (ncr, ncr); // Ac g.resize (ncr, p); // Bc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-20 12:45:41
|
Revision: 9435 http://octave.svn.sourceforge.net/octave/?rev=9435&view=rev Author: paramaniac Date: 2011-12-20 12:45:30 +0000 (Tue, 20 Dec 2011) Log Message: ----------- control-devel: handle special warning case Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/common.cc trunk/octave-forge/extra/control-devel/src/slab09id.cc Modified: trunk/octave-forge/extra/control-devel/src/common.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/common.cc 2011-12-18 20:42:24 UTC (rev 9434) +++ trunk/octave-forge/extra/control-devel/src/common.cc 2011-12-20 12:45:30 UTC (rev 9435) @@ -80,3 +80,16 @@ else warning ("%s: unknown warning, iwarn = %d", name, index); } + +void warning_msg (const char name[], int index, int max, const char* msg[], int offset) +{ + if (index == 0) + return; + + if (index > 0 && index <= max) + warning ("%s: %s", name, msg[index]); + else if (index > offset) + warning ("%s: %d+%d: %d %s", name, offset, index-offset, index-offset, msg[max+1]); + else + warning ("%s: unknown warning, iwarn = %d", name, index); +} Modified: trunk/octave-forge/extra/control-devel/src/slab09id.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slab09id.cc 2011-12-18 20:42:24 UTC (rev 9434) +++ trunk/octave-forge/extra/control-devel/src/slab09id.cc 2011-12-20 12:45:30 UTC (rev 9435) @@ -367,14 +367,13 @@ "than the order of the ALPHA-unstable part of the " "given system; in this case NR is set equal to the " "order of the ALPHA-unstable part.", - "10+%d: %d violations of the numerical stability condition " +/* 10+%d: %d */ "violations of the numerical stability condition " "occured during the assignment of eigenvalues in the " - "SLICOT Library routines SB08CD and/or SB08DD."};//, info, info); + "SLICOT Library routines SB08CD and/or SB08DD."}; - // TODO: handle case 10+info error_msg ("modred", info, 10, err_msg); - warning_msg ("modred", iwarn, 4, warn_msg); + warning_msg ("modred", iwarn, 3, warn_msg, 10); // resize a.resize (nr, nr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-03-15 19:24:27
|
Revision: 9905 http://octave.svn.sourceforge.net/octave/?rev=9905&view=rev Author: paramaniac Date: 2012-03-15 19:24:20 +0000 (Thu, 15 Mar 2012) Log Message: ----------- control-devel: quicksave id draft code Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/slib01bd.cc Added Paths: ----------- trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/src/slib01bd.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slib01bd.cc 2012-03-15 17:44:49 UTC (rev 9904) +++ trunk/octave-forge/extra/control-devel/src/slib01bd.cc 2012-03-15 19:24:20 UTC (rev 9905) @@ -63,7 +63,7 @@ int nargin = args.length (); octave_value_list retval; - if (nargin != 11) + if (nargin != 5) { print_usage (); } @@ -71,81 +71,37 @@ { // arguments in char meth; - char alg; - char jobd; - char batch; - char conct; - char ctrl; + char job = 'A'; + char jobck = 'K'; - Matrix y = args(0).matrix_value (); - Matrix u = args(1).matrix_value (); - int nobr = args(2).int_value (); - + Matrix r = args(0).matrix_value (); + int nsmpl = args(1).int_value (); + int n = args(2).int_value (); const int imeth = args(3).int_value (); - const int ialg = args(4).int_value (); - const int ijobd = args(5).int_value (); - const int ibatch = args(6).int_value (); - const int iconct = args(7).int_value (); - const int ictrl = args(8).int_value (); - - double rcond = args(9).double_value (); - double tol = args(10).double_value (); - + double tol = args(4).double_value (); - if (imeth == 0) - meth = 'M'; - else - meth = 'N'; - switch (ialg) + switch (imeth) { case 0: - alg = 'C'; + meth = 'M'; break; case 1: - alg = 'F'; + meth = 'N'; break; case 2: - alg = 'Q'; + meth = 'C'; break; default: - error ("slib01bd: argument 'alg' invalid"); + error ("slib01bd: argument 'meth' invalid"); } + + // TODO: if meth == 'C', which meth should be taken for IB01AD.f, 'M' or 'N'? - if (ijobd == 0) - jobd = 'M'; - else - jobd = 'N'; + int m = + int nobr = r.rows () / (2*(m+l)); - switch (ibatch) - { - case 0: - batch = 'F'; - break; - case 1: - batch = 'I'; - break; - case 2: - batch = 'L'; - break; - case 3: - batch = 'O'; - break; - default: - error ("slib01bd: argument 'batch' invalid"); - } - - if (iconct == 0) - conct = 'C'; - else - conct = 'N'; - - if (ictrl == 0) - ctrl = 'C'; - else - ctrl = 'N'; - - + int m = u.columns (); // m: number of inputs int l = y.columns (); // l: number of outputs int nsmp = y.rows (); // nsmp: number of samples @@ -178,60 +134,13 @@ // workspace int liwork; - if (meth == 'N') // if METH = 'N' - liwork = (m+l)*nobr; - else if (alg == 'F') // if METH = 'M' and ALG = 'F' - liwork = m+l; - else // if METH = 'M' and ALG = 'C' or 'Q' - liwork = 0; - // TODO: Handle 'k' for DWORK int ldwork; - ldwork = 0; - if (alg == 'C' && (batch == 'F' || batch == 'I') && conct = 'C') - ldwork = (4*nobr-2)*(m+l); - else if (alg == 'C' && (batch == 'F' || batch == 'I') && conct = 'N') - ldwork = 1; - else if (meth == 'M' && alg == 'C' && batch == 'L' && conct == 'C') - ldwork = max ((4*nobr-2)*(m+l), 5*l*nobr); - else if ((meth == 'M' && jobd = 'M' && alg == 'C' && batch == 'O') || (batch == 'L' && conct == 'N')) - ldwork = max ((2*m-1)*nobr, (m+l)*nobr, 5*l*nobr); - else if ((meth == 'M' && jobd == 'N' && alg == 'C' && batch == 'O') || (batch == 'L' && conct == 'N')) - ldwork = 5*l*nobr; - // FIXME : two times || (batch == 'L' && conct == 'N') doesn't make sense -C LDWORK >= 5*(M+L)*NOBR+1, if METH = 'N', ALG = 'C', and -C BATCH = 'L' or 'O'; -C LDWORK >= (M+L)*2*NOBR*(M+L+3), if ALG = 'F', -C BATCH <> 'O' and CONCT = 'C'; -C LDWORK >= (M+L)*2*NOBR*(M+L+1), if ALG = 'F', -C BATCH = 'F', 'I' and CONCT = 'N'; -C LDWORK >= (M+L)*4*NOBR*(M+L+1)+(M+L)*2*NOBR, if ALG = 'F', -C BATCH = 'L' and CONCT = 'N', or -C BATCH = 'O'; -C LDWORK >= 4*(M+L)*NOBR, if ALG = 'Q', BATCH = 'F', and -C LDR >= NS = NSMP - 2*NOBR + 1; -C LDWORK >= max(4*(M+L)*NOBR, 5*L*NOBR), if METH = 'M', -C ALG = 'Q', BATCH = 'O', and LDR >= NS; -C LDWORK >= 5*(M+L)*NOBR+1, if METH = 'N', ALG = 'Q', -C BATCH = 'O', and LDR >= NS; -C LDWORK >= 6*(M+L)*NOBR, if ALG = 'Q', (BATCH = 'F' or 'O', -C and LDR < NS), or (BATCH = 'I' or -C 'L' and CONCT = 'N'); -C LDWORK >= 4*(NOBR+1)*(M+L)*NOBR, if ALG = 'Q', BATCH = 'I' -C or 'L' and CONCT = 'C'. -C The workspace used for ALG = 'Q' is -C LDRWRK*2*(M+L)*NOBR + 4*(M+L)*NOBR, -C where LDRWRK = LDWORK/(2*(M+L)*NOBR) - 2; recommended -C value LDRWRK = NS, assuming a large enough cache size. -C For good performance, LDWORK should be larger. - - - OCTAVE_LOCAL_BUFFER (int, iwork, liwork); OCTAVE_LOCAL_BUFFER (double, dwork, ldwork); Added: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc (rev 0) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-03-15 19:24:20 UTC (rev 9905) @@ -0,0 +1,466 @@ +/* + +Copyright (C) 2012 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/>. + +SLICOT system identification +Uses SLICOT IB01AD, IB01BD and IB01CD by courtesy of NICONET e.V. +<http://www.slicot.org> + +Author: Lukas Reichlin <luk...@gm...> +Created: March 2012 +Version: 0.1 + +*/ + +#include <octave/oct.h> +#include <f77-fcn.h> +#include "common.h" + +extern "C" +{ + int F77_FUNC (ib01ad, IB01AD) + (char& METH, char& ALG, char& JOBD, + char& BATCH, char& CONCT, char& CTRL, + int& NOBR, int& M, int& L, + int& NSMP, + double* U, int& LDU, + double* Y, int& LDY, + int& N, + double* R, int& LDR, + double* SV, + double& RCOND, double& TOL, + int* IWORK, + double* DWORK, int& LDWORK, + int& IWARN, int& INFO); + + int F77_FUNC (ib01bd, IB01BD) + (char& METH, char& JOB, char& JOBCK, + int& NOBR, int& N, int& M, int& L, + int& NSMPL, + double* R, int& LDR, + double* A, int& LDA, + double* C, int& LDC, + double* B, int& LDB, + double* D, int& LDD, + double* Q, int& LDQ, + double* RY, int& LDRY, + double* S, int& LDS, + double* K, int& LDK, + double& TOL, + int* IWORK, + double* DWORK, int& LDWORK, + bool* BWORK, + int& IWARN, int& INFO); + +} + +// PKG_ADD: autoload ("slident", "devel_slicot_functions.oct"); +DEFUN_DLD (slident, args, nargout, + "-*- texinfo -*-\n\ +Slicot IB01AD Release 5.0\n\ +No argument checking.\n\ +For internal use only.") +{ + int nargin = args.length (); + octave_value_list retval; + + if (nargin != 11) + { + print_usage (); + } + else + { + // arguments in + char meth; + char alg; + char jobd; + char batch; + char conct; + char ctrl; + + Matrix y = args(0).matrix_value (); + Matrix u = args(1).matrix_value (); + int nobr = args(2).int_value (); + + const int imeth = args(3).int_value (); + const int ialg = args(4).int_value (); + const int ijobd = args(5).int_value (); + const int ibatch = args(6).int_value (); + const int iconct = args(7).int_value (); + const int ictrl = args(8).int_value (); + + double rcond = args(9).double_value (); + double tol = args(10).double_value (); + + + if (imeth == 0) + meth = 'M'; + else + meth = 'N'; + + switch (ialg) + { + case 0: + alg = 'C'; + break; + case 1: + alg = 'F'; + break; + case 2: + alg = 'Q'; + break; + default: + error ("slib01ad: argument 'alg' invalid"); + } + + if (ijobd == 0) + jobd = 'M'; + else + jobd = 'N'; + + switch (ibatch) + { + case 0: + batch = 'F'; + break; + case 1: + batch = 'I'; + break; + case 2: + batch = 'L'; + break; + case 3: + batch = 'O'; + break; + default: + error ("slib01ad: argument 'batch' invalid"); + } + + if (iconct == 0) + conct = 'C'; + else + conct = 'N'; + + if (ictrl == 0) + ctrl = 'C'; + else + ctrl = 'N'; + + + int m = u.columns (); // m: number of inputs + int l = y.columns (); // l: number of outputs + int nsmp = y.rows (); // nsmp: number of samples + // y.rows == u.rows is checked by iddata class + // TODO: check minimal nsmp size + + int ldu; + + if (m == 0) + ldu = 1; + else // m > 0 + ldu = nsmp; + + int ldy = nsmp; + + // arguments out + int n; + int ldr; + + if (meth == 'M' && jobd == 'M') + ldr = max (2*(m+l)*nobr, 3*m*nobr); + else if (meth == 'N' || (meth == 'M' && jobd == 'N')) + ldr = 2*(m+l)*nobr; + else + error ("slib01ad: could not handle 'ldr' case"); + + Matrix r (ldr, 2*(m+l)*nobr); + ColumnVector sv (l*nobr); + + // workspace + int liwork; + + if (meth == 'N') // if METH = 'N' + liwork = (m+l)*nobr; + else if (alg == 'F') // if METH = 'M' and ALG = 'F' + liwork = m+l; + else // if METH = 'M' and ALG = 'C' or 'Q' + liwork = 0; + + // TODO: Handle 'k' for DWORK + + int ldwork; + + ldwork = 0; + + if (alg == 'C') + { + if (batch == 'F' || batch == 'I') + { + if (conct == 'C') + ldwork = (4*nobr-2)*(m+l); + else // (conct == 'N') + ldwork = 1; + } + else if (meth == 'M') // && (batch == 'L' || batch == 'O') + { + if (conct == 'C' && batch == 'L') + ldwork = max ((4*nobr-2)*(m+l), 5*l*nobr); + else if (jobd == 'M') + ldwork = max ((2*m-1)*nobr, (m+l)*nobr, 5*l*nobr); + else // (jobd == 'N') + ldwork = 5*l*nobr; + } + else // meth == 'N' && (batch == 'L' || batch == 'O') + { + ldwork = 5*(m+l)*nobr + 1; + } + } + else if (alg == 'F') + { +/* +For the second LDWORK case, code and documentation don't match: +doc line 276: BATCH = 'F', 'I' +code line 586: BATCH = 'F', 'I', 'O' +The third case with BATCH = 'O' is never reached. + + +IB01AD.f Lines 273-279: +C LDWORK >= (M+L)*2*NOBR*(M+L+3), if ALG = 'F', +C BATCH <> 'O' and CONCT = 'C'; +C LDWORK >= (M+L)*2*NOBR*(M+L+1), if ALG = 'F', +C BATCH = 'F', 'I' and CONCT = 'N'; +C LDWORK >= (M+L)*4*NOBR*(M+L+1)+(M+L)*2*NOBR, if ALG = 'F', +C BATCH = 'L' and CONCT = 'N', or +C BATCH = 'O'; + + +IB01AD.f Lines 499-500: + ONEBCH = LSAME( BATCH, 'O' ) + FIRST = LSAME( BATCH, 'F' ) .OR. ONEBCH + + +IB01AD.f Lines 583-591: + ELSE IF ( FQRALG ) THEN + IF ( .NOT.ONEBCH .AND. CONNEC ) THEN + MINWRK = NR*( M + L + 3 ) + ELSE IF ( FIRST .OR. INTERM ) THEN // (batch = F || O) || batch = I + MINWRK = NR*( M + L + 1 ) ^ + ELSE | + MINWRK = 2*NR*( M + L + 1 ) + NR ??? + END IF + ELSE +*/ + if (batch != 'O' && conct == 'C') + ldwork = (m+l)*2*nobr*(m+l+3); + else if (batch == 'F' || batch == 'O' || batch == 'I') // && conct == 'N' + ldwork = (m+l)*2*nobr*(m+l+1); + else // (batch == 'L' && conct == 'N') + ldwork = (m+l)*4*nobr*(m+l+1)+(m+l)*2*nobr; + } + else // (alg == 'Q') + { + int ns = nsmp - 2*nobr + 1; + + if (ldr >= ns && batch == 'F') + { + ldwork = 4*(m+l)*nobr; + } + else if (ldr >= ns && batch == 'O') + { + if (meth == 'M') + ldwork = max (4*(m+l)*nobr, 5*l*nobr); + else // (meth == 'N') + ldwork = 5*(m+l)*nobr + 1; + } + else if (conct == 'C' && (batch == 'I' || batch == 'L')) + { + ldwork = 4*(nobr+1)*(m+l)*nobr; + } + else // if ALG = 'Q', (BATCH = 'F' or 'O', and LDR < NS), or (BATCH = 'I' or 'L' and CONCT = 'N') + { + ldwork = 6*(m+l)*nobr; + } + } + +/* +IB01AD.f Lines 291-195: +c the workspace used for alg = 'q' is +c ldrwrk*2*(m+l)*nobr + 4*(m+l)*nobr, +c where ldrwrk = ldwork/(2*(m+l)*nobr) - 2; recommended +c value ldrwrk = ns, assuming a large enough cache size. +c for good performance, ldwork should be larger. + +somehow ldrwrk and ldwork must have been mixed up here + +*/ + + + OCTAVE_LOCAL_BUFFER (int, iwork, liwork); + OCTAVE_LOCAL_BUFFER (double, dwork, ldwork); + + // error indicators + int iwarn = 0; + int info = 0; + + + // SLICOT routine IB01AD + F77_XFCN (ib01ad, IB01AD, + (meth, alg, jobd, + batch, conct, ctrl, + nobr, m, l, + nsmp, + u.fortran_vec (), ldu, + y.fortran_vec (), ldy, + n, + r.fortran_vec (), ldr, + sv.fortran_vec (), + rcond, tol, + iwork, + dwork, ldwork, + iwarn, info)); + + + if (f77_exception_encountered) + error ("ident: exception in SLICOT subroutine IB01AD"); + + static const char* err_msg[] = { + "0: OK", + "1: a fast algorithm was requested (ALG = 'C', or 'F') " + "in sequential data processing, but it failed; the " + "routine can be repeatedly called again using the " + "standard QR algorithm", + "2: the singular value decomposition (SVD) algorithm did " + "not converge"}; + + static const char* warn_msg[] = { + "0: OK", + "1: the number of 100 cycles in sequential data " + "processing has been exhausted without signaling " + "that the last block of data was get; the cycle " + "counter was reinitialized", + "2: a fast algorithm was requested (ALG = 'C' or 'F'), " + "but it failed, and the QR algorithm was then used " + "(non-sequential data processing)", + "3: all singular values were exactly zero, hence N = 0 " + "(both input and output were identically zero)", + "4: the least squares problems with coefficient matrix " + "U_f, used for computing the weighted oblique " + "projection (for METH = 'N'), have a rank-deficient " + "coefficient matrix", + "5: the least squares problem with coefficient matrix " + "r_1 [6], used for computing the weighted oblique " + "projection (for METH = 'N'), has a rank-deficient " + "coefficient matrix"}; + + + error_msg ("ident", info, 2, err_msg); + warning_msg ("ident", iwarn, 5, warn_msg); + + + // resize + int rs = 2*(m+l)*nobr; + r.resize (rs, rs); + +////////////////////////////////////////////////////////// +// SLICOT IB01BD - A, B, C, D // +////////////////////////////////////////////////////////// + + // arguments in + char job = 'A'; + char jobck = 'K'; + + // TODO: if meth == 'C', which meth should be taken for IB01AD.f, 'M' or 'N'? + + int nsmpl = nsmp; + + // arguments out + + // error indicators + int iwarn = 0; + int info = 0; + + + // SLICOT routine IB01BD + F77_XFCN (ib01bd, IB01BD, + (meth, job, jobck, + nobr, n, m, l, + nsmpl, + r.fortran_vec (), ldr, + a.fortran_vec (), lda, + c.fortran_vec (), ldc, + b.fortran_vec (), ldb, + d.fortran_vec (), ldd, + q.fortran_vec (), ldq, + ry.fortran_vec (), ldry, + s.fortran_vec (), lds, + k.fortran_vec (), ldk, + tol, + iwork, + dwork, ldwork, + bwork, + iwarn, info)); + + + if (f77_exception_encountered) + error ("ident: exception in SLICOT subroutine IB01BD"); + + static const char* err_msg_b[] = { + "0: OK", + "1: error message not specified", + "2: the singular value decomposition (SVD) algorithm did " + "not converge", + "3: a singular upper triangular matrix was found", + "4: matrix A is (numerically) singular in discrete-" + "time case", + "5: the Hamiltonian or symplectic matrix H cannot be " + "reduced to real Schur form", + "6: the real Schur form of the Hamiltonian or " + "symplectic matrix H cannot be appropriately ordered", + "7: the Hamiltonian or symplectic matrix H has less " + "than N stable eigenvalues", + "8: the N-th order system of linear algebraic " + "equations, from which the solution matrix X would " + "be obtained, is singular to working precision", + "9: the QR algorithm failed to complete the reduction " + "of the matrix Ac to Schur canonical form, T", + "10: the QR algorithm did not converge"}; + + static const char* warn_msg_b[] = { + "0: OK", + "1: warning message not specified", + "2: warning message not specified", + "3: warning message not specified", + "4: a least squares problem to be solved has a " + "rank-deficient coefficient matrix", + "5: the computed covariance matrices are too small. " + "The problem seems to be a deterministic one; the " + "gain matrix is set to zero"}; + + + error_msg ("ident", info, 10, err_msg_b); + warning_msg ("ident", iwarn, 5, warn_msg_b); + + + // return values + //retval(0) = octave_value (n); + //retval(1) = r; + //retval(2) = sv; + } + + return retval; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-03-15 21:26:31
|
Revision: 9907 http://octave.svn.sourceforge.net/octave/?rev=9907&view=rev Author: paramaniac Date: 2012-03-15 21:26:25 +0000 (Thu, 15 Mar 2012) Log Message: ----------- control-devel: quicksave id draft code (3) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc 2012-03-15 20:04:50 UTC (rev 9906) +++ trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc 2012-03-15 21:26:25 UTC (rev 9907) @@ -1 +1,2 @@ #include "slib01ad.cc" // preprocess the input-output data +#include "slident.cc" // system identification Modified: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc 2012-03-15 20:04:50 UTC (rev 9906) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-03-15 21:26:25 UTC (rev 9907) @@ -390,14 +390,14 @@ int nsmpl = nsmp; // arguments out - lda = max (1, n); - ldc = max (1, l); - ldb = max (1, n); - ldd = max (1, l); - ldq = n; // if JOBCK = 'C' or 'K' - ldry = l; // if JOBCK = 'C' or 'K' - lds = n; // if JOBCK = 'C' or 'K' - ldk = n; // if JOBCK = 'K' + int lda = max (1, n); + int ldc = max (1, l); + int ldb = max (1, n); + int ldd = max (1, l); + int ldq = n; // if JOBCK = 'C' or 'K' + int ldry = l; // if JOBCK = 'C' or 'K' + int lds = n; // if JOBCK = 'C' or 'K' + int ldk = n; // if JOBCK = 'K' Matrix a (lda, n); Matrix c (ldc, n); @@ -410,18 +410,74 @@ Matrix k (ldk, l); // workspace - int liwork; + int liwork_b; + int liw1; + int liw2; + + liw1 = max (n, m*nobr+n, l*nobr, m*(n+l)); + liw2 = n*n; // if JOBCK = 'K' + liwork_b = max (liw1, liw2); - int ldwork; + int ldwork_b; + int ldw1; + int ldw2; + int ldw3; + + if (meth == 'M') + { + int ldw1a = max (2*(l*nobr-l)*n+2*n, (l*nobr-l)*n+n*n+7*n); + int ldw1b = max (2*(l*nobr-l)*n+n*n+7*n, + (l*nobr-l)*n+n+6*m*nobr, + (l*nobr-l)*n+n+max (l+m*nobr, l*nobr + max (3*l*nobr+1, m))); + ldw1 = max (ldw1a, ldw1b); + + int aw; + + if (m == 0 || job == 'C') + aw = n + n*n; + else + aw = 0; + + ldw2 = l*nobr*n + max ((l*nobr-l)*n+aw+2*n+max(5*n,(2*m+l)*nobr+l), 4*(m*nobr+n)+1, m*nobr+2*n+l ); + } + else if (meth == 'N') + { + ldw1 = l*nobr*n + max ((l*nobr-l)*n+2*n+(2*m+l)*nobr+l, + 2*(l*nobr-l)*n+n*n+8*n, + n+4*(m*nobr+n)+1, + m*nobr+3*n+l); + + if (m == 0 || job == 'C') + ldw2 = 0; + else + ldw2 = l*nobr*n+m*nobr*(n+l)*(m*(n+l)+1)+ max ((n+l)*(n+l), 4*m*(n+l)+1); + } + else // (meth == 'C') + { + int ldw1a = max (2*(l*nobr-l)*n+2*n, (l*nobr-l)*n+n*n+7*n); + int ldw1b = l*nobr*n + max ((l*nobr-l)*n+2*n+(2*m+l)*nobr+l, + 2*(l*nobr-l)*n+n*n+8*n, + n+4*(m*nobr+n)+1, + m*nobr+3*n+l); + + ldw1 = max (ldw1a, ldw1b); + + ldw2 = l*nobr*n+m*nobr*(n+l)*(m*(n+l)+1)+ max ((n+l)*(n+l), 4*m*(n+l)+1); - OCTAVE_LOCAL_BUFFER (int, iwork, liwork); - OCTAVE_LOCAL_BUFFER (double, dwork, ldwork); + } + + ldw3 = max(4*n*n + 2*n*l + l*l + max (3*l, n*l), 14*n*n + 12*n + 5); + ldwork_b = max (ldw1, ldw2, ldw3); + OCTAVE_LOCAL_BUFFER (int, iwork_b, liwork_b); + OCTAVE_LOCAL_BUFFER (double, dwork_b, ldwork_b); + OCTAVE_LOCAL_BUFFER (bool, bwork, 2*n); + // error indicators - int iwarn = 0; - int info = 0; + int iwarn_b = 0; + int info_b = 0; // SLICOT routine IB01BD @@ -439,10 +495,10 @@ s.fortran_vec (), lds, k.fortran_vec (), ldk, tolb, - iwork, - dwork, ldwork, + iwork_b, + dwork_b, ldwork_b, bwork, - iwarn, info)); + iwarn_b, info_b)); if (f77_exception_encountered) @@ -481,8 +537,8 @@ "gain matrix is set to zero"}; - error_msg ("ident", info, 10, err_msg_b); - warning_msg ("ident", iwarn, 5, warn_msg_b); + error_msg ("ident", info_b, 10, err_msg_b); + warning_msg ("ident", iwarn_b, 5, warn_msg_b); // resize a.resize (n, n); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-04-23 16:27:41
|
Revision: 10313 http://octave.svn.sourceforge.net/octave/?rev=10313&view=rev Author: paramaniac Date: 2012-04-23 15:59:35 +0000 (Mon, 23 Apr 2012) Log Message: ----------- control-devel: include reference lapack for debugging Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/Makefile Added Paths: ----------- trunk/octave-forge/extra/control-devel/src/lapack-3.4.1.tgz Modified: trunk/octave-forge/extra/control-devel/src/Makefile =================================================================== --- trunk/octave-forge/extra/control-devel/src/Makefile 2012-04-23 15:58:14 UTC (rev 10312) +++ trunk/octave-forge/extra/control-devel/src/Makefile 2012-04-23 15:59:35 UTC (rev 10313) @@ -1,5 +1,5 @@ -LAPACK_LIBS := $(shell mkoctfile -p LAPACK_LIBS) -BLAS_LIBS := $(shell mkoctfile -p BLAS_LIBS) +# LAPACK_LIBS := $(shell mkoctfile -p LAPACK_LIBS) +# BLAS_LIBS := $(shell mkoctfile -p BLAS_LIBS) FLIBS := $(shell mkoctfile -p FLIBS) all: devel_slicot_functions.oct @@ -10,16 +10,25 @@ mv slicot/src/*.f . mv slicot/src_aux/*.f . mkoctfile -c *.f - ar -r slicotlibrary.a *.o + ar -rc slicotlibrary.a *.o rm -rf *.o *.f slicot +lapacklibrary.a: lapack-3.4.1.tgz + tar -xzf lapack-3.4.1.tgz + mv lapack-3.4.1/BLAS/SRC/*.f . + mv lapack-3.4.1/INSTALL/*.f . + mv lapack-3.4.1/SRC/*.f . + mkoctfile -c *.f + ar -rc lapacklibrary.a *.o + rm -rf *.o *.f lapack-3.4.1 + # slicot functions -devel_slicot_functions.oct: devel_slicot_functions.cc slicotlibrary.a - mkoctfile devel_slicot_functions.cc common.cc slicotlibrary.a \ - ${LAPACK_LIBS} ${BLAS_LIBS} ${FLIBS} +devel_slicot_functions.oct: devel_slicot_functions.cc slicotlibrary.a lapacklibrary.a + mkoctfile devel_slicot_functions.cc common.cc slicotlibrary.a lapacklibrary.a \ + ${FLIBS} clean: - rm -rf *.o core octave-core *.oct *~ *.f slicot + rm -rf *.o core octave-core *.oct *~ *.f slicot lapack-3.4.1 realclean: clean rm -rf *.a \ No newline at end of file Added: trunk/octave-forge/extra/control-devel/src/lapack-3.4.1.tgz =================================================================== (Binary files differ) Property changes on: trunk/octave-forge/extra/control-devel/src/lapack-3.4.1.tgz ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-09 15:38:38
|
Revision: 10611 http://octave.svn.sourceforge.net/octave/?rev=10611&view=rev Author: paramaniac Date: 2012-06-09 15:38:32 +0000 (Sat, 09 Jun 2012) Log Message: ----------- control-devel: add modified slident routine to compute singular values only Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc Added Paths: ----------- trunk/octave-forge/extra/control-devel/src/slib01ad.cc Modified: trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc 2012-06-09 09:29:34 UTC (rev 10610) +++ trunk/octave-forge/extra/control-devel/src/devel_slicot_functions.cc 2012-06-09 15:38:32 UTC (rev 10611) @@ -1,6 +1,6 @@ -// #include "slib01ad.cc" // preprocess the input-output data #include "slident.cc" // system identification #include "slib01cd.cc" // compute initial state vector +#include "slib01ad.cc" // compute singular values #include "slident_a.cc" #include "slident_b.cc" Added: trunk/octave-forge/extra/control-devel/src/slib01ad.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slib01ad.cc (rev 0) +++ trunk/octave-forge/extra/control-devel/src/slib01ad.cc 2012-06-09 15:38:32 UTC (rev 10611) @@ -0,0 +1,383 @@ +/* + +Copyright (C) 2012 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/>. + +SLICOT system identification +Uses SLICOT IB01AD, IB01BD and IB01CD by courtesy of NICONET e.V. +<http://www.slicot.org> + +Author: Lukas Reichlin <luk...@gm...> +Created: March 2012 +Version: 0.1 + +*/ + +#include <octave/oct.h> +#include <octave/f77-fcn.h> +#include <octave/Cell.h> +#include "common.h" + +extern "C" +{ + int F77_FUNC (ib01ad, IB01AD) + (char& METH, char& ALG, char& JOBD, + char& BATCH, char& CONCT, char& CTRL, + int& NOBR, int& M, int& L, + int& NSMP, + double* U, int& LDU, + double* Y, int& LDY, + int& N, + double* R, int& LDR, + double* SV, + double& RCOND, double& TOL, + int* IWORK, + double* DWORK, int& LDWORK, + int& IWARN, int& INFO); +} + +// PKG_ADD: autoload ("slib01ad", "devel_slicot_functions.oct"); +DEFUN_DLD (slib01ad, args, nargout, + "-*- texinfo -*-\n\ +Slicot IB01AD Release 5.0\n\ +No argument checking.\n\ +For internal use only.") +{ + int nargin = args.length (); + octave_value_list retval; + + if (nargin != 10) + { + print_usage (); + } + else + { +//////////////////////////////////////////////////////////////////////////////////// +// SLICOT IB01AD - preprocess the input-output data // +//////////////////////////////////////////////////////////////////////////////////// + + // arguments in + char meth_a; + char meth_b; + char alg; + char jobd; + char batch; + char conct; + char ctrl = 'N'; + + const Cell y_cell = args(0).cell_value (); + const Cell u_cell = args(1).cell_value (); + int nobr = args(2).int_value (); + int nuser = args(3).int_value (); + + const int imeth = args(4).int_value (); + const int ialg = args(5).int_value (); + const int iconct = args(6).int_value (); + const int ictrl = args(7).int_value (); // ignored + + double rcond = args(8).double_value (); + double tol_a = args(9).double_value (); + + double tol_b = rcond; + double tol_c = rcond; + + + switch (imeth) + { + case 0: + meth_a = 'M'; + meth_b = 'M'; + break; + case 1: + meth_a = 'N'; + meth_b = 'N'; + break; + case 2: + meth_a = 'N'; // no typo here + meth_b = 'C'; + break; + default: + error ("slib01ad: argument 'meth' invalid"); + } + + switch (ialg) + { + case 0: + alg = 'C'; + break; + case 1: + alg = 'F'; + break; + case 2: + alg = 'Q'; + break; + default: + error ("slib01ad: argument 'alg' invalid"); + } + + if (meth_a == 'M') + jobd = 'M'; + else // meth_a == 'N' + jobd = 'N'; // IB01AD.f says: This parameter is not relevant for METH = 'N' + + if (iconct == 0) + conct = 'C'; + else + conct = 'N'; +/* + if (ictrl == 0) + ctrl = 'C'; + else + ctrl = 'N'; +*/ + // m and l are equal for all experiments, checked by iddata class + int n_exp = y_cell.nelem (); // number of experiments + int m = u_cell.elem(0).columns (); // m: number of inputs + int l = y_cell.elem(0).columns (); // l: number of outputs + int nsmpl = 0; // total number of samples + + // arguments out + int n; + int ldr; + + if (meth_a == 'M' && jobd == 'M') + ldr = max (2*(m+l)*nobr, 3*m*nobr); + else if (meth_a == 'N' || (meth_a == 'M' && jobd == 'N')) + ldr = 2*(m+l)*nobr; + else + error ("slib01ad: could not handle 'ldr' case"); + + Matrix r (ldr, 2*(m+l)*nobr); + ColumnVector sv (l*nobr); + + + // repeat for every experiment in the dataset + for (int i = 0; i < n_exp; i++) + { + if (n_exp == 1) + batch = 'O'; // one block only + else if (i == 0) + batch = 'F'; // first block + else if (i == n_exp-1) + batch = 'L'; // last block + else + batch = 'I'; // intermediate block + + Matrix y = y_cell.elem(i).matrix_value (); + Matrix u = u_cell.elem(i).matrix_value (); + + // y.rows == u.rows is checked by iddata class + // int m = u.columns (); // m: number of inputs + // int l = y.columns (); // l: number of outputs + int nsmp = y.rows (); // nsmp: number of samples in the current experiment + nsmpl += nsmp; // nsmpl: total number of samples of all experiments + + // minimal nsmp size checked by __slicot_identification__.m + if (batch == 'O') + { + if (nsmp < 2*(m+l+1)*nobr - 1) + error ("slident: require NSMP >= 2*(M+L+1)*NOBR - 1"); + } + else + { + if (nsmp < 2*nobr) + error ("slident: require NSMP >= 2*NOBR"); + } + + int ldu; + + if (m == 0) + ldu = 1; + else // m > 0 + ldu = nsmp; + + int ldy = nsmp; + + // workspace + int liwork_a; + + if (meth_a == 'N') // if METH = 'N' + liwork_a = (m+l)*nobr; + else if (alg == 'F') // if METH = 'M' and ALG = 'F' + liwork_a = m+l; + else // if METH = 'M' and ALG = 'C' or 'Q' + liwork_a = 0; + + // TODO: Handle 'k' for DWORK + + int ldwork_a; + int ns = nsmp - 2*nobr + 1; + + if (alg == 'C') + { + if (batch == 'F' || batch == 'I') + { + if (conct == 'C') + ldwork_a = (4*nobr-2)*(m+l); + else // (conct == 'N') + ldwork_a = 1; + } + else if (meth_a == 'M') // && (batch == 'L' || batch == 'O') + { + if (conct == 'C' && batch == 'L') + ldwork_a = max ((4*nobr-2)*(m+l), 5*l*nobr); + else if (jobd == 'M') + ldwork_a = max ((2*m-1)*nobr, (m+l)*nobr, 5*l*nobr); + else // (jobd == 'N') + ldwork_a = 5*l*nobr; + } + else // meth_b == 'N' && (batch == 'L' || batch == 'O') + { + ldwork_a = 5*(m+l)*nobr + 1; + } + } + else if (alg == 'F') + { + if (batch != 'O' && conct == 'C') + ldwork_a = (m+l)*2*nobr*(m+l+3); + else if (batch == 'F' || batch == 'I') // && conct == 'N' + ldwork_a = (m+l)*2*nobr*(m+l+1); + else // (batch == 'L' || '0' && conct == 'N') + ldwork_a = (m+l)*4*nobr*(m+l+1)+(m+l)*2*nobr; + } + else // (alg == 'Q') + { + // int ns = nsmp - 2*nobr + 1; + + if (ldr >= ns && batch == 'F') + { + ldwork_a = 4*(m+l)*nobr; + } + else if (ldr >= ns && batch == 'O') + { + if (meth_a == 'M') + ldwork_a = max (4*(m+l)*nobr, 5*l*nobr); + else // (meth == 'N') + ldwork_a = 5*(m+l)*nobr + 1; + } + else if (conct == 'C' && (batch == 'I' || batch == 'L')) + { + ldwork_a = 4*(nobr+1)*(m+l)*nobr; + } + else // if ALG = 'Q', (BATCH = 'F' or 'O', and LDR < NS), or (BATCH = 'I' or 'L' and CONCT = 'N') + { + ldwork_a = 6*(m+l)*nobr; + } + } + + /* + IB01AD.f Lines 438-445 + C FURTHER COMMENTS + C + C For ALG = 'Q', BATCH = 'O' and LDR < NS, or BATCH <> 'O', the + C calculations could be rather inefficient if only minimal workspace + C (see argument LDWORK) is provided. It is advisable to provide as + C much workspace as possible. Almost optimal efficiency can be + C obtained for LDWORK = (NS+2)*(2*(M+L)*NOBR), assuming that the + C cache size is large enough to accommodate R, U, Y, and DWORK. + */ + + ldwork_a = max (ldwork_a, (ns+2)*(2*(m+l)*nobr)); + + /* + IB01AD.f Lines 291-195: + c the workspace used for alg = 'q' is + c ldrwrk*2*(m+l)*nobr + 4*(m+l)*nobr, + c where ldrwrk = ldwork/(2*(m+l)*nobr) - 2; recommended + c value ldrwrk = ns, assuming a large enough cache size. + c for good performance, ldwork should be larger. + + somehow ldrwrk and ldwork must have been mixed up here + + */ + + + OCTAVE_LOCAL_BUFFER (int, iwork_a, liwork_a); + OCTAVE_LOCAL_BUFFER (double, dwork_a, ldwork_a); + + // error indicators + int iwarn_a = 0; + int info_a = 0; + + + // SLICOT routine IB01AD + F77_XFCN (ib01ad, IB01AD, + (meth_a, alg, jobd, + batch, conct, ctrl, + nobr, m, l, + nsmp, + u.fortran_vec (), ldu, + y.fortran_vec (), ldy, + n, + r.fortran_vec (), ldr, + sv.fortran_vec (), + rcond, tol_a, + iwork_a, + dwork_a, ldwork_a, + iwarn_a, info_a)); + + + if (f77_exception_encountered) + error ("ident: exception in SLICOT subroutine IB01AD"); + + static const char* err_msg[] = { + "0: OK", + "1: a fast algorithm was requested (ALG = 'C', or 'F') " + "in sequential data processing, but it failed; the " + "routine can be repeatedly called again using the " + "standard QR algorithm", + "2: the singular value decomposition (SVD) algorithm did " + "not converge"}; + + static const char* warn_msg[] = { + "0: OK", + "1: the number of 100 cycles in sequential data " + "processing has been exhausted without signaling " + "that the last block of data was get; the cycle " + "counter was reinitialized", + "2: a fast algorithm was requested (ALG = 'C' or 'F'), " + "but it failed, and the QR algorithm was then used " + "(non-sequential data processing)", + "3: all singular values were exactly zero, hence N = 0 " + "(both input and output were identically zero)", + "4: the least squares problems with coefficient matrix " + "U_f, used for computing the weighted oblique " + "projection (for METH = 'N'), have a rank-deficient " + "coefficient matrix", + "5: the least squares problem with coefficient matrix " + "r_1 [6], used for computing the weighted oblique " + "projection (for METH = 'N'), has a rank-deficient " + "coefficient matrix"}; + + + error_msg ("ident: IB01AD", info_a, 2, err_msg); + warning_msg ("ident: IB01AD", iwarn_a, 5, warn_msg); + } + + + // resize + int rs = 2*(m+l)*nobr; + r.resize (rs, rs); + + + // return values + retval(0) = sv; + retval(1) = octave_value (n); + } + + return retval; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-07-03 12:06:32
|
Revision: 10713 http://octave.svn.sourceforge.net/octave/?rev=10713&view=rev Author: paramaniac Date: 2012-07-03 12:06:21 +0000 (Tue, 03 Jul 2012) Log Message: ----------- control-devel: remove custom lapack from makefile Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/Makefile Removed Paths: ------------- trunk/octave-forge/extra/control-devel/src/lapack-3.4.1.tgz Modified: trunk/octave-forge/extra/control-devel/src/Makefile =================================================================== --- trunk/octave-forge/extra/control-devel/src/Makefile 2012-07-03 09:56:20 UTC (rev 10712) +++ trunk/octave-forge/extra/control-devel/src/Makefile 2012-07-03 12:06:21 UTC (rev 10713) @@ -1,7 +1,16 @@ -# LAPACK_LIBS := $(shell mkoctfile -p LAPACK_LIBS) -# BLAS_LIBS := $(shell mkoctfile -p BLAS_LIBS) -FLIBS := $(shell mkoctfile -p FLIBS) +MKOCTFILE ?= mkoctfile +ifndef LAPACK_LIBS +LAPACK_LIBS := $(shell $(MKOCTFILE) -p LAPACK_LIBS) +endif +ifndef BLAS_LIBS +BLAS_LIBS := $(shell $(MKOCTFILE) -p BLAS_LIBS) +endif +ifndef FLIBS +FLIBS := $(shell $(MKOCTFILE) -p FLIBS) +endif +LFLAGS := $(shell $(MKOCTFILE) -p LFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) + all: devel_slicot_functions.oct \ is_matrix.oct @@ -10,30 +19,21 @@ tar -xzf slicot.tar.gz mv slicot/src/*.f . mv slicot/src_aux/*.f . - mkoctfile -c *.f + $(MKOCTFILE) -c *.f ar -rc slicotlibrary.a *.o rm -rf *.o *.f slicot -lapacklibrary.a: lapack-3.4.1.tgz - tar -xzf lapack-3.4.1.tgz - mv lapack-3.4.1/BLAS/SRC/*.f . - mv lapack-3.4.1/INSTALL/*.f . - mv lapack-3.4.1/SRC/*.f . - mkoctfile -c *.f - ar -rc lapacklibrary.a *.o - rm -rf *.o *.f lapack-3.4.1 - # slicot functions -devel_slicot_functions.oct: devel_slicot_functions.cc slicotlibrary.a lapacklibrary.a - mkoctfile devel_slicot_functions.cc common.cc slicotlibrary.a lapacklibrary.a \ - ${FLIBS} +devel_slicot_functions.oct: devel_slicot_functions.cc slicotlibrary.a + LFLAGS="$(LFLAGS)" \ + $(MKOCTFILE) devel_slicot_functions.cc common.cc slicotlibrary.a # helpers is_matrix.oct: is_matrix.cc - mkoctfile is_matrix.cc + $(MKOCTFILE) is_matrix.cc clean: - rm -rf *.o core octave-core *.oct *~ *.f slicot lapack-3.4.1 + rm -rf *.o core octave-core *.oct *~ *.f slicot realclean: clean rm -rf *.a \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/src/lapack-3.4.1.tgz =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |