[julia-users] Help in Array of mutable types
Any hint on how to do this?: type parms r::Vector{Float64} K::Vector{Float64} end r=rand(N)*(0.05-0.001)+0.001 K=rand(N)*100+1 p=Vector{parms} p[1]=parms(r,K) p[2]=parms(r,K) etc I get error: no method setindex!(Type{Array{parms,1}}, parms, Int64) while loading In[36], in expression starting on line 1 Many thanks
Re: [julia-users] Help in Array of mutable types
This line p=Vector{parms} seems like it’s not what you want. You want to create an object of that type, not the type, I imagine. To do that, try parms[] or Array(parms, 0) — Jon On Jun 15, 2014, at 11:24 PM, Jon Norberg jon.norb...@ecology.su.se wrote: p=Vector{parms}
[julia-users] Help with getting an array of arrays into a 2D array
When I'm working with time series data I often end up with things like this: function lowpass(lp::Float64, input::Float64, g::Float64) hp::Float64 = input - lp lp += g * hp [lp, hp] end s = 0.0; data=[flatten([t, lowpass(s, sin(t), 0.5)]) for t in linspace(0,2pi,20)] 20-element Array{Any,1}: [0.0,0.0,0.0] [0.330694,0.16235,0.324699] [0.661388,0.307106,0.614213] [0.992082,0.418583,0.837166] [1.32278,0.4847,0.9694] [1.65347,0.498292,0.996584] [1.98416,0.457887,0.915773] [2.31486,0.367862,0.735724] [2.64555,0.237974,0.475947] [2.97625,0.0822973,0.164595] [3.30694,-0.0822973,-0.164595] [3.63763,-0.237974,-0.475947] [3.96833,-0.367862,-0.735724] [4.29902,-0.457887,-0.915773] [4.62972,-0.498292,-0.996584] [4.96041,-0.4847,-0.9694] [5.2911,-0.418583,-0.837166] [5.6218,-0.307106,-0.614213] [5.95249,-0.16235,-0.324699] [6.28319,-1.22465e-16,-2.44929e-16] Can anyone please help out with how to turn an array of arrays like this into a 2D array? (or even to pass data as a single chunk into DataFrames to do the job?)
[julia-users] Re: Help with getting an array of arrays into a 2D array
Depending on the number of samples in your actual problem this might not be very performant (because ... is slow for large arrays) but here’s an approach using vcat. I had to generate the data slightly differently from you, because I had no function flatten. julia data = [[t,lowpass(s,sin(t),0.5)...] for t in linspace(0,2pi,20)] 20-element Array{Any,1}: [0.0,0.0,0.0] # etc... julia vcat([d' for d in data]...) 20x3 Array{Float64,2}: 0.00.0 0.0 0.330694 0.16235 0.324699 # etc... On Monday, June 16, 2014 8:54:57 AM UTC+2, Andrew Simper wrote: When I'm working with time series data I often end up with things like this: function lowpass(lp::Float64, input::Float64, g::Float64) hp::Float64 = input - lp lp += g * hp [lp, hp] end s = 0.0; data=[flatten([t, lowpass(s, sin(t), 0.5)]) for t in linspace(0,2pi,20)] 20-element Array{Any,1}: [0.0,0.0,0.0] [0.330694,0.16235,0.324699] [0.661388,0.307106,0.614213] [0.992082,0.418583,0.837166] [1.32278,0.4847,0.9694] [1.65347,0.498292,0.996584] [1.98416,0.457887,0.915773] [2.31486,0.367862,0.735724] [2.64555,0.237974,0.475947] [2.97625,0.0822973,0.164595] [3.30694,-0.0822973,-0.164595] [3.63763,-0.237974,-0.475947] [3.96833,-0.367862,-0.735724] [4.29902,-0.457887,-0.915773] [4.62972,-0.498292,-0.996584] [4.96041,-0.4847,-0.9694] [5.2911,-0.418583,-0.837166] [5.6218,-0.307106,-0.614213] [5.95249,-0.16235,-0.324699] [6.28319,-1.22465e-16,-2.44929e-16] Can anyone please help out with how to turn an array of arrays like this into a 2D array? (or even to pass data as a single chunk into DataFrames to do the job?)
Re: [julia-users] Help in Array of mutable types
Thanks! On Monday, June 16, 2014 8:26:11 AM UTC+2, John Myles White wrote: This line p=Vector{parms} seems like it’s not what you want. You want to create an object of that type, not the type, I imagine. To do that, try parms[] or Array(parms, 0) — Jon On Jun 15, 2014, at 11:24 PM, Jon Norberg jon.n...@ecology.su.se javascript: wrote: p=Vector{parms}
[julia-users] Re: Help with getting an array of arrays into a 2D array
I suspect it is easier to just pre-allocate an array of the correct dimensions and then assign into it. Something like this: function lowpassarray(arr::Vector{Float64}) out = Array(Float64, length(arr), 3) s = 0.0 for i in 1:length(arr) out[i, 1] = arr[i] out[i, 2], out[i, 3] = lowpass(s, sin(arr[i]), 0.5) end out end data = linspace(0, 2pi, 20) data = lowpassarray(data, 0.0) 20x3 Array{Float64,2}: 0.00.0 0.0 0.330694 0.16235 0.324699 0.661388 0.307106 0.614213 0.992082 0.418583 0.837166 1.322780.48470.9694 1.653470.498292 0.996584 1.984160.457887 0.915773 2.314860.367862 0.735724 2.645550.237974 0.475947 2.976250.0822973 0.164595 3.30694 -0.0822973-0.164595 3.63763 -0.237974 -0.475947 3.96833 -0.367862 -0.735724 4.29902 -0.457887 -0.915773 4.62972 -0.498292 -0.996584 4.96041 -0.4847 -0.9694 5.2911-0.418583 -0.837166 5.6218-0.307106 -0.614213 5.95249 -0.16235 -0.324699 6.28319 -1.22465e-16 -2.44929e-16 On Monday, June 16, 2014 9:54:57 AM UTC+3, Andrew Simper wrote: When I'm working with time series data I often end up with things like this: function lowpass(lp::Float64, input::Float64, g::Float64) hp::Float64 = input - lp lp += g * hp [lp, hp] end s = 0.0; data=[flatten([t, lowpass(s, sin(t), 0.5)]) for t in linspace(0,2pi,20)] 20-element Array{Any,1}: [0.0,0.0,0.0] [0.330694,0.16235,0.324699] [0.661388,0.307106,0.614213] [0.992082,0.418583,0.837166] [1.32278,0.4847,0.9694] [1.65347,0.498292,0.996584] [1.98416,0.457887,0.915773] [2.31486,0.367862,0.735724] [2.64555,0.237974,0.475947] [2.97625,0.0822973,0.164595] [3.30694,-0.0822973,-0.164595] [3.63763,-0.237974,-0.475947] [3.96833,-0.367862,-0.735724] [4.29902,-0.457887,-0.915773] [4.62972,-0.498292,-0.996584] [4.96041,-0.4847,-0.9694] [5.2911,-0.418583,-0.837166] [5.6218,-0.307106,-0.614213] [5.95249,-0.16235,-0.324699] [6.28319,-1.22465e-16,-2.44929e-16] Can anyone please help out with how to turn an array of arrays like this into a 2D array? (or even to pass data as a single chunk into DataFrames to do the job?)
[julia-users] Re: Using 0-dimensional arrays to store single boxed immutables
See also #964 https://github.com/JuliaLang/julia/issues/964 Ivar kl. 11:48:47 UTC+2 mandag 16. juni 2014 skrev Cristóvão Duarte Sousa følgende: While I've been used to use threads (heavyweight ones) everywhere in my projects, I'm starting to understand and really love the coroutines. They make lot more sense in many applications where I was used to use threads having to care about preemption and to use mutexes to avoid inconsistent shared memory states. Maybe this is not the best way to do it, but I'm sharing data between tasks using global consts. With mutables it guarantees type stability and good type inference inside the task functions, however, if I need to share a single Bool state it can't be const. On the other hand, if I make it not const then there will be no type stability with regards to that variable and type inference will not work. I've found out that I was able to create 0-dimensional arrays to box a single immutable element (in global scope): const flag = Array(Bool) and then use it inside tasks as: flag[] = true .. if flag[] . I tend to read the [] as the C dereference operator. My question is: is this a reasonable use of this feature?
Re: [julia-users] Re: Using 0-dimensional arrays to store single boxed immutables
Thanks Ivar. I see the issue is under investigation. On Mon, Jun 16, 2014 at 11:15 AM, Ivar Nesje iva...@gmail.com wrote: See also #964 https://github.com/JuliaLang/julia/issues/964 Ivar kl. 11:48:47 UTC+2 mandag 16. juni 2014 skrev Cristóvão Duarte Sousa følgende: While I've been used to use threads (heavyweight ones) everywhere in my projects, I'm starting to understand and really love the coroutines. They make lot more sense in many applications where I was used to use threads having to care about preemption and to use mutexes to avoid inconsistent shared memory states. Maybe this is not the best way to do it, but I'm sharing data between tasks using global consts. With mutables it guarantees type stability and good type inference inside the task functions, however, if I need to share a single Bool state it can't be const. On the other hand, if I make it not const then there will be no type stability with regards to that variable and type inference will not work. I've found out that I was able to create 0-dimensional arrays to box a single immutable element (in global scope): const flag = Array(Bool) and then use it inside tasks as: flag[] = true .. if flag[] . I tend to read the [] as the C dereference operator. My question is: is this a reasonable use of this feature?
[julia-users] juliabloggers.com is now live!
Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
[julia-users] Re: juliabloggers.com is now live!
Thanks a lot, this is great! Am Montag, 16. Juni 2014 13:17:47 UTC+2 schrieb Randy Zwitch: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
[julia-users] Re: juliabloggers.com is now live!
Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
Re: [julia-users] Re: juliabloggers.com is now live!
Thanks for putting this together, Randy. It's going to be really good to have all these blogs together in one place finally. On Mon, Jun 16, 2014 at 7:32 AM, Tomas Lycken tomas.lyc...@gmail.com wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
[julia-users] How to find the index of maximum but omitting to check any field eg not x [5,7]
I have a random vector x = rand (10) how to find the index of maximum but omitting to check any field eg not x [ 5,7] some like: indmax y = (x [but not read [5,7]]) Paul
[julia-users] Re: juliabloggers.com is now live!
Nothing shady about it at all and a good reminder I need to add a visible RSS icon. Here's the feed: http://www.juliabloggers.com/feed/ On Monday, June 16, 2014 7:32:49 AM UTC-4, Tomas Lycken wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
Re: [julia-users] Exception Efficiency
Not an answer to your questions, but: you might want to keep an eye on (or try out) this patch exposing labels and gotos at the user level. It was developed by Daniel Jones for parser backend purposes, and might be useful for a regex engine: https://github.com/JuliaLang/julia/pull/5699 (I believe it is going to be merged, just a question of when) On Thu, Jun 5, 2014 at 8:22 PM, andrew cooke and...@acooke.org wrote: in the docs it says that exceptions in julia are implemented using tasks. can i take that to mean that they come with a significant overhead? and do you pay for that overhead even if the exception is not thrown? in particular, what is the best way to handle errors in fairly tight loops: 1 - exceptions 2 - maybe types (ie unions with nothing) 3 - (flag, result) tuples (result is not a union but you have a tuple to unpack) and does that change if the excptions are common (say, 10% of loops) or rare (0.1%)? the reason i ask is that i am thinking of writing a regular expression engine in julia (i know it already has an interface to pcre, but it might be cool to have regular expressions over things other than characters, for example). that needs an efficient inner loop, but is also fairly complex, and i'm trying to sketch out how things might work. thanks, andrew
Re: [julia-users] Problem compiling Julia on Fedora
In that case, it's ext4. Thanks for the RPM link, I'll try that if I can't get the main repo to work. On Sunday, June 15, 2014 5:39:43 AM UTC-4, Milan Bouchet-Valat wrote: Le samedi 14 juin 2014 à 17:35 -0700, Jack Holland a écrit : KDE, using bash. KDE is your desktop environment, not your file system. :-) You can find out the file system by calling 'mount' and typically looking at the / or /home entries. Probably this will be ext4. But if you just want to use a recent Julia version, you can try my RPM package from this Copr project: http://copr.fedoraproject.org/coprs/nalimilan/julia/ Regards On Friday, June 13, 2014 4:02:21 PM UTC-4, Mike Nolta wrote: Which filesystem? -Mike On Fri, Jun 13, 2014 at 3:33 PM, Jack Holland jak...@gmail.com wrote: I'm not sure if this is the right place to ask this, but I can't find any documentation, posts, etc. on it anywhere else. I'm trying to compile Julia on Fedora 20 (x64), but I keep getting a strange error when running `make`: patching file dSFMT.h patch: getting attribute system.posix_acl_access of system.posix_acl_access: No data available patch: getting attribute system.posix_acl_default of system.posix_acl_default: No data available make[2]: *** [dsfmt-2.2/config.status] Error 2 make[1]: *** [julia-release] Error 2 make: *** [release] Error 2 Running with VERBOSE=1 prints the following lines preceding the above output: [my local directory structure]/julia/deps/jlchecksum dsfmt-2.2.tar.gz mkdir -p dsfmt-2.2 \ `which gtar 2/dev/null || which tar 2/dev/null` -C dsfmt-2.2 --strip-components 1 -xf dsfmt-2.2.tar.gz \ cd dsfmt-2.2 patch ../dSFMT.h.patch patch ../dSFMT.c.patch But I don't know how relevant those are to the problem. I would install dSFMT myself and tell Julia to use that version, but Make.inc doesn't include USE_SYSTEM_DSFMT or anything like that, so this approach doesn't appear to be a solution. I've also tried downloading all of the dependencies at once (using `make -C deps getall`) but that hasn't fixed it. Has anyone experienced this problem or know a workaround? Unfortunately, I don't have root access on my machine, but hopefully there is a solution that doesn't require it. Any suggestions or advice are appreciated! Thanks, Jack Holland
Re: [julia-users] juliabloggers.com is now live!
Looks great, Randy. Thanks for doing this. — John On Jun 16, 2014, at 5:52 AM, Randy Zwitch randy.zwi...@fuqua.duke.edu wrote: Nothing shady about it at all and a good reminder I need to add a visible RSS icon. Here's the feed: http://www.juliabloggers.com/feed/ On Monday, June 16, 2014 7:32:49 AM UTC-4, Tomas Lycken wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
Re: [julia-users] Sort array of tuples
On Sunday, June 15, 2014 5:11:31 PM UTC-4, Kevin Squire wrote: At one point while I was developing the OrderedDict class in DataStructures.jl, I made it possible to sort it (and sorting regular dictionaries returned an OrderedDict. It should be pretty easy to add that functionality back. You would need to load the DataStructures.jl package, of course. That makes a lot of sense to me. Is this something that works now, or are you suggesting this as a possible future functionality? Also, I assume the time it takes to sort an OrderedDict would be on the same order as sorting a Array of Tuple pairs. Is that right?
Re: [julia-users] Sort array of tuples
On Sunday, June 15, 2014 6:23:00 PM UTC-4, Stefan Karpinski wrote: Right, but for getting all the pairs in order, I don't think that ordering them during insertion is helpful – it would be better to just sort them all at once afterwards. I think so too. Which is why I don't think a priority queue is the right choice either. (Priority queues proactively keep order at insertion time, correct?)
Re: [julia-users] Sort array of tuples
Yep, I suspect that this approach is probably best: d = Dict{String,Int}() # count the words a = [ (c,w) for (w,c) in d ] sort!(a) For very large data, this may take up too much memory, however. I'm not sure if that's your situation. If your data is large enough to take up more than half of your available memory, then you need to get more clever. On Mon, Jun 16, 2014 at 11:42 AM, TR NS transf...@gmail.com wrote: On Sunday, June 15, 2014 6:23:00 PM UTC-4, Stefan Karpinski wrote: Right, but for getting all the pairs in order, I don't think that ordering them during insertion is helpful – it would be better to just sort them all at once afterwards. I think so too. Which is why I don't think a priority queue is the right choice either. (Priority queues proactively keep order at insertion time, correct?)
[julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian.osw...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com javascript: wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
[julia-users] Project organization and CLI
I am trying to organize my current project so that I have a few separate files/modules to keep things tidy, including a separate cli module for invoking the program. But I am having some trouble bringing it all together. The main of my project's layout is: bin/ corpus code/ cli.jl ngrams.jl ... Where `bin/corpus` contains: #!/usr/bin/env julia include(../code/cli.jl) Corpus.Cli.run(ARGS) And `code/cli.jl` starts out with: module Corpus module Cli include(./ngrams.jl) function run(args) ... But when I run `bin/corpus`, the program just hangs, and it appears to be doing so on the `include`. So how does one do this properly? I have read through the documentation on Modules, but it is not very clear to me. In fact, to be honest, it seems overly complicated, with `include`, `import`, `require`, `using`, etc. (Makes me long for the simplicity of Lua's and Javascript/NPM's `require`.) println(Corpus) include(../code/cli.jl) Corpus.Cli.run(ARGS)
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tree/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] support for '?' suffix on functions that return boolean types.
On Sunday, June 15, 2014 9:33:32 PM UTC-4, Jacob Quinn wrote: Yeah, I feel kind of torn on this on. On the one hand, I've kind of grown used to the `is...` method naming convention and it has nice discoverability properties (tab-completion) and isn't generally too awkward (though double s's are sometimes weird `issubset` `issubtype`, and it took me a while to figure out isa() = is a). The syntax-hungry beast in me though loves the handiness of adding a `?` to boolean methods. At this point, it's probably not worth the change, and my main concern would be combining it with the ternary operator: result = good?(x) ? good : bad The double `?` would probably get real old real fast. As a long time Rubyist, I concur that the double `?` from ternary operator has always been a little annoying. On the other hand the readability of `?`-suffixed predicate methods has easily outweighed the downside of this one usage. And in Julia at least you have a `()` in between. In Ruby you don't even have that. Valid Ruby: result = good? ? good : bad The Julia equivalent of result = good?() ? good : bad isn't so bad. And if I might add a small aside, ternary as an honest to god function: result = ?(good?(), good, bad)
Re: [julia-users] support for '?' suffix on functions that return boolean types.
We already have ifelse as the ternary function. If the function form has different evaluation rules than the operator form, then it ought to have a different name. On Mon, Jun 16, 2014 at 12:34 PM, TR NS transf...@gmail.com wrote: On Sunday, June 15, 2014 9:33:32 PM UTC-4, Jacob Quinn wrote: Yeah, I feel kind of torn on this on. On the one hand, I've kind of grown used to the `is...` method naming convention and it has nice discoverability properties (tab-completion) and isn't generally too awkward (though double s's are sometimes weird `issubset` `issubtype`, and it took me a while to figure out isa() = is a). The syntax-hungry beast in me though loves the handiness of adding a `?` to boolean methods. At this point, it's probably not worth the change, and my main concern would be combining it with the ternary operator: result = good?(x) ? good : bad The double `?` would probably get real old real fast. As a long time Rubyist, I concur that the double `?` from ternary operator has always been a little annoying. On the other hand the readability of `?`-suffixed predicate methods has easily outweighed the downside of this one usage. And in Julia at least you have a `()` in between. In Ruby you don't even have that. Valid Ruby: result = good? ? good : bad The Julia equivalent of result = good?() ? good : bad isn't so bad. And if I might add a small aside, ternary as an honest to god function: result = ?(good?(), good, bad)
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
That's an interesting comparison. Being on par with Java is quite respectable. There's nothing really obvious to change with that code and it definitely doesn't need so many type annotations – if the annotations do improve the performance, it's possible that there's a type instability somewhere without the annotation. The annotation would avoid the instability, but by converting, but conversion itself can be expensive. On Mon, Jun 16, 2014 at 12:21 PM, Florian Oswald florian.osw...@gmail.com wrote: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tree/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
[julia-users] Re: Project organization and CLI
Made a modicum of progress. I am not sure why, but it stopped hanging, and now I get a warning. replacing module Corpus and then an error that is can't find Ngrams. My `ngrams.jl` file starts out: module Corpus module Ngrams And now I am pretty sure I totally don't understand how different files are supposed to be included together.
Re: [julia-users] Re: Project organization and CLI
`include` is like copy-pasting the code from the included file into the spot where you called include. You shouldn't have `module Corpus` in ngrams.jl. -- Leah On Mon, Jun 16, 2014 at 11:53 AM, TR NS transf...@gmail.com wrote: Made a modicum of progress. I am not sure why, but it stopped hanging, and now I get a warning. replacing module Corpus and then an error that is can't find Ngrams. My `ngrams.jl` file starts out: module Corpus module Ngrams And now I am pretty sure I totally don't understand how different files are supposed to be included together.
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
I think that the log in openlibm is slower than most system logs. On my mac, if I use mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) the code runs 25 pct. faster. If I also use @inbounds and devectorise the max(abs) it runs in 2.26 seconds on my machine. The C++ version with the XCode compiler and -O3 runs in 1.9 seconds. 2014-06-16 18:21 GMT+02:00 Florian Oswald florian.osw...@gmail.com: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tree/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics -- Med venlig hilsen Andreas Noack Jensen
[julia-users] Julia advice/idioms for interacting with a REST api?
Hi all, Just getting started with Julia and enjoying it greatly. I have been working on porting some code from iPython notebooks to iJulia. I am stumped moving this from Python though: import requests t = requests.get(http://localhost:9000/project/penobscot/volume/penobscot_dz.sgy/1000/1001;) print t.json() In Julia if the payload is not gzipped I found this works: using Requests resp = get(http://localhost:9000/project/penobscot/volume/Penobscot.sgy/1251/1376;) println(JSON.parse(resp.data)) But when it is gzipped it doesn't work (the stack trace is below). Some questions are 1) do you all recommend using 'requests' module when working with JSON payloads and REST apis? 2) does 'requests' have an equivalent method to the Python library's .json() method? 3) if I have to unzip the payload myself from resp.data how do I do that in Julia? Thanks for any help or advice, pointers to a blog post or tutorial would be much appreciated too. Duncan Unknown value Line: 0 Around: ... 횏ǑƯ... ^ at In[79]:5 in error at error.jl:21 in _error at /Users/duncan/.julia/v0.2/JSON/src/Parser.jl:43 in parse_value at /Users/duncan/.julia/v0.2/JSON/src/Parser.jl:177 in parse at /Users/duncan/.julia/v0.2/JSON/src/Parser.jl:236 in parse at /Users/duncan/.julia/v0.2/JSON/src/JSON.jl:7
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Doing the math, that makes that optimized Julia version 18% slower than C++, which is fast indeed. On Mon, Jun 16, 2014 at 1:02 PM, Andreas Noack Jensen andreasnoackjen...@gmail.com wrote: I think that the log in openlibm is slower than most system logs. On my mac, if I use mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) the code runs 25 pct. faster. If I also use @inbounds and devectorise the max(abs) it runs in 2.26 seconds on my machine. The C++ version with the XCode compiler and -O3 runs in 1.9 seconds. 2014-06-16 18:21 GMT+02:00 Florian Oswald florian.osw...@gmail.com: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tree/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics -- Med venlig hilsen Andreas Noack Jensen
Re: [julia-users] Re: How to fork a child process and communicate low-level system calls between parent process (popen)?
Great, thanks for the info on base/poll.jl On Sunday, June 15, 2014 9:21:29 PM UTC-4, Jameson wrote: It's is unclear what you are asking for. The Julia Base library includes a high-performance, cross-platform framework for responding to file change events on disk. (see base/poll.jl) Interprocess communication is done through the creation of a named pipe. (see base/spawn.jl for examples) popen is unrelated to fork, select, or file notification. although the equivalent call in julia is more object-based, around the Cmd object and backtick (`) notation, and functions such as run, spawn, and open On Sun, Jun 15, 2014 at 7:54 PM, Alireza Nejati alire...@gmail.com javascript: wrote: It's my impression that to do this sort of stuff you should use Julia's built-in process creation/communication facilities. Have a look at this page: http://docs.julialang.org/en/release-0.1/manual/parallel-computing/ On Monday, June 16, 2014 10:57:28 AM UTC+12, Aerlinger wrote: I'm writing a package to allow a Julia program to asynchronously listen and respond to file change events on disk, but I've hit a bit of a stumbling block. I need a way to fork a Julia process and have it listen to specific OS system calls such as select, and then notify the parent process of the event. This is sometimes called 'popen' in other languages ( http://www.ruby-doc.org/core-2.1.2/IO.html#method-c-popen). I'm aware that there are a bunch of functions for handling general IO ( http://julia.readthedocs.org/en/latest/stdlib/base/#i-o) but they don't quite give me the control and interprocess communication that I'm looking for. There was also a short discussion about this a couple of years ago: https://groups.google.com/forum/#!topic/julia-dev/l-4HLYX2qSI. Was wondering if there have been any developments or if anyone else has some insight on this capability. Thanks!
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
interesting! just tried that - I defined mylog inside the computeTuned function https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L193 but that actually slowed things down considerably. I'm on a mac as well, but it seems that's not enough to compare this? or where did you define this function? On 16 June 2014 18:02, Andreas Noack Jensen andreasnoackjen...@gmail.com wrote: I think that the log in openlibm is slower than most system logs. On my mac, if I use mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) the code runs 25 pct. faster. If I also use @inbounds and devectorise the max(abs) it runs in 2.26 seconds on my machine. The C++ version with the XCode compiler and -O3 runs in 1.9 seconds. 2014-06-16 18:21 GMT+02:00 Florian Oswald florian.osw...@gmail.com: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tree/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics -- Med venlig hilsen Andreas Noack Jensen
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Different systems have quite different libm implementations, both in terms of speed and accuracy, which is why we have our own. It would be nice if we could get our log to be faster. On Mon, Jun 16, 2014 at 1:16 PM, Florian Oswald florian.osw...@gmail.com wrote: interesting! just tried that - I defined mylog inside the computeTuned function https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L193 but that actually slowed things down considerably. I'm on a mac as well, but it seems that's not enough to compare this? or where did you define this function? On 16 June 2014 18:02, Andreas Noack Jensen andreasnoackjen...@gmail.com wrote: I think that the log in openlibm is slower than most system logs. On my mac, if I use mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) the code runs 25 pct. faster. If I also use @inbounds and devectorise the max(abs) it runs in 2.26 seconds on my machine. The C++ version with the XCode compiler and -O3 runs in 1.9 seconds. 2014-06-16 18:21 GMT+02:00 Florian Oswald florian.osw...@gmail.com: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tree/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming- Languages-Economics -- Med venlig hilsen Andreas Noack Jensen
Re: [julia-users] Re: Project organization and CLI
On Monday, June 16, 2014 12:56:29 PM UTC-4, Leah Hanson wrote: `include` is like copy-pasting the code from the included file into the spot where you called include. You shouldn't have `module Corpus` in ngrams.jl. Thanks. That helps me understand include(). Unfortunately it doesn't seem to bring things together though. Per your advice, I add a new corpus.jl file: module Corpus include(cli.jl) include(ngrams.jl) end And I removed `module Corpus` from both cli.jl and ngrams.jl. Then in `bin/corpus` I change the include to `include(../code/corpus.jl)`. The end result is the error: `Ngrams not defined`. Apparently the cli.jl code can't see the ngrams.jl code?
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
From the sound of it, one possibility is that you made it a private function inside the computeTuned function. That creates the equivalent of an anonymous function, which is slow. You need to make it a generic function (define it outside computeTuned). --Tim On Monday, June 16, 2014 06:16:49 PM Florian Oswald wrote: interesting! just tried that - I defined mylog inside the computeTuned function https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/ master/julia/floswald/model.jl#L193 but that actually slowed things down considerably. I'm on a mac as well, but it seems that's not enough to compare this? or where did you define this function? On 16 June 2014 18:02, Andreas Noack Jensen andreasnoackjen...@gmail.com wrote: I think that the log in openlibm is slower than most system logs. On my mac, if I use mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) the code runs 25 pct. faster. If I also use @inbounds and devectorise the max(abs) it runs in 2.26 seconds on my machine. The C++ version with the XCode compiler and -O3 runs in 1.9 seconds. 2014-06-16 18:21 GMT+02:00 Florian Oswald florian.osw...@gmail.com: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tr ee/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/bl ob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics -- Med venlig hilsen Andreas Noack Jensen
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Here's an economics blog post that links to this study: http://juliaeconomics.com/2014/06/15/why-i-started-a-blog-about-programming-julia-for-economics/ On Mon, Jun 16, 2014 at 1:30 PM, Tim Holy tim.h...@gmail.com wrote: From the sound of it, one possibility is that you made it a private function inside the computeTuned function. That creates the equivalent of an anonymous function, which is slow. You need to make it a generic function (define it outside computeTuned). --Tim On Monday, June 16, 2014 06:16:49 PM Florian Oswald wrote: interesting! just tried that - I defined mylog inside the computeTuned function https://github.com/floswald/Comparison-Programming-Languages-Economics/blob/ master/julia/floswald/model.jl#L193 but that actually slowed things down considerably. I'm on a mac as well, but it seems that's not enough to compare this? or where did you define this function? On 16 June 2014 18:02, Andreas Noack Jensen andreasnoackjen...@gmail.com wrote: I think that the log in openlibm is slower than most system logs. On my mac, if I use mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) the code runs 25 pct. faster. If I also use @inbounds and devectorise the max(abs) it runs in 2.26 seconds on my machine. The C++ version with the XCode compiler and -O3 runs in 1.9 seconds. 2014-06-16 18:21 GMT+02:00 Florian Oswald florian.osw...@gmail.com: Hi guys, thanks for the comments. Notice that I'm not the author of this code [so variable names are not on me :-) ] just tried to speed it up a bit. In fact, declaring types before running the computation function and using @inbounds made the code 24% faster than the benchmark version. here's my attempt https://github.com/floswald/Comparison-Programming-Languages-Economics/tr ee/master/julia/floswald should try the Base.maxabs. in profiling this i found that a lot of time is spent here: https://github.com/floswald/Comparison-Programming-Languages-Economics/bl ob/master/julia/floswald/model.jl#L119 which i'm not sure how to avoid. On 16 June 2014 17:13, Dahua Lin linda...@gmail.com wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming- Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics -- Med venlig hilsen Andreas Noack Jensen
Re: [julia-users] support for '?' suffix on functions that return boolean types.
On Monday, June 16, 2014 12:39:39 PM UTC-4, Stefan Karpinski wrote: We already have ifelse as the ternary function. If the function form has different evaluation rules than the operator form, then it ought to have a different name. Ok. I suppose it couldn't evaluate like the ternary operator. Well, just ignore the last statement about the ?() function. I was really just being a bit silly there, and it isn't relevant to the main of the conversation.
Re: [julia-users] Re: Project organization and CLI
Could you post a gist with all the files? (https://gist.github.com/) It would be easier to understand what's going on if I could see the whole thing. Have you tried switching the order of the imports? `cli.jl` won't be able to see `ngrams.jl` if all of cli is included run first, before ngrams is included run. -- Leah On Mon, Jun 16, 2014 at 12:31 PM, TR NS transf...@gmail.com wrote: On Monday, June 16, 2014 12:56:29 PM UTC-4, Leah Hanson wrote: `include` is like copy-pasting the code from the included file into the spot where you called include. You shouldn't have `module Corpus` in ngrams.jl. Thanks. That helps me understand include(). Unfortunately it doesn't seem to bring things together though. Per your advice, I add a new corpus.jl file: module Corpus include(cli.jl) include(ngrams.jl) end And I removed `module Corpus` from both cli.jl and ngrams.jl. Then in `bin/corpus` I change the include to `include(../code/corpus.jl)`. The end result is the error: `Ngrams not defined`. Apparently the cli.jl code can't see the ngrams.jl code?
Re: [julia-users] juliabloggers.com is now live!
Good job on getting this going, need to figure out how to seperate out Julia posts from my blog. Could the theme be adjusted to point the source blog under the post title? On Monday, June 16, 2014 11:05:02 AM UTC-4, John Myles White wrote: Looks great, Randy. Thanks for doing this. — John On Jun 16, 2014, at 5:52 AM, Randy Zwitch randy@fuqua.duke.edu javascript: wrote: Nothing shady about it at all and a good reminder I need to add a visible RSS icon. Here's the feed: http://www.juliabloggers.com/feed/ On Monday, June 16, 2014 7:32:49 AM UTC-4, Tomas Lycken wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
[julia-users] How Delete row or col of array? like deleteat! in vectors
a=rand(5,5) how Delete row(s) or col(s) of array ? Paul
[julia-users] Re: How to find the index of maximum but omitting to check any field eg not x [5,7]
No sugestion ? Paul W dniu poniedziałek, 16 czerwca 2014 14:06:23 UTC+2 użytkownik paul analyst napisał: I have a random vector x = rand (10) how to find the index of maximum but omitting to check any field eg not x [5,7] some like: indmax y = (x [but not read [5,7]]) Paul
Re: [julia-users] Re: Project organization and CLI
You can see the project here: https://github.com/openbohemians/corpus But I've now changed the code to get it to work. I just had to throw the `Corpus` module out the window and include `ngrams.jl` directly into `cli.jl`. That works, but it doesn't get me anywhere with designing more complex compositions in the future -- I was hoping to have a few submodules in the end, `Corpus.Ngrams`, `Corpus.Words` and `Corpus.Letters`. I started looking at some other projects to see how other's did things. I am seeing the same basic pattern: A single main capitalized file that has the *only* module statement and every other file is a set of types and functions dumped into it (via include). I have yet to find a project using submodules.
Re: [julia-users] Re: Project organization and CLI
There's significantly less need for fine-grained modules in Julia. Is the lack of submodules causing some kind of problem or just discomfort at their absence? On Mon, Jun 16, 2014 at 2:56 PM, TR NS transf...@gmail.com wrote: You can see the project here: https://github.com/openbohemians/corpus But I've now changed the code to get it to work. I just had to throw the `Corpus` module out the window and include `ngrams.jl` directly into `cli.jl`. That works, but it doesn't get me anywhere with designing more complex compositions in the future -- I was hoping to have a few submodules in the end, `Corpus.Ngrams`, `Corpus.Words` and `Corpus.Letters`. I started looking at some other projects to see how other's did things. I am seeing the same basic pattern: A single main capitalized file that has the *only* module statement and every other file is a set of types and functions dumped into it (via include). I have yet to find a project using submodules.
Re: [julia-users] juliabloggers.com is now live!
I definitely plan on putting a more obvious attribution on the posts, I just need to take a minute and refresh my PHP :) I looked at your blog Iain, you're using Jekyll? For the dynamic platforms like WordPress, every category and tag gets its own RSS feed. Not sure if you need to custom build that functionality for your blog, as I'm not familiar with that framework. On Monday, June 16, 2014 2:25:16 PM UTC-4, Iain Dunning wrote: Good job on getting this going, need to figure out how to seperate out Julia posts from my blog. Could the theme be adjusted to point the source blog under the post title? On Monday, June 16, 2014 11:05:02 AM UTC-4, John Myles White wrote: Looks great, Randy. Thanks for doing this. — John On Jun 16, 2014, at 5:52 AM, Randy Zwitch randy@fuqua.duke.edu wrote: Nothing shady about it at all and a good reminder I need to add a visible RSS icon. Here's the feed: http://www.juliabloggers.com/feed/ On Monday, June 16, 2014 7:32:49 AM UTC-4, Tomas Lycken wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
Re: [julia-users] Re: Metaprogramming weirdness
There's no way to do that that I know of, but it might be possible (though nontrivial) to implement functionality of that kind through a macro. Much of the code in the Debug.jl package is dedicated to that kind of AST analysis, though so far not exposed for other purposes.
[julia-users] Re: How Delete row or col of array? like deleteat! in vectors
deleting in place a matrix is not supported and does not make sense. why is that? you've for instance a 5x5 matrix and you want to delete an item. deleteat! shifts subsequent items to fill the resulting gap, so you're loosing dimensionality. basically what you can do is this: a = deleteat!(a[1:end], 1) which is deleting item at position 1. if you want to bring that back into a matrix representation the problems rear up. what dimension you'll have afterwards? 6x4? if you delete another one you'll have 23 elements left, which is really hard to bring into a 2D shape. in the end you've to come up with your own scheme with deleting an item at (i, j). deleting an item and presuming deleting means zeroing it out: a[2,2] = convert(eltype(a), 0) deleting the 2nd column: a[:,2] = convert(eltype(a), 0) deleting the 1st row: a[1, 1:end] = convert(eltype(a), 0) don't know if this tackles your question, but hope this helps.
[julia-users] Re: How to find the index of maximum but omitting to check any field eg not x [5,7]
Probably, it would be easier to simply write a loop u = trues(length(x)) u[[5, 7]] = false ir = 0 vr = -Inf for i = 1:length(x) if u[i] x[i] vr ir = i vr = x[i] end end # ir would be what you want If are your list of numbers are all positive, you can write this in a more concise way ir = indmax(x .* u) Dahua On Monday, June 16, 2014 7:06:23 AM UTC-5, paul analyst wrote: I have a random vector x = rand (10) how to find the index of maximum but omitting to check any field eg not x [5,7] some like: indmax y = (x [but not read [5,7]]) Paul
[julia-users] signals handling
Is there a way to handle signals such as SIGINT in Julia?
Re: [julia-users] Re: Metaprogramming weirdness
I'm not sure if it would help your case, but I did something similar for a much simpler case. The result is kind of hideous but it works. I wanted to expose a function called debug from the Lumberjack.jl logging package as a macro, so function arguments would not be evaluated when the current loglevel was less verbose. I'm sure there is a less hideous way to do this, but this is what ended up working after trial and error: using Lumberjack # defines the debug function, among others macro debug(msg) :(esc(debug(string($(esc(msg)) end So inside the macro, debug resolves to a function defined in the scope of this file (through the using Lumberjack statement). Other files that import this one do not import Lumberjack, yet this macro works, which is why I think it might be similar to your case. On Friday, June 13, 2014 1:45:52 PM UTC-4, Andrew McKinlay wrote: Is it possible to quote code where the methods are already resolved? For example, instead of `+` being a symbol in the quoted code, it would be resolved to the + operator from the current module? On Friday, May 23, 2014 8:31:19 PM UTC-4, Isaiah wrote: parse(...codez...) can be helpful too. For (1) (2), the single-quoted numbers are interpreted as literals rather than symbols. It is possible to create a Symbol called `:1` with `symbol(1)`, if needed, but that seems strange. The entry syntax `:1` might be disallowed for efficiency and disambiguation - I'm not sure. For (3), in general, a TopNode tells the compiler to resolve any names to the current base module. It might be illustrative to look at the difference between these expressions: julia a = 1 1 julia :($a + 1) :(1 + 1) julia :(1+:(a+2)) :(1 + :(a + 2)) julia :(1+:($a+2)) :(1 + top(Expr)(:call,:+,a,2)) The last case asks for an interpolation which cannot be expanded at parse time, because the interpolation is quoted. The `top(Expr)` and `call` are generated to guarantee that `foo` - whatever the value of `foo` ends up as in the Top module namespace - is used when the expression is evaluated. (as an aside, eval'ing those last two examples will give errors, because it is not possible to add an Int and an Expr) On Fri, May 23, 2014 at 3:53 PM, Adam Smith swiss.arm...@gmail.com wrote: I find it quite helpful to use dump() on expressions to see the first few levels of the parsed AST. That makes it easier to see what Julia is doing with your expressions. On Thursday, May 22, 2014 5:17:13 PM UTC-4, Andrew McKinlay wrote: I have been trying to grok Julia macros, so I've dived into the metaprogramming docs. Whilst playing around with the interpreter, I've run into some peculiarities that I don't quite understand. julia versioninfo() Julia Version 0.3.0-prerelease+2690 Commit e4c2f68* (2014-04-20 12:15 UTC) ... 1. Why is typeof( :(:(1+2)) ) == Expr, but typeof( :(:(1)) ) == QuoteNode? 2. Why is typeof( :(1) ) == Int64, but again typeof( :(:(1)) ) == QuoteNode? 3. Why is typeof( :(1+:($1+2)).args[3].args[1] ) == TopNode? I was assuming that quoting was just a shorthand way for constructing expressions, since the docs say: There is special syntax for “quoting” code (analogous to quoting strings) that makes it easy to create expression objects without explicitly constructing Expr objects. But the types of objects constructed by quoting do not always take the form of an Expr, as above. What is going on here?
Re: [julia-users] Re: Project organization and CLI
On Monday, June 16, 2014 3:07:36 PM UTC-4, Stefan Karpinski wrote: There's significantly less need for fine-grained modules in Julia. Is the lack of submodules causing some kind of problem or just discomfort at their absence? Is there? I always appreciated code that broke things up into reasonably manageable chunks. Having a single module with a dozens upon dozens of functions tends to overtax the function namespace. For example, in my case I want the separate submodules so I can do `Ngrams.report(...)` and `Words.report(...)` rather than having them in the same space with function names `ngramsreport()` and `wordsreport`, plus having to ensure none of their supporting function names clash. Presently I was able to work around my previous troubles by dumping the Cli module and just have a `cli()` method within the toplevel Corpus module, under which I import the submodules. That works well. The only potential problem I foresee is sharing code between submodules. Since Cli previously was unable to see Ngrams, I imagine all my submodules are going to have the same issue if I create a Utils module to be shared. if so, that means I will have to include utils.jl into each submodule. But will that create code redundancy --the same exact code being included multiple times in different places? I am too new to Julia, so its too early for me to say if it's a real disadvantage or simply a discomfort of unfamiliarity. But I will note that I have a renewed appreciation of Ruby's open class approach.
Re: [julia-users] Re: Project organization and CLI
Generic functions are the reason this issue is less pressing in Julia. Instead of Ngrams.report and Words.report or ngramsreport and wordsreport, you can have report(x::Ngrams, ...) and report(x::Words, ...) – Ngrams, Words and report can all live in the same namespace without any issues and the two report methods are just different ways to report things. On Mon, Jun 16, 2014 at 4:13 PM, TR NS transf...@gmail.com wrote: On Monday, June 16, 2014 3:07:36 PM UTC-4, Stefan Karpinski wrote: There's significantly less need for fine-grained modules in Julia. Is the lack of submodules causing some kind of problem or just discomfort at their absence? Is there? I always appreciated code that broke things up into reasonably manageable chunks. Having a single module with a dozens upon dozens of functions tends to overtax the function namespace. For example, in my case I want the separate submodules so I can do `Ngrams.report(...)` and `Words.report(...)` rather than having them in the same space with function names `ngramsreport()` and `wordsreport`, plus having to ensure none of their supporting function names clash. Presently I was able to work around my previous troubles by dumping the Cli module and just have a `cli()` method within the toplevel Corpus module, under which I import the submodules. That works well. The only potential problem I foresee is sharing code between submodules. Since Cli previously was unable to see Ngrams, I imagine all my submodules are going to have the same issue if I create a Utils module to be shared. if so, that means I will have to include utils.jl into each submodule. But will that create code redundancy --the same exact code being included multiple times in different places? I am too new to Julia, so its too early for me to say if it's a real disadvantage or simply a discomfort of unfamiliarity. But I will note that I have a renewed appreciation of Ruby's open class approach.
Re: [julia-users] Re: Project organization and CLI
You should definitely not include the same code many times – in that case, what you need is a module that all the users use. On Mon, Jun 16, 2014 at 4:43 PM, Stefan Karpinski ste...@karpinski.org wrote: Generic functions are the reason this issue is less pressing in Julia. Instead of Ngrams.report and Words.report or ngramsreport and wordsreport, you can have report(x::Ngrams, ...) and report(x::Words, ...) – Ngrams, Words and report can all live in the same namespace without any issues and the two report methods are just different ways to report things. On Mon, Jun 16, 2014 at 4:13 PM, TR NS transf...@gmail.com wrote: On Monday, June 16, 2014 3:07:36 PM UTC-4, Stefan Karpinski wrote: There's significantly less need for fine-grained modules in Julia. Is the lack of submodules causing some kind of problem or just discomfort at their absence? Is there? I always appreciated code that broke things up into reasonably manageable chunks. Having a single module with a dozens upon dozens of functions tends to overtax the function namespace. For example, in my case I want the separate submodules so I can do `Ngrams.report(...)` and `Words.report(...)` rather than having them in the same space with function names `ngramsreport()` and `wordsreport`, plus having to ensure none of their supporting function names clash. Presently I was able to work around my previous troubles by dumping the Cli module and just have a `cli()` method within the toplevel Corpus module, under which I import the submodules. That works well. The only potential problem I foresee is sharing code between submodules. Since Cli previously was unable to see Ngrams, I imagine all my submodules are going to have the same issue if I create a Utils module to be shared. if so, that means I will have to include utils.jl into each submodule. But will that create code redundancy --the same exact code being included multiple times in different places? I am too new to Julia, so its too early for me to say if it's a real disadvantage or simply a discomfort of unfamiliarity. But I will note that I have a renewed appreciation of Ruby's open class approach.
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Hi I am one of the authors of the paper :) Our first version of the code did not declare types. It was thanks to Florian's suggestion that we started doing it. We discovered, to our surprise, that it reduced execution time by around 25%. I may be mistaken but I do not think there are type-stability problems. We have a version of the code that is nearly identical in C++ and we did not have any of those type problems. On Monday, June 16, 2014 11:55:50 AM UTC-4, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com javascript: wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Hi 1) Yes, we pre-compiled the function. 2) As I mentioned before, we tried the code with and without type declaration, it makes a difference. 3) The variable names turns out to be quite useful because this code will be eventually nested into a much larger project where it is convenient to have very explicit names. Thanks On Monday, June 16, 2014 12:13:44 PM UTC-4, Dahua Lin wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
[julia-users] signals handling
SIGINT gets converted to a InterruptException, that can be caught in a catch statement. If you happened to be in a ccall, you might cause your program to be in a corrupt state and leak resources such as memory. I'm not sure how you can interact with other signals.
[julia-users] An appreciation of two contributors among many
So many talented people have contributed so much to the Julia project that it would not be possible to acknowledge them all. Nonetheless, my recent work has made me especially appreciative of the work of Tim Holy for the Profile code and the ProfileView package and of Dahua Lin for the NumericExtensions and NumericFuns in particular. These are incredible tools. It is so easy to forget the you should profile before you attempt to optimize your code. I just learned that again. I was getting very good performance on an example using my MixedModels package - about twice the speed of the R/C++ package lme4 that other contributors and I have been working on seemingly forever. Then I profiled my Julia code, which was already 2-3 as fast as the R/C++ version, viewed the profile and thought, what's that wide bar over on the left?. I knew where the function must be spending its time and, of course, most of the time was being taken up in another part of the function entirely. Some rewriting has now resulted in code that is 10 times as fast as the R/C++ code. I had a similar experience earlier in this development cycle when I replaced a call to fma! in the NumericExtensions package with an explicit loop using @inbounds that I knew would be just as fast. It wasn't.
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Also, defining mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) made quite a bit of difference for me, from 1.92 to around 1.55. If I also add @inbounds, I go down to 1.45, making Julia only twice as sslow as C++. Numba still beats Julia, which kind of bothers me a bit Thanks for the suggestions. On Monday, June 16, 2014 4:56:34 PM UTC-4, Jesus Villaverde wrote: Hi 1) Yes, we pre-compiled the function. 2) As I mentioned before, we tried the code with and without type declaration, it makes a difference. 3) The variable names turns out to be quite useful because this code will be eventually nested into a much larger project where it is convenient to have very explicit names. Thanks On Monday, June 16, 2014 12:13:44 PM UTC-4, Dahua Lin wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] An appreciation of two contributors among many
Thank you! Reading your message was a very nice way to finish off my official work day. Best, --Tim On Monday, June 16, 2014 02:48:56 PM Douglas Bates wrote: So many talented people have contributed so much to the Julia project that it would not be possible to acknowledge them all. Nonetheless, my recent work has made me especially appreciative of the work of Tim Holy for the Profile code and the ProfileView package and of Dahua Lin for the NumericExtensions and NumericFuns in particular. These are incredible tools. It is so easy to forget the you should profile before you attempt to optimize your code. I just learned that again. I was getting very good performance on an example using my MixedModels package - about twice the speed of the R/C++ package lme4 that other contributors and I have been working on seemingly forever. Then I profiled my Julia code, which was already 2-3 as fast as the R/C++ version, viewed the profile and thought, what's that wide bar over on the left?. I knew where the function must be spending its time and, of course, most of the time was being taken up in another part of the function entirely. Some rewriting has now resulted in code that is 10 times as fast as the R/C++ code. I had a similar experience earlier in this development cycle when I replaced a call to fma! in the NumericExtensions package with an explicit loop using @inbounds that I knew would be just as fast. It wasn't.
[julia-users] animation using Gtk+/Cairo
I was looking for a way to display a simulation in Julia. Originally I was going to just use PyPlot, but it occurred to me it would be better to just use Gtk+ + Cairo to do the drawing rather than something whose main purpose is drawing graphs. So far, following the examples on the Github page, I have no problem creating a window with a Cairo canvas. I can also display content on the canvas fairly easily (which speaks volumes on the awesomeness of Julia and the Gtk+ library). However, after looking through the code and samples, it's not obvious to me how to redraw the canvas every fraction of a second to display new content. I did find an example of animating with Cairo and Gtk+ in C (http://cairographics.org/threaded_animation_with_cairo/). However, I assume one would want to use Julia's timers instead of of GLibs? Secondly, there in their function 'timer_exe', call is made directly to Gtk+ to send a redraw queue to the window. Is there a cleaner way to do it with the Gtk+ library? Thanks! A
Re: [julia-users] juliabloggers.com is now live!
Ok, there is now more obvious attribution on each post, with the author name and link of the original post prominently displayed before the article. If anyone else has any other recommendations/requests (still need a logo!), please let me know. On Monday, June 16, 2014 3:13:25 PM UTC-4, Randy Zwitch wrote: I definitely plan on putting a more obvious attribution on the posts, I just need to take a minute and refresh my PHP :) I looked at your blog Iain, you're using Jekyll? For the dynamic platforms like WordPress, every category and tag gets its own RSS feed. Not sure if you need to custom build that functionality for your blog, as I'm not familiar with that framework. On Monday, June 16, 2014 2:25:16 PM UTC-4, Iain Dunning wrote: Good job on getting this going, need to figure out how to seperate out Julia posts from my blog. Could the theme be adjusted to point the source blog under the post title? On Monday, June 16, 2014 11:05:02 AM UTC-4, John Myles White wrote: Looks great, Randy. Thanks for doing this. — John On Jun 16, 2014, at 5:52 AM, Randy Zwitch randy@fuqua.duke.edu wrote: Nothing shady about it at all and a good reminder I need to add a visible RSS icon. Here's the feed: http://www.juliabloggers.com/feed/ On Monday, June 16, 2014 7:32:49 AM UTC-4, Tomas Lycken wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
Re: [julia-users] Exception Efficiency
interesting thanks! On Monday, 16 June 2014 10:09:00 UTC-4, Isaiah wrote: Not an answer to your questions, but: you might want to keep an eye on (or try out) this patch exposing labels and gotos at the user level. It was developed by Daniel Jones for parser backend purposes, and might be useful for a regex engine: https://github.com/JuliaLang/julia/pull/5699 (I believe it is going to be merged, just a question of when) On Thu, Jun 5, 2014 at 8:22 PM, andrew cooke and...@acooke.org javascript: wrote: in the docs it says that exceptions in julia are implemented using tasks. can i take that to mean that they come with a significant overhead? and do you pay for that overhead even if the exception is not thrown? in particular, what is the best way to handle errors in fairly tight loops: 1 - exceptions 2 - maybe types (ie unions with nothing) 3 - (flag, result) tuples (result is not a union but you have a tuple to unpack) and does that change if the excptions are common (say, 10% of loops) or rare (0.1%)? the reason i ask is that i am thinking of writing a regular expression engine in julia (i know it already has an interface to pcre, but it might be cool to have regular expressions over things other than characters, for example). that needs an efficient inner loop, but is also fairly complex, and i'm trying to sketch out how things might work. thanks, andrew
Re: [julia-users] animation using Gtk+/Cairo
ImageView's navigation.jl contains an example. The default branch is Tk (because as far as binary distribution goes, Tk is solved and Gtk isn't yet), but it has a gtk branch you can look at. --Tim On Monday, June 16, 2014 04:01:46 PM Abe Schneider wrote: I was looking for a way to display a simulation in Julia. Originally I was going to just use PyPlot, but it occurred to me it would be better to just use Gtk+ + Cairo to do the drawing rather than something whose main purpose is drawing graphs. So far, following the examples on the Github page, I have no problem creating a window with a Cairo canvas. I can also display content on the canvas fairly easily (which speaks volumes on the awesomeness of Julia and the Gtk+ library). However, after looking through the code and samples, it's not obvious to me how to redraw the canvas every fraction of a second to display new content. I did find an example of animating with Cairo and Gtk+ in C (http://cairographics.org/threaded_animation_with_cairo/). However, I assume one would want to use Julia's timers instead of of GLibs? Secondly, there in their function 'timer_exe', call is made directly to Gtk+ to send a redraw queue to the window. Is there a cleaner way to do it with the Gtk+ library? Thanks! A
Re: [julia-users] Re: juliabloggers.com is now live!
Is there something wrong with the feed? http://www.juliabloggers.com/feed/ juliabloggers.com Entered url doesn't contain valid feed or doesn't link to feed. It is also possible feed contains no items. On 06/16/2014 08:52 PM, Randy Zwitch wrote: Nothing shady about it at all and a good reminder I need to add a visible RSS icon. Here's the feed: http://www.juliabloggers.com/feed/ On Monday, June 16, 2014 7:32:49 AM UTC-4, Tomas Lycken wrote: Nice! I'm missing a feature: something to help me pull this into my RSS reader. If it feels shady to re-publish an aggregated blog like this in RSS, at least a list of the feeds that are currently pulled in would be nice, but ultimately I'd like to add juliabloggers.com http://juliabloggers.com to my feedly and get everything posted there - and if someone comes in tomorrow and adds a new feed to the site, I get that content too. // T On Monday, June 16, 2014 1:17:47 PM UTC+2, Randy Zwitch wrote: Hey everyone - Several posts had popped up over the past few month about creating a centralized location for Julia content. I'm proud to announce that http://www.juliabloggers.com/ http://www.juliabloggers.com/ is now live! This is still very much a work-in-progress, as the theme is fairly vanilla and I need to work out some oddities with how the content is ingested, but the concept certainly works. If you'd like to contribute your content to Julia Bloggers, all it takes is submitting an RSS/Atom feed via this link: http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ http://www.juliabloggers.com/julia-bloggers-submit-rss-feed/ Once your link is imported into Julia Bloggers, that's it. The site will regularly check your feed for new content, then post it to Julia Bloggers once it becomes available. To-Do: While the current theme adds an author to each post, it is my intention to put a larger attribution section for each post, to make it clear the post owner and a link back to the original blog location (similar to how R-Bloggers has it at the end of each post). Logo: If anyone wants to create a logo, perhaps modifying the current Julia SVG code to read 'JuliaBloggers' or something similar, that would be fantastic. The header needs to be 960x250 or so, but if you make it larger/higher resolution I can deal with the sizing I need. We've already got 3 contributors so far, and the content is getting posted to Twitter via https://twitter.com/juliabloggers https://twitter.com/juliabloggers. If there are any questions or comments, please comment here. Thanks! Randy
Re: [julia-users] animation using Gtk+/Cairo
I would definately use Julia's timers. See `Gtk.jl/src/cairo.jl` for an example interface to the Cairo backing to a Gtk window (used in `Winston.jl/src/gtk.jl`). If you are using this wrapper, call `draw(w)` to force a redraw immediately, or `draw(w,false)` to queue a redraw request for when Gtk is idle. On Mon, Jun 16, 2014 at 9:12 PM, Tim Holy tim.h...@gmail.com wrote: ImageView's navigation.jl contains an example. The default branch is Tk (because as far as binary distribution goes, Tk is solved and Gtk isn't yet), but it has a gtk branch you can look at. --Tim On Monday, June 16, 2014 04:01:46 PM Abe Schneider wrote: I was looking for a way to display a simulation in Julia. Originally I was going to just use PyPlot, but it occurred to me it would be better to just use Gtk+ + Cairo to do the drawing rather than something whose main purpose is drawing graphs. So far, following the examples on the Github page, I have no problem creating a window with a Cairo canvas. I can also display content on the canvas fairly easily (which speaks volumes on the awesomeness of Julia and the Gtk+ library). However, after looking through the code and samples, it's not obvious to me how to redraw the canvas every fraction of a second to display new content. I did find an example of animating with Cairo and Gtk+ in C (http://cairographics.org/threaded_animation_with_cairo/). However, I assume one would want to use Julia's timers instead of of GLibs? Secondly, there in their function 'timer_exe', call is made directly to Gtk+ to send a redraw queue to the window. Is there a cleaner way to do it with the Gtk+ library? Thanks! A
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
By a process of elimination, I determined that the only variable whose declaration affected the run time was vGridCapital. The variable is declared to be of type Array{Float64,1}, but is initialized as vGridCapital = 0.5*capitalSteadyState:0.1:1.5*capitalSteadyState which, unlike in Matlab, produces a Range object, rather than an array. If the line above is modified to vGridCapital = [0.5*capitalSteadyState:0.1:1.5*capitalSteadyState] then the type instability is eliminated, and all type declarations can be removed with no effect on execution time. --Peter On Monday, June 16, 2014 2:59:31 PM UTC-7, Jesus Villaverde wrote: Also, defining mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) made quite a bit of difference for me, from 1.92 to around 1.55. If I also add @inbounds, I go down to 1.45, making Julia only twice as sslow as C++. Numba still beats Julia, which kind of bothers me a bit Thanks for the suggestions. On Monday, June 16, 2014 4:56:34 PM UTC-4, Jesus Villaverde wrote: Hi 1) Yes, we pre-compiled the function. 2) As I mentioned before, we tried the code with and without type declaration, it makes a difference. 3) The variable names turns out to be quite useful because this code will be eventually nested into a much larger project where it is convenient to have very explicit names. Thanks On Monday, June 16, 2014 12:13:44 PM UTC-4, Dahua Lin wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest
Ah! Excellent sleuthing. That's about the kind of thing I suspected was going on. On Jun 17, 2014, at 12:03 AM, Peter Simon psimon0...@gmail.com wrote: By a process of elimination, I determined that the only variable whose declaration affected the run time was vGridCapital. The variable is declared to be of type Array{Float64,1}, but is initialized as vGridCapital = 0.5*capitalSteadyState:0.1:1.5*capitalSteadyState which, unlike in Matlab, produces a Range object, rather than an array. If the line above is modified to vGridCapital = [0.5*capitalSteadyState:0.1:1.5*capitalSteadyState] then the type instability is eliminated, and all type declarations can be removed with no effect on execution time. --Peter On Monday, June 16, 2014 2:59:31 PM UTC-7, Jesus Villaverde wrote: Also, defining mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x) made quite a bit of difference for me, from 1.92 to around 1.55. If I also add @inbounds, I go down to 1.45, making Julia only twice as sslow as C++. Numba still beats Julia, which kind of bothers me a bit Thanks for the suggestions. On Monday, June 16, 2014 4:56:34 PM UTC-4, Jesus Villaverde wrote: Hi 1) Yes, we pre-compiled the function. 2) As I mentioned before, we tried the code with and without type declaration, it makes a difference. 3) The variable names turns out to be quite useful because this code will be eventually nested into a much larger project where it is convenient to have very explicit names. Thanks On Monday, June 16, 2014 12:13:44 PM UTC-4, Dahua Lin wrote: First, I agree with John that you don't have to declare the types in general, like in a compiled language. It seems that Julia would be able to infer the types of most variables in your codes. There are several ways that your code's efficiency may be improved: (1) You can use @inbounds to waive bound checking in several places, such as line 94 and 95 (in RBC_Julia.jl) (2) Line 114 and 116 involves reallocating new arrays, which is probably unnecessary. Also note that Base.maxabs can compute the maximum of absolute value more efficiently than maximum(abs( ... )) In terms of measurement, did you pre-compile the function before measuring the runtime? A side note about code style. It seems that it uses a lot of Java-ish descriptive names with camel case. Julia practice tends to encourage more concise naming. Dahua On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote: Maybe it would be good to verify the claim made at https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Julia.jl#L9 I would think that specifying all those types wouldn’t matter much if the code doesn’t have type-stability problems. — John On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com wrote: Dear all, I thought you might find this paper interesting: http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf It takes a standard model from macro economics and computes it's solution with an identical algorithm in several languages. Julia is roughly 2.6 times slower than the best C++ executable. I was bit puzzled by the result, since in the benchmarks on http://julialang.org/, the slowest test is 1.66 times C. I realize that those benchmarks can't cover all possible situations. That said, I couldn't really find anything unusual in the Julia code, did some profiling and removed type inference, but still that's as fast as I got it. That's not to say that I'm disappointed, I still think this is great. Did I miss something obvious here or is there something specific to this algorithm? The codes are on github at https://github.com/jesusfv/Comparison-Programming-Languages-Economics
Re: [julia-users] Re: How to find the index of maximum but omitting to check any field eg not x [5,7]
Big thx, it work, Paul W dniu 2014-06-16 21:24, Dahua Lin pisze: |u =trues(length(x)) u[[5,7]]=false ir =0 vr =-Inf fori =1:length(x) ifu[i]x[i]vr ir =i vr =x[i] end end |
Re: [julia-users] Re: How Delete row or col of array? like deleteat! in vectors
Thx, for this info But not about items I need delete some rows ... How fast delete rows in arrray, one [3,:]or more [[2,4],:] ? Paul W dniu 2014-06-16 21:22, Stefan Schwarz pisze: deleting in place a matrix is not supported and does not make sense. why is that? you've for instance a 5x5 matrix and you want to delete an item. deleteat! shifts subsequent items to fill the resulting gap, so you're loosing dimensionality. basically what you can do is this: a = deleteat!(a[1:end], 1) which is deleting item at position 1. if you want to bring that back into a matrix representation the problems rear up. what dimension you'll have afterwards? 6x4? if you delete another one you'll have 23 elements left, which is really hard to bring into a 2D shape. in the end you've to come up with your own scheme with deleting an item at (i, j). deleting an item and presuming deleting means zeroing it out: a[2,2] = convert(eltype(a), 0) deleting the 2nd column: a[:,2] = convert(eltype(a), 0) deleting the 1st row: a[1, 1:end] = convert(eltype(a), 0) don't know if this tackles your question, but hope this helps.