view examples/@polynomial/polynomial.m @ 8664:e07e93c04080

style fixes
author John W. Eaton <jwe@octave.org>
date Wed, 04 Feb 2009 10:56:23 -0500
parents dba0037e6602
children 567e3e4ab74d
line wrap: on
line source

## -*- texinfo -*-
## @deftypefn {Function File} {} polynomial ()
## @deftypefnx {Function File} {} polynomial (@var{a})
## Creates a polynomial object representing the polynomial
##
## @example
## a0 + a1 * x + a2 * x^2 + @dots{} + an * x^n
## @end example
## @end deftypefn

function p = polynomial (a)
  if (nargin == 0)
    p.poly = [];
    p = class (p, "polynomial");
  elseif (nargin == 1)
    if (strcmp (class (a), "polynomial"))
      p = a;
    elseif (isvector (a) && isreal (a))
      p.poly = a(:)';
      p = class (p, "polynomial");
    else
      error ("polynomial: expecting real or complex vector");
    endif
  else
    print_usage ();
  endif
  superiorto ("double");
endfunction