[Scilab-users] u .^ k ?

Adrien Vogt-Schilb vogt at centre-cired.fr
Wed Dec 19 11:30:18 CET 2012


On 19/12/2012 11:17, Lamy Alain wrote:
> Hi,
>
> Does anyone know how to perform efficiently an operation like :
> u .^k
>
> with:
> u = [u1, u2, ..., un]  // ui : real numbers
> and:
> k = [k1; k2; kp]  // ki : positive integers
>
>
> The result being :
>
> [ u1^k1, u2^k1, ..., un^k1;
>    u1^k2, u2^k2, ..., un^k2;
> ...
>    u1^kp, u2^kp, ..., un^kp ]
>
>
> I know  how to do it with cumprod (for instance), but it does not seem to be
> efficient enough.
>
>

Hi

I'm not sure you can imagine something more efficient for the general 
case (arbitrary k's) than:

U = ones(1,n)*u;
K = ones(1,n)*k;

ans = U.^K;





>
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121219/dd4bc891/attachment.htm>


More information about the users mailing list