[Scilab-users] u .^ k ?

classic Classic list List threaded Threaded
4 messages Options
Alain LAMY Alain LAMY
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] u .^ k ?

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.








_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: u .^ k ?

Le 19/12/12 11:17, Lamy Alain a écrit :

> 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.
>
>
>
>
>
>
>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users

maybe u(ones(1,p),:).^k(:,ones(1,n)) ?

S.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Adrien Vogt-Schilb Adrien Vogt-Schilb
Reply | Threaded
Open this post in threaded view
|

Re: u .^ k ?

In reply to this post by Alain LAMY
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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Alain LAMY Alain LAMY
Reply | Threaded
Open this post in threaded view
|

Re: u .^ k ?

Thanks !

 

I'll check how efficient it is .

 

Alain

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users