str2poly
Converts multivariate polynomials from strings to arrays.
Syntax
Pset = str2poly(strcell, varnames)
Description
Pset = str2poly(strcell, varnames) follows Ben Petschel (2010)
algorithm. Function REOG2VEC must be applyed at output.
Input
strcell = cell array of strings, one per polynomial all numbers must
be whole or decimal form (no scientific notation) brackets
and double negatives are not allowed. All spaces in the
strings are ignored.
varnames = cell array of strings which must include all variable names
that occur in strcell [default: {'x1', 'x2', ...}]. In Tau
library applications is used for variable 't' or 'x'.
Output
Pset = cell array of polynomial coefficients where row j of Pset{i}
is [c, k1, k2, ...] representing the monomial c*x1^k1*x2^k2*...
Example
p = reorg2vec(str2poly({'2*t^3+4*t^5-6*t^7'}, {'t'}))
returns:
p = [0 0 0 2 0 4 0 -6]'.
Example by ben petschel
str2poly({'- 1 * x 1 * x 2 ^ 2'})
returns
{[-1, 1, 2]}
See also
REORG2POLY and POLY2STR
Pset = str2poly(strcell, varnames) follows Ben Petschel (2010) algorithm. Function REOG2VEC must be applyed at output.
Input
strcell = cell array of strings, one per polynomial all numbers must
be whole or decimal form (no scientific notation) brackets
and double negatives are not allowed. All spaces in the
strings are ignored.
varnames = cell array of strings which must include all variable names
that occur in strcell [default: {'x1', 'x2', ...}]. In Tau
library applications is used for variable 't' or 'x'.
Output
Pset = cell array of polynomial coefficients where row j of Pset{i}
is [c, k1, k2, ...] representing the monomial c*x1^k1*x2^k2*...
Example
p = reorg2vec(str2poly({'2*t^3+4*t^5-6*t^7'}, {'t'}))
returns:
p = [0 0 0 2 0 4 0 -6]'.
Example by ben petschel
str2poly({'- 1 * x 1 * x 2 ^ 2'})
returns
{[-1, 1, 2]}
See also
REORG2POLY and POLY2STR
Pset = cell array of polynomial coefficients where row j of Pset{i} is [c, k1, k2, ...] representing the monomial c*x1^k1*x2^k2*...
Example
p = reorg2vec(str2poly({'2*t^3+4*t^5-6*t^7'}, {'t'}))
returns:
p = [0 0 0 2 0 4 0 -6]'.
Example by ben petschel
str2poly({'- 1 * x 1 * x 2 ^ 2'})
returns
{[-1, 1, 2]}
See also
REORG2POLY and POLY2STR
str2poly({'- 1 * x 1 * x 2 ^ 2'}) returns {[-1, 1, 2]}