4,212 reputation
2947
bio website
location China
age
visits member for 2 years, 2 months
seen 2 hours ago

Feel free to correct the grammar mistakes in my posts.


Oct
9
comment Has this implementation of FDM touched the speed limit of Mathematica?
Just a side note, it's not necessary to make numbers inside Sin explicitly real and use "InlineExternalDefinitions" -> True, and in some computer (for example mine) one may need to use something like And @@ PossibleZeroQ[result2 - result // Chop] to test the result. Then, this answer is really… surprising, it seems to be the first example in this site showing devectorizing can speed up code inside Compile.
Oct
9
comment GCC compiler options passed by Mathematica
Does $CCompiler = {"Compiler" -> CCompilerDriver`MinGWCompiler`MinGWCompiler, "CompilerInstallation" -> "C:\\Program Files\\mingw-builds\\x64-4.8.1-posix-seh-rev5\\mingw64\\bin", "CompilerName" -> Automatic}; help?
Oct
9
revised Has this implementation of FDM touched the speed limit of Mathematica?
added 85 characters in body
Oct
9
accepted Bad performance of LengthWhile?
Oct
9
revised List of compilable functions
added 4 characters in body
Oct
9
answered List of compilable functions
Oct
9
comment Has this implementation of FDM touched the speed limit of Mathematica?
@AlexeyBobrick AFAIK, compilation is hard to combine with these techniques, which are much slower than compilation when used separately.
Oct
8
comment Bad performance of LengthWhile?
@ybeltukov BTW it's indeed strange that the predfun is defined inside findLastPosition, it only causes the side-effect: function definitions based on pattern-matching can't be inlined. (There seems to be no specific post for the issue, this is a related one, also notice the comments below. )
Oct
8
comment Bad performance of LengthWhile?
@ybeltukov I tested the code in my question. After deleting the definition of predfun and replacing all the predfun with pred, I got 1 second speed up.
Oct
8
revised Puzzling NDSolve[] behavior for PDE (smooth solution, inconsistent with boundary conditions)
modify the tags.
Oct
8
reviewed Approve suggested edit on Eliminating the Parameter: Transform parametric equation to Cartesian equation and draw arrows along parametric growth
Oct
8
comment Has this implementation of FDM touched the speed limit of Mathematica?
@blochwave That list isn't all… Span is compiled as we see with CompilePrint, and vectorization is still one of the most important way to speed up code even inside Compile, rewriting Span with loops only makes the code slower. Try fdtd1d = Compile[{{steps}}, Module[{ie = ie, ez = ez, hy = hy}, Do[Do[ez[[i + 1]] += (hy[[i + 1]] - hy[[i]]), {i, ie - 1}]; ez[[1]] = Sin[n/10]; Do[hy[[i]] += (ez[[i + 1]] - ez[[i]]), {i, ie}], {n, steps}]; ez]];
Oct
8
awarded  Inquisitive
Oct
8
revised Has this implementation of FDM touched the speed limit of Mathematica?
had a second look at those tag wikis and decided to add one more
Oct
8
comment Bad performance of LengthWhile?
@ybeltukov Just dug out the definition of Statistics`TakeWhileDump`findLastPosition with ?? and modified all the predfun part, the AbsoluteTiming changed from 3.7s to 2.7s in my computer.
Oct
8
comment Has this implementation of FDM touched the speed limit of Mathematica?
@blochwave Yeah, in this case "InlineExternalDefinitions" -> True or changing the beginning part to With[{ie2 = ie, ez2 = ez, hy2 = hy}, Compile[{{steps}}, Module[{ie = ie2, ez = ez2, hy = hy2}, … or With[{ie = 200}, Compile[{{steps}}, Module[{ez = Table[0., {ie + 1}], hy = Table[0., {ie}]}, … doesn't help, the bottleneck is inside Do.
Oct
8
revised Has this implementation of FDM touched the speed limit of Mathematica?
deleted 21 characters in body
Oct
8
comment Has this implementation of FDM touched the speed limit of Mathematica?
@DanielLichtblau Sadly the magic of C is ineffective here, at least with TDM-GCC 4.8.1 and Vista 32bit.
Oct
8
awarded  Nice Question
Oct
7
asked Has this implementation of FDM touched the speed limit of Mathematica?