Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 641ebb3060c35990cc021d8f7aaf9aca > files > 21

octave-doc-5.1.0-7.1.mga7.noarch.rpm

## -*- texinfo -*-
## @deftypefn  {} {} polynomial ()
## @deftypefnx {} {} 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 > 1)
    print_usage ();
  endif

  if (nargin == 0)
    p.poly = 0;
    p = class (p, "polynomial");
  else
    if (isa (a, "polynomial"))
      p = a;
    elseif (isreal (a) && isvector (a))
      p.poly = a(:).';  # force row vector
      p = class (p, "polynomial");
    else
      error ("@polynomial: A must be a real vector");
    endif
  endif

endfunction