Reputation
70,378
Next tag badge:
213/100 score
19/20 answers
Badges
6 211 298
Newest
 Enlightened
Impact
~448k people reached

Mar
12
comment How make f[{x,y}] evaluate as f[x,y]?
"so Sequence along with Apply is much too sophisticated for them" - but here is a problem: what you request is not quite a trivial manipulation, and Apply and Sequence are exactly the tools. I can imagine that one may be able to find some twisted ways out, but I am sure those will be (much) harder to understand than Apply or Sequence. Actually, I don't consider the latter two so hard to comprehend. Apply "eats up" the head it operates on, replacing by another one, while Sequence means "no head", and gives a bare sequence of function's arguments. Not hard, even for a newbie.
Mar
12
comment Faster alternatives for DayOfWeek
@AndreasLauschke Yep, all your points make perfect sense to me.
Mar
12
comment Faster alternatives for DayOfWeek
@Andreas Re:Java compiler - it should be inside. My relaoder uses that. The JRE shipped with Mathematica is a bit non-standard, exactly in that it includes the compiler, while standard JREs don't. But I did not check for the version 9.
Mar
12
comment Faster alternatives for DayOfWeek
Oh boy, it's been 8 months already. The time is flying. Can't say I am too happy about that, I could have been more productive...
Mar
12
comment Faster alternatives for DayOfWeek
@Andreas Yes, true. Re: Stefan: There are tons of similar things to be done for Mathematica. One reason I like Mathematica as a platform is that so little has been done yet in terms of seamless interops with other languages / tools, and development tools for all this. So, I can learn by making some of these things (if only I had enough time for that ...:-)). By the way, Andreas has made big progress in this area with his JVM tools, they should get more traction.
Mar
12
comment Faster alternatives for DayOfWeek
+1. I should try using Joda library to see if I can beat that, but even if it so happens that pure Java code is somehow faster, I will probably lose anyway due to JLink/MathLink data transfer overhead - not to mention that this overhead is huge for smaller lists, which is not the case for LibraryLink.
Mar
12
comment Efficient implementation of a linear complexity measure of binary sequences
@Stefan "I'll stop" - no, why? I was just explaining my attitude for this particular answer. Actually, it may also be that your interpretation of it (getting the optimized version) is closer to what the OP wanted. I just wanted to illustrate that particular aspect of plain export of M code into C more or less verbatim, and the difference in performance, but it does not mean that my interpretation is the right one. For the one of "give me the fastest possible code", your suggestion is spot on and your version is better than mine.
Mar
12
comment Efficient implementation of a linear complexity measure of binary sequences
@Stefan By attribution I meant that I will mention that that input came from you :-). Re: understanding - not all folks here know C, and things like n & m-1 or memcpy can be cryptic enough for those who don't know it. My point basically was that just taking the code from Compile pretty much verbatim, and leaving all the rest to the compiler without doing further optimizations, can still lead to a rather dramatic speed-up in this case.
Mar
12
comment Efficient implementation of a linear complexity measure of binary sequences
@Stefan As I get some spare moment again, I will edit in your input (with attribution, of course).
Mar
12
comment Efficient implementation of a linear complexity measure of binary sequences
@Stefan Thanks for your input. I was not concerned with squeezing the every last millisecond out of the code, or I would have employed similar optimizations. My point was to have code with minimal changes from Mathematica's Compile, so that it is easy to follow for folks not too familiar with C ( I would have probably missed the unroll loops option but other things you described did cross my mind). So, the code may be badly written for the C standards, but it has been done intentionally, to make it easier to understand.
Mar
12
answered Efficient implementation of a linear complexity measure of binary sequences
Mar
10
comment Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs
@Jens So, thanks for the input, in particular it shows that some people read what I write, carefully enough :). I will make an edit and make my statements more precise, some time soon.
Mar
10
comment Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs
@Jens Yes, the first case I actually noticed, but was too lazy to correct my wording. Basically, my main point was that the decisions about renamings are made by Module. In the case Module[{z},Function[z,0]], it was smart enough to realize that simply keeping x in Function would be enough to avoid cinflicts. As to the second case, this seems to be a general problem with Module (and more generally, the emulation of lexical scoping in Mathematica): take Module[{z$, z}, 1], and you get the same. I wasn't aware of this particular issue, but I am not too surprised either.
Mar
8
comment Parallelization of REvaluate[]?
@Szabolcs I missed that one. Yes, this is the same idea - R libraries are just loaded into the JVM, so for all practical purposes, this is also just a parallel JLink problem. Actually, at the time, I saw both of your answers and upvoted both, but then I forgot about them. I think, people tend to remember their answers better than the answers of others, alas.
Mar
8
comment Parallelization of REvaluate[]?
@Szabolcs Actually, this may be important enough to include this as a section into the docs for RLink, for the next release.
Mar
8
comment Parallelization of REvaluate[]?
@Szabolcs Well, I think it is not quite a duplicate, because here one has to run several JVM and R instances, and while this is possible, it seems good to mention this explicitly. Also, this sort of uses for RLink seem general enough to merit its own discussion, even if this is a special case of the general question you have answered there.
Mar
8
comment Does pass-by-value affect the performance of function calls?
I think @Nasser makes a valid point. When one needs to modify something inside a function, passing symbol (variable) where that something is stored, by reference, greatly reduces the overhead of modification, since it is done in place. I actually also felt that this is worth mentioning back then, see my last comment to your answer on SO.
Mar
8
comment Does pass-by-value affect the performance of function calls?
@Nasser Actually, the question you linked is relevant, but only tangentially. Besides, the accepted answer there promotes dangerous practice of using Unevaluated, which is a wrong thing to do from the software development perspective. Instead, Hold- attributes should be used, as I emphasized in my answer there, and then also here.
Mar
8
comment Does pass-by-value affect the performance of function calls?
This excellent answer by @Szabolcs probably addresses most of this question.
Mar
8
comment OpenCL Dot Product
As an alternative, you may look for some Map-Reduce frameworks for GPUs, such as this. I never tried those, and it is probably also quite a bit of work. But the advantage here is that problems like your can be treated by Map-Reduce more directly and universally, while the first approach I suggested is not universal.