octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: polyval discussion


From: Robert T. Short
Subject: Re: polyval discussion
Date: Sun, 24 Jul 2011 10:09:25 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4) Gecko/20091017 SeaMonkey/2.0

Ben Abbott wrote:
On Jul 23, 2011, at 12:30 PM, Robert T. Short wrote:

I have some questions about polyval.  Depending on the outcome of this 
discussion I will submit patches as necessary.

-----------------------
First, a MATLAB compatibility issue.

If we have a matrix

p = [ [ 1 2 ];
         [ 3 4 ] ];

and we attempt to evaluate p

p = polyval(p,1)

octave errors - p must be a vector.  MATLAB on the other hand returns

p = 4

MATLAB seems to use the first column as the polynomial.

Personally, I think the MATLAB approach makes no sense, but should polyval 
emulate MATLAB?

-----------------------
Second, here is what I would REALLY like polyval to do.

If p is a matrix, I would like polyval to return a vector in which each row is 
treated as a polynomial.  That is, for the example above,

p = polyval(p,1)

would return

p= [3;7]

The modifications to polyval to do this are very simple but this is decidedly 
not MATLAB compatible.

I could submit a new function, say mpolyval, but the new function would be a 
near clone of polyval.
Might using cell array for the multiplicity of coefficients be a better idea?

Using cells should be easy to parse without introducing an incompatibility with 
Matlab.

Ben



My first thought was to do this with cell arrays, but that meant fairly substantial changes to polyval. Since yesterday, though, I thought about my request a bit and realized that while I would only need to change polyval slightly for my specific requirement, making things more general and more useful would require pretty massive changes, so I retract my "what I would REALLY like polyval to do" comment. I just built a function called 'mpolyval' for my own library that does what I need. If anybody is interested I will submit it to the patch tracker when I have wrung it out a bit.

I will make the changes required for MATLAB compatibility if anyone cares, but I don't see how it makes any sense.

Sorry for the noise.

Bob


reply via email to

[Prev in Thread] Current Thread [Next in Thread]