view examples/@polynomial/display.m @ 14855:1b48b209a8d6

maint: Use Octave coding conventions for coddling parentheses in examples directory * display.m, subsref.m, display.m, mtimes.m, plot.m, polyval.m, myprop.c, stringdemo.cc, unwinddemo.cc: Use Octave coding conventions for coddling parentheses.
author Rik <octave@nomad.inbox5.com>
date Mon, 09 Jul 2012 13:23:31 -0700
parents 567e3e4ab74d
children
line wrap: on
line source

function display (p)
  a = p.poly;
  first = true;
  fprintf ("%s =", inputname (1));
  for i = 1 : length (a);
    if (a(i) != 0)
      if (first)
        first = false;
      elseif (a(i) > 0)
        fprintf (" +");
      endif
      if (a(i) < 0)
        fprintf (" -");
      endif
      if (i == 1)
        fprintf (" %g", abs (a(i)));
      elseif (abs(a(i)) != 1)
        fprintf (" %g *", abs (a(i)));
      endif
      if (i > 1)
        fprintf (" X");
      endif
      if (i > 2)
        fprintf (" ^ %d", i - 1);
      endif
    endif
  endfor
  if (first)
    fprintf (" 0");
  endif
  fprintf ("\n");
endfunction