Mercurial > hg > octave-nkf
view examples/@polynomial/polynomial.m @ 11117:3cbc0d77db48 ss-3-3-53
update version info for snapshot
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 19 Oct 2010 02:25:32 -0400 |
parents | 567e3e4ab74d |
children | 050bc580cb60 |
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 ## ## from a vector of coefficients [a0 a1 a2 ... 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