From: <par...@us...> - 2010-09-15 00:52:58
|
Revision: 7724 http://octave.svn.sourceforge.net/octave/?rev=7724&view=rev Author: paramaniac Date: 2010-09-15 00:52:51 +0000 (Wed, 15 Sep 2010) Log Message: ----------- control: try sticking to GNU coding standards (not finished yet) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@tf/__set__.m trunk/octave-forge/main/control/inst/@tf/tf.m trunk/octave-forge/main/control/inst/@tfpoly/minus.m trunk/octave-forge/main/control/inst/@tfpoly/plus.m trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m Added Paths: ----------- trunk/octave-forge/main/control/inst/@tfpoly/__make_equally_long__.m trunk/octave-forge/main/control/inst/@tfpoly/__remove_leading_zeros__.m trunk/octave-forge/main/control/inst/__vec2tfpoly__.m Removed Paths: ------------- trunk/octave-forge/main/control/inst/@tfpoly/__equalizer__.m trunk/octave-forge/main/control/inst/@tfpoly/__remleadzer__.m trunk/octave-forge/main/control/inst/__conv2tfpolycell__.m Modified: trunk/octave-forge/main/control/inst/@tf/__set__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__set__.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tf/__set__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -26,12 +26,12 @@ switch (prop) # {<internal name>, <user name>} case "num" - num = __conv2tfpolycell__ (val); + num = __vec2tfpoly__ (val); [p, m] = __tf_dim__ (num, sys.den); sys.num = num; case "den" - den = __conv2tfpolycell__ (val); + den = __vec2tfpoly__ (val); [p, m] = __tf_dim__ (sys.num, den); sys.den = den; Modified: trunk/octave-forge/main/control/inst/@tf/tf.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/tf.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tf/tf.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -79,15 +79,15 @@ return; elseif (isnumeric (num)) # static gain num = num2cell (num); - num = __conv2tfpolycell__ (num); + num = __vec2tfpoly__ (num); [p, m] = size (num); den = tfpolyones (p, m); tsam = -1; tfvar = "x"; # undefined elseif (ischar (num)) # s = tf ("s") tfvar = num; - num = __conv2tfpolycell__ ([1, 0]); - den = __conv2tfpolycell__ ([1]); + num = __vec2tfpoly__ ([1, 0]); + den = __vec2tfpoly__ ([1]); tsam = 0; else print_usage (); @@ -97,18 +97,18 @@ if (ischar (num) && issample (den)) # z = tf ("z", 0.3) tfvar = num; tsam = den; - num = __conv2tfpolycell__ ([1, 0]); - den = __conv2tfpolycell__ ([1]); + num = __vec2tfpoly__ ([1, 0]); + den = __vec2tfpoly__ ([1]); else # sys = tf (num, den) - num = __conv2tfpolycell__ (num); - den = __conv2tfpolycell__ (den); + num = __vec2tfpoly__ (num); + den = __vec2tfpoly__ (den); tfvar = "s"; tsam = 0; endif otherwise # default case - num = __conv2tfpolycell__ (num); - den = __conv2tfpolycell__ (den); + num = __vec2tfpoly__ (num); + den = __vec2tfpoly__ (den); argc = numel (varargin); if (issample (varargin{1}, 1)) # sys = tf (num, den, tsam, "prop1, "val1", ...) Deleted: trunk/octave-forge/main/control/inst/@tfpoly/__equalizer__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/__equalizer__.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tfpoly/__equalizer__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -1,41 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Make two polynomials equally long by adding leading zeros -## to the shorter one. For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function [peq1, peq2] = __equalizer__ (p1, p2) - - lp1 = length (p1.poly); - lp2 = length (p2.poly); - lmax = max (lp1, lp2); - - leadzer1 = zeros (1, lmax - lp1); - leadzer2 = zeros (1, lmax - lp2); - - peq1 = p1; - peq2 = p2; - - peq1.poly = [leadzer1, p1.poly]; - peq2.poly = [leadzer2, p2.poly]; - -endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@tfpoly/__make_equally_long__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/__make_equally_long__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tfpoly/__make_equally_long__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -0,0 +1,41 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Make two polynomials equally long by adding leading zeros +## to the shorter one. For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function [peq1, peq2] = __make_equally_long__ (p1, p2) + + lp1 = length (p1.poly); + lp2 = length (p2.poly); + lmax = max (lp1, lp2); + + leadzer1 = zeros (1, lmax - lp1); + leadzer2 = zeros (1, lmax - lp2); + + peq1 = p1; + peq2 = p2; + + peq1.poly = [leadzer1, p1.poly]; + peq2.poly = [leadzer2, p2.poly]; + +endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@tfpoly/__remleadzer__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/__remleadzer__.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tfpoly/__remleadzer__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -1,34 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Remove leading zeros from a polynomial, except for polynomials -## which are of length 1. For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function p = __remleadzer__ (p) - - idx = find (p.poly != 0); - - if (! isempty (idx) && idx(1) > 1) - p.poly = p.poly(idx(1) : end); # p.poly(idx) would remove all zeros - endif - -endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@tfpoly/__remove_leading_zeros__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/__remove_leading_zeros__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tfpoly/__remove_leading_zeros__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -0,0 +1,34 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Remove leading zeros from a polynomial, except for polynomials +## which are of length 1. For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function p = __remove_leading_zeros__ (p) + + idx = find (p.poly != 0); + + if (! isempty (idx) && idx(1) > 1) + p.poly = p.poly(idx(1) : end); # p.poly(idx) would remove all zeros + endif + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@tfpoly/minus.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/minus.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tfpoly/minus.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -32,12 +32,12 @@ b = tfpoly (b); endif - [a, b] = __equalizer__ (a, b); + [a, b] = __make_equally_long__ (a, b); p = tfpoly (); p.poly = a.poly - b.poly; - p = __remleadzer__ (p); + p = __remove_leading_zeros__ (p); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@tfpoly/plus.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/plus.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tfpoly/plus.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -32,12 +32,12 @@ b = tfpoly (b); endif - [a, b] = __equalizer__ (a, b); + [a, b] = __make_equally_long__ (a, b); p = tfpoly (); p.poly = a.poly + b.poly; - p = __remleadzer__ (p); + p = __remove_leading_zeros__ (p); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -38,7 +38,7 @@ elseif (isreal (a) && isvector (a)) p.poly = reshape (a, 1, []); p = class (p, "tfpoly"); - p = __remleadzer__ (p); + p = __remove_leading_zeros__ (p); else error ("tfpoly: argument must be a real vector"); endif Deleted: trunk/octave-forge/main/control/inst/__conv2tfpolycell__.m =================================================================== --- trunk/octave-forge/main/control/inst/__conv2tfpolycell__.m 2010-09-15 00:36:45 UTC (rev 7723) +++ trunk/octave-forge/main/control/inst/__conv2tfpolycell__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -1,34 +0,0 @@ -## Copyright (C) 2009 - 2010 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Convert a (cell of) row vector(s) to a cell of tfpoly objects. -## Used by tf and __set__. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.2 - -function ndr = __conv2tfpolycell__ (nd) - - if (! iscell (nd)) - nd = {nd}; - endif - - ndr = cellfun (@tfpoly, nd, "uniformoutput", false); - -endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/__vec2tfpoly__.m =================================================================== --- trunk/octave-forge/main/control/inst/__vec2tfpoly__.m (rev 0) +++ trunk/octave-forge/main/control/inst/__vec2tfpoly__.m 2010-09-15 00:52:51 UTC (rev 7724) @@ -0,0 +1,34 @@ +## Copyright (C) 2009 - 2010 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Convert a (cell of) row vector(s) to a cell of tfpoly objects. +## Used by tf and __set__. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.2 + +function ndr = __vec2tfpoly__ (nd) + + if (! iscell (nd)) + nd = {nd}; + endif + + ndr = cellfun (@tfpoly, nd, "uniformoutput", false); + +endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |