New answers tagged compile
7
Runs in a quarter-second by reformulating as a single two-index sum:
c = Compile[{{x, _Integer}},
Sum[1/Sqrt[a^2 + t^2 + (100000 - 0.7)^2] -
1/Sqrt[a^2 + t^2 + (100000 + 0.7)^2],
{t, 1, x - 1}, {a, t + 1, 40000}],
CompilationTarget -> "C", Parallelization -> True, RuntimeOptions -> "Speed"];
c[...
6
This runs in about a second:
Needs["CCompilerDriver`"]
c = Compile[{{x, _Integer}}, Block[{pover,t}, pover = 0.0; t = 1.0;
While[t <= x - 1,
pover = pover +
Total[Table[
1.0/Sqrt[a^2 + t^2 + (100000.0 - 0.7)^2] -
1.0/Sqrt[a^2 + t^2 + (100000.0 + 0.7)^2],
{a, t + 1, 40000.0,
1}]]; t++];
...
2
tst =
Block[{x = rlist[[1]], y = rlist[[1]]},
Module[{sol = (Last[#1] &) /@ First[NDSolve[{eqs, ic}, var, {t, -tmax, tmax}]],
Bsol}, Bsol = Table[Map[#1[t1] &, sol, {1}], {t1, ttlist}];
Map[(#1 . G0 . ConjugateTranspose[#1] &)[ttmesh Partition[#1 . Bsol, 2]] &,
smat, {2}]]]; // AbsoluteTiming
(* {0.0249631, Null} *...
Top 50 recent answers are included
Related Tags
compile × 539performance-tuning × 125
list-manipulation × 36
function-construction × 24
parallelization × 24
warning-messages × 23
ccompilerdriver × 20
numerics × 18
bugs × 18
matrix × 17
mathematical-optimization × 15
scoping × 15
functions × 14
programming × 14
numerical-integration × 11
random × 11
equation-solving × 10
recursion × 10
librarylink × 10
differential-equations × 9
complex × 9
evaluation × 8
linear-algebra × 8
plotting × 7
special-functions × 7