On Sat, Mar 29, 2008 at 8:00 PM, John Randall
<[EMAIL PROTECTED]> wrote:
> NB. Vandermonde matrix
> van=:(>@{. */ >@{:)@:((^ [EMAIL PROTECTED])/&.>)@:(<"1@:(],.$@:[))
That seems different from what I know as the "vandermonde matrix".
For example, with the values 2 and 11 and a third order polynomial,
the vandermonde matrix I am familiar with would look like:
1 2 4 8
1 11 121 1331
Your result looks like
1 11
2 22
4 44
8 88
But this is just a nit about names, I think.
However, if I change my example equation, adding another variable,
and turning my matrix of coefficients into a rank 3 array:
NB. x + y + 2xy +(-x^3 )+z
ex2=: 0&{ + 1&{ + (2 * 0&{ * 1&{) + (_1 * 3 ^~ 0&{) + 2&{
NB. coefficient array -- dimensions: represent powers of x, y, and z
arr=: 1 1 2 _1 1 (1 0 0;0 1 0;1 1 0;3 0 0;0 0 1)} 4 2 2$0
ex2 i.3 9
27 49 69 81 79 57 9 _71 _189
arr mvp i.3 9
27 49 69 81 79 57 9 _71 _189
I am not quite sure how to use your approach with this kind
of polynomial.
That said, note that if I rewrite my multivariable polynomial
evaluator so that it requires its coefficient matrix be represented
as a sparse array, it can be written more concisely:
sarr=: 0 $. arr
mvps=: (5 $. [) +/@:*"1 |:@] */@:^"1/ 4 $. [
sarr mvps i.3 9
27 49 69 81 79 57 9 _71 _189
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm