« first day (458 days earlier)      last day (4016 days later) » 

1:57 AM
@J.M. Give me some minutes.. there is more to come..
 
Sure.
 
2:49 AM
@halirutan do you know how to efficiently use compiled functions in packages? The obvious way is to compile each time on package load, but is it possible to distribute a compiled function as a saved file or would it be better to compile it once on the specific platform and then save it (and load it instead of compiling it the next time)?
 
@rm-rf Currently, I'm using about 8 compiled functions in one of my packages. They are recompiled when the package is loaded and I wouldn't know whether it is worth the effort to save precompiled versions.
 
@halirutan Hmm... ok.
 
But when you compile to C, then it shouldn't be too hard to save the libraries and just reload them.
 
Thanks, I think I'll just recompile... it's just a few seconds anyway
 
@rm-rf Do we have an original question for this one?
-1
Q: Why is NonlinearModelFit calling the model function with symbolic arguments?

VladimirI have a model to fit which is made of numerical functions and so it can give a value for any numerical value of the arguments, but creates an error when called with symbols. NonlinearModelFit chooses numerical values for parameters and puts them in, but for the variables it keeps symbols when ca...

@rm-rf It's about calling Fit with a target-function having _?NumericQ arguments.
The usual mistake..
 
 
13 hours later…
drN
3:54 PM
When I write a module such as this: `myExp[x0_, p0_] := Module[{x = x0, p = p0},
exp = Sum[x^n/n!, {n, 0, p}] // N;
{exp, x, p}
]` to calculate `Exp[x]`. Is this already an approximation like an Interpolating function?
 
Hummm, I just commented on an old question and got -1 rep? Confused
@drN Hello
Not sure what you mean
The first element of the resulting list will be the exact value of the sum converted to machine precision, because of N. The other two elements will be exact.
 
drN
@Rojo I am having a difficult time phrasing my question. Don't yet know/understand mathematica jargon.
In other words, how does myExp compare with Exp[...]? I am trying to plot these two as we speak...
 
Exp is exact i fyou want it exact
 
drN
I see that myExp compares well (100%) with Exp[...]. So I suppose that besides being a good exercise, writing the whole module myExp is pointless.
What does "exact" mean? Why sin't myExp exact?
 
your myExp will only return machine precision numbers, and they probably won't completely match
What's your objective?
 
drN
4:02 PM
My objective: learning mathematica.
 
Great one
 
drN
@Rojo So I am told.
 
The exact result for Exp[1] is E
However, if I define exp[x_] := N@Exp[x]
exp[1] will be 2.718....
 
drN
Sure, Exp[1]//N = 2.71828 and so is myExp[1]. So I have just created a slower way of calculating Exp?
 
which is not exactly E
 
drN
4:03 PM
Aah... you have me there: Why is this not E?
 
Because E is an irrational number, and you would need an infinite number of bytes to represent it in standard numerical floating point blablah
Try, for example
 
drN
@Rojo So for all practical purposes, myExp and Exp compare well as a result of the constraint issued by MachinePrecision.
 
E - 2.7182818284590452353602874713526624977572470936987 // N
(exaggeration)
and now try
N@E - 2.7182818284590452353602874713526624977572470936987 // N
@drN Right
 
drN
Ok, the difference here in your suggested example is of $1 \times 10^{-48}$. So really nothing critical.
Ruddy latex doesn't seem to work!
 
Depends on what you want
E can be maniuplated symbolically, which can be nice
 
drN
4:07 PM
@Rojo What do you mean by "symbolic manipulation" in this case?
 
@drN Compare SeriesCoefficient[E^x, {x, 0, n}] to SeriesCoefficient[N[E]^x, {x, 0, n}]
Mathematica keeps everything exact until you ask it not to (except for a few numerical functions)
so if speed is not an issue you can work symbolically and in the end ask for whatever precision you need
Try plotting the distribution of the first 10000 digits of E
N[E, 10000] // RealDigits // First // Histogram
A middle ground would be to be explicit with the precision of numerical values and use arbitrary precision numbers.
Ohh, no need to star those comments, people will think I said something interesting
4
 
drN
Interesting. I did an absolute timing: `SeriesCoefficient[E^x, {x, 0, 10}] // N // AbsoluteTiming` which resulted in `{0.000545,2.75573*10^-7}`.

And another absolute time `SeriesCoefficient[N[E]^x, {x, 0, 10}] // AbsoluteTiming` which resulted in `{0.000151,2.75573*10^-7}`. Clearly the latter is *faster* since I suppose it levies a machine precision *tax* on calculations.
@Rojo Thanks a lot. I must now go and vaccum my house. Oh Saturday bloody staurday!
 
Right
It is usually a good practice for speedy numerical calculations to switch to machine numbers early
 
drN
@Rojo Now this (switching to machine prec.) is something I have never realized before. Thanks!
 
The difference between 2 and 2. (or 2`) can be huge in Mathematica
Never take it lightly :P
 
drN
4:16 PM
@Rojo What is 2`? I noticed that it is the fastest among 2, 2. and 2`.....
 
2. is the same as 2`, it means machine precision 2
2 is an Integer (so, it is exact)
 
drN
2 // AbsoluteTiming, 2. // AbsoluteTiming, 2` // AbsoluteTiming Resulted in {0.000045, 2}, {0.000023, 2.}, {0.000022, 2.} consistently.
 
That's weird, but
whatever the reason, not worth paying attention to that
Nothing is evaluated, so
no timing to compare
 
drN
Oh well... Thanks a bunch!
 
Try them with Do[2`, {10000000}] // AbsoluteTiming and you'll see what I mean
However, for real calculations
Nest[Sin, 2, 50000] // N
surely takes longer and more memory than
Nest[Sin, 2`, 50000] // N
 
4:38 PM
@Rojo -1 or +1?
 
5:01 PM
@drN If you want to see $\LaTeX$ in chat, see this.
 
drN
5:33 PM
@J.M. Thanks!
 
@rm-rf -1
but it came back up_
?
Ah, nevermind
 
drN
6:12 PM
@J.M. Ooooh! StartJax is nice!
@J.M. But will the other party see it too in chat? In case they don't "startJax"
 
@drN Yes, a lot of the people using the math.SE chatroom think so.
@drN Well, they have to install it themselves.
 
drN
@J.M. Fantastic! Thank you!
 
 
3 hours later…
9:18 PM
@Rojo I don't think I really understand that.
In[9]:= Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, _?(# != 0 &)]

Out[9]= {2, 3}

In[10]:= Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, Except[0]]

Out[10]= {1, 2, 3, 4, 5}
Pick really doesn't behave as advertised for Except
 
@SjoerdC.deVries That's because {0, 1}!=0 doesn't give True
so MatchQ[{1, 2}, _?(# != 0 &)] is False
 
@Rojo Pick's pattern is working on list element level
 
@SjoerdC.deVries Only after it fails at level 0 as far as my experience
 
Pick[list,sel,patt]
picks out those elements of list for which the corresponding element of sel matches patt.
official description
 
Then it doesn't work as advertised at all, for Except or for whatever
 
9:22 PM
note the word "elements"
?
 
Humm
Now you confused me too
 
It has always worked for me as I understood it, except now for Except
 
@SjoerdC.deVries For me it worked as I understood it
for all cases
but
I understood it as it worked
and not as officially described
which seems to be totally different
Well, actually at first I thought it was like you understand until I bumped into an issue and then just played around without going to the docs
 
To me, Pick sets up a True/False mask
 
Yeah
 
9:24 PM
which filters the first argument, either a list, or a list of lists
 
but it's not in level 1
Try for example Pick[{1, 2}, True]
 
The docs never describe it working at level 1. They always mentioned lists
 
or Pick[notList[boo], True], same
 
"Pick[list,sel,patt] picks out those list[[i1,i2,...]] for which sel[[i1,i2],...]] matches patt. "
 
@SjoerdC.deVries The heads in list and sel do not have to be List.
sel can be a nested list of any depth.
 
9:27 PM
That's close to my quote
 
@SjoerdC.deVries @Rojo Try Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, pat : 0]
 
nested list == list
 
The only "bonus" I see in the real behaviour that's undocumented is that it doesn't care about the selector's head being a list
@MichaelE2 I see that
I'm confused as to what's the confusion now
 
@MichaelE2 Interesting
I'm confused about you being confused
 
@SjoerdC.deVries I was confused because from your quote of the docs I thought it said it worked only on list elements
which made me think the docs where way off
 
9:30 PM
list elements may be lists
 
but the point is that it goes into every subexpression if necessary
 
MIchael's example is quite unexpected. A named pattern is a pattern nevertheless
 
Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, pat : 0]
Does {0, 1, 1, 0, 0} match pat:0?
No
Ok, then let's go inside {0, 1, 1, 0, 0}'s elements
Does 0, or 1, match pat:0?
No
 
why not?
In[17]:= Cases[{1, 2, 3}, pat : 1]

Out[17]= {1}
see my counterexample?
 
I see
Now I'm confused
 
9:36 PM
@MichaelE2 What do you think about Pick and Except?
 
Ok, I see now
 
I think it does not work as described.
 
Try this: Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, _?(! MatchQ[#, 0] &)]
How do you get the complement/negation of a pattern with Pick?
 
(I didn't leave, I'm fighting Pick on the side)
 
9:39 PM
@MichaelE2 hmmm, this is even weirder than Except. Without Not, everything goes as expected.
 
Hi, I remember once having seen a Manipulate that helps building other Manipulates (for adding controls), does someone know the link to this ? This is independent of your current discussion. Thanks
 
In any case, the fact that naming a pattern gives a different result than not naming it seems a different issue
 
Both Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, _?(# != 0 &)] and
Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, _?(# == 0 &)]
 
You need to avoid the pattern matching the whole selector
so it goes in level 1
 
do what I think they should do
 
9:40 PM
@SjoerdC.deVries Try the two with Trace -- you will see what @Rojo is talking about.
 
such as Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, Except[0 | _List]]
 
Minecraft computers blow my mind :P
 
@MichaelE2 I see, it starts at the whole list
 
@SjoerdC.deVries Yes, apparently Pick starts at level 0
 
This is definitely not as described in the docs
 
9:42 PM
I'm feeling my English isn't at it's best these days :P
 
@Rojo I think the English in the manual page leads one to ignore heads as potential matches
 
I suspect that the named pattern issue may be because of that optimization Pick got in the lasts versions
Anyone has v7 or below to test?
 
@MichaelE2 It's the worst kind — technically correct, but misleading :)
@Rojo I have 7
 
@rm-rf Nice
Could you try Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, 0 /; True]?
or Pick[{1, 2, 3, 4, 5}, {0, 1, 1, 0, 0}, patt:0]
 
{1,4,5} for both, but Except still fails
 
9:46 PM
@rm-rf Then all is clear
 
So you're saying that the optimizations added cause Except, /;, patt: etc. to not work?
 
I don't see Except's problem
but naming patterns that they optimized because they "don't have _s", or adding a condition to them, clearly brakes everything
 
@Rojo Not if you assume Pick should also work on the highest level
 
@SjoerdC.deVries Even if you don't, it's not Except
Pick[{1, 2, 4}, {0, 1}, {0, 1}]`
will work at level 0 too
 
hmm
Well, I'd say the naming of the function (Pick) and the description suggest a different modus operandi.
 
9:52 PM
Agreed
 
To select from a group
I feel the way the current implementation works out is probably unintended
 
@Rojo My understanding has always been that if MemberQ[sel, patt] returns True, then it returns elements in list corresponding to positions in sel where MatchQ[#, patt]& /@ sel is True.
Except[0] is definitely a pattern that is respected by MemberQ and MatchQ, and Pick fails in that respect, given the above interpretation.
 
@rm-rf That's the main use case
but that just seems to be a special case of how it works, it seems to scan the whole selector, preorder (like ReplaceAll)
 
@SjoerdC.deVries The way I see it now is that it prunes non-matches from the expression tree.
 
Stop whenever sel matches the pattern
and dig inside if it doesn't and if it still has somewhere to dig in
 
9:57 PM
@SjoerdC.deVries Wait
That's not quite right...
 
@rm-rf I had sketched some code a couple of days ago of how I think it works, here in chat, did you get to see it?
 
It goes down the branches, stop at any branch that matches, which is then included in the output.
 
Yeap
It eats up the selector
until its very depths
first trying the big chunks
and complaining if it has to go down smaller chunks with no counterpart in the expression (first argument)
 
Looks like it, but it's extremely badly documented. Not in the description, and certainly not in the examples
And I dont have a use for this behaviour
 
@SjoerdC.deVries I've had this idea of how Pick works for at least a year and never used it either
 
10:05 PM
@SjoerdC.deVries I suppose if one has nested lists and want to pick out the highest level lists with a property, it could be used. Something like _?(FreeQ[#, x]&)...?
 
I use Pick a lot, but only for list element matching. Now that I'm aware of its actual behaviour I may come up with something useful
 
@SjoerdC.deVries Let me know when you do. I have been empty so far :P
 
OK. I'm off to my SO now. Good night all!
 
Night
 
@SjoerdC.deVries Good night.
 
10:06 PM
@MichaelE2 How's all going?
 
@Rojo Pretty well. End of the semester. Tons of work.
How's it with you?
 
@MichaelE2 Nheeee
In my case, having tons of work and doing it totally are different things
These days I started missing MMA and this site. I've been quite inactive lately
I never lost the muscle memory to enter the site almost every day however
 
@Rojo Yeah, I check in everyday, but during the week, I don't really have time to deal with the interesting problems.
 
@MichaelE2 Hehe, happens
I had a couple of questions on my to-answer list
but
in time, I even forgot which they were
:)
 
10:23 PM
@SjoerdC.deVries @Rojo @MichaelE2 Please consider a Q&A for this... this was an interesting discussion about Pick's behaviour which (IMO) is un/poorly documented
 
@Rojo Sometimes I will get to them after a couple of days, but they won't get upvoted then, especially if there's already an accepted answer, even when the method of solution is distinct.
It's not the rep but the feeling that someone appreciated the answer.
 
@MichaelE2 Mr Wizard had a charitable fund for that
:D
I don't know if it still has funds
 
@Rojo Yes, he even encouraged me to through my answers and post some suggestions for the fund. First, it takes time, but mostly I'm too shy. I'd rather someone else look at the answer and say whether it's worthwhile.
 
@MichaelE2 I can relate
He thinks he owes me 200 rep
but is waiting for me to choose an answer of mine
He'll probably wait forever
 
@Rojo Alternately, you could use it for an unanswered question of yours (or 4 of them)... that way, it gets attention and someone else gets the bounty
but not the undo one... that'll probably be a waste
 
10:30 PM
Yeah. Let me see what my unanswered questions are
 
@Rojo I did look through some. The best had received enough votes. Most of the good ones had received some... I'm better at the math Qs than the programming ones.
 
Humm, I got an open question that only the Futz can answer, and he said he would "when he has time" (that was a year ago). He probably won't be motivated by rep
@mr.wizard, hellooooo
Could you put some small bounty on this question and consider it payment for the scheduledTasks thing?
for not having received enough attention
 
oops
:D
 
 
1 hour later…
11:56 PM
Hello! Does anyone know if it is possible in LibraryLink to get pointers to the actual arrays underlying MTensors so that we can manipulate their data directly rather than having to use the WolframLibraryData->MTensor_* functions? It seems otherwise one has the choice to either copy the tensors (memory cost) or to put all these function calls inside one's inner loops directly (performance cost)?
Or have I misunderstood and actually the WolframLibraryData->MTensor_get*Data functions provide this pointer directly rather than a pointer to a copy of the data?
 

« first day (458 days earlier)      last day (4016 days later) »