Дмитрий Рыбас on Sun, 21 Jul 2019 00:28:24 +0200


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

Re: Help understanding generating functions, (partitioning n into k parts)


Mike,

Make sure you feed it with n>k, as I forgot to insert checking that. Or put a check yourself :)


P.S. You can add something to each element of a vector this way:

apply(x->x+2,v)

Adds 2 to each element of v

Regards,
Dmitry.

суббота, 20 июля 2019 г. пользователь Mike Day <mike_liz.day@tiscali.co.uk> написал:
Should change this thread’s subject!
Tried pnk, by “mihaild” as sent by Dmitry ... yes, it’s good, and generates
P(n,i) for i in [1,k] which can be output instead. 

I’ve coded it back into J where it’s also good, and will try to bring it to the attention of the J programming forum when back home.  Quite tricky to recode the double loop on i, j to a single loop, which I might try sharing here, too,  when home again.

Qns:
A) why no cumulative vector sum/products in pari?
eg veccumsum(v) = vector (#v, i, v[i]+if(i>1, v[i-1], 0))

B) I can multiply a vector by an integer; why can’t I add an integer?

Thanks,

Mike
.     
Sent from my iPad