Vectorization
- To: mathgroup at smc.vnet.net
- Subject: [mg60623] Vectorization
- From: "Marcelo Mayall" <mmayall at bol.com.br>
- Date: Thu, 22 Sep 2005 02:08:17 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
It's possible to initialize a vector starting from an elementary functions:
In[1]:=
Table[Sin[Random[]],{10000000}]//Timing//First
Out[1]=
3.203 Second
The same problem can be done a bit more efficiently if the elementary function is applied to the numerical vector:
In[2]:=
Sin[Table[Random[],{10000000}]]//Timing//First
Out[2]=
1.969 Second
But why the tendency is opposed when the numbers are complex ? Is this a bug ?
In[3]:=
Table[Sin[I Random[]],{1000000}]//Timing//First
Sin[Table[I Random[],{1000000}]]//Timing//First
Out[3]=
2.484 Second
Out[4]=
2.656 Second
Thanks,
Marcelo Mayall
- Follow-Ups:
- Re: Vectorization
- From: Zhengji Li <zhengji.li@gmail.com>
- Re: Vectorization