What you need to keep straight is the rank of the various parts. Breaking
this into two parts, first evaluating the values for each value of x against
the powers of x times the coefficients for each power:

   x=:5 8

   1 _1 1*"1 x^/i.3
1 _5 25
1 _8 64

Then sum each row. Here you have to override the rank of the sum:

   +/"1]1 _1 1*"1 x^/i.3
21 57

But you might prefer using p. which is much cleaner.

   1 _1 1 p. x
21 57


On Thu, Aug 19, 2010 at 5:02 PM, Johann Hibschman
<[email protected]<jhibschman%[email protected]>
> wrote:

> (I accidentally sent this to j.general, to which I'm not yet subscribed;
> I don't expect that to go through, but if it does, apologies for the
> duplication.)
>
>
> Here's a simple question from a rank beginner:
>
> Expressing polynomials as, for example,
>
>  +/1 _1 1*x^i.3
>
> works well, as long as x is a scalar.  If x is of higher rank, this
> stops working.  My somewhat brute-force solution is to manually set the
> rank used, as in:
>
>  x=:2 3 5
>  +/1 _1 1*x^_ 0 i. 3
>
> Is this good style?  Is there a better way?
>
> Thanks, and pardon the pun,
> Johann
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to