Re: [julia-users] Re: Text editor for coding Julia: Atom vs Light Table vs Bracket
Ah ok, well this https://www.sublimetext.com/docs/2/column_selection.html page says you can use Shift + Right drag on Linux for Sublime. Atom is probably the same but I don't know for sure about LT. On 30 November 2014 at 05:49, Hans W Borchers hwborch...@gmail.com wrote: Thanks, Mike, but in Linux ALT will drag the whole window, not the cursor. On Saturday, November 29, 2014 4:30:05 PM UTC+1, Mike Innes wrote: (PS Hans: You can do block selection in LT by dragging with the alt key)
[julia-users] Re: Linter for Julia: any alternatives for Atom or Brackets?
Hi Pileas, For Atom there is a (meta) package Linter (https://github.com/AtomLinter/Linter) which seems to be a good place to start. It doesn't have Julia support yet, but you could file an issue or try to modify an existing plugin. In any case I would try to use Tony's Lint.jl (https://github.com/tonyhffong/Lint.jl). BTW since you were asking about a terminal in Atom. Have you tried the Script (https://atom.io/packages/script) package? It looks promising and claims to have Julia support. Best, Alex. On Sunday, 30 November 2014 04:12:47 UTC+1, Pileas wrote: As the title says, I am wondering whether there is a linter for julia-lang that can be installed in Atom Editor or Brackets. Any suggestion would be welcome. P.S. Not sure if I should have said welcome or welcomed ...
[julia-users] Metropolis within Gibbs from R to Julia
Dear Julia users, I'm new to Julia, but from what I've been reading it looks like it has a very bright future. I've been working on a function in R that performs Metropolis-within Gibbs to estimate linear mixing proportions. The code in R works well, but I wanted to speed things up, since I have to try different specifications, data, etc., and redoing analysis with several data points takes some time. I attached my current R function (along with simulated data), and what I think is the equivalent Julia code. It is not yet complete (it is not wrapped in a function yet), as there are some pieces of code that I couldn't quite figure out (I commented out some lines in order to make it work temporarily, but the results are not what they're supposed to). The R version right now takes around 11 seconds for 25000 iterations on a single observation, but for my validation I would probably have to try it on several hundred observations, thus my wanting to speed things up. I'd appreciate any help or suggestion. Napo. BayesM.R Description: Binary data 0.126588,0.052453 0.130058,0.052541 0.133527,0.05263 0.136997,0.052694 0.140466,0.052757 0.143936,0.0528 0.147405,0.052844 0.150875,0.052921 0.154344,0.052997 0.157814,0.053054 0.161283,0.053111 0.164753,0.05314 0.168222,0.053169 0.171692,0.053229 0.175161,0.053288 0.178631,0.053372 0.1821,0.053457 0.18557,0.053489 0.189039,0.053522 0.192509,0.053571 0.195978,0.053621 0.199448,0.053688 0.202917,0.053754 0.207648,0.053846 0.212378,0.053938 0.214251,0.053978 0.216123,0.054018 0.213532,0.054053 0.21094,0.054088 0.213245,0.054226 0.21555,0.054364 0.21617,0.054365 0.21679,0.054367 0.215446,0.05444 0.214102,0.054514 0.21,0.05453 0.212564,0.054545 0.215408,0.054632 0.218251,0.054719 0.218986,0.05477 0.21972,0.054821 0.218814,0.054871 0.217909,0.054922 0.219132,0.054966 0.220356,0.05501 0.221005,0.05508 0.221655,0.05515 0.221572,0.055223 0.221489,0.055296 0.221792,0.055357 0.222095,0.055418 0.222655,0.055468 0.223214,0.055518 0.223593,0.02 0.223972,0.055586 0.224027,0.055649 0.224082,0.055711 0.224225,0.055782 0.224368,0.055853 0.224971,0.055933 0.225575,0.056014 0.225411,0.056064 0.225248,0.056114 0.225881,0.056167 0.226515,0.05622 0.22668,0.056254 0.226846,0.056287 0.226748,0.056348 0.226651,0.056409 0.226565,0.05648 0.226479,0.056551 0.226981,0.056605 0.227484,0.056659 0.227839,0.05674 0.228194,0.056821 0.228367,0.056859 0.228541,0.056898 0.228377,0.056945 0.228212,0.056992 0.228757,0.057055 0.229301,0.057118 0.229277,0.057199 0.229252,0.057279 0.229549,0.057302 0.229846,0.057324 0.229953,0.057408 0.230059,0.057492 0.230392,0.057532 0.230725,0.057572 0.2309,0.05764 0.231075,0.057709 0.231491,0.057769 0.231907,0.057829 0.232132,0.057879 0.232357,0.05793 0.232514,0.058072 0.232671,0.058214 0.232985,0.058517 0.233299,0.058819 0.233737,0.059228 0.234175,0.059636 0.234623,0.060152 0.235071,0.060668 0.235348,0.061263 0.235624,0.061858 0.236158,0.062487 0.236693,0.063117001 0.237149,0.06403 0.237604,0.064943 0.238063,0.066240999 0.238521,0.067538 0.239053,0.068968 0.239586,0.070399 0.240017,0.071882 0.240448,0.073366 0.241001,0.075197 0.241554,0.077028 0.242057,0.079176 0.242559,0.081324001 0.242921,0.083365 0.243283,0.085407 0.243488,0.087509 0.243694,0.08961 0.243855,0.092045 0.244017,0.09448 0.24451,0.096826 0.245003,0.099173 0.245585,0.10121 0.246167,0.103247 0.246989,0.105192 0.24781,0.107138 0.248467,0.109029 0.249124,0.11092 0.250037,0.112339 0.25095,0.113759 0.251623,0.114837 0.252295,0.115914 0.253145,0.116834 0.253996,0.117754 0.254831,0.118629 0.255667,0.119504 0.256453,0.120264 0.25724,0.121024 0.25787,0.121679 0.258501,0.122334 0.259085,0.122839 0.259669,0.123344 0.260099,0.123684 0.260529,0.124024 0.260944,0.124234 0.261359,0.12 0.261886,0.124654 0.262413,0.124864 0.263202,0.125094 0.263991,0.125324 0.264777,0.125389 0.265564,0.125454 0.26651,0.125219 0.267456,0.124984 0.268326,0.124479 0.269196,0.123974 0.270741,0.123314 0.272287,0.122654 0.273576,0.121849 0.274864,0.121044 0.276136,0.120169 0.277409,0.119294 0.278754,0.118209 0.2801,0.117124 0.281154,0.115794 0.282209,0.114464 0.283533,0.112995 0.284858,0.111526 0.285896,0.110182 0.286933,0.108838 0.288103,0.107466 0.289272,0.106095 0.290319,0.104674 0.291366,0.103254 0.292376,0.10222 0.293387,0.101187 0.294484,0.100359 0.295581,0.099530001 0.296414,0.098695001 0.297247,0.09786 0.298121,0.097003001 0.298995,0.096146 0.300012,0.095313 0.30103,0.094481 0.301746,0.093769001 0.302462,0.093057 0.303107,0.092465001 0.303752,0.091874 0.304596,0.091415 0.30544,0.090956 0.305886,0.090554 0.306331,0.090153 0.307069,0.089881 0.307807,0.089608999 0.308342,0.089367 0.308878,0.089125 0.309548,0.088811 0.310218,0.088497001 0.310626,0.088132 0.311033,0.087767 0.311534,0.087403 0.312035,0.087039001 0.312678,0.086677 0.313321,0.086316 0.31373,0.085887001 0.314138,0.085459001 0.31468,0.085017
[julia-users] sortcols not working
Hi When I apply sortcols to a matrix (A) it only sorts the first row. When I use sort(A,2) it works fine. Below is the printout from IJulia and the same thing happens when I run Julia in the terminal: In [51]: A = rand(3,3) Out [51]: 3x3 Array{Float64,2}: 0.305663 0.810061 0.32777 0.697199 0.592799 0.977908 0.492569 0.486371 0.7781 In [52]: sort(A,2) Out [52]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.592799 0.697199 0.977908 0.486371 0.492569 0.7781 In [53]: sortcols(A) Out [53]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.697199 0.977908 0.592799 0.492569 0.77810.486371 Is there something else I should know about sortcols? Thanks
[julia-users] Are receivers idiomatic in Julia?
Hi Julia-users, I'd find it natural to attach a method to a particular instance of an object as in traditional object-oriented programming (see the example below). I can manage this with the constructor NewFoo, which binds the instance to the method after the object is created. Is this idiomatic in Julia? Is there a more idiomatic way? The most I could find in Julia documentation on the subject was this footnote: http://docs.julialang.org/en/release-0.2/manual/methods/#id1 Thanks in advance, Sean type Foo x::Number y::Number Compute::Function end function NewFoo(x, y) f = Foo(x, y, function() 0 end) f.Compute = function() f.x + f.y end f end foo = NewFoo(2, 3) foo.Compute()
[julia-users] Re: Are receivers idiomatic in Julia?
On Sunday, November 30, 2014 6:40:31 PM UTC+10, Sean Gerrish wrote: Hi Julia-users, I'd find it natural to attach a method to a particular instance of an object as in traditional object-oriented programming (see the example below). I can manage this with the constructor NewFoo, which binds the instance to the method after the object is created. Is this idiomatic in Julia? Is there a more idiomatic way? The most I could find in Julia documentation on the subject was this footnote: http://docs.julialang.org/en/release-0.2/manual/methods/#id1 If you look at the section of the manual above this you will find a discussion of multiple dispatch. This is really the idiomatic approach in Julia. So methods are defined outside the type definition (since they need not belong to any one type). What Julia doesn't provide is what has been called dot oriented programming (TM Jeff?) where there is a specific syntax to associate a receiver with a function. Again thats because methods don't belong to any one type. Cheers Lex Thanks in advance, Sean type Foo x::Number y::Number Compute::Function end function NewFoo(x, y) f = Foo(x, y, function() 0 end) f.Compute = function() f.x + f.y end f end foo = NewFoo(2, 3) foo.Compute()
[julia-users] Re: Are receivers idiomatic in Julia?
(By the way, the manual you referenced is for julia v 0.2, which is outdated. The current version is here: http://julia.readthedocs.org/en/release-0.3/manual/. One way would be to define an inner constructor http://julia.readthedocs.org/en/release-0.3/manual/constructors/#inner-constructor-methods : type Foo x::Number y::Number Compute::Function function Foo(x,y) f = new(x, y) f.x=x f.y=y f.Compute = function() f.x+f.y end return f end end This is not ideomatic julia however. The julian way would be to define a function called Compute with a method for Foo types. type Foo x::Number y::Number end Compute(f::Foo) = f.x + f.y If you have some other type that needs a Compute method, you would also define it for that type: Compute(x::Float64) = x+x for example. On Sunday, November 30, 2014 12:40:31 AM UTC-8, Sean Gerrish wrote: Hi Julia-users, I'd find it natural to attach a method to a particular instance of an object as in traditional object-oriented programming (see the example below). I can manage this with the constructor NewFoo, which binds the instance to the method after the object is created. Is this idiomatic in Julia? Is there a more idiomatic way? The most I could find in Julia documentation on the subject was this footnote: http://docs.julialang.org/en/release-0.2/manual/methods/#id1 Thanks in advance, Sean type Foo x::Number y::Number Compute::Function end function NewFoo(x, y) f = Foo(x, y, function() 0 end) f.Compute = function() f.x + f.y end f end foo = NewFoo(2, 3) foo.Compute()
Re: [julia-users] sortcols not working
sortcols takes the whole colums and reorders them lexicographically (whereas sort(A,2) sorts each row separately). Thus sortcols will mostly sort according to the first row and only if entries are equal there will it take the next row into account. On Sun, 2014-11-30 at 08:49, Adriaan van Niekerk adri...@qsolvo.com wrote: Hi When I apply sortcols to a matrix (A) it only sorts the first row. When I use sort(A,2) it works fine. Below is the printout from IJulia and the same thing happens when I run Julia in the terminal: In [51]: A = rand(3,3) Out [51]: 3x3 Array{Float64,2}: 0.305663 0.810061 0.32777 0.697199 0.592799 0.977908 0.492569 0.486371 0.7781 In [52]: sort(A,2) Out [52]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.592799 0.697199 0.977908 0.486371 0.492569 0.7781 In [53]: sortcols(A) Out [53]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.697199 0.977908 0.592799 0.492569 0.77810.486371 Is there something else I should know about sortcols? Thanks
Re: [julia-users] spzeros column vs row vector memory footprint
In CSC sparse matrix format, each column will need a slot in colptr irrespective of whether it contains non-zeros or not. julia spzeros(Float32, 1,4).colptr 5-element Array{Int64,1}: 1 1 1 1 1 julia spzeros(Float32, 4,1).colptr 2-element Array{Int64,1}: 1 1 I think this is what makes the difference in your example. I think there is some plans to make also compressed row storage. Using this would reverse above situation. On Sun, 2014-11-30 at 01:29, Zouhair Mahboubi zouhair.mahbo...@gmail.com wrote: I have the following code: NS = 23^3 TSA = Array(Dict, NS) for from_i in 1:NS TSA[from_i] = Dict() for a in 1:6 TSA[from_i][a] = spzeros(Float32, 1, NS) end end This gobbles up about 4G of memory. If instead, I use TSA[from_i][a] = spzeros(Float32, NS, 1) it barely makes a dent in my memory usage. FYI, I’m using dictionaries here because in my application a’s are actually tuples of symbols, not integers, and it makes things easier. The only reason I wrote it as a rowvector is because I need to dot it with a non-sparse vector b, but unfortunately dot does not support SparseMatrixCSC so I’m using a' * b instead. I can get away with using the column vector for now by doing b' * a. I was surprised at the difference in memory footprint, and I’m curious if someone would care to explain why that is? Thanks, -z
Re: [julia-users] sortcols not working
Thanks Mauro That clears things up. On Sunday, 30 November 2014 11:27:26 UTC+2, Mauro wrote: sortcols takes the whole colums and reorders them lexicographically (whereas sort(A,2) sorts each row separately). Thus sortcols will mostly sort according to the first row and only if entries are equal there will it take the next row into account. On Sun, 2014-11-30 at 08:49, Adriaan van Niekerk adr...@qsolvo.com javascript: wrote: Hi When I apply sortcols to a matrix (A) it only sorts the first row. When I use sort(A,2) it works fine. Below is the printout from IJulia and the same thing happens when I run Julia in the terminal: In [51]: A = rand(3,3) Out [51]: 3x3 Array{Float64,2}: 0.305663 0.810061 0.32777 0.697199 0.592799 0.977908 0.492569 0.486371 0.7781 In [52]: sort(A,2) Out [52]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.592799 0.697199 0.977908 0.486371 0.492569 0.7781 In [53]: sortcols(A) Out [53]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.697199 0.977908 0.592799 0.492569 0.77810.486371 Is there something else I should know about sortcols? Thanks
Re: [julia-users] sortcols not working
Le dimanche 30 novembre 2014 à 01:44 -0800, Adriaan van Niekerk a écrit : Thanks Mauro That clears things up. Would you care making a pull request on GitHub to improve the documentation for sortcols? I don't find it very explicit either. And the race to become contributor #300 is still open! The file in question is here: https://github.com/JuliaLang/julia/edit/master/doc/stdlib/sort.rst Regards On Sunday, 30 November 2014 11:27:26 UTC+2, Mauro wrote: sortcols takes the whole colums and reorders them lexicographically (whereas sort(A,2) sorts each row separately). Thus sortcols will mostly sort according to the first row and only if entries are equal there will it take the next row into account. On Sun, 2014-11-30 at 08:49, Adriaan van Niekerk adr...@qsolvo.com wrote: Hi When I apply sortcols to a matrix (A) it only sorts the first row. When I use sort(A,2) it works fine. Below is the printout from IJulia and the same thing happens when I run Julia in the terminal: In [51]: A = rand(3,3) Out [51]: 3x3 Array{Float64,2}: 0.305663 0.810061 0.32777 0.697199 0.592799 0.977908 0.492569 0.486371 0.7781 In [52]: sort(A,2) Out [52]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.592799 0.697199 0.977908 0.486371 0.492569 0.7781 In [53]: sortcols(A) Out [53]: 3x3 Array{Float64,2}: 0.305663 0.32777 0.810061 0.697199 0.977908 0.592799 0.492569 0.77810.486371 Is there something else I should know about sortcols? Thanks
Re: [julia-users] Are receivers idiomatic in Julia?
Hi, Sean-- I'm new to Julia myself, so take this with a grain of salt ... also, I'm not going to tell you that what you are trying to do is wrong or not done. However, I do think it is unidiomatic. I guess that, coming from an OO background, you are accustomed to thinking of 'method' as meaning a function that belongs to a particular object, and has access to that object's internal state. In a language like Julia that uses multiple dispatch, 'method' is a specialized implementation of a generic function. You probably read that somewhere, but if it's a new idea to you perhaps it's not clear what that means. There aren't many languages that fully support multiple dispatch, but it's very powerful. Anyway, I suppose it could be argued that 'methods' in Julia and in Java are in some sense the same thing - but I'll leave that argument to the academic computer scientists. There is no doubt that the two kinds of methods are very different in their surface manifestations. [PS: if you are indeed new to the concept of multiple dispatch, I've included a fun little exercise at the end that might give you some insights] On Sun, Nov 30, 2014 at 12:06 AM, Sean Gerrish sean.gerr...@gmail.com wrote: I'd find it natural to attach a method to a particular instance of an object as in traditional object-oriented programming (see the example below). I can manage this with the constructor NewFoo, which binds the instance to the method after the object is created. Is this idiomatic in Julia? Is there a more idiomatic way? The question is, what problem are you trying to solve? You are trying to recreate a familiar programming paradigm in a language that doesn't natively support it. I would guess that as you become more familiar with this language, you'll discover a better solution. But that's hard to say without knowing what you are trying to accomplish in the real world. However, if we define the problem as create a type that contains two numeric values, and a method that performs a computation with those values, here's my suggestion: type Foo x::Number y::Number end function compute(f::Foo) f.x + f.y end foo = Foo(2, 3) compute(foo) = 5 And here's something you can try. I'm just showing code for you to enter - the results are omitted. julia + julia a + b julia methods(+) julia function +(a::String, b::String) string(a, b) end julia + julia a + b julia methods(+) Pretty cool, huh? NOTE that I am not suggesting you distribute any code that does this for real - I think a lot of people would have a problem with extending '+' in that particular way; this is not Python. Hope that helps, and sorry for being long-winded. -- Matt Gushee
Re: [julia-users] Re: what's the best way to do R table() in julia? (why does StatsBase.count(x,k) need k?)
Le mercredi 26 novembre 2014 à 09:30 -0800, David van Leeuwen a écrit : Hello again, I worked hard on NamedArrays.jl to solve the problems indicated below: On Monday, November 10, 2014 1:43:57 AM UTC+1, Dahua Lin wrote: NamedArrays.jl generally goes along this way. However, it remains limited in two aspects: 1. Some fields in NamedArrays are not declared of specific types. In particular, the field `dicts` is of the type `Vector{Dict}`, and the use of this field is on the critical path when looping over the table, e.g. when counting. This would potentially lead to substantial impact on performance. A NamedArray is now parameterized by the complete set of Dicts that are used for the indices. It took me a while to get the constructors right, in intermediate stages of the development I ended up with VarType parameters of NamedArray. 2. Currently, it only accepts a limited set of types for indices, e.g. Real and String. But in some cases, people may go beyond this. I don't think we have to impose this limit. The indexing code is completely overhauled now, and the indices() methods are now explicitly parameterized by the dictionary key type, their call should be efficient. It should now be possible to index a NamedArray with any type, although some types (AbstractVector, Range, Int) are interpreted specially. As a consequence, the type of the key for the indices cannot be altered after initialization of a NamedArray (the names themselves still can). Thus, if you want other types than ASCIIString (which is used to give default names to indices), you need to call a constructor with your names prepared instead of filling them in afterwards. You can try the code for julia-0.3 with Pkg.checkout(NamedArrays), or read it at Github. This looks cool. Have you considered allowing any object other than Dict to be passed at construction? This was requested by Simon here (and comments below): https://github.com/JuliaStats/StatsBase.jl/issues/32#issuecomment-43443093 The idea is that any type could be used instead of a Dict, as long as it can be indexed with a key and return the index. For small NamedArrays, doing a linear search on an array is faster than using a Dict. And when computing frequency tables from PooledDataArrays, we could reuse the existing pool instead of creating a Dict from it, it would save some memory. Also, John suggested that the array that a NamedArray wraps could be of any AbstractArray type, not just Array. Sounds like a good idea (e.g. to wrap a sparse matrix). Regards Cheers, ---david Dahua On Monday, November 10, 2014 8:35:32 AM UTC+8, Dahua Lin wrote: I have been observing an interesting differences between people coming from stats and machine learning. Stats people tend to favor the approach that allows one to directly use the category names to index the table, e.g. A[apple]. This tendency is clearly reflected in the design of R, where one can attach a name to everything. While in machine learning practice, it is a common convention to just encode categories into integers, and simply use an ordinary array to represent a counting table. Whereas it makes it a little bit inconvenient in an interactive environment, this way is generally more efficient when you have to deal with these categories over a large number of samples. These differences aside, I believe, however, that there exist a very generic approach to this problem -- a multi-dimensional associative map, which allows one to write A[i1, i2, ...] where the indices can be arbitrary hashable equality-comparable instances, including integers, strings, symbols, among many other things. A multi-dimensional associative map can be considered as a multi-dimensional generalization of dictionaries, which can be easily implemented via an multidimensional array and several dictionaries, each for one dimension, to map user-side indexes to integer indexes. - Dahua On Monday, November 10, 2014
Re: [julia-users] Re: Text editor for coding Julia: Atom vs Light Table vs Bracket
I just updated my linux box to a recent ubuntu and thought: Hey let's give it a try. What is this issue with LT and the cmd key or non-working bindings? I tried (one of the first things in the tutorial) crtl+Space to open a command window: Nothing. I tried cmd/ctrl-shift-o and recognized, i do not have a cmd key and ctrl-shift-o: Nothing. Linux topics in the docs? Nothing.
Re: [julia-users] Swapping two columns (or rows) of an array efficiently
It's also possible that BLAS's swap would be no more efficient than writing it with loops in julia. --Tim On Saturday, November 29, 2014 11:40:19 PM Ivar Nesje wrote: If you know BLAS, you'll likely be able to use Base.LinAlg.BLAS, that is a direct wrapper. Not sure if there is a more convenient way.
Re: [julia-users] Re: Text editor for coding Julia: Atom vs Light Table vs Bracket
Why does nobody mention EMACS as an alternative?
Re: [julia-users] Metropolis within Gibbs from R to Julia
Essential reading: http://docs.julialang.org/en/release-0.3/manual/performance-tips/ --Tim On Saturday, November 29, 2014 11:29:14 PM Napoleon Vargas wrote: Dear Julia users, I'm new to Julia, but from what I've been reading it looks like it has a very bright future. I've been working on a function in R that performs Metropolis-within Gibbs to estimate linear mixing proportions. The code in R works well, but I wanted to speed things up, since I have to try different specifications, data, etc., and redoing analysis with several data points takes some time. I attached my current R function (along with simulated data), and what I think is the equivalent Julia code. It is not yet complete (it is not wrapped in a function yet), as there are some pieces of code that I couldn't quite figure out (I commented out some lines in order to make it work temporarily, but the results are not what they're supposed to). The R version right now takes around 11 seconds for 25000 iterations on a single observation, but for my validation I would probably have to try it on several hundred observations, thus my wanting to speed things up. I'd appreciate any help or suggestion. Napo.
[julia-users] Re: Simple Finite Difference Methods
Belated update to this thread: I have now finished a first draft of three tutorial-like numerical PDE notebooks; they can be viewed at http://homepages.warwick.ac.uk/staff/C.Ortner/index.php?page=julia I have two more coming up in the near future, one on spectral methods, the other on an optimisation problem. For the moment, I am using them primarily for my research group to learn Julia, and to show it to colleagues when they are interested. Q1: May I use the Julia logo on that website, as well as for any tutorials / courses that I teach based on Julia? Q2: Eventually I think it would be good to have a Julia Examples page such as http://www.mathworks.com/examples/ Q3: I'd of course be interested in feedback.
Re: [julia-users] Multiple lines statement?
I think that the standard in mathematical typesetting is to write 2 + 3 rather than 2 + 3 so personally I find the Matlab syntax easier to read. One of the very few choices Julia made that I am not so sure about. Christoph
Re: [julia-users] Re: how to import csv data of varying length rows into an array of float
Andrew, Big Thx My number col now is 24, but in future is unknow. How to know colcnt ? (in script is 4) (Now data after script is rotated , real data is data' ;) ) Paul W dniu 2014-11-29 o 07:56, Andrew Dolgert pisze: The readcsv command only pads https://github.com/JuliaLang/julia/blob/ab1f287906327941f401ed85f0fa6fd549b17bbf/base/datafmt.jl#L173 for the Any type and AbstractString type. The skipblanks option doesn't appear to help. If the file is as regular as you show, then parsing might not be so bad. function readit(filename) # Just one way to get the number of lines. Needs unix. linecnt=int(match(r\d+, readall(`wc -l z.txt`)).match) data=Array(Int, (4,linecnt)) open(filename) do fileio anint=r\d+ idx=1 for line=eachline(fileio) m=matchall(anint, line) if m!=nothing data[1:length(m),idx]=map(int, m) idx+=1 end end end data end
[julia-users] Re: Metropolis within Gibbs from R to Julia
I think you need to worry about correctness before you worry about speed, because as it is this code makes no sense to me. For example, at the top of the code you define: R = size(X, 2) This means R is an integer. Then, inside your loop, you do: tmp = randperm(R) Doing randperm() on an integer is the same as doing randperm() on a vector from 1 to the integer, so now tmp is a vector of the integers from 1 to R in a random order. Then you do: r = tmp[1] So, now r is the first integer from the randomly ordered vector tmp. Which is the same thing as setting r to be a random integer in 1:R. Then you do: comp_r = setdiff(tmp, r) This serts comp_r to be a vector of the integers in tmp, that are not in r. But since tmp is a permutation of 1:R every element is unique this is the same as comp_r = tmp[2:R]. Then: comp_r = comp_r[1] So now comp_r is effectively the second element of the random permutation of 1:R. What you've effectively done is pick a random integer in the range 1 to R, but you've gone through a lot of computations to do so. And you do this every iteration. I think you have made a mistake somewhere, because you then go on to: for k in comp_r Since comp_r is a integer this loop will run only once with k taking on the value of comp_r. The first thing you do in the loop is: ind_k = find(comp_r == k) which doesn't make any sense since both must be the same value and you will always get a vector with a single 1 in it. I assume comp_r is supposed to be a vector of something, but I don't know enough about the algorithm you are trying to implement to tell what it is your trying to do. On Sunday, November 30, 2014 9:29:14 AM UTC+2, Napoleon Vargas wrote: Dear Julia users, I'm new to Julia, but from what I've been reading it looks like it has a very bright future. I've been working on a function in R that performs Metropolis-within Gibbs to estimate linear mixing proportions. The code in R works well, but I wanted to speed things up, since I have to try different specifications, data, etc., and redoing analysis with several data points takes some time. I attached my current R function (along with simulated data), and what I think is the equivalent Julia code. It is not yet complete (it is not wrapped in a function yet), as there are some pieces of code that I couldn't quite figure out (I commented out some lines in order to make it work temporarily, but the results are not what they're supposed to). The R version right now takes around 11 seconds for 25000 iterations on a single observation, but for my validation I would probably have to try it on several hundred observations, thus my wanting to speed things up. I'd appreciate any help or suggestion. Napo.
[julia-users] How to remove from Dict separately 1st and 2nd column?
I heve julia x Dict{ASCIIString,Int64} with 3 entries: c = 3336270 b = 3331795 a = 3331935 Ineed 2 vectors : x= c b a y= 3336270 3331795 3331935 Paul
[julia-users] How to remove from Dict separately 1st and 2nd column?
You need keys and value, they return iterators so call collect on them return a vector a=[a=1, b=2] collect(keys(a)) collect(values(a))
[julia-users] Re: Linter for Julia: any alternatives for Atom or Brackets?
Alex, thanks for the feedback. It appears that I have already installed `script`. I am sure that I did not use it in the past because it did not work for Julia, but luckily now it does. As far as `Linter` is concerned I started an issue in Github. Let us see how it goes. Best, Pileas Τη Κυριακή, 30 Νοεμβρίου 2014 3:33:05 π.μ. UTC-5, ο χρήστης Alex έγραψε: Hi Pileas, For Atom there is a (meta) package Linter ( https://github.com/AtomLinter/Linter) which seems to be a good place to start. It doesn't have Julia support yet, but you could file an issue or try to modify an existing plugin. In any case I would try to use Tony's Lint.jl (https://github.com/tonyhffong/Lint.jl). BTW since you were asking about a terminal in Atom. Have you tried the Script (https://atom.io/packages/script) package? It looks promising and claims to have Julia support. Best, Alex. On Sunday, 30 November 2014 04:12:47 UTC+1, Pileas wrote: As the title says, I am wondering whether there is a linter for julia-lang that can be installed in Atom Editor or Brackets. Any suggestion would be welcome. P.S. Not sure if I should have said welcome or welcomed ...
Re: [julia-users] Re: Text editor for coding Julia: Atom vs Light Table vs Bracket
VIM and Emacs have steeper learning curves. The new ones are quite good to do the job and frankly speaking more modern and fun to use. Τη Κυριακή, 30 Νοεμβρίου 2014 6:45:00 π.μ. UTC-5, ο χρήστης Christoph Ortner έγραψε: Why does nobody mention EMACS as an alternative?
[julia-users] WARNING: (Dict{K,V})(ks::AbstractArray{K},vs::AbstractArray{V}) is deprecated, use (Dict{K,V})(zip(ks,vs)) instead
What wrong ? julia s=slo[1:10,:] 10x2 Array{Any,2}: a a aa aa AA AA aa ad acta Aachen Aachen Aalborg Aalborg Aalborgach Aalborg Aalborgami Aalborg AalborgiAalborg Aalborgiem Aalborg julia D=Dict(s[:,1],s[:,2]) WARNING: (Dict{K,V})(ks::AbstractArray{K},vs::AbstractArray{V}) is deprecated, use (Dict{K,V})(zip(ks,vs)) instead . in call at deprecated.jl:26 Dict{Any,Any} with 9 entries: Aachen = Aachen Aalborg= Aalborg Aalborgach = Aalborg AA = AA Aalborgiem = Aalborg Aalborgami = Aalborg aa = ad acta a = a Aalborgi = Aalborg -- _ Win7 _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_)| Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type help() for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.0-dev+1642 (2014-11-17 08:38 UTC) _/ |\__'_|_|_|\__'_| | Commit aa1f53b (13 days old master) |__/ | x86_64-w64-mingw32
Re: [julia-users] Multiple lines statement?
Thank you all! That clears it up. On Sun Nov 30 2014 at 6:55:22 AM Christoph Ortner christophortn...@gmail.com wrote: I think that the standard in mathematical typesetting is to write 2 + 3 rather than 2 + 3 so personally I find the Matlab syntax easier to read. One of the very few choices Julia made that I am not so sure about. Christoph
[julia-users] Re: WARNING: (Dict{K,V})(ks::AbstractArray{K},vs::AbstractArray{V}) is deprecated, use (Dict{K,V})(zip(ks,vs)) instead
Nothing is wrong. It is just that we have deprecated our Dict(keys, vals) constructor, and plan to remove it in Julia 0.5. In Julia 0.4 the code will work, but you will get a deprecation warning. As the message says you should consider moving to Dict(zip(keys, vals)), but unfortuenatly that doesn't work in 0.3, so if you need compatibility (without deprecation warnings) things becomes harder. Ivar kl. 16:33:22 UTC+1 søndag 30. november 2014 skrev paul analyst følgende: What wrong ? julia s=slo[1:10,:] 10x2 Array{Any,2}: a a aa aa AA AA aa ad acta Aachen Aachen Aalborg Aalborg Aalborgach Aalborg Aalborgami Aalborg AalborgiAalborg Aalborgiem Aalborg julia D=Dict(s[:,1],s[:,2]) WARNING: (Dict{K,V})(ks::AbstractArray{K},vs::AbstractArray{V}) is deprecated, use (Dict{K,V})(zip(ks,vs)) instead . in call at deprecated.jl:26 Dict{Any,Any} with 9 entries: Aachen = Aachen Aalborg= Aalborg Aalborgach = Aalborg AA = AA Aalborgiem = Aalborg Aalborgami = Aalborg aa = ad acta a = a Aalborgi = Aalborg -- _ Win7 _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_)| Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type help() for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.0-dev+1642 (2014-11-17 08:38 UTC) _/ |\__'_|_|_|\__'_| | Commit aa1f53b (13 days old master) |__/ | x86_64-w64-mingw32
Re: [julia-users] Are receivers idiomatic in Julia?
+1 to everything Matt said. On Sun, Nov 30, 2014 at 5:18 AM, Matt Gushee m...@gushee.net wrote: Hi, Sean-- I'm new to Julia myself, so take this with a grain of salt ... also, I'm not going to tell you that what you are trying to do is wrong or not done. However, I do think it is unidiomatic. I guess that, coming from an OO background, you are accustomed to thinking of 'method' as meaning a function that belongs to a particular object, and has access to that object's internal state. In a language like Julia that uses multiple dispatch, 'method' is a specialized implementation of a generic function. You probably read that somewhere, but if it's a new idea to you perhaps it's not clear what that means. There aren't many languages that fully support multiple dispatch, but it's very powerful. Anyway, I suppose it could be argued that 'methods' in Julia and in Java are in some sense the same thing - but I'll leave that argument to the academic computer scientists. There is no doubt that the two kinds of methods are very different in their surface manifestations. [PS: if you are indeed new to the concept of multiple dispatch, I've included a fun little exercise at the end that might give you some insights] On Sun, Nov 30, 2014 at 12:06 AM, Sean Gerrish sean.gerr...@gmail.com wrote: I'd find it natural to attach a method to a particular instance of an object as in traditional object-oriented programming (see the example below). I can manage this with the constructor NewFoo, which binds the instance to the method after the object is created. Is this idiomatic in Julia? Is there a more idiomatic way? The question is, what problem are you trying to solve? You are trying to recreate a familiar programming paradigm in a language that doesn't natively support it. I would guess that as you become more familiar with this language, you'll discover a better solution. But that's hard to say without knowing what you are trying to accomplish in the real world. However, if we define the problem as create a type that contains two numeric values, and a method that performs a computation with those values, here's my suggestion: type Foo x::Number y::Number end function compute(f::Foo) f.x + f.y end foo = Foo(2, 3) compute(foo) = 5 And here's something you can try. I'm just showing code for you to enter - the results are omitted. julia + julia a + b julia methods(+) julia function +(a::String, b::String) string(a, b) end julia + julia a + b julia methods(+) Pretty cool, huh? NOTE that I am not suggesting you distribute any code that does this for real - I think a lot of people would have a problem with extending '+' in that particular way; this is not Python. Hope that helps, and sorry for being long-winded. -- Matt Gushee
[julia-users] `methodswith` on `Union` types
I’m not sure if this is a bug or not but methodswith doesn’t seem to work on Union types. I came across this working with a linear fit in the GLM package using GLM, DataFrames lmfit = lm(y ~ x, DataFrame(x=[1,2,3], y=[2,3,3])) methodswith(typeof(lmfit)) Here is a minimal working example julia type Type1 x end julia type Type2 x y end julia foo(t::Union(Type1, Type2)) = t.x foo (generic function with 1 method) julia foo(Type1(10)) 10 julia methodswith(Type1) 0-element Array{Method,1} Here is my version info julia versioninfo() Julia Version 0.3.4-pre+2 Commit 9f76ed3 (2014-11-24 17:47 UTC) Platform Info: System: Darwin (x86_64-apple-darwin14.0.0) CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell) LAPACK: libopenblas LIBM: libopenlibm LLVM: libLLVM-3.3
Re: [julia-users] removing function completely?
We don't support undefining one specific value but the workspace() function will give you an entirely fresh workspace which may be faster than restarting the entire repl. On Sun, Nov 30, 2014 at 2:13 AM, Daniel Høegh dhoeg...@gmail.com wrote: Just restart the terminal.
[julia-users] Is opiste commnad to get ? in Dict... How to return all keys of value ?
I have Dict: ulia D ict{Any,Any} with 17 entries: Aara = Aara Aalborgami = Aalborg a = a Aalborgom = Aalborg AAP= AAP Aalborgowi = Aalborg Aalborgiem = Aalborg aa = ad acta Aalborgu = Aalborg Aachen = Aachen Aar= Aara Aalborgów = Aalborg Aarach = Aara Aalborgi = Aalborg Aalborg= Aalborg Aalborgach = Aalborg AA = AA by key Aalborgi ulia get!(D,Aalborgi,null) Julis return Aalborg ,OK How to return all keys of value Aalborg ? COMMAND Aalborg = Aalborgami Aalborgom Aalborgowi Aalborgiem Aalborgu Aalborgów Aalborgi Aalborg Aalborgach
[julia-users] Is opposed commnad to get ? For Dict... How to return all keys of value ?
I have Dict: ulia D ict{Any,Any} with 17 entries: Aara = Aara Aalborgami = Aalborg a = a Aalborgom = Aalborg AAP= AAP Aalborgowi = Aalborg Aalborgiem = Aalborg aa = ad acta Aalborgu = Aalborg Aachen = Aachen Aar= Aara Aalborgów = Aalborg Aarach = Aara Aalborgi = Aalborg Aalborg= Aalborg Aalborgach = Aalborg AA = AA by key Aalborgi ulia get!(D,Aalborgi,null) Julis return Aalborg , is nce. How to return all keys of value Aalborg ? COMMAND (D, Aalborg) = Aalborgami Aalborgom Aalborgowi Aalborgiem Aalborgu Aalborgów Aalborgi Aalborg Aalborgach Is any ? Paul
[julia-users] in-place array operations
I am trying to figure out the most efficient way to perform in-place array operations in Julia. julia a=rand(1,1) julia tic(); b=sin(a); toc(); elapsed time: 1.25738114 seconds julia tic(); map!(sin,a); toc(); elapsed time: 7.821650464 seconds julia tic(); for i=1:length(a); a[i]=sin(a[i]); end; toc(); elapsed time: 24.993171377 seconds Nothing seems faster than creating a new array, which I'd like to avoid without slowing down the code if possible. Any ideas?
Re: [julia-users] in-place array operations
Hi Deniz, If you time things in the global scope, you will come to incorrect conclusions about performance. If you want to do performance comparisons, you need to do them inside of a function body to get meaningful results. — John On Nov 30, 2014, at 9:24 AM, Deniz Yuret denizyu...@gmail.com wrote: I am trying to figure out the most efficient way to perform in-place array operations in Julia. julia a=rand(1,1) julia tic(); b=sin(a); toc(); elapsed time: 1.25738114 seconds julia tic(); map!(sin,a); toc(); elapsed time: 7.821650464 seconds julia tic(); for i=1:length(a); a[i]=sin(a[i]); end; toc(); elapsed time: 24.993171377 seconds Nothing seems faster than creating a new array, which I'd like to avoid without slowing down the code if possible. Any ideas?
Re: [julia-users] Is opiste commnad to get ? in Dict... How to return all keys of value ?
Le dimanche 30 novembre 2014 à 09:09 -0800, paul analyst a écrit : I have Dict: ulia D ict{Any,Any} with 17 entries: Aara = Aara Aalborgami = Aalborg a = a Aalborgom = Aalborg AAP= AAP Aalborgowi = Aalborg Aalborgiem = Aalborg aa = ad acta Aalborgu = Aalborg Aachen = Aachen Aar= Aara Aalborgów = Aalborg Aarach = Aara Aalborgi = Aalborg Aalborg= Aalborg Aalborgach = Aalborg AA = AA by key Aalborgi ulia get!(D,Aalborgi,null) Julis return Aalborg ,OK How to return all keys of value Aalborg ? COMMAND Aalborg = Aalborgami Aalborgom Aalborgowi Aalborgiem Aalborgu Aalborgów Aalborgi Aalborg Aalborgach You can use something like this: filter((k, v) - v == Aalborg, x) Regards
Re: [julia-users] Julia on ARM Radxa Rock Pro Quad Core
More INFO: -- julia versioninfo(true) Julia Version 0.4.0-dev+1876 Commit a0542e7 (2014-11-30 02:13 UTC) Platform Info: System: Linux (arm-linux-gnueabihf) CPU: ARMv7 Processor rev 0 (v7l) WORD_SIZE: 32 Linaro 14.04 uname: Linux 3.0.36+ #14 SMP PREEMPT Tue Aug 26 13:51:06 CST 2014 armv7l armv7l Memory: 2.0 GB (1366.35546875 MB free) Uptime: 2827.0 sec Load Avg: 2.22607421875 0.77392578125 0.41015625 ARMv7 Processor rev 0 (v7l): speed user nice sys idle irq #1 1008 MHz 2372 s 0 s 30710 s 243273 s 51 s #2 1008 MHz 2236 s 0 s 3846 s 273905 s 0 s #3 1008 MHz 1864 s 0 s 4416 s 271809 s 0 s #4 1008 MHz 3116 s 0 s 2180 s 275603 s 0 s BLAS: libopenblas (NO_AFFINITY ARMV7) LAPACK: libopenblas LIBM: libm LLVM: libLLVM-3.5.0 Environment: TERM = xterm PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games HOME = /root Package Directory: /root/.julia/v0.4 INFO: Initializing package repository /root/.julia/v0.4 INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl No packages installed julia -- root@radxa:~/julia# cat /proc/cpuinfo Processor : ARMv7 Processor rev 0 (v7l) processor : 0 BogoMIPS: 3214.95 processor : 1 BogoMIPS: 3214.95 processor : 2 BogoMIPS: 3214.95 processor : 3 BogoMIPS: 3214.95 Features: swp half thumb fastmult vfp edsp neon vfpv3 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x3 CPU part: 0xc09 CPU revision: 0 Hardware: RK30board Revision: Serial : On Sunday, November 30, 2014 12:36:34 AM UTC-7, Airhead Bit wrote: Finished compiling, Lots of warnings, %CPU at 299~310, Used your below test and mine is the same. How can we find what is spinning all the CPU cycles? https://lh4.googleusercontent.com/-ZtUw4ml2dXc/VHrI7joXJhI/AFs/VGb5yUeYq-8/s1600/htop.JPG On Saturday, November 29, 2014 9:17:33 PM UTC-7, Viral Shah wrote: However, upon building, it looks ok, and peakflops() which was crashing for me before works fine now. julia Base.LinAlg.BlasInt Int32 julia Base.USE_BLAS64 false -viral On 30-Nov-2014, at 9:31 am, Viral Shah vi...@mayin.org wrote: Interestingly, I get the same error now. I had cleaned out the whole openblas directory before starting the build. -viral On 30-Nov-2014, at 6:14 am, Isaiah Norton isaiah...@gmail.com wrote: You will probably need to do `make -C deps clean-openblas` first (or just remove the openblas-0.2.12 subdirectory). On Sat, Nov 29, 2014 at 7:01 PM, Airhead Bit airhe...@gmail.com wrote: git pull verified that ARM.inc was updated with USE_BLAS64=0 Same error message : ErrorException(BLAS and LAPACK are compiled with 32-bit integer support, but Julia expects 64-bit integers. Please build Julia with USE_BLAS64=0.) Unit still compiling. On Saturday, November 29, 2014 1:03:32 AM UTC-7, Viral Shah wrote: I added USE_BLAS64=0 to ARM.inc. Could you git pull and try again? -viral On 29-Nov-2014, at 1:01 pm, Airhead Bit airhe...@gmail.com wrote: Yes, followed the directions made a Make.user added the include ARM.inc if I had not I don't think the compile would have completed, no x86 stuff on the Radxa box where I compiled it. No, I don't think an ARMv8 would even run ARM7 code, not sure. Radxa Rock Pro is ARM7 hfp with an ARM9 (quad core ARM7) 2GB memory, 8GB Flash, desktop box, nice for working with Android. Should I add USE_BLAS64=0 to the Make.user and re-compile? Is there a way to have make testall load juliadebug test/all? On Friday, November 28, 2014 11:18:39 AM UTC-7, Airhead Bit wrote: Just finished compiling one Error: Warning: error initializing module LinAlg: ErrorException(BLAS and LAPACK are compiled with 32-bit integer support, but Julia expects 64-bit integers. Please build Julia with USE_BLAS64=0.) exports.jl Julia works at the prompt but: TOP shows 400% CPU... root@radxa:~/julia# make testall JULIA test/all Master process (id 1) could not connect within 60.0 seconds. exiting. Master process (id 1) could not connect within 60.0 seconds. exiting. Master process (id 1) could not connect within 60.0 seconds. exiting. Worker 5 terminated. Worker 4 terminated.Worker 2 terminated. Eventually I was left with two Julia process's that each took 198.n% until I killed the terminal I'm going to build a clean system and build adding USE_BLAS64=0 in the Make.user file. Any other ideas for a build? Any
Re: [julia-users] in-place array operations
Thanks John. Here is the results when wrapped in a function body. The for loop wins as expected, map! still looks horrible... julia a=rand(1,1) julia f1(a::Array{Float64})=map!(sin,a) julia @time f1(a); elapsed time: 7.344967598 seconds (471904 bytes allocated, 21.07% gc time) julia function g1(a::Array{Float64}) b=sin(a); end julia @time g1(a); elapsed time: 0.886401569 seconds (80128 bytes allocated) julia function h1(a::Array{Float64}) for i=1:length(a); a[i]=sin(a[i]); end ; end julia @time h1(a); elapsed time: 0.70801756 seconds (80 bytes allocated) On Sunday, November 30, 2014 7:26:15 PM UTC+2, John Myles White wrote: Hi Deniz, If you time things in the global scope, you will come to incorrect conclusions about performance. If you want to do performance comparisons, you need to do them inside of a function body to get meaningful results. — John On Nov 30, 2014, at 9:24 AM, Deniz Yuret deniz...@gmail.com javascript: wrote: I am trying to figure out the most efficient way to perform in-place array operations in Julia. julia a=rand(1,1) julia tic(); b=sin(a); toc(); elapsed time: 1.25738114 seconds julia tic(); map!(sin,a); toc(); elapsed time: 7.821650464 seconds julia tic(); for i=1:length(a); a[i]=sin(a[i]); end; toc(); elapsed time: 24.993171377 seconds Nothing seems faster than creating a new array, which I'd like to avoid without slowing down the code if possible. Any ideas?
Re: [julia-users] Re: Text editor for coding Julia: Atom vs Light Table vs Bracket
Yes, I found that link about Sublime Text, too. Here is my summary. Sublime Text - Shift-Left will give you column selection mode -- even if you have reset the primary mouse button from right to left hand (which is a bit irritating). - Select a block of text and press Control-Shift-L, this will also provide parallel editing on all lines of the selection. Atom Editor All this does *not* work in Atom, at least not for me. Instead: - The command select lines is what I wanted. I could even bind it to the key maps Alt-Shift-up resp. Alt-Shift-down. Nice and helpful. Light Table - Using Control-Space and then in the command tab (Control-Space) Editor: Select lines upward/downward with multiple cursors. Unfortunately, the command tab closes when clicking a command (How can I avoid this?). I have to learn how to assign a key combination to it. Gedit - The gedit plugin multi edit needs to be loaded. Enter/leave this mode with Control-Shift-C. Then edit points will be inserted with Control-E at quite different places in the file. Kate - Block selection mode will be enabled with Control-Shift-B. The a block region will be selected with the mouse. Conclusion: It's not recommended to use too many editor, otherwise the different key mappings will drive you crazy. Sorry to all for so much fuss about a tiny editing feature. On Sunday, November 30, 2014 9:06:05 AM UTC+1, Mike Innes wrote: Ah ok, well this https://www.sublimetext.com/docs/2/column_selection.html page says you can use Shift + Right drag on Linux for Sublime. Atom is probably the same but I don't know for sure about LT. On 30 November 2014 at 05:49, Hans W Borchers hwbor...@gmail.com javascript: wrote: Thanks, Mike, but in Linux ALT will drag the whole window, not the cursor. On Saturday, November 29, 2014 4:30:05 PM UTC+1, Mike Innes wrote: (PS Hans: You can do block selection in LT by dragging with the alt key)
Re: [julia-users] how to import csv data of varying length rows into an array of float
Hi Paul, If memory usage is a challenge, then the only way to know the number of columns is to read the whole thing twice. Loop through it once something like: cnt=0 for line=eachline(file) cnt=max(cnt, length(split(line, “,”))) end and then loop again as before. As to the rotation of the array, I chose the order that was fastest for reading the file, but you might do better to choose the order fastest for working with the data. Julia uses Fortran order. The other order would use “data=zeros(Int, (linecnt,4)” and “data[idx,1:length(m)]=linecnt”. In either case, change “data=Array(...” to “data=zeros(“ so that you don’t get uninitialized entries. Sorry about that. - Drew On Nov 30, 2014, at 8:03 AM, Paul Analyst paul.anal...@mail.com wrote: Andrew, Big Thx My number col now is 24, but in future is unknow. How to know colcnt ? (in script is 4) (Now data after script is rotated , real data is data' ;) ) Paul W dniu 2014-11-29 o 07:56, Andrew Dolgert pisze: The readcsv command only pads https://github.com/JuliaLang/julia/blob/ab1f287906327941f401ed85f0fa6fd549b17bbf/base/datafmt.jl#L173 for the Any type and AbstractString type. The skipblanks option doesn't appear to help. If the file is as regular as you show, then parsing might not be so bad. function readit(filename) # Just one way to get the number of lines. Needs unix. linecnt=int(match(r\d+, readall(`wc -l z.txt`)).match) data=Array(Int, (4,linecnt)) open(filename) do fileio anint=r\d+ idx=1 for line=eachline(fileio) m=matchall(anint, line) if m!=nothing data[1:length(m),idx]=map(int, m) idx+=1 end end end data end
Re: [julia-users] in-place array operations
map is horrible for small and fast functions like sin, because Julia currently doesn't generate specialized code, so method dispatch for both sin and the resulting setindex! call needs to be performed runtime (for every element of the array). There are open issues about fixing this. Ivar kl. 18:52:02 UTC+1 søndag 30. november 2014 skrev Deniz Yuret følgende: Thanks John. Here is the results when wrapped in a function body. The for loop wins as expected, map! still looks horrible... julia a=rand(1,1) julia f1(a::Array{Float64})=map!(sin,a) julia @time f1(a); elapsed time: 7.344967598 seconds (471904 bytes allocated, 21.07% gc time) julia function g1(a::Array{Float64}) b=sin(a); end julia @time g1(a); elapsed time: 0.886401569 seconds (80128 bytes allocated) julia function h1(a::Array{Float64}) for i=1:length(a); a[i]=sin(a[i]); end; end julia @time h1(a); elapsed time: 0.70801756 seconds (80 bytes allocated) On Sunday, November 30, 2014 7:26:15 PM UTC+2, John Myles White wrote: Hi Deniz, If you time things in the global scope, you will come to incorrect conclusions about performance. If you want to do performance comparisons, you need to do them inside of a function body to get meaningful results. — John On Nov 30, 2014, at 9:24 AM, Deniz Yuret deniz...@gmail.com wrote: I am trying to figure out the most efficient way to perform in-place array operations in Julia. julia a=rand(1,1) julia tic(); b=sin(a); toc(); elapsed time: 1.25738114 seconds julia tic(); map!(sin,a); toc(); elapsed time: 7.821650464 seconds julia tic(); for i=1:length(a); a[i]=sin(a[i]); end; toc(); elapsed time: 24.993171377 seconds Nothing seems faster than creating a new array, which I'd like to avoid without slowing down the code if possible. Any ideas?
Re: [julia-users] `methodswith` on `Union` types
Yep, you should file an issue if one doesn't exist yet. On Sun, 2014-11-30 at 17:02, Ethan Anderes ethanande...@gmail.com wrote: I’m not sure if this is a bug or not but methodswith doesn’t seem to work on Union types. I came across this working with a linear fit in the GLM package using GLM, DataFrames lmfit = lm(y ~ x, DataFrame(x=[1,2,3], y=[2,3,3])) methodswith(typeof(lmfit)) Here is a minimal working example julia type Type1 x end julia type Type2 x y end julia foo(t::Union(Type1, Type2)) = t.x foo (generic function with 1 method) julia foo(Type1(10)) 10 julia methodswith(Type1) 0-element Array{Method,1} Here is my version info julia versioninfo() Julia Version 0.3.4-pre+2 Commit 9f76ed3 (2014-11-24 17:47 UTC) Platform Info: System: Darwin (x86_64-apple-darwin14.0.0) CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell) LAPACK: libopenblas LIBM: libopenlibm LLVM: libLLVM-3.3
Re: [julia-users] `methodswith` on `Union` types
Ok, thanks. I posted the issue here https://github.com/JuliaLang/julia/issues/9203. On Sunday, November 30, 2014 11:09:11 AM UTC-8, Mauro wrote: Yep, you should file an issue if one doesn't exist yet. On Sun, 2014-11-30 at 17:02, Ethan Anderes ethana...@gmail.com javascript: wrote: I’m not sure if this is a bug or not but methodswith doesn’t seem to work on Union types. I came across this working with a linear fit in the GLM package using GLM, DataFrames lmfit = lm(y ~ x, DataFrame(x=[1,2,3], y=[2,3,3])) methodswith(typeof(lmfit)) Here is a minimal working example julia type Type1 x end julia type Type2 x y end julia foo(t::Union(Type1, Type2)) = t.x foo (generic function with 1 method) julia foo(Type1(10)) 10 julia methodswith(Type1) 0-element Array{Method,1} Here is my version info julia versioninfo() Julia Version 0.3.4-pre+2 Commit 9f76ed3 (2014-11-24 17:47 UTC) Platform Info: System: Darwin (x86_64-apple-darwin14.0.0) CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell) LAPACK: libopenblas LIBM: libopenlibm LLVM: libLLVM-3.3
[julia-users] Re: Simple Finite Difference Methods
Nice work! Regarding the pretty Julia version of Lennard-Jones MD. You can shape of another second (on my machine) by not passing in the lj method as a parameter, but directly calling it. I tried to write an optimize version of your lj_pretty function by analysing it with @profile and rewriting the slow parts. You can see my results here: https://gist.github.com/vchuravy/f42f458717a7a49395a5 I went step for step through it and applied one optimization at a time. You can also see the time computation time spend at each line as a comment. Mostly I just removed temporary array allocation and then applied your math optimization. One question though. In lj_cstyle(x) you calculate dJ = -12.*(t*t - t) * s , shouldn't it be dJ = -12.*(t*t - t) / s? Kind regards, Valentin On Sunday, 30 November 2014 12:51:31 UTC+1, Christoph Ortner wrote: Belated update to this thread: I have now finished a first draft of three tutorial-like numerical PDE notebooks; they can be viewed at http://homepages.warwick.ac.uk/staff/C.Ortner/index.php?page=julia I have two more coming up in the near future, one on spectral methods, the other on an optimisation problem. For the moment, I am using them primarily for my research group to learn Julia, and to show it to colleagues when they are interested. Q1: May I use the Julia logo on that website, as well as for any tutorials / courses that I teach based on Julia? Q2: Eventually I think it would be good to have a Julia Examples page such as http://www.mathworks.com/examples/ Q3: I'd of course be interested in feedback.
Re: [julia-users] Re: Text editor for coding Julia: Atom vs Light Table vs Bracket
So one argument feature wise for Juno/Lightable is the good integration of profile(). You get an inline view of how expensive each line is that you can directly jump from the call tree to the appropriate line. On Sunday, 30 November 2014 19:00:07 UTC+1, Hans W Borchers wrote: Yes, I found that link about Sublime Text, too. Here is my summary. Sublime Text - Shift-Left will give you column selection mode -- even if you have reset the primary mouse button from right to left hand (which is a bit irritating). - Select a block of text and press Control-Shift-L, this will also provide parallel editing on all lines of the selection. Atom Editor All this does *not* work in Atom, at least not for me. Instead: - The command select lines is what I wanted. I could even bind it to the key maps Alt-Shift-up resp. Alt-Shift-down. Nice and helpful. Light Table - Using Control-Space and then in the command tab (Control-Space) Editor: Select lines upward/downward with multiple cursors. Unfortunately, the command tab closes when clicking a command (How can I avoid this?). I have to learn how to assign a key combination to it. Gedit - The gedit plugin multi edit needs to be loaded. Enter/leave this mode with Control-Shift-C. Then edit points will be inserted with Control-E at quite different places in the file. Kate - Block selection mode will be enabled with Control-Shift-B. The a block region will be selected with the mouse. Conclusion: It's not recommended to use too many editor, otherwise the different key mappings will drive you crazy. Sorry to all for so much fuss about a tiny editing feature. On Sunday, November 30, 2014 9:06:05 AM UTC+1, Mike Innes wrote: Ah ok, well this https://www.sublimetext.com/docs/2/column_selection.html page says you can use Shift + Right drag on Linux for Sublime. Atom is probably the same but I don't know for sure about LT. On 30 November 2014 at 05:49, Hans W Borchers hwbor...@gmail.com wrote: Thanks, Mike, but in Linux ALT will drag the whole window, not the cursor. On Saturday, November 29, 2014 4:30:05 PM UTC+1, Mike Innes wrote: (PS Hans: You can do block selection in LT by dragging with the alt key)
Re: [julia-users] how to import csv data of varying length rows into an array of float
Thanks a lot, it works. The second loop gave nothing new: julia o=open(output_4b.txt) IOStream(file output_4b.txt) julia cnt=0 0 julia for line=eachline(o) cnt=max(cnt, length(split(line, ,))) end julia cnt 24 julia for line=eachline(o) cnt=max(cnt, length(split(line, ,))) end julia cnt 24 Paul W dniu 2014-11-30 o 19:28, Andrew Dolgert pisze: Hi Paul, If memory usage is a challenge, then the only way to know the number of columns is to read the whole thing twice. Loop through it once something like: cnt=0 for line=eachline(file) cnt=max(cnt, length(split(line, “,”))) end and then loop again as before. As to the rotation of the array, I chose the order that was fastest for reading the file, but you might do better to choose the order fastest for working with the data. Julia uses Fortran order. The other order would use “data=zeros(Int, (linecnt,4)” and “data[idx,1:length(m)]=linecnt”. In either case, change “data=Array(...” to “data=zeros(“ so that you don’t get uninitialized entries. Sorry about that. - Drew On Nov 30, 2014, at 8:03 AM, Paul Analyst paul.anal...@mail.com mailto:paul.anal...@mail.com wrote: Andrew, Big Thx My number col now is 24, but in future is unknow. How to know colcnt ? (in script is 4) (Now data after script is rotated , real data is data' ;) ) Paul W dniu 2014-11-29 o 07:56, Andrew Dolgert pisze: The readcsv command only pads https://github.com/JuliaLang/julia/blob/ab1f287906327941f401ed85f0fa6fd549b17bbf/base/datafmt.jl#L173 for the Any type and AbstractString type. The skipblanks option doesn't appear to help. If the file is as regular as you show, then parsing might not be so bad. function readit(filename) # Just one way to get the number of lines. Needs unix. linecnt=int(match(r\d+, readall(`wc -l z.txt`)).match) data=Array(Int, (4,linecnt)) open(filename) do fileio anint=r\d+ idx=1 for line=eachline(fileio) m=matchall(anint, line) if m!=nothing data[1:length(m),idx]=map(int, m) idx+=1 end end end data end
Re: [julia-users] Are receivers idiomatic in Julia?
Thanks, Matt and others! All the best, Sean On Sunday, November 30, 2014 2:18:48 AM UTC-8, Matt Gushee wrote: Hi, Sean-- I'm new to Julia myself, so take this with a grain of salt ... also, I'm not going to tell you that what you are trying to do is wrong or not done. However, I do think it is unidiomatic. I guess that, coming from an OO background, you are accustomed to thinking of 'method' as meaning a function that belongs to a particular object, and has access to that object's internal state. In a language like Julia that uses multiple dispatch, 'method' is a specialized implementation of a generic function. You probably read that somewhere, but if it's a new idea to you perhaps it's not clear what that means. There aren't many languages that fully support multiple dispatch, but it's very powerful. Anyway, I suppose it could be argued that 'methods' in Julia and in Java are in some sense the same thing - but I'll leave that argument to the academic computer scientists. There is no doubt that the two kinds of methods are very different in their surface manifestations. [PS: if you are indeed new to the concept of multiple dispatch, I've included a fun little exercise at the end that might give you some insights] On Sun, Nov 30, 2014 at 12:06 AM, Sean Gerrish sean.g...@gmail.com javascript: wrote: I'd find it natural to attach a method to a particular instance of an object as in traditional object-oriented programming (see the example below). I can manage this with the constructor NewFoo, which binds the instance to the method after the object is created. Is this idiomatic in Julia? Is there a more idiomatic way? The question is, what problem are you trying to solve? You are trying to recreate a familiar programming paradigm in a language that doesn't natively support it. I would guess that as you become more familiar with this language, you'll discover a better solution. But that's hard to say without knowing what you are trying to accomplish in the real world. However, if we define the problem as create a type that contains two numeric values, and a method that performs a computation with those values, here's my suggestion: type Foo x::Number y::Number end function compute(f::Foo) f.x + f.y end foo = Foo(2, 3) compute(foo) = 5 And here's something you can try. I'm just showing code for you to enter - the results are omitted. julia + julia a + b julia methods(+) julia function +(a::String, b::String) string(a, b) end julia + julia a + b julia methods(+) Pretty cool, huh? NOTE that I am not suggesting you distribute any code that does this for real - I think a lot of people would have a problem with extending '+' in that particular way; this is not Python. Hope that helps, and sorry for being long-winded. -- Matt Gushee
[julia-users] Re: Simple Finite Difference Methods
I found a second error in lj_cstyle t is calculated wrongly: t = 1./s*s*s != 1/s^3 It probably should be t = 1.0 / (s * s * s) t = 1.0 / (s*s*s) E += t*t - 2.*t dJ = -12.0 *(t*t - t) / s cstyle is on my machine still two times faster then my optimized variant of jl_pretty Best Valentin On Sunday, 30 November 2014 20:54:58 UTC+1, Valentin Churavy wrote: Nice work! Regarding the pretty Julia version of Lennard-Jones MD. You can shape of another second (on my machine) by not passing in the lj method as a parameter, but directly calling it. I tried to write an optimize version of your lj_pretty function by analysing it with @profile and rewriting the slow parts. You can see my results here: https://gist.github.com/vchuravy/f42f458717a7a49395a5 I went step for step through it and applied one optimization at a time. You can also see the time computation time spend at each line as a comment. Mostly I just removed temporary array allocation and then applied your math optimization. One question though. In lj_cstyle(x) you calculate dJ = -12.*(t*t - t) * s , shouldn't it be dJ = -12.*(t*t - t) / s? Kind regards, Valentin On Sunday, 30 November 2014 12:51:31 UTC+1, Christoph Ortner wrote: Belated update to this thread: I have now finished a first draft of three tutorial-like numerical PDE notebooks; they can be viewed at http://homepages.warwick.ac.uk/staff/C.Ortner/index.php?page=julia I have two more coming up in the near future, one on spectral methods, the other on an optimisation problem. For the moment, I am using them primarily for my research group to learn Julia, and to show it to colleagues when they are interested. Q1: May I use the Julia logo on that website, as well as for any tutorials / courses that I teach based on Julia? Q2: Eventually I think it would be good to have a Julia Examples page such as http://www.mathworks.com/examples/ Q3: I'd of course be interested in feedback.
Re: [julia-users] Re: N in NTuple not enforced
Hi Drew Thanks for the explanation. I didn't know the snoop trick. Andreas 2014-11-29 12:35 GMT-05:00 Andrew Dolgert adolg...@gmail.com: Apparently I was wanting something to do. I'll fix it. - Drew
[julia-users] Rendering images with Julia and seeing them in iJulia
Hi, I'd like to experiment with writing rendering / graphics algorithms in Julia. Mostly for fun and education, but partly because I wonder: if you used much higher level rendering optimisations, could regular processors achieve what graphics cards do, while being more flexible? I'd like to be able to generate RGB bitmaps and see them in iJulia. Is there a standard way to do this? Thanks. p.s. – I'm a complete Julia newbie, but I've been programming for far to long.
Re: [julia-users] Re: N in NTuple not enforced
You figured out that I had a typo where I renamed f() to snoop(). If you're interested in how Julia deals with types, and you may not be, forget the weird function-on-the-right thing, and take a look at code_lowered() and code_typed(). Most of the bug you found happens during a call to typeintersect, which finds the common subtype of two given types. First look at normal operation. The call happens twice, once in the definition of the type test{T}, when T is a TypeVar, and once when T is an Int. julia T=TypeVar(:T, true) julia h()=typeintersect(NTuple{T,Int},(Int,Int)) julia g()=typeintersect(NTuple{2,Int},(Int,Int)) What you found, we'll call f(). julia f()=typeintersect(NTuple{Float64,Int},(Int,Int)) Now, for each of these, look at code_lowered() and code_typed(), and you'll see that substitution happens at earlier steps when there isn't a TypeVar. julia code_lowered(f,()) julia code_typed(f,()) julia code_llvm(f, ()) NTuple is a strange beast. It isn't a TypeConstructor, such as you would form with typealias IntDict{V} Dict{Int,V}. It isn't a normal parametric type either, because it compares with a tuple, but when it becomes a tuple depends on when you ask. In short, my suggested fix was dead wrong and breaks hoards of unit tests. I'm learning a lot, but you get all the blame. :) - Drew
Re: [julia-users] Installing IJulia
Two ways via extensions (can be easily installed): [1] Use `*Atom terminal*` (Ctrl + Shift + T) opens the terminal in the place where the Julia file is at. Then just write: `julia filename.jl` [2] Use `*script*` (another extension), it supports Julia and with (Ctrl + Shift + B) you can do what you want. Julia is easy in that matter because it does not need compiling. Best, Pileas Τη Πέμπτη, 27 Νοεμβρίου 2014 3:59:05 π.μ. UTC-5, ο χρήστης Abram Demski έγραψε: Pileas, Atom looks very cool, but it appears existing Julia customization is very minimal. Do you know if there is an easy way to have a command to run the current file in a julia terminal? (I miiight be tempted into trying to build it, seeing as the Atom customization stuff looks fun...) On Wed, Nov 26, 2014 at 3:26 PM, Abram Demski abram...@gmail.com javascript: wrote: Pileas, Given that I've still been unable to install IJulia, that's very helpful, thanks. On Tue, Nov 25, 2014 at 6:29 PM, Pileas phoebus@gmail.com javascript: wrote: I have to suggest a very good editor that supports Julia and it is called Atom. It becomes better each day: Give it a try if you have time: https://atom.io/ Τη Τρίτη, 25 Νοεμβρίου 2014 6:12:52 μ.μ. UTC-5, ο χρήστης Abram Demski έγραψε: Thanks! I figured out how to do it in the default shell: julia print(ENV[PATH]) C:\Users\abram\AppData\Local\Julia-0.3.3\bin;C:\Users\ abram\AppData\Local\Julia- 0.3.3\bin\..\Git\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\ Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\ Wbem;C:\wi ndows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Managemen t Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Compon ents\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Progra m Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\P rogram Files\Condusiv Technologies\ExpressCache\;C:\Program Files (x86)\Common F iles\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps; C:\Anaconda;C:\Anaco nda\Scripts (I have not used windows much since Windows 98! ;p) On Tue, Nov 25, 2014 at 3:02 PM, cdm cdmcle...@gmail.com wrote: if you have access to the PowerShell in Windows 8 ( ... and similar, new-ish, MS OSs ...), then highlighting a block of text from the PowerShell and right clicking should rip it to the clipboard for pasting else-where ... best, cdm On Tuesday, November 25, 2014 2:42:51 PM UTC-8, Abram Demski wrote: Julia shows a similar PATH when I run ENV[PATH], but with more julia-specific things. (It seems that command prompts in Windows 8.1 do not allow one to copy text out of them directly.. otherwise I'd copy.) -- Abram Demski Blog: http://lo-tho.blogspot.com/ -- Abram Demski Blog: http://lo-tho.blogspot.com/ -- Abram Demski Blog: http://lo-tho.blogspot.com/
[julia-users] exceptions disabled - Clang
Hi I am not very familiar with the mechanics of exception handling in Clang and I realize that exceptions (throw/catch) work well in Julia itself. However, I am specifically trying to use exception handling in C++ code nested inside Julia with Cxx.jl. I noticed exception handling is meant to be switched off by default in Clang, but still it seems to me that it would be very useful to have it switched on when dealing with GUI applications. I tried several C++ exceptions (e.g., throw/catch, std::exception) but it seems they are disabled in my current Julia-v0.4.0-dev build (OSX 10.9.5). Since I did not use the -fno-exceptions flag to build Julia, I wonder why/where exceptions are switched off when I built Julia. In Xcode(with libc++-LLVM, C++11), I can run the following script with C++ exceptions and it works: const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } int main() { try { divide(1, 0); } catch(int i) { if(i==ZeroDivisionError) { std::cerrDivide by zero error; } } } *Divide by zero error *Program ended with exit code: 0 However, when I try to compile essentially the same code in Julia (with Cxx), I see the following ERROR: julia cxx #include iostream //std::cerr const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } void exceptiontest() { try { divide(1, 0); } catch(int i) { if(i==ZeroDivisionError) { std::cerrDivide by zero error; } } } In file included from :1: :9:25: error: cannot use 'throw' with exceptions disabled throw ZeroDivisionError; ^ :16:20: error: cannot use 'try' with exceptions disabled try ^ Does anyone know how I can switch on exception handling in Clang for building Julia? Alternatively, if the exception flag is already included by default, then at least I know to focus on why it is not being used by Cxx. Thank you for your time. Max
Re: [julia-users] exceptions disabled - Clang
This is primarily a Cxx.jl issue, though you might run into problem if you're trying to unwind through non-C++ frames later. In any case, in the spirit of experimentation, you can enable exception handling by setting the appropriate options from here: https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/LangOptions.def#L106-L109 in bootstrap.cpp, e.g. here: https://github.com/Keno/Cxx.jl/blob/master/src/bootstrap.cpp#L464 On Sun, Nov 30, 2014 at 5:59 PM, Max Suster mxsst...@gmail.com wrote: Hi I am not very familiar with the mechanics of exception handling in Clang and I realize that exceptions (throw/catch) work well in Julia itself. However, I am specifically trying to use exception handling in C++ code nested inside Julia with Cxx.jl. I noticed exception handling is meant to be switched off by default in Clang, but still it seems to me that it would be very useful to have it switched on when dealing with GUI applications. I tried several C++ exceptions (e.g., throw/catch, std::exception) but it seems they are disabled in my current Julia-v0.4.0-dev build (OSX 10.9.5). Since I did not use the -fno-exceptions flag to build Julia, I wonder why/where exceptions are switched off when I built Julia. In Xcode(with libc++-LLVM, C++11), I can run the following script with C++ exceptions and it works: const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } int main() { try { divide(1, 0); } catch(int i) { if(i==ZeroDivisionError) { std::cerrDivide by zero error; } } } *Divide by zero error *Program ended with exit code: 0 However, when I try to compile essentially the same code in Julia (with Cxx), I see the following ERROR: julia cxx #include iostream //std::cerr const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } void exceptiontest() { try { divide(1, 0); } catch(int i) { if(i==ZeroDivisionError) { std::cerrDivide by zero error; } } } In file included from :1: :9:25: error: cannot use 'throw' with exceptions disabled throw ZeroDivisionError; ^ :16:20: error: cannot use 'try' with exceptions disabled try ^ Does anyone know how I can switch on exception handling in Clang for building Julia? Alternatively, if the exception flag is already included by default, then at least I know to focus on why it is not being used by Cxx. Thank you for your time. Max
[julia-users] Re: Is it wrong to think of Julia as a Lisp that uses m-expressions?
Try typing julia --lisp and see what happens. On Thursday, June 27, 2013 6:38:33 AM UTC+10, Ben Racine wrote: I stumbled across this on wiki... The use of S-expressions http://en.wikipedia.org/wiki/S-expression which characterize the syntax of Lisp was initially intended to be an interim measure pending the development of a language employing what McCarthy called M-expressions http://en.wikipedia.org/wiki/M-expression. As an example, the M-expression car[cons[A,B]] is equivalent to the S-expression (car (cons A B)). S-expressions proved popular, however, and the many attempts to implement M-expressions failed to catch on. I've seen the (awesome) language designers mention that Julia can be thought of a Lisp (in different words)... and I'm just wondering if anybody cares to confirm, expound, or deny this. Main source: http://en.wikipedia.org/wiki/History_of_the_Scheme_programming_language Further background: http://en.wikipedia.org/wiki/M-expression
[julia-users] map to each row of a 2d array, returning 2d array
Hi, How do I use map or pmap in Julia to apply a function each row of a 2D matrix and get back a 2D matrix with each row appropriately updated? Currently, map returns an array of 1D arrays instead of a 2D array, e.g.: *julia **a=rand(5,3)* *5x3 Array{Float64,2}:* * 0.0970387 0.944568 0.589086 * * 0.477571 0.916078 0.0674227* * 0.424044 0.827748 0.49385 * * 0.691055 0.0370019 0.845552 * * 0.686033 0.812021 0.222669 * *julia **map(row-a[row,:]+1, 1:size(a)[1])* *5-element Array{Array{Float64,2},1}:* * 1x3 Array{Float64,2}:* * 1.09704 1.94457 1.58909* * 1x3 Array{Float64,2}:* * 1.47757 1.91608 1.06742* * 1x3 Array{Float64,2}:* * 1.42404 1.82775 1.49385* * 1x3 Array{Float64,2}:* * 1.69106 1.037 1.84555 * * 1x3 Array{Float64,2}:* * 1.68603 1.81202 1.22267* Although I could probably post-process the output of map back into a 2D array, is there is a more elegant way of doing it? Mike
Re: [julia-users] removing function completely?
thank you. how do I delete just one dispatch binding then? what is the equivalent of assigning . or undef or nothing or Nothing for removing just one dispatch? how do I mark an empty variable? (Nothing?) how do I remove a variable? regards, /iaw Ivo Welch (ivo.we...@gmail.com) http://www.ivo-welch.info/ J. Fred Weston Distinguished Professor of Finance Anderson School at UCLA, C519 Director, UCLA Anderson Fink Center for Finance and Investments Free Finance Textbook, http://book.ivo-welch.info/ Exec Editor, Critical Finance Review, http://www.critical-finance-review.org/ Editor and Publisher, FAMe, http://www.fame-jagazine.com/ On Mon, Dec 1, 2014 at 12:02 AM, Stefan Karpinski ste...@karpinski.org wrote: We don't support undefining one specific value but the workspace() function will give you an entirely fresh workspace which may be faster than restarting the entire repl. On Sun, Nov 30, 2014 at 2:13 AM, Daniel Høegh dhoeg...@gmail.com wrote: Just restart the terminal.
Re: [julia-users] removing function completely?
how do I delete just one dispatch binding then? You can't remove a method from a generic function. You can overwrite it though, for instance make it throw an error or point it to another method. what is the equivalent of assigning . or undef or nothing or Nothing for removing just one dispatch? how do I mark an empty variable? (Nothing?) how do I remove a variable? http://docs.julialang.org/en/latest/manual/faq/#how-do-i-delete-an-object-in-memory regards, /iaw Ivo Welch (ivo.we...@gmail.com) http://www.ivo-welch.info/ J. Fred Weston Distinguished Professor of Finance Anderson School at UCLA, C519 Director, UCLA Anderson Fink Center for Finance and Investments Free Finance Textbook, http://book.ivo-welch.info/ Exec Editor, Critical Finance Review, http://www.critical-finance-review.org/ Editor and Publisher, FAMe, http://www.fame-jagazine.com/ On Mon, Dec 1, 2014 at 12:02 AM, Stefan Karpinski ste...@karpinski.org wrote: We don't support undefining one specific value but the workspace() function will give you an entirely fresh workspace which may be faster than restarting the entire repl. On Sun, Nov 30, 2014 at 2:13 AM, Daniel Høegh dhoeg...@gmail.com wrote: Just restart the terminal.
Re: [julia-users] exceptions disabled - Clang
On Monday, December 1, 2014 9:18:41 AM UTC+10, Keno Fischer wrote: This is primarily a Cxx.jl issue, though you might run into problem if you're trying to unwind through non-C++ frames later. To amplify, Julia uses lots of libraries that are not guaranteed to be exception safe, and can leak resources or leave memory in unknown and/or illegal states when you throw exceptions through them. If your exceptions are only used to terminate the process thats mostly fine since most resources (memory, open files) are returned on process terminate anyway and the state of memory doesn't matter. But if you catch the exceptions after they have unwound through non-c++ code and then you try to continue, you could run into problems with leaks or data structures in indeterminate states. Caveat Emptor :) Cheers Lex In any case, in the spirit of experimentation, you can enable exception handling by setting the appropriate options from here: https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/LangOptions.def#L106-L109 in bootstrap.cpp, e.g. here: https://github.com/Keno/Cxx.jl/blob/master/src/bootstrap.cpp#L464 On Sun, Nov 30, 2014 at 5:59 PM, Max Suster mxss...@gmail.com javascript: wrote: Hi I am not very familiar with the mechanics of exception handling in Clang and I realize that exceptions (throw/catch) work well in Julia itself. However, I am specifically trying to use exception handling in C++ code nested inside Julia with Cxx.jl. I noticed exception handling is meant to be switched off by default in Clang, but still it seems to me that it would be very useful to have it switched on when dealing with GUI applications. I tried several C++ exceptions (e.g., throw/catch, std::exception) but it seems they are disabled in my current Julia-v0.4.0-dev build (OSX 10.9.5). Since I did not use the -fno-exceptions flag to build Julia, I wonder why/where exceptions are switched off when I built Julia. In Xcode(with libc++-LLVM, C++11), I can run the following script with C++ exceptions and it works: const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } int main() { try { divide(1, 0); } catch(int i) { if(i==ZeroDivisionError) { std::cerrDivide by zero error; } } } *Divide by zero error *Program ended with exit code: 0 However, when I try to compile essentially the same code in Julia (with Cxx), I see the following ERROR: julia cxx #include iostream //std::cerr const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } void exceptiontest() { try { divide(1, 0); } catch(int i) { if(i==ZeroDivisionError) { std::cerrDivide by zero error; } } } In file included from :1: :9:25: error: cannot use 'throw' with exceptions disabled throw ZeroDivisionError; ^ :16:20: error: cannot use 'try' with exceptions disabled try ^ Does anyone know how I can switch on exception handling in Clang for building Julia? Alternatively, if the exception flag is already included by default, then at least I know to focus on why it is not being used by Cxx. Thank you for your time. Max
[julia-users] Lua Jit out performed Julia for my stock prediction engine use case
Just finished some basic tests comparing the lua jit and Julia for the kinds of statistical functions we commonly compute. It essentially loads 70K 1 minute bar records and computes a sma(14) and sma(600) for every row in the file. This time I included source code so others can figure out what I missed. It is admittedly a simplified case but I have found that if this function runs fast the rest of our system tends to run fast so I consider it a realistic starting benchmark. http://bayesanalytic.com/lua_jit_faster_than_julia_stock_prediction/ The results were not what I expected. I expected Julia to blow away lua even with a jit due to the fact that I could allocate memory for result arrays in typed arrays in Julia as blocks and couldn't figure out how to do the same in lua. In addition the lua array index access seem more like a hash rather than a pure numeric array index which should give Julia a substantial advantage when looping across items in an array.What I found is that Lua jit out performed Julia in all but 1 test even if you don't consider Julia's horrible start-up performance. I am hoping that somebody finds a mistake that would make Julia out perform as I really want to love it.I like the Julia community I also really like the multi-dispatch function system. The Julia community seems to be working at a incredible velocity but Julia's poor error messages, slow startup time and letting lua beat them makes me skeptical for investing in it for larger projects.On the other-hand Lua has been around for a long time and is used as a scripting engine in many games and consoles and is unlikely to go away anytime soon. If any of you produce a better Julia version that performs better then let me know and I will add it to the original article.If any of you have a chance to port the same code to Python to using pypy, Java, Scala, C then let me know and I will add it to the original article.
Re: [julia-users] Lua Jit out performed Julia for my stock prediction engine use case
Hi Joseph, Have you read http://julia.readthedocs.org/en/release-0.3/manual/performance-tips/ ? I didn't read your code in detail, but a superficial read suggests that your code has a lot of type-instability, which is a showstopper for Julia. -- John On Nov 30, 2014, at 4:58 PM, Joseph Ellsworth joexd...@gmail.com wrote: Just finished some basic tests comparing the lua jit and Julia for the kinds of statistical functions we commonly compute. It essentially loads 70K 1 minute bar records and computes a sma(14) and sma(600) for every row in the file. This time I included source code so others can figure out what I missed. It is admittedly a simplified case but I have found that if this function runs fast the rest of our system tends to run fast so I consider it a realistic starting benchmark. http://bayesanalytic.com/lua_jit_faster_than_julia_stock_prediction/ The results were not what I expected. I expected Julia to blow away lua even with a jit due to the fact that I could allocate memory for result arrays in typed arrays in Julia as blocks and couldn't figure out how to do the same in lua. In addition the lua array index access seem more like a hash rather than a pure numeric array index which should give Julia a substantial advantage when looping across items in an array.What I found is that Lua jit out performed Julia in all but 1 test even if you don't consider Julia's horrible start-up performance. I am hoping that somebody finds a mistake that would make Julia out perform as I really want to love it.I like the Julia community I also really like the multi-dispatch function system. The Julia community seems to be working at a incredible velocity but Julia's poor error messages, slow startup time and letting lua beat them makes me skeptical for investing in it for larger projects.On the other-hand Lua has been around for a long time and is used as a scripting engine in many games and consoles and is unlikely to go away anytime soon. If any of you produce a better Julia version that performs better then let me know and I will add it to the original article.If any of you have a chance to port the same code to Python to using pypy, Java, Scala, C then let me know and I will add it to the original article.
Re: [julia-users] exceptions disabled - Clang
Thanks for the quick feedback. I managed to get C++ exception handling working in Cxx, after some back and forth experimentation. In the end, I added the following to bootstrap.cpp: // Enable C++ exception handling clang_compiler-getLangOpts().Exceptions = 1; // exception handling clang_compiler-getLangOpts().ObjCExceptions = 1; // Objective-C exceptions clang_compiler-getLangOpts().CXXExceptions = 1; // C++ exceptions However, note that you may NOT add SjLjExceptions at least on OSX (at least not without further changes): clang_compiler-getLangOpts().SjLjExceptions = 1;// setjmp-longjump exception handling The latter produced the following ERROR after using a simple throw test code (see below): LLVM ERROR: Program used external function '___gxx_personality_sj0' which could not be resolved! I then rebuilt libcxxffi.dylib with Pkg.build(Cxx) and tested the same zeroDivExceptionTest C++ script: julia cxx #include iostream //std::cerr const int ZeroDivisionError = 1; double divide(double x, double y) { if(y==0) { throw ZeroDivisionError; } return x/y; } void zeroDivExceptionTest(double a, double b) { try { double c = divide(a, b); std::coutResult is: c std::endl; } catch(int i) { if(i==ZeroDivisionError) { std::cerr Divide by zero error! std::endl; } } } julia @cxx zeroDivExceptionTest(5.0, 0) Divide by zero error! julia @cxx zeroDivExceptionTest(1.0, 5.0) Result is: 0.2 julia @cxx zeroDivExceptionTest(43.3, 0) Divide by zero error!
Re: [julia-users] [ANN,X-post julia-stats] Mocha.jl v0.0.3, Image Classification IJulia Notebook Demo
Hi Tim, Thanks! I'm actually looking forward to see a version update of your great HDF5.jl. And BTW: I have been thinking about data randomization. How inefficient do you think it will be if I read hdf5_dset[:,:,:,i] for i be 100 random numbers within the index range, comparing to reading hdf5_dset[:,:,:,k+1:k+100], reading 100 consecutive examples (no randomization here) all at one time? Is there a recommended / better way of doing random access in HDF5 (HDF5.jl)? Thank you very much! Best, Chiyuan On Friday, November 28, 2014 2:51:29 PM UTC-5, Tim Holy wrote: Cool stuff! --Tim On Friday, November 28, 2014 07:42:47 AM Chiyuan Zhang wrote: Hi all, Mocha.jl https://github.com/pluskid/Mocha.jl is a Deep Learning framework for Julia http://julialang.org/, inspired by the C++ Deep Learning framework Caffe http://caffe.berkeleyvision.org/. Please checkout the new IJulia Notebook demo of using pre-trained CNN on imagenet to do image classification: http://nbviewer.ipython.org/github/pluskid/Mocha.jl/blob/master/examples/iju lia/ilsvrc12/imagenet-classifier.ipynb Here are detailed change log since the last release: v0.0.3 2014.11.27 - Interface - IJulia-notebook example - Image classifier wrapper - Network - Data transformers for data layers - Argmax, Crop, Reshape, HDF5 Output, Weighted Softmax-loss Layers - Infrastructure - Unit tests are extended to cover all layers in both Float32 and Float64 - Compatibility with Julia v0.3.3 and v0.4 nightly build - Documentation - Complete User's Guide - Tutorial on image classification with pre-trained imagenet model Best, pluskid
Re: [julia-users] Matrix Extraction Efficiency Problem
I have a n by m dense matrix, and each row is a vector representing variating flows like stock price, and I'd like to find out the two vectors which have the highest similarity using cor(). Hence, a nested for-loop was utilized to calculate the similarity between each pair, and fill the similarity into an n by n adjacency matrix. On Fri Nov 28 2014 at 8:49:51 PM Milan Bouchet-Valat nalimi...@club.fr wrote: Le vendredi 28 novembre 2014 à 10:21 +, SLiZn Liu a écrit : I'm doing row-wise/col-wise calculation, isn't it inevitable to create row/col copies after iteratively extract single elements? No, I don't think so, though sometimes you'll want to extract a full row/column to pass it to a standard function instead of writing all of the computations by hand. That's where array views are very useful. But can you give more details about the calculation you need to do? Regards I will consider to take a shot on option 1, ArrayViews if this single-element-extraction comes to a dead end. Thanks, Milan! On Fri Nov 28 2014 at 6:00:07 PM Milan Bouchet-Valat nalimi...@club.fr wrote: Le vendredi 28 novembre 2014 à 01:45 -0800, Todd Leo a écrit : Hi Fellows, Say I have a 1000 x 1000 matrix, and I'm going to do some calculation in a nested for-loop, with each pair of rows/cols in the matrix. But I suffered a heavy performance penalty in row/col extraction. Here's my minimum reproducible example, which I hope explains itself. A = rand(0.:0.01:1.,1000,1000) function test(x) for i in 1:1000, j in 1:1000 x[:,i] x[:,j] end end test(A) # warm up gc() @time test(A) ## elapsed time: 13.28547939 seconds (1620880 bytes allocated, 72.42% gc time) It takes 13 seconds, only extracting the rows/cols for the sake of further calculations. I'm wondering if anything I could do to improve the performance.Thanks in advance. This is because extracting a row/column creates a copy. Depending on what calculation you want to do on them, you can: - use arrays views (which will become the default when extracting slices in 0.4): https://github.com/JuliaLang/ArrayViews.jl - manually write loops to go over the row and column so that you only extract one individual element of the matrix at a time Regards
Re: [julia-users] Re: Is it wrong to think of Julia as a Lisp that uses m-expressions?
On Sun, Nov 30, 2014 at 3:28 PM, Chris Kohlhepp chris.kohlh...@gmail.com wrote: Try typing julia --lisp and see what happens. Wow, that is some easter egg! Is there a serious purpose for this? Any documentation? -- Matt Gushee
Re: [julia-users] Re: Is it wrong to think of Julia as a Lisp that uses m-expressions?
This isn't documented because it's not meant to be an official part of Julia. At present, Julia's parser is written in Scheme. That command lets you use the Scheme implementation that Julia uses internally. -- John On Nov 30, 2014, at 7:45 PM, Matt Gushee m...@gushee.net wrote: On Sun, Nov 30, 2014 at 3:28 PM, Chris Kohlhepp chris.kohlh...@gmail.com wrote: Try typing julia --lisp and see what happens. Wow, that is some easter egg! Is there a serious purpose for this? Any documentation? -- Matt Gushee
Re: [julia-users] Lua Jit out performed Julia for my stock prediction engine use case
Check out https://gist.github.com/IainNZ/1afb9318c841c9bd2234 I get IAINMAC:Desktop idunning$ julia test.jl elapsed time: 0.006008895 seconds (2800048 bytes allocated) elapsed time: 0.011813825 seconds (2800048 bytes allocated) elapsed time: 0.33829981 seconds (2800048 bytes allocated) elapsed time: 0.004994186 seconds (2800048 bytes allocated) elapsed time: 0.006508385 seconds (2800048 bytes allocated) elapsed time: 0.056528559 seconds (2800048 bytes allocated) Which is pretty neat, and is generalized to work with any number type. I wouldn't put much stock in the DataFrames times - the performance isn't going to be great. The pure data times though, those surprise me - I don't get how LuaJIT is generating better code for something so simple. On Sunday, November 30, 2014 9:10:37 PM UTC-5, Andreas Noack wrote: Hi Joseph I just tried to run your code and I get approximately the same numbers for Julia and I couldn't see any obvious errors in your implementation. DataVectors have some overhead to allow for missing values, so I don't know they can be made faster. It might be cheating in the comparison with LuaJit, but the code vectorizes very nicely so if I add @simd before the inner for loop and @inbounds before the line in that loop I get a five fold speed up on my fairly new MacBook Pro. Andreas 2014-11-30 20:04 GMT-05:00 John Myles White johnmyl...@gmail.com javascript:: Hi Joseph, Have you read http://julia.readthedocs.org/en/release-0.3/manual/performance-tips/ ? I didn't read your code in detail, but a superficial read suggests that your code has a lot of type-instability, which is a showstopper for Julia. -- John On Nov 30, 2014, at 4:58 PM, Joseph Ellsworth joex...@gmail.com javascript: wrote: Just finished some basic tests comparing the lua jit and Julia for the kinds of statistical functions we commonly compute. It essentially loads 70K 1 minute bar records and computes a sma(14) and sma(600) for every row in the file. This time I included source code so others can figure out what I missed. It is admittedly a simplified case but I have found that if this function runs fast the rest of our system tends to run fast so I consider it a realistic starting benchmark. http://bayesanalytic.com/lua_jit_faster_than_julia_stock_prediction/ The results were not what I expected. I expected Julia to blow away lua even with a jit due to the fact that I could allocate memory for result arrays in typed arrays in Julia as blocks and couldn't figure out how to do the same in lua. In addition the lua array index access seem more like a hash rather than a pure numeric array index which should give Julia a substantial advantage when looping across items in an array.What I found is that Lua jit out performed Julia in all but 1 test even if you don't consider Julia's horrible start-up performance. I am hoping that somebody finds a mistake that would make Julia out perform as I really want to love it.I like the Julia community I also really like the multi-dispatch function system. The Julia community seems to be working at a incredible velocity but Julia's poor error messages, slow startup time and letting lua beat them makes me skeptical for investing in it for larger projects.On the other-hand Lua has been around for a long time and is used as a scripting engine in many games and consoles and is unlikely to go away anytime soon. If any of you produce a better Julia version that performs better then let me know and I will add it to the original article.If any of you have a chance to port the same code to Python to using pypy, Java, Scala, C then let me know and I will add it to the original article.
Re: [julia-users] Lua Jit out performed Julia for my stock prediction engine use case
(those times are on 0.3.0, OSX, by the way - may be better/different on new versions) On Sunday, November 30, 2014 11:33:58 PM UTC-5, Iain Dunning wrote: Check out https://gist.github.com/IainNZ/1afb9318c841c9bd2234 I get IAINMAC:Desktop idunning$ julia test.jl elapsed time: 0.006008895 seconds (2800048 bytes allocated) elapsed time: 0.011813825 seconds (2800048 bytes allocated) elapsed time: 0.33829981 seconds (2800048 bytes allocated) elapsed time: 0.004994186 seconds (2800048 bytes allocated) elapsed time: 0.006508385 seconds (2800048 bytes allocated) elapsed time: 0.056528559 seconds (2800048 bytes allocated) Which is pretty neat, and is generalized to work with any number type. I wouldn't put much stock in the DataFrames times - the performance isn't going to be great. The pure data times though, those surprise me - I don't get how LuaJIT is generating better code for something so simple. On Sunday, November 30, 2014 9:10:37 PM UTC-5, Andreas Noack wrote: Hi Joseph I just tried to run your code and I get approximately the same numbers for Julia and I couldn't see any obvious errors in your implementation. DataVectors have some overhead to allow for missing values, so I don't know they can be made faster. It might be cheating in the comparison with LuaJit, but the code vectorizes very nicely so if I add @simd before the inner for loop and @inbounds before the line in that loop I get a five fold speed up on my fairly new MacBook Pro. Andreas 2014-11-30 20:04 GMT-05:00 John Myles White johnmyl...@gmail.com: Hi Joseph, Have you read http://julia.readthedocs.org/en/release-0.3/manual/performance-tips/ ? I didn't read your code in detail, but a superficial read suggests that your code has a lot of type-instability, which is a showstopper for Julia. -- John On Nov 30, 2014, at 4:58 PM, Joseph Ellsworth joex...@gmail.com wrote: Just finished some basic tests comparing the lua jit and Julia for the kinds of statistical functions we commonly compute. It essentially loads 70K 1 minute bar records and computes a sma(14) and sma(600) for every row in the file. This time I included source code so others can figure out what I missed. It is admittedly a simplified case but I have found that if this function runs fast the rest of our system tends to run fast so I consider it a realistic starting benchmark. http://bayesanalytic.com/lua_jit_faster_than_julia_stock_prediction/ The results were not what I expected. I expected Julia to blow away lua even with a jit due to the fact that I could allocate memory for result arrays in typed arrays in Julia as blocks and couldn't figure out how to do the same in lua. In addition the lua array index access seem more like a hash rather than a pure numeric array index which should give Julia a substantial advantage when looping across items in an array.What I found is that Lua jit out performed Julia in all but 1 test even if you don't consider Julia's horrible start-up performance. I am hoping that somebody finds a mistake that would make Julia out perform as I really want to love it.I like the Julia community I also really like the multi-dispatch function system. The Julia community seems to be working at a incredible velocity but Julia's poor error messages, slow startup time and letting lua beat them makes me skeptical for investing in it for larger projects.On the other-hand Lua has been around for a long time and is used as a scripting engine in many games and consoles and is unlikely to go away anytime soon. If any of you produce a better Julia version that performs better then let me know and I will add it to the original article.If any of you have a chance to port the same code to Python to using pypy, Java, Scala, C then let me know and I will add it to the original article.
[julia-users] How to best convert array of Uint8's to long hex string
Suppose you have a length-n array x of Uint8's = [1,5,32,7,...] , and you want to convert this to a long string of hex digits (two per x[i]). The code y = reduce(string, [hex(xi,2) for xi in x]) == 01052007... will do the trick. (Or, you could use map_reduce or one of the fold operations.) But I would like this operation to run in linear time. Would any of the reduce, map_reduce, or fold operations run in linear time? With a strict abstract implementation, each intermediate result string would need to be created, and each such intermediate result string is immutable, so the running time would be Theta(n^2). Or is the compiler smart about this case? (A small experiment suggests not.) Perhaps the right approach is: x2 = [ hex(xi,2) for xi in x] y = string(x2) ?? Cheers, Ron
Re: [julia-users] How to best convert array of Uint8's to long hex string
This should help a bit, although there's probably some room for improvement by replacing the hex(byte, 2) calls with something that doesn't allocate an intermediate string object: function bytes2hex(bytes::Vector{Uint8}) io = IOBuffer() for byte in bytes write(io, hex(byte, 2)) end return takebuf_string(io) end bytes2hex([0x01, 0x23, 0xab, 0xff]) # = 0123abff -- John On Nov 30, 2014, at 9:39 PM, Ronald L. Rivest rivest@gmail.com wrote: Suppose you have a length-n array x of Uint8's = [1,5,32,7,...] , and you want to convert this to a long string of hex digits (two per x[i]). The code y = reduce(string, [hex(xi,2) for xi in x]) == 01052007... will do the trick. (Or, you could use map_reduce or one of the fold operations.) But I would like this operation to run in linear time. Would any of the reduce, map_reduce, or fold operations run in linear time? With a strict abstract implementation, each intermediate result string would need to be created, and each such intermediate result string is immutable, so the running time would be Theta(n^2). Or is the compiler smart about this case? (A small experiment suggests not.) Perhaps the right approach is: x2 = [ hex(xi,2) for xi in x] y = string(x2) ?? Cheers, Ron
Re: [julia-users] Installing IJulia
Hi, I see winpython-64-3.3.5.0 in your screenshot. you may try a more recent one, or better a Python3.4 one (winpython.github.io). I had that permanent reboot phenomenon also at the early tries, it was the main cause of failure after the bad suse mirror in europe. Suggestion : - remove the julia that may be system installed on your pc, if you have one, it may be the root cause, (and the .Julia directory that goes with it) - retry with a more recent winpython , like WinPython-64bit-3.4.2.2.exe http://sourceforge.net/projects/stonebig.u/files/Winpython_3.4/WinPython-64bit-3.4.2.2.exe/download http://sourceforge.net/projects/stonebig.u/files/Winpython_3.3/WinPython-64bit-3.3.5.3.exe/download , as it may be an old Tornado issue. Not sure it will fix your problem, just two shots in the dark. On Sunday, November 30, 2014 11:08:27 PM UTC+1, Abram Demski wrote: The winpython install has also failed, FYI. The common element is Nettle. (The attempt with anaconda complained about nettle when the IJulia package.) This time, I get all the way to an IJulia session opening in my browser, but the kernel crashes and restarts every few seconds. Screenshot attached. Attempting the fix suggested in the error message, Pkg.build(Nettle), causes Julia to hang. On Thu, Nov 27, 2014 at 8:54 AM, stone...@gmail.com javascript: wrote: Hi Abram, (sorry for the keyboard error) I wrote last resort as I supposed you were relying on Anaconda for other purposes. If the only goal for you is to get Ijulia working on windows, this solution as the advantage of working since a few months. On Thursday, November 27, 2014 9:59:05 AM UTC+1, Abram Demski wrote: Pileas, Atom looks very cool, but it appears existing Julia customization is very minimal. Do you know if there is an easy way to have a command to run the current file in a julia terminal? (I miiight be tempted into trying to build it, seeing as the Atom customization stuff looks fun...) On Wed, Nov 26, 2014 at 3:26 PM, Abram Demski abram...@gmail.com wrote: Pileas, Given that I've still been unable to install IJulia, that's very helpful, thanks. On Tue, Nov 25, 2014 at 6:29 PM, Pileas phoebus@gmail.com wrote: I have to suggest a very good editor that supports Julia and it is called Atom. It becomes better each day: Give it a try if you have time: https://atom.io/ Τη Τρίτη, 25 Νοεμβρίου 2014 6:12:52 μ.μ. UTC-5, ο χρήστης Abram Demski έγραψε: Thanks! I figured out how to do it in the default shell: julia print(ENV[PATH]) C:\Users\abram\AppData\Local\Julia-0.3.3\bin;C:\Users\abram\ AppData\Local\Julia- 0.3.3\bin\..\Git\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\ Intel\iCLS Client\;C:\windows\system32;C: \windows;C:\windows\System32\Wbem;C:\wi ndows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Managemen t Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Compon ents\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Progra m Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\P rogram Files\Condusiv Technologies\ExpressCache\;C:\Program Files (x86)\Common F iles\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps; C:\Anaconda;C:\Anaco nda\Scripts (I have not used windows much since Windows 98! ;p) On Tue, Nov 25, 2014 at 3:02 PM, cdm cdmcle...@gmail.com wrote: if you have access to the PowerShell in Windows 8 ( ... and similar, new-ish, MS OSs ...), then highlighting a block of text from the PowerShell and right clicking should rip it to the clipboard for pasting else-where ... best, cdm On Tuesday, November 25, 2014 2:42:51 PM UTC-8, Abram Demski wrote: Julia shows a similar PATH when I run ENV[PATH], but with more julia-specific things. (It seems that command prompts in Windows 8.1 do not allow one to copy text out of them directly.. otherwise I'd copy.) -- Abram Demski Blog: http://lo-tho.blogspot.com/ -- Abram Demski Blog: http://lo-tho.blogspot.com/ -- Abram Demski Blog: http://lo-tho.blogspot.com/ -- Abram Demski Blog: http://lo-tho.blogspot.com/
[julia-users] Re: Lua Jit out performed Julia for my stock prediction engine use case
Pepsi challenge time?! Do you have a link to your data?