From bug-request at octave dot org Mon May 31 10:53:34 2004 Subject: leading complex in polyout From: Paul Kienzle To: bugs at octave dot org Date: Mon, 31 May 2004 11:52:01 -0400 --Apple-Mail-4-337339213 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Paul Kienzle * polynomial/polyout.m: Use parenthesis if necessary around complex polynomial coefficient. --Apple-Mail-4-337339213 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="polyout.diff" Content-Disposition: attachment; filename=polyout.diff Index: polyout.m =================================================================== RCS file: /cvs/octave/scripts/polynomial/polyout.m,v retrieving revision 1.4 diff -c -p -r1.4 polyout.m *** a/polyout.m 9 Aug 2002 18:58:15 -0000 1.4 --- b/polyout.m 31 May 2004 15:48:29 -0000 *************** function y = polyout (c, x) *** 53,64 **** if(n > 0) n1 = n+1; - if (imag (c(1))) - tmp = com2str(c(1)) - else - tmp = num2str(c(1)); - endif for ii = 2:n if (real (c(ii)) < 0) ns = " - "; --- 53,60 ---- if(n > 0) n1 = n+1; + tmp = coeff (c(1)); for ii = 2:n if (real (c(ii)) < 0) ns = " - "; *************** function y = polyout (c, x) *** 67,79 **** ns = " + "; endif ! if (imag (c(ii))) ! nstr = sprintf ("(%s)", com2str (c(ii))); ! else ! nstr = num2str (c(ii)); ! endif ! ! tmp = sprintf ("%s*%s^%d%s%s", tmp, x, n1-ii, ns, nstr); endfor else --- 63,69 ---- ns = " + "; endif ! tmp = sprintf ("%s*%s^%d%s%s", tmp, x, n1-ii, ns, coeff (c(ii))); endfor else *************** function y = polyout (c, x) *** 87,89 **** --- 77,91 ---- endif endfunction + + function str = coeff(c) + if (imag (c)) + if (real (c)) + str = sprintf ("(%s)", com2str(c)); + else + str = com2str(c); + endif + else + str = num2str(c); + endif + --Apple-Mail-4-337339213-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------