4,337 reputation
2947
bio website
location China
age
visits member for 2 years, 3 months
seen 2 days ago

Feel free to correct the grammar mistakes in my posts.


Oct
10
comment C compiler options passed by Mathematica
"C:\Program is not recognized……" seems that the white space in the path isn't recognized correctly. I'm not sure about the reason. Did you forget to add double quotation marks somewhere?
Oct
10
comment Has this implementation of FDM touched the speed limit of Mathematica?
@AlexeyBobrick I'm sorry but this won't work, as the document said, Parallelization -> True only works together with RuntimeAttributes -> {Listable}, it just makes a Listable compiled function paralleled, while it's not the case of this question.
Oct
9
comment Has this implementation of FDM touched the speed limit of Mathematica?
@AlexeyBobrick Just scaned this document and tried several flags in "CompileOptions" (-O3, -Ofast, etc.) but didn't get a speed-up… Could you give an example? (BTW -Ofast does help in speeding up this code :D)
Oct
9
comment C compiler options passed by Mathematica
@RolfMertig I guess the \\bin isn't the issue. Just found a 64-bit machine and tested OP's settings, I only changed the "CompilerInstall‌​ation" to mine i.e. "C:\\TDM-GCC-64\\bin", and it works well. BTW, why you think your test code failed to compile? What's the output of your greeter?
Oct
9
comment C compiler options passed by Mathematica
I have TDM-GCC installed in my computer. What's the output if you run CCompilers[Full]?
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 C 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
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
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
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
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.
Sep
30
comment Transfer graphics from Mathematica to Word without loss of quality
I think you lost a link :)
Sep
27
comment How to do replacements in Compile'd code?
Also, it's hard to tell what you're trying to do with your first piece of code: some of the definitions of the functions and variables are absent, what' more, as you said, it's polluted. You'd better clarify your intention more a bit.
Sep
27
comment How to do replacements in Compile'd code?
Well, why you want to make the replacement HoldPattern[e_ /. r_] :> Block[{}, (Hold[e] /. r) /; True]? Just a example? You're exploring how to write the code programmatically?
Sep
27
comment How to do replacements in Compile'd code?
Sorry for my poor English, I thought "do something in the spirit of this code" was suggesting that you're writing your code based on an idea showed in "this code" pasted in a link or something. Then what're you trying to achieve?
Sep
27
comment Increasing MaxPoints in NDSolve results in memory issue
"FiniteElement" in v10 might help. (Not tested, the wolfram cloud is currently down. ) See for example this, this and this post.
Sep
27
comment Discrepancy between Mathematica and Fortran expressions — Fortran gives wrong output (C,C++ programmer trying to use Fortran)
I suggest you give a minimal working example. (I know little fortran, but I think in fortran your code should be contained in a function or a subroutine or at least a loop, and some code for plotting is also necessary, right?) And the button for the uploading of image is here.