Mercurial > octave-nkf
view examples/@polynomial/polynomial.m @ 12134:6c54ad0fde04 release-3-4-x ss-3-3-90
update copyright and version info for release branch
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 22 Jan 2011 13:50:32 -0500 |
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