Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 81381

Questions about the generation and use of compiled functions using Compile.

3 votes

Something faster than RandomReal and RandomInteger?

No need to generate random numbers with every Do loop iteration. code2=Compile[{{data,_Real,2},{n,_Integer},{n1s,_Integer,1},{n2s,_Integer,1},{randoms,_Real,1}},Module[{sum=0.,len=Length[data],n1,n2,val … =0.}, Do[ n1=n1s[[i]]; n2=n2s[[i]]; val=Compile`GetElement[data,n1,1]/Compile`GetElement[data,n2,2]; If[val<randoms[[i]],sum+=val];,{i,1,n,1} ]; sum ],CompilationTarget->"C",RuntimeOptions->"Speed"]; …
Anton's user avatar
  • 1,128
3 votes

Making faster extraction of table elements in Mathematica or beyond

It's hard to give a precise answer, because the OP hasn't asked a precise question. Also, what the testcode returns equals to data. res1=ParallelMap[testcode[#,0.1*npts^2/2]&,data];//AbsoluteTiming …
Anton's user avatar
  • 1,128