view examples/@polynomial/polynomial.m @ 14093:050bc580cb60 stable

doc: Various docstring improvements before 3.6.0 release. * NEWS, aspell-octave.en.pws, intro.txi, oop.txi, testfun.txi, tips.txi, FIRfilter.m, FIRfilter_aggregation.m, polynomial.m, polynomial_superiorto.m, usejava.m, pcg.m, pcr.m, nchoosek.m, validatestring.m, assert.m, weekday.m, cellfun.cc, error.cc, strfns.cc: Various docstring improvements before 3.6.0 release.
author Rik <octave@nomad.inbox5.com>
date Wed, 21 Dec 2011 19:46:57 -0800
parents 567e3e4ab74d
children
line wrap: on
line source

## -*- texinfo -*-
## @deftypefn  {Function File} {} polynomial ()
## @deftypefnx {Function File} {} polynomial (@var{a})
## Create a polynomial object representing the polynomial
##
## @example
## a0 + a1 * x + a2 * x^2 + @dots{} + an * x^n
## @end example
##
## @noindent
## from a vector of coefficients [a0 a1 a2 @dots{} an].
## @end deftypefn

function p = polynomial (a)
  if (nargin == 0)
    p.poly = [0];
    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 vector");
    endif
  else
    print_usage ();
  endif
endfunction