Re: [julia-users] solving large system of complex nonlinear ODEs
ok, so the system under discussion is this one: http://scicomp.stackexchange.com/questions/19585/system-of-coupled-nonlinear-odes-with-complex-coefficients i think the choice basically comes down to either a) an explicit RK method in ODE.jl or b) CVODE(S) in Sundials.jl What do you guys suggest based on your experience? a) has the advantage that it is a pure Julia solution, but not production ready. b) seems more reliable but indeed it seems to only solve equations with real coefficients. On Thursday, May 7, 2015 at 7:12:40 AM UTC+2, Mauro wrote: Any suggestions for solving a nonlinear system of ~1000 coupled ODEs with complex coefficients? Try your luck with the ODE solvers: ODE.jl, DASSL.jl and Sundials.jl. For sundials you will probably have to split the equations into real and imaginary part.
[julia-users] solving large system of complex nonlinear ODEs
Any suggestions for solving a nonlinear system of ~1000 coupled ODEs with complex coefficients?
[julia-users] Re: pre-allocation for sparse matrices
OK so I'm not sure how to directly access the CSC structure. Anyway, for clarity, here is the method which generates my sparse matrix. In a typical usage scenario, I need to generate and diagonalize a lot of these matrices, which are obtained varying the *s* Function. I guess this qualifies as a low-order method? *function genspmat(l::Function,r::Function,u::Function,d::Function,s::Function, N::Int,nz::Int,α::Float64)# PreallocateI = Array(Int64,nz)J = Array(Int64,nz)V = Array(Complex{Float64},nz) function setnzelem(i::Int,n::Int,m::Int; pos::ASCIIString = self)if pos==leftk += 1J[k] = i-N; I[k] = i; V[k] = l(n,m,α)elseif pos==rightk += 1J[k] = i+N; I[k] = i; V[k] = r(n,m,α)elseif pos==upk += 1J[k] = i-1; I[k] = i; V[k] = u(n,m,α)elseif pos==downk += 1J[k] = i+1; I[k] = i; V[k] = d(n,m,α)elseif pos==selfk += 1J[k] = i; I[k] = i; V[k] = s(n,m,α)endend# maximum value of m or n indicesmaxm = div(N-1,2) k = 0for i in 1:N^2m = getm(i,N)n = getn(i,N)setnzelem(i,n,m; pos=self) #corners#top leftif n==maxm m==-maxm setnzelem(i,n,m; pos=right)setnzelem(i,n,m; pos=down)#top rightelseif n==maxm m==maxm setnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=down) #bottom rightelseif n==-maxm m==maxm setnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=up) #bottom leftelseif n==-maxm m==-maxm setnzelem(i,n,m; pos=right)setnzelem(i,n,m; pos=up) #edges#topelseif n == maxmsetnzelem(i,n,m; pos=right)setnzelem(i,n,m; pos=left) setnzelem(i,n,m; pos=down)#rightelseif m == maxmsetnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=up)setnzelem(i,n,m; pos=down)#bottom elseif n == -maxmsetnzelem(i,n,m; pos=left) setnzelem(i,n,m; pos=up)setnzelem(i,n,m; pos=right) #leftelseif m == -maxmsetnzelem(i,n,m; pos=down)setnzelem(i,n,m; pos=up) setnzelem(i,n,m; pos=right)else #bulksetnzelem(i,n,m; pos=down)setnzelem(i,n,m; pos=up) setnzelem(i,n,m; pos=right)setnzelem(i,n,m; pos=left)endendreturn sparse(I,J,V)end* On Friday, April 10, 2015 at 10:15:22 PM UTC+2, Christoph Ortner wrote: For example, for finite elements or finite differences, the connectivity information gives you the sparsity pattern, which you could assemble once and for all and then change the entries as needed. If it is a low-order method, then you have few elements in each column and it would be very efficient (and easy to implement) to make these changes by directly accessing the CSC structure. Christoph
Re: [julia-users] Re: in-place matrix division
The problem is, as I loop though my parameter space, I need to solve a lot of linear systems of the type \(A,B), where B stays the same but A changes depending on the parameters. Therefore a method that overwrites B doen't really help. On Friday, April 10, 2015 at 6:19:34 PM UTC+2, Andreas Noack wrote: Yes. This has to be made more clear. The problem is that the libraries we are using for sparse factorizations don't allow us to update b in place. 2015-04-10 4:26 GMT-07:00 Kristoffer Carlsson kcarl...@gmail.com javascript:: I think it should be A_ldiv_B! however this seems inconcistent to me: julia a = rand(3,3); b = rand(3) 3-element Array{Float64,1}: 0.95134 0.43887 0.719551 julia A_ldiv_B!(sparse(a), b) 3-element Array{Float64,1}: 0.455667 0.712479 0.326213 julia b # Note: b is not overwritten 3-element Array{Float64,1}: 0.95134 0.43887 0.719551 julia A_ldiv_B!(lufact(a), b) 3-element Array{Float64,1}: 0.455667 0.712479 0.326213 julia b # For this, b is overwritten 3-element Array{Float64,1}: 0.455667 0.712479 0.326213 On Friday, April 10, 2015 at 11:19:45 AM UTC+2, Andrei Berceanu wrote: I am solving a linear system of the type A*X == B, where A is a sparse matrix. I use the matrix division function \(*A*, *B*) Is there an in-place version of this function, where one can pre-allocate the output X and then pass it, i.e. \!(A,B,X)
Re: [julia-users] code review: my first outer constructor :)
Hi Gabriel, thanks a lot for your reply! (1) I use the WaveFunction type inside the Spectrum type, which as you can see is a collection of wavefunctions. For a typical usage case, have a look at http://nbviewer.ipython.org/github/berceanu/topo-photon/blob/master/anc/exploratory.ipynb I am not quite sure what you mean with defining a methods for the int attribute. (2) As you can see, the gauge is an attribute of the Spectrum type, which is what I use in practice so I didn't see much point in storing it inside every wavefunction. Do you have a suggestion for a better implementation? In fact there are only these 2 gauge choices, landau and symmetric. (3) P should be a Vector of length N^2, and I thought that declaring N to be an int means implicit conversion as well - is that not so? (4) genspmat generates the (sparse) matrix of the Hamiltonian, so countnonzeros() simply counts beforehand how many nonzero elements there will be in this sparse matrix. If you think of an NxN 2D lattice, countnonzeros() simply counts the number of neighbours of each site (4 for a center site, 3 for an edge site and 2 for a corner site). What do you mean by irrelevant in this case? Are you refering to the gauge parameter? On Sunday, April 12, 2015 at 11:28:48 PM UTC+2, Gabriel Mitchell wrote: Hi Andrei. I am not really Julia expert, but I do have a couple of high level questions about your code, which might help anyone that feels inclined to contribute a review. (1) Why have you made the WaveFunction type in the first place? In particular, is there any reason that you just don't use alias Vector{Complex{Float64}} and define a methods for the int attribute? (2) the outer construction seems to allow for the option for different gauges (which, in my unsophisticated mindset, I think of as alternative parameterizations). Since different gauge choices in some sense imply different semantics for the values in Psi (although presumably not other function invariant to the gauge choice), it would seem that the user (or a function naive to the gauge choice) would want a means to inspect this change in the object. In other words why is the gauge not an attribute of the WaveFunction object, assuming you actually want this type? A related question would be how many different gauges choices does one expect the user to want to use. Just these two? These two plus a few more? All of them? (3) Line 17 asserts that N is an integer, but sqrt(length(P)) could be non-integral. (4) I don't really understand what is going on with countnonzeros, but maybe a pattern matching syntax ala Match.jl could help to make a more declarative version of this function? As a side note, I think the problem of how to describe and take advantage of irrelevant degrees of freedom in numerical computations is pretty interesting and certainly has applications in all kids of fields, so it would be cool if you had some ideas about how to systematically approach this problem. On Sunday, April 12, 2015 at 10:06:10 PM UTC+2, Andrei Berceanu wrote: Hi Mauro, I realised after posting this that I should have been much more specific. I apologise for that! Anyway, thanks for you reply. Not sure what you mean by OO programming, as I thought Julia uses multiple dispatch and not OO. PS: You're the first person I see that also uses runbox, that makes us email brothers I guess :p On Sunday, April 12, 2015 at 8:29:44 PM UTC+2, Mauro wrote: Hi Andrei, just a general note, unless someone is actually interested in using your code, a code review might be too much to ask of people. Thus the lack in responses. See: https://groups.google.com/forum/#!searchin/julia-users/karpinski$20reivew/julia-users/C5cVjAuGA8U/HLV5rAjIuLMJ The way to get most feedback, is to condense your problem into a small snippet which can just be run with copy-paste (you're gists fails there) and ask something specific. An exception seem to be questions of the kind I ported this from C/Fortran/... and it is 100x slower, where did I go wrong, which seem to regularly attract much feedback. I didn't look into the code in detail: It's the first time I try to use Julia constructors properly (or improperly?!) so I need your opinion on a couple of points. Use of constructors seem to be fine. 1. On Julia's IRC channel I was told that using AbstractArray instead of e.g. Matrix/Vector might yield a performance boost - is that the case? No, I don't think so. Did you read the Performance section of the manual? There it also tells you how to profile your code. 2. Can you spot any major performance killers in my code? 3. Coming from Python, I am used to things like enumerate etc, but perhaps that is not very Julian? :) So this last aspect concerns more the coding style, I guess. Using enumerate is totally fine. Just don't do object-oriented programming. Looks all good
[julia-users] Re: pre-allocation for sparse matrices
Yes but so how do I update it inplace? On Monday, April 13, 2015 at 5:37:50 PM UTC+2, Kristoffer Carlsson wrote: If you have the same sparse structures in your matrices then it should be sufficient to to the IJV - CSC sparse matrix conversion only once and then update A in place instead of generating a new IJV and converting to CSC again and again.
Re: [julia-users] code review: my first outer constructor :)
Hi Mauro, I realised after posting this that I should have been much more specific. I apologise for that! Anyway, thanks for you reply. Not sure what you mean by OO programming, as I thought Julia uses multiple dispatch and not OO. PS: You're the first person I see that also uses runbox, that makes us email brothers I guess :p On Sunday, April 12, 2015 at 8:29:44 PM UTC+2, Mauro wrote: Hi Andrei, just a general note, unless someone is actually interested in using your code, a code review might be too much to ask of people. Thus the lack in responses. See: https://groups.google.com/forum/#!searchin/julia-users/karpinski$20reivew/julia-users/C5cVjAuGA8U/HLV5rAjIuLMJ The way to get most feedback, is to condense your problem into a small snippet which can just be run with copy-paste (you're gists fails there) and ask something specific. An exception seem to be questions of the kind I ported this from C/Fortran/... and it is 100x slower, where did I go wrong, which seem to regularly attract much feedback. I didn't look into the code in detail: It's the first time I try to use Julia constructors properly (or improperly?!) so I need your opinion on a couple of points. Use of constructors seem to be fine. 1. On Julia's IRC channel I was told that using AbstractArray instead of e.g. Matrix/Vector might yield a performance boost - is that the case? No, I don't think so. Did you read the Performance section of the manual? There it also tells you how to profile your code. 2. Can you spot any major performance killers in my code? 3. Coming from Python, I am used to things like enumerate etc, but perhaps that is not very Julian? :) So this last aspect concerns more the coding style, I guess. Using enumerate is totally fine. Just don't do object-oriented programming. Looks all good to me!
[julia-users] Re: smallest eigenvalue of sparse matrix
I now get *CHOLMOD warning: not positive definiteERROR: `-` has no method matching -(::(Array{Complex{Float64},1},Array{Complex{Float64},2},Int64,Int64,Int64,Array{Complex{Float64},1}), ::Float64)* I must probably mention that I generate my sparse matrix using this constructor: *sparse(I,J,V)*, with *I = Array(Int64,N)J = Array(Int64,N)V = Array(Complex{Float64},N)* On Thursday, April 9, 2015 at 7:53:32 PM UTC+2, Alex wrote: Try eigs(A, nev=1, which=:SM) You might want to look into the docs to see the other keywords, for example if you need the eigenvector(s) as well. Best, Alex. On Thursday, 9 April 2015 19:34:40 UTC+2, Andrei Berceanu wrote: How can I get the minimum eigenvalue of a sparse matrix? I found eigmin(A), but it only seems to work on dense matrices. ERROR: `eigmin` has no method matching eigmin(::SparseMatrixCSC{Complex{Float64},Int64})
[julia-users] smallest eigenvalue of sparse matrix
How can I get the minimum eigenvalue of a sparse matrix? I found eigmin(A), but it only seems to work on dense matrices. ERROR: `eigmin` has no method matching eigmin(::SparseMatrixCSC{Complex{Float64},Int64})
[julia-users] Re: smallest eigenvalue of sparse matrix
It's hard to post the code because the function that generates the matrix A is quite involved. However, I tracked down the error. In fact the problem was that whereas before I had *val = eigmin(full(A))* I was now trying to do *val = eigs(A, nev=1, which=:SM) * Which of course fails because eigs does not return a single value. So now I have come up with the nice construct *real(eigs(A, nev=1, which=:SR, ritzvec=false)[1][1])* which seems to give the same results as before. However, I still see two issues here: 1. my matrix A is Hermitian, and I don't know if this info is used by eigs, or weather indeed it would make any difference (performance-wise) 2. using eigs like this instead of eigmin on the full matrix seems to be a few percent slower (i can provide timings if necessary). Is that to be expected? On Thursday, April 9, 2015 at 8:15:19 PM UTC+2, Viral Shah wrote: Could you post a self-sufficient code so that the errors can be reproduced? -viral On Thursday, April 9, 2015 at 11:40:00 PM UTC+5:30, Andrei Berceanu wrote: I now get *CHOLMOD warning: not positive definiteERROR: `-` has no method matching -(::(Array{Complex{Float64},1},Array{Complex{Float64},2},Int64,Int64,Int64,Array{Complex{Float64},1}), ::Float64)* I must probably mention that I generate my sparse matrix using this constructor: *sparse(I,J,V)*, with *I = Array(Int64,N)J = Array(Int64,N)V = Array(Complex{Float64},N)* On Thursday, April 9, 2015 at 7:53:32 PM UTC+2, Alex wrote: Try eigs(A, nev=1, which=:SM) You might want to look into the docs to see the other keywords, for example if you need the eigenvector(s) as well. Best, Alex. On Thursday, 9 April 2015 19:34:40 UTC+2, Andrei Berceanu wrote: How can I get the minimum eigenvalue of a sparse matrix? I found eigmin(A), but it only seems to work on dense matrices. ERROR: `eigmin` has no method matching eigmin(::SparseMatrixCSC{Complex{Float64},Int64})
[julia-users] code review: my first outer constructor :)
Hi guys! Here is [part of] some code I recently wrote for solving a physics problem: https://gist.github.com/berceanu/010d331884848205acef It's the first time I try to use Julia constructors properly (or improperly?!) so I need your opinion on a couple of points. 1. On Julia's IRC channel I was told that using AbstractArray instead of e.g. Matrix/Vector might yield a performance boost - is that the case? 2. Can you spot any major performance killers in my code? 3. Coming from Python, I am used to things like enumerate etc, but perhaps that is not very Julian? :) So this last aspect concerns more the coding style, I guess. Thanks so much! //A
[julia-users] Re: holoviews in julia
I just found this as a starting point http://philippjfr.com/blog/interfacing-holoviews-with-julia/ On Saturday, April 4, 2015 at 1:21:00 AM UTC+2, Andrei Berceanu wrote: Are you guys familiar with http://ioam.github.io/holoviews ? Is anyone working on a Julia interface or port? //A
[julia-users] holoviews in julia
Are you guys familiar with http://ioam.github.io/holoviews ? Is anyone working on a Julia interface or port? //A
[julia-users] Re: debugging Kernel died in IJulia
So where am I supposed to see the extra debugging info? I still get the same Kerned died message window. On Friday, March 27, 2015 at 6:06:29 AM UTC+1, Daniel Høegh wrote: This looks like issue: https://github.com/JuliaLang/IJulia.jl/issues/286
[julia-users] default value for slider in Interact.js
Is there any way of setting a default value for a slider object, different from the middle of the slider interval (which is automatically chosen)? I am refering to, i.e. *using Reactive, Interacta = slider(1:10)* *-- *this will have a default value of 5.
Re: [julia-users] strange behaviour of togglebuttons in Interact.jl
Hi Shashi, Thanks for your prompt reply! To make my question clearer, please take a look at the following (contrived) example: *using Reactive, Interact, DataStructuresp = Input(3.);α = @lift p/2;m = @lift Input(α);lift(a - togglebuttons(OrderedDict([one, two], [a,2a]), signal=m), α)* The problem with this is that now the togglebuttons seem to no longer affect the value of the signal *m*, that stays constant at 1.5 no matter which option the user selects. This is what I meant earlier when saying I would like to initialize a signal with a value that depends on another signal. This is done in the line *m = @lift Input(α);* in the example above. But it seems to break the behaviour of the toggle buttons. Tnx, //A On Wednesday, March 25, 2015 at 2:55:44 PM UTC+1, Shashi Gowda wrote: using Interact, Reactive α = Input(2) display(togglebuttons([one = 1, two = 2], signal=α)) signal(α) results in two being selected initially. If you want to set initial label to be selected, you can use the value_label keyword argument If you want the selection to change wrt another signal, you will need to lift the togglebuttons and set the value_label, but the value in the input won't change without user interaction... I may not have understood your question fully well. I hope you can play around with value_label and let me know where you get! Thanks Shashi On Tue, Mar 24, 2015 at 10:23 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: OK, I see. Now my problem is that, in my code, the initial value should then depend on another signal, and I have found no way of resolving this. The actual code I have is *lift(a - togglebuttons([Landau = ( (n,m) - one(Complex{Float64}), (n,m) - one(Complex{Float64}), (n,m) - exp(-im*2π*a*m), (n,m) - exp(im*2π*a*m) ), Symmetric = ((n,m) - exp(-im*π*a*n), (n,m) - exp(im*π*a*n),(n,m) - exp(-im*π*a*m), (n,m) - exp(im*π*a*m))], signal=ft), α)* So I would like to initialize *ft* beforehand with, say, the first value in my Dict, the one under the key Landau, but this depends on the value of the signal *α.* On Tuesday, March 24, 2015 at 3:43:04 PM UTC+1, Shashi Gowda wrote: Not a bug, if you are passing in your own input signal to widgets, you need to take care of maintaining the right initial values. It's also better to use OrderedDict from DataStructures package here to keep the ordering of the key-value pairs. On Tue, Mar 24, 2015 at 7:39 PM, Andrei Berceanu andreib...@gmail.com wrote: Consider the following code *using Reactive, Interactα = Input(0)togglebuttons([one = 1, two = 2], signal=α)signal(α)*I would expect the value of *α *to change after executing the *togglebuttons*(..) line, however this is not the case. *signal(α) *on the next line shows that *α *is still 0, even though one of the buttons is pre-selected. One has to press the buttons at least once to change the value of *α*. Can this behaviour be changed? Is it a bug?
[julia-users] debugging Kernel died in IJulia
I seem to be getting this message, with no other error, quite often when evaluating my notebook. What is the recommended way of debugging such a thing? Since no extra information is provided I have no idea what is causing it in my code, or even if its an IJulia problem. //A
[julia-users] strange behaviour of togglebuttons in Interact.jl
Consider the following code *using Reactive, Interactα = Input(0)togglebuttons([one = 1, two = 2], signal=α)signal(α)*I would expect the value of *α *to change after executing the *togglebuttons*(..) line, however this is not the case. *signal(α) *on the next line shows that *α *is still 0, even though one of the buttons is pre-selected. One has to press the buttons at least once to change the value of *α*. Can this behaviour be changed? Is it a bug?
[julia-users] metaprogramming for modifying expression inside anonymous function?
Hi guys, Say I have a tuple of anonymous functions, such as: *foolist = ((x,y)- exp(x*y), (x,y)- sin(x+y))* and would like to (programatically) produce another tuple where every function has its overall sign changed. In my example this would be *newfoolist = ((x,y)- -exp(x*y), (x,y)- -sin(x+y))*Can this be done, i.e. metaprogramming or some other technique? How? Tnx!
Re: [julia-users] strange behaviour of togglebuttons in Interact.jl
OK, I see. Now my problem is that, in my code, the initial value should then depend on another signal, and I have found no way of resolving this. The actual code I have is *lift(a - togglebuttons([Landau = ( (n,m) - one(Complex{Float64}), (n,m) - one(Complex{Float64}), (n,m) - exp(-im*2π*a*m), (n,m) - exp(im*2π*a*m) ), Symmetric = ((n,m) - exp(-im*π*a*n), (n,m) - exp(im*π*a*n),(n,m) - exp(-im*π*a*m), (n,m) - exp(im*π*a*m))], signal=ft), α)* So I would like to initialize *ft* beforehand with, say, the first value in my Dict, the one under the key Landau, but this depends on the value of the signal *α.* On Tuesday, March 24, 2015 at 3:43:04 PM UTC+1, Shashi Gowda wrote: Not a bug, if you are passing in your own input signal to widgets, you need to take care of maintaining the right initial values. It's also better to use OrderedDict from DataStructures package here to keep the ordering of the key-value pairs. On Tue, Mar 24, 2015 at 7:39 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Consider the following code *using Reactive, Interactα = Input(0)togglebuttons([one = 1, two = 2], signal=α)signal(α)*I would expect the value of *α *to change after executing the *togglebuttons*(..) line, however this is not the case. *signal(α) *on the next line shows that *α *is still 0, even though one of the buttons is pre-selected. One has to press the buttons at least once to change the value of *α*. Can this behaviour be changed? Is it a bug?
[julia-users] shorten redundant code
Hi, I need some help shortening this fragment of Julia code https://gist.github.com/berceanu/e4fdfa6285d30c024a71 The main idea is that *ft* and *ftex* are both tuples containing 4 anonymous functions. The are initialized as the identical function, but then depending on the toggle buttons, can take 2 separate sets of values. The important thing to notice however is that between the 2 *togglebuttons* instances, the anonymous functions (for each branch) are the same except for an overall minus sign. What I would like to do is have a single *togglebuttons* instance, which sets the value of *ft* and then *ftex* should get the same value, but with minus signs in front of al the anonymous functions. How can this be achieved? //A
[julia-users] gadfly plot of array with single nonzero element
Trying to plot a Matrix with a single nonzero element in Gadfly using *using Gadflya = zeros(Float64, 10,10);a[5,5] = 1;spy(a)* The result is shown in the attached figure. How can I convince Gadfly to show me also the zero values, in order to see the whole array, not just one element? To see what I mean, replace *zeros(Float64, 10,10) *with *rand(10,10) *for instance.
Re: [julia-users] Re: using Gadfly and PyPlot at the same time
ok so now im doing import PyPlot, but have some problems with the latex axis labels this used to work before ax[:set_xlabel](L$\kappa$) while now it gives @L_str not defined so i tried ax[:set_xlabel](PyPlot.L$\kappa$) which gives syntax: invalid interpolation syntax: \ On Friday, March 6, 2015 at 2:16:58 PM UTC+1, René Donner wrote: To get rid of name clashed you could e.g. also say import Gadfly using PyPlot Like this plot will refer to PyPlot.plot, and you can use Gadfly.plot anytime you need Gadfly's plot. You can find more info here: http://docs.julialang.org/en/release-0.3/manual/modules/#summary-of-module-usage Am 06.03.2015 um 14:12 schrieb Andreas Lobinger lobi...@gmail.com javascript:: Hello colleague, On Friday, March 6, 2015 at 2:05:19 PM UTC+1, Andrei Berceanu wrote: Hi guys, when I do using Gadfly, PyPlot i get Warning: using PyPlot.plot in module Main conflicts with an existing identifier. And other warning of the same type. How can I solve this? I guess to solve this, you need to work on the packages (or even the julia logic for exporting). Still you should be able to use (as this is a warning only) both .plot by prefixing Gadly.plot and PyPlot.plot.
[julia-users] using Gadfly and PyPlot at the same time
Hi guys, when I do using Gadfly, PyPlot i get Warning: using PyPlot.plot in module Main conflicts with an existing identifier. And other warning of the same type. How can I solve this?
[julia-users] Re: 2D plot in gadfly
But Geom.rectbin seems to only work for square arrays, which is a severe limitation. On Saturday, February 7, 2015 at 12:44:26 AM UTC+1, Iain Dunning wrote: How about: using Gadfly # Generate some data N = 100 X = Float64[] Y = Float64[] Z = Float64[] for x in linspace(0.0,2π,N), y in linspace(0.0,2π,N) push!(X, x) push!(Y, y) push!(Z, sin(x)*sin(y)) end plot(x=X,y=Y,color=Z,Geom.rectbin) On Friday, February 6, 2015 at 5:34:45 PM UTC-5, Andrei Berceanu wrote: The only thing keeping me from migrating from PyPlot to Gadfly is the lack of 2D plotting abilities. To exemplify, I used the following code to generate the attached image with PyPlot (here data is a 2d array): *fig, ax = plt.subplots(figsize=(4, 4))img = ax[:imshow](data, origin=upper, ColorMap(hot), interpolation=none, extent=[x[1], x[end], x[1], x[end]]) ax[:set_ylim](x[1], x[end]) ax[:set_xlim](x[1], x[end]) ax[:set_xlabel](L$p_x$) ax[:set_ylabel](L$p_y$) tks = [-3., -1.5, 0, 1.5, 3.] ax[:xaxis][:set_ticks](tks) ax[:yaxis][:set_ticks](tks) cbar = fig[:colorbar](img, shrink=0.8, aspect=20, fraction=.12,pad=.02) cbar[:ax][:tick_params](labelsize=7) fig[:savefig](fig_berry_bz, bbox_inches=tight)* What is the current alternative for obtaining such a plot using Gadfly? Are there plans for getting similar functionality anytime soon?
[julia-users] 3D interactive plots in IJulia
Is there some Julia library that allows one to do create 3D (surface plots) in the IJulia notebook and then rotate them interactively, using the mouse? //A
[julia-users] nonlinear curve fitting
i found this post concerning nonlinear curve fitting in Julia, http://www.walkingrandomly.com/?p=5181 but it appears the curve_fit method no longer exists does anyone have an updated version?
Re: [julia-users] nonlinear curve fitting
im using the code in the blog post model(xdata,p) = p[1]*cos(p[2]*xdata)+p[2]*sin(p[1]*xdata) xdata = [-2,-1.64,-1.33,-0.7,0,0.45,1.2,1.64,2.32,2.9] ydata = [0.699369,0.700462,0.695354,1.03905,1.97389,2.41143,1.91091,0.919576,-0.730975,-1.42001] beta, r, J = curve_fit(model, xdata, ydata, [1.0, 0.2]) # beta = best fit parameters # r = vector of residuals # J = estimated Jacobian at solution @printf(Best fit parameters are: %f and %f,beta[1],beta[2]) @printf(The sum of squares of residuals is %f,sum(r.^2.0)) and my julia is 0.3.7-pre On Tuesday, March 3, 2015 at 11:11:26 PM UTC+1, René Donner wrote: Can you post the code you are trying to run? Which Julia version are you on? The example given on https://github.com/JuliaOpt/LsqFit.jl works fine here on 0.3.6. Am 03.03.2015 um 22:55 schrieb Andrei Berceanu andreib...@gmail.com javascript:: i now get `start` has no method matching start(::LsqFitResult{Float64}) On Tuesday, March 3, 2015 at 10:41:11 PM UTC+1, René Donner wrote: Looks like curve_fit has been moved to https://github.com/JuliaOpt/LsqFit.jl Am 03.03.2015 um 22:30 schrieb Andrei Berceanu andreib...@gmail.com: i found this post concerning nonlinear curve fitting in Julia, http://www.walkingrandomly.com/?p=5181 but it appears the curve_fit method no longer exists does anyone have an updated version?
[julia-users] Gadfly legend for different layers
I have a 2D plot of 2 layers with different colors: *using Gadflyplot(layer(x=1:10, y=rand(10), Geom.line, Geom.point, Theme(default_color=color(red))), layer(x=1:10, y=rand(10), Geom.line, Geom.point, Theme(default_color=color(green*How can I generate a legend which specifies what each line color represents? I tried using Guide.colorkey but that doesn't seem to work for layers. //A
[julia-users] latex axis labels in Gadfly
I am trying to get rendering of LaTeX expressions in Gadfly axes labels, with *using Gadflyplot(x=1:10, y=rand(10), Geom.line, Geom.point, Guide.xlabel($c^2$), Guide.ylabel(E))* however this does not seem to work. Does anyone know how to do it? //A
[julia-users] Re: change size of individual plot in gadfly under IJulia
yes, but this loses the interactivity, i.e. the zoom functionality is no longer present. i just wanted the usual IJulia plot, but bigger :) On Thursday, February 12, 2015 at 3:06:13 AM UTC+1, Daniel Jones wrote: Hi Andrei, You can do this using the draw function, like: draw(SVG(20cm, 10cm), plot(...)) On Wednesday, February 11, 2015 at 3:42:47 PM UTC-8, Andrei Berceanu wrote: set_default_plot_size changes the default size of all following plots, but how can i set the size of a certain plot individually? //A
[julia-users] drawing geometrical shapes on top of gadfly plot
Does anyone know how I could draw a circle/square of a given radius/size on top of a Gadfly plot? Can I do it directly from within the plot command, or do I need to compose the figure after plotting it? I am using IJulia so im guessing its using svgs via the D3 backend (i do not explicitly call draw in my notebook). Thank you, //A
[julia-users] way around passing functions as arguments
I have written the following function for generating a sparse matrix: *function genspmat(ω0::Float64; N=pm[N], α=pm[α], γ=pm[γ], κ=pm[κ])# Determine memory usagenz = countnonzeros(; N=N)# PreallocateI = Array(Int64,nz)J = Array(Int64,nz)V = Array(Complex{Float64},nz)function setnzelem(i,n,m; pos=self) if pos==leftk += 1J[k] = i-N; I[k] = i; V[k] = 1elseif pos==rightk += 1J[k] = i+N; I[k] = i; V[k] = 1elseif pos==upk += 1J[k] = i-1; I[k] = i; V[k] = exp(-im*2π*α*m)elseif pos==down k += 1J[k] = i+1; I[k] = i; V[k] = exp(im*2π*α*m)elseif pos==selfk += 1J[k] = i; I[k] = i; V[k] = ω0 + im*γ - 1/2*κ*(m^2+n^2)endend# maximum value of m or n indicesmaxm = div(N-1,2)k = 0for i in 1:N^2m = getm(i; N=N)n = getn(i; N=N)#self interaction is always presentsetnzelem(i,n,m)#corners#top leftif n==maxm m==-maxmsetnzelem(i,n,m; pos=right) setnzelem(i,n,m; pos=down)#top rightelseif n==maxm m==maxmsetnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=down)#bottom rightelseif n==-maxm m==maxm setnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=up)#bottom leftelseif n==-maxm m==-maxm setnzelem(i,n,m; pos=right)setnzelem(i,n,m; pos=up)#edges#topelseif n == maxm setnzelem(i,n,m; pos=right)setnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=down)#right elseif m == maxmsetnzelem(i,n,m; pos=left) setnzelem(i,n,m; pos=up)setnzelem(i,n,m; pos=down) #bottomelseif n == -maxmsetnzelem(i,n,m; pos=left)setnzelem(i,n,m; pos=up) setnzelem(i,n,m; pos=right)#leftelseif m == -maxmsetnzelem(i,n,m; pos=down)setnzelem(i,n,m; pos=up)setnzelem(i,n,m; pos=right)else #bulksetnzelem(i,n,m; pos=down)setnzelem(i,n,m; pos=up)setnzelem(i,n,m; pos=right) setnzelem(i,n,m; pos=left)endendreturn sparse(I,J,V)end* Notice that inside this function I have defined *setnzelem(i,n,m; pos=self), *which is where all the action really takes place :) Now I would like to generalize the *genspmat* to values V[k] which can be arbitrary functions of m and n. One way of doing so is to define *function genspmat(l::Function,r::Function,u::Function,d::Function,s::Function, N::Int,nz::Int)*and then inside setnzelem do function setnzelem(i::Int,n::Int,m::Int; pos=self) if pos==left k += 1 J[k] = i-N; I[k] = i; V[k] = l(m,n) elseif pos==right k += 1 J[k] = i+N; I[k] = i; V[k] = r(m,n) elseif pos==up k += 1 J[k] = i-1; I[k] = i; V[k] = u(m,n) elseif pos==down k += 1 J[k] = i+1; I[k] = i; V[k] = d(m,n) elseif pos==self k += 1 J[k] = i; I[k] = i; V[k] = s(m,n) end end The problem with this is that passing functions as arguments tends to be slow in Julia. So what is your advice on accomplishing what I want? Tnx!
[julia-users] change size of individual plot in gadfly under IJulia
set_default_plot_size changes the default size of all following plots, but how can i set the size of a certain plot individually? //A
[julia-users] Re: building GUI on top of julia code
The problem is that the errors seem to happen at random times, and without any error message the kernel just dies. I am overly familiar with any of the 2 frameworks you mention, i.e. i know of their existence, but thats about it. On Friday, February 6, 2015 at 10:26:00 PM UTC+1, Avik Sengupta wrote: I would have said IJulia with Interact.jl is your best bet to get this gone quickly. But I see that doesn't work for you. That is unfortunate, because doing it that way is going to be the easiest by far. If you can replicate the issues, an IJulia bug report would be appreciated, I imagine. Julia does have bindings to GTK and TK. Depending on your familiarity with these frameworks, they may work for you. Regards - Avik On Friday, 6 February 2015 18:40:46 UTC, Andrei Berceanu wrote: So I have wrote the code for a numerical simulation in Julia, and I have a few free parameters that I can play with (5-6) which will change the resulting plots. The plots are done using Matplotlib via PyPlot. I would like to build a simple GUI with a few sliders for my parameters and an array of plots that will change interactively as I change the sliders. What are my options for quickly building such a thing? I prefer avoiding the IJulia notebook because the kernel crashes quite often for some reason when plotting stuff (this doesnt happen in the REPL). Thanks, A
[julia-users] 2D plot in gadfly
The only thing keeping me from migrating from PyPlot to Gadfly is the lack of 2D plotting abilities. To exemplify, I used the following code to generate the attached image with PyPlot (here data is a 2d array): *fig, ax = plt.subplots(figsize=(4, 4))img = ax[:imshow](data, origin=upper, ColorMap(hot), interpolation=none, extent=[x[1], x[end], x[1], x[end]]) ax[:set_ylim](x[1], x[end]) ax[:set_xlim](x[1], x[end]) ax[:set_xlabel](L$p_x$) ax[:set_ylabel](L$p_y$) tks = [-3., -1.5, 0, 1.5, 3.] ax[:xaxis][:set_ticks](tks) ax[:yaxis][:set_ticks](tks) cbar = fig[:colorbar](img, shrink=0.8, aspect=20, fraction=.12,pad=.02) cbar[:ax][:tick_params](labelsize=7) fig[:savefig](fig_berry_bz, bbox_inches=tight)* What is the current alternative for obtaining such a plot using Gadfly? Are there plans for getting similar functionality anytime soon?
[julia-users] building GUI on top of julia code
So I have wrote the code for a numerical simulation in Julia, and I have a few free parameters that I can play with (5-6) which will change the resulting plots. The plots are done using Matplotlib via PyPlot. I would like to build a simple GUI with a few sliders for my parameters and an array of plots that will change interactively as I change the sliders. What are my options for quickly building such a thing? I prefer avoiding the IJulia notebook because the kernel crashes quite often for some reason when plotting stuff (this doesnt happen in the REPL). Thanks, A
Re: [julia-users] Re: compute quantity along contour
I'm thinking, given that the phase map was produced by applying Base.angle() on another (complex) matrix (say we call it M), it is this function which caused the phase wrapping in the first place, right? So can't I somehow get around the problem and produce the unwrapped map directly from M? On Wednesday, February 4, 2015 at 4:41:12 PM UTC+1, Yuuki Soho wrote: It seems you want to unwrap the phase (plus pi) along your path: https://gist.github.com/ssfrr/7995008 But as you data are quite discrete, I'm not sure it will work. Maybe if you interpolate.
[julia-users] Re: compute quantity along contour
Sorry, perhaps I did not explain myself :) One can see the phase oscillates between -\pi and \pi. I would like to compute how many times the phase changes by 2\pi as one goes around the origin. On Wednesday, February 4, 2015 at 1:31:53 AM UTC+1, Steven G. Johnson wrote: On Tuesday, February 3, 2015 at 1:17:15 PM UTC-5, Andrei Berceanu wrote: How can I numerically compute the total change in phase as one goes around a closed loop centered on the site $m=n=0$? Seems like totalchangeinphase(m,n) = 0 would work and be very efficient. (As you described your problem, your phase sounds like a single-valued function of m n, hence the total change around any closed loop would be zero. Unless you mean something different by total change?)
[julia-users] Re: compute quantity along contour
I guess what I'm trying to say is that your answer makes sense for continuous functions, while mine has jumps of 2\pi, and so the phase change is equal to the total number of these jumps (times 2\pi). Does this make sense? On Wednesday, February 4, 2015 at 11:36:51 AM UTC+1, Andrei Berceanu wrote: Sorry, perhaps I did not explain myself :) One can see the phase oscillates between -\pi and \pi. I would like to compute how many times the phase changes by 2\pi as one goes around the origin. On Wednesday, February 4, 2015 at 1:31:53 AM UTC+1, Steven G. Johnson wrote: On Tuesday, February 3, 2015 at 1:17:15 PM UTC-5, Andrei Berceanu wrote: How can I numerically compute the total change in phase as one goes around a closed loop centered on the site $m=n=0$? Seems like totalchangeinphase(m,n) = 0 would work and be very efficient. (As you described your problem, your phase sounds like a single-valued function of m n, hence the total change around any closed loop would be zero. Unless you mean something different by total change?)
Re: [julia-users] Re: compute quantity along contour
I'm hoping it wouldn't, but it is actually one of the things I would like to test. On Wednesday, February 4, 2015 at 3:17:39 PM UTC+1, Michele Zaffalon wrote: Wouldn't the answer depend on the path you choose? On Wed, Feb 4, 2015 at 3:04 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: I guess what I'm trying to say is that your answer makes sense for continuous functions, while mine has jumps of 2\pi, and so the phase change is equal to the total number of these jumps (times 2\pi). Does this make sense? On Wednesday, February 4, 2015 at 11:36:51 AM UTC+1, Andrei Berceanu wrote: Sorry, perhaps I did not explain myself :) One can see the phase oscillates between -\pi and \pi. I would like to compute how many times the phase changes by 2\pi as one goes around the origin. On Wednesday, February 4, 2015 at 1:31:53 AM UTC+1, Steven G. Johnson wrote: On Tuesday, February 3, 2015 at 1:17:15 PM UTC-5, Andrei Berceanu wrote: How can I numerically compute the total change in phase as one goes around a closed loop centered on the site $m=n=0$? Seems like totalchangeinphase(m,n) = 0 would work and be very efficient. (As you described your problem, your phase sounds like a single-valued function of m n, hence the total change around any closed loop would be zero. Unless you mean something different by total change?)
[julia-users] compute quantity along contour
I would like to use Julia to solve the following problem, any suggestions are welcome :) The attached image (obtained in Julia) represents the phase of a wavefunction (in radians) on a square lattice, where m and n label the lattice sites. Computationally speaking, it is the density plot of a 41x41 real matrix. How can I numerically compute the total change in phase as one goes around a closed loop centered on the site $m=n=0$?
[julia-users] compute hermite polynomials
Hi, Are Hermite polynomials (http://en.wikipedia.org/wiki/Hermite_polynomials) implemented in Julia? Is there an easy way to compute Hn(x)? //A
[julia-users] Re: compute hermite polynomials
Yes, exactly, in order to generate plots like http://en.wikipedia.org/wiki/Hermite_polynomials#mediaviewer/File:Hermite_poly_phys.svg //A On Monday, February 2, 2015 at 4:36:55 PM UTC+1, Jiahao Chen wrote: Is there an easy way to compute Hn(x)? Do you mean to evaluate a given Hermite polynomial of order n at a value x?
[julia-users] Re: compute hermite polynomials
Andras, no worries :) Now I understand why I couldn't find the polynomials in your gist! //A On Monday, February 2, 2015 at 5:19:49 PM UTC+1, Andras Niedermayer wrote: Sorry, I meant Cubic Hermite Interpolation. Now I see you're looking for Hermite polynomials. On Monday, February 2, 2015 at 4:50:00 PM UTC+1, Andras Niedermayer wrote: I was looking for Hermite polynomials and haven't found any code. I have some (very unpolished) code. I haven't made a public package yet, since it needs to be improved (especially in terms of efficiency, also documentation). Unfortunately, I'm unlikely to have time for this in the near future, so I'll just post a link to a gist: https://gist.github.com/afniedermayer/57873094430e8ddb201c I mainly used it with the output of the ODE.jl. I hope this is a useful starting point... Best, Andras On Monday, February 2, 2015 at 4:38:57 PM UTC+1, Andrei Berceanu wrote: Yes, exactly, in order to generate plots like http://en.wikipedia.org/wiki/Hermite_polynomials#mediaviewer/File:Hermite_poly_phys.svg //A On Monday, February 2, 2015 at 4:36:55 PM UTC+1, Jiahao Chen wrote: Is there an easy way to compute Hn(x)? Do you mean to evaluate a given Hermite polynomial of order n at a value x?
[julia-users] Re: compute hermite polynomials
Jiahao, it's not just for reproducing the Wikipedia figure. I will need to compute higher orders as well, i.e. Hn for n = 48. I was just wondering if there was anything already implemented in Julia. Meanwhile I found this: https://github.com/daviddelaat/Orthopolys.jl On Monday, February 2, 2015 at 4:50:00 PM UTC+1, Andras Niedermayer wrote: I was looking for Hermite polynomials and haven't found any code. I have some (very unpolished) code. I haven't made a public package yet, since it needs to be improved (especially in terms of efficiency, also documentation). Unfortunately, I'm unlikely to have time for this in the near future, so I'll just post a link to a gist: https://gist.github.com/afniedermayer/57873094430e8ddb201c I mainly used it with the output of the ODE.jl. I hope this is a useful starting point... Best, Andras On Monday, February 2, 2015 at 4:38:57 PM UTC+1, Andrei Berceanu wrote: Yes, exactly, in order to generate plots like http://en.wikipedia.org/wiki/Hermite_polynomials#mediaviewer/File:Hermite_poly_phys.svg //A On Monday, February 2, 2015 at 4:36:55 PM UTC+1, Jiahao Chen wrote: Is there an easy way to compute Hn(x)? Do you mean to evaluate a given Hermite polynomial of order n at a value x?
[julia-users] Re: compute hermite polynomials
I came up with this, so far *function compute_hermite_polynomial(n)P = Poly([1])const x = Poly([0; 1]) for i = 1:nP = 2x*P - polyder(P)endPend* On Monday, February 2, 2015 at 5:24:21 PM UTC+1, Andrei Berceanu wrote: Andras, no worries :) Now I understand why I couldn't find the polynomials in your gist! //A On Monday, February 2, 2015 at 5:19:49 PM UTC+1, Andras Niedermayer wrote: Sorry, I meant Cubic Hermite Interpolation. Now I see you're looking for Hermite polynomials. On Monday, February 2, 2015 at 4:50:00 PM UTC+1, Andras Niedermayer wrote: I was looking for Hermite polynomials and haven't found any code. I have some (very unpolished) code. I haven't made a public package yet, since it needs to be improved (especially in terms of efficiency, also documentation). Unfortunately, I'm unlikely to have time for this in the near future, so I'll just post a link to a gist: https://gist.github.com/afniedermayer/57873094430e8ddb201c I mainly used it with the output of the ODE.jl. I hope this is a useful starting point... Best, Andras On Monday, February 2, 2015 at 4:38:57 PM UTC+1, Andrei Berceanu wrote: Yes, exactly, in order to generate plots like http://en.wikipedia.org/wiki/Hermite_polynomials#mediaviewer/File:Hermite_poly_phys.svg //A On Monday, February 2, 2015 at 4:36:55 PM UTC+1, Jiahao Chen wrote: Is there an easy way to compute Hn(x)? Do you mean to evaluate a given Hermite polynomial of order n at a value x?
Re: [julia-users] Re: compute hermite polynomials
That depends on weather one uses the Polynomial or Polynomials package. I use the latter (which has in fact superseded the former). The main difference is the ordering of the coefficients. On Monday, February 2, 2015 at 5:59:45 PM UTC+1, Jiahao Chen wrote: This code computes the coefficient of the leading order term, not the value of the polynomial. Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory On Mon, Feb 2, 2015 at 11:43 AM, Andrei Berceanu andreib...@gmail.com javascript: wrote: I came up with this, so far *function compute_hermite_polynomial(n)P = Poly([1])const x = Poly([0; 1]) for i = 1:nP = 2x*P - polyder(P)endPend* On Monday, February 2, 2015 at 5:24:21 PM UTC+1, Andrei Berceanu wrote: Andras, no worries :) Now I understand why I couldn't find the polynomials in your gist! //A On Monday, February 2, 2015 at 5:19:49 PM UTC+1, Andras Niedermayer wrote: Sorry, I meant Cubic Hermite Interpolation. Now I see you're looking for Hermite polynomials. On Monday, February 2, 2015 at 4:50:00 PM UTC+1, Andras Niedermayer wrote: I was looking for Hermite polynomials and haven't found any code. I have some (very unpolished) code. I haven't made a public package yet, since it needs to be improved (especially in terms of efficiency, also documentation). Unfortunately, I'm unlikely to have time for this in the near future, so I'll just post a link to a gist: https://gist.github.com/afniedermayer/57873094430e8ddb201c I mainly used it with the output of the ODE.jl. I hope this is a useful starting point... Best, Andras On Monday, February 2, 2015 at 4:38:57 PM UTC+1, Andrei Berceanu wrote: Yes, exactly, in order to generate plots like http://en.wikipedia.org/wiki/Hermite_polynomials# mediaviewer/File:Hermite_poly_phys.svg //A On Monday, February 2, 2015 at 4:36:55 PM UTC+1, Jiahao Chen wrote: Is there an easy way to compute Hn(x)? Do you mean to evaluate a given Hermite polynomial of order n at a value x?
[julia-users] eigenvalues of sparse matrix
Is there any Julia function for computing the eigenvalues of a large, sparse, hermitian matrix M? I have tried eig(M) and eigvals(M) and got the no method error. //A
Re: [julia-users] eigenvalues of sparse matrix
Besides, the help of eigs says using Lanczos or Arnoldi iterations for real symmetric or general nonsymmetric matrices respectively. Mine is hermitian, i.e. complex and symmetric. On Monday, January 26, 2015 at 4:02:16 PM UTC+1, Andrei Berceanu wrote: That seems to return a lot of things besides the eigenvalues. On Monday, January 26, 2015 at 3:43:01 PM UTC+1, Andreas Noack wrote: You can use eigs. Usually, you only ask for a few of the values, but in theory, you could get all of them, but it could take some time to compute them. 2015-01-26 9:40 GMT-05:00 Andrei Berceanu andreib...@gmail.com: Is there any Julia function for computing the eigenvalues of a large, sparse, hermitian matrix M? I have tried eig(M) and eigvals(M) and got the no method error. //A
Re: [julia-users] eigenvalues of sparse matrix
Indeed it seems to work with complex matrices as well. What would be very useful for me is the ability to get eigenvalues within a certain interval, emin to emax. I dont see this in the capabilities of eigs. //A On Monday, January 26, 2015 at 4:21:58 PM UTC+1, Andreas Noack wrote: Yes. There is some extra output including convergence information and the Ritz vectors. It should probably be explained in the manual, but the first argument is the values. You can avoid the vectors with ritzvec=false, so something like eigs(A, ritzvec = false)[1] should give you the largest (in magnitude) values. I think the documentation is simply wrong when stating that the matrix has to be real. I just tried a complex matrix and it worked just fine, so please open an issue about the documentation. 2015-01-26 10:03 GMT-05:00 Andrei Berceanu andreib...@gmail.com javascript:: Besides, the help of eigs says using Lanczos or Arnoldi iterations for real symmetric or general nonsymmetric matrices respectively. Mine is hermitian, i.e. complex and symmetric. On Monday, January 26, 2015 at 4:02:16 PM UTC+1, Andrei Berceanu wrote: That seems to return a lot of things besides the eigenvalues. On Monday, January 26, 2015 at 3:43:01 PM UTC+1, Andreas Noack wrote: You can use eigs. Usually, you only ask for a few of the values, but in theory, you could get all of them, but it could take some time to compute them. 2015-01-26 9:40 GMT-05:00 Andrei Berceanu andreib...@gmail.com: Is there any Julia function for computing the eigenvalues of a large, sparse, hermitian matrix M? I have tried eig(M) and eigvals(M) and got the no method error. //A
Re: [julia-users] eigenvalues of sparse matrix
That seems to return a lot of things besides the eigenvalues. On Monday, January 26, 2015 at 3:43:01 PM UTC+1, Andreas Noack wrote: You can use eigs. Usually, you only ask for a few of the values, but in theory, you could get all of them, but it could take some time to compute them. 2015-01-26 9:40 GMT-05:00 Andrei Berceanu andreib...@gmail.com javascript:: Is there any Julia function for computing the eigenvalues of a large, sparse, hermitian matrix M? I have tried eig(M) and eigvals(M) and got the no method error. //A
Re: [julia-users] eigenvalues of sparse matrix
The matrix is 1681x1681 with 8240 non-zero entries (i.e. 0.29% non-zero). I'm not sure how this relates to your second comment though :) On Monday, January 26, 2015 at 5:48:37 PM UTC+1, Andreas Noack wrote: How large is the matrix and what is the sparsity? You might be able to get closer to what you want by using shifts in eigs. Then you'll get the values closest to the value of the shift. 2015-01-26 11:41 GMT-05:00 Andrei Berceanu andreib...@gmail.com javascript:: Indeed it seems to work with complex matrices as well. What would be very useful for me is the ability to get eigenvalues within a certain interval, emin to emax. I dont see this in the capabilities of eigs. //A On Monday, January 26, 2015 at 4:21:58 PM UTC+1, Andreas Noack wrote: Yes. There is some extra output including convergence information and the Ritz vectors. It should probably be explained in the manual, but the first argument is the values. You can avoid the vectors with ritzvec=false, so something like eigs(A, ritzvec = false)[1] should give you the largest (in magnitude) values. I think the documentation is simply wrong when stating that the matrix has to be real. I just tried a complex matrix and it worked just fine, so please open an issue about the documentation. 2015-01-26 10:03 GMT-05:00 Andrei Berceanu andreib...@gmail.com: Besides, the help of eigs says using Lanczos or Arnoldi iterations for real symmetric or general nonsymmetric matrices respectively. Mine is hermitian, i.e. complex and symmetric. On Monday, January 26, 2015 at 4:02:16 PM UTC+1, Andrei Berceanu wrote: That seems to return a lot of things besides the eigenvalues. On Monday, January 26, 2015 at 3:43:01 PM UTC+1, Andreas Noack wrote: You can use eigs. Usually, you only ask for a few of the values, but in theory, you could get all of them, but it could take some time to compute them. 2015-01-26 9:40 GMT-05:00 Andrei Berceanu andreib...@gmail.com: Is there any Julia function for computing the eigenvalues of a large, sparse, hermitian matrix M? I have tried eig(M) and eigvals(M) and got the no method error. //A
Re: [julia-users] Re: package proposal
Well the status of this is that NLSolve people are not interested, because PHCpack can only solve polynomial systems, while they target arbitrary nonlinear functions. The remaining alternative is to make a stand-alone phc package for Julia, distributing the Ada code under GPL and including a suitable version of the gnu-ada compiler from http://libre.adacore.com. See details at https://github.com/janverschelde/PHCpack/issues/3. On 12/27/2014 01:11 AM, Evan Pu wrote: is this thread still alive? a phc package would be good... On Monday, June 23, 2014 5:26:34 AM UTC-7, Andrei Berceanu wrote: By the way I recently stumbled upon NLSolve.jl, and asked them if they would be interested in PHCpack https://github.com/EconForge/NLsolve.jl/issues/12 https://github.com/EconForge/NLsolve.jl/issues/12 Still no reply on their part yet though. On Monday, June 23, 2014 1:06:03 PM UTC+2, Andrei Berceanu wrote: Free binary versions for Mac and Windows of the gnu-ada compiler are available at http://libre.adacore.com/ and are very easy to install. As for HOMPACK, the main difference is that PHCpack is specifically targeted for polynomial systems. HOMPACK provides continuation methods for general nonlinear systems and has extra drivers for polynomial systems. Another main difference is that PHCpack offers polyhedral homotopies, which are absent from HOMPACK. So I guess it depends on what we want really, personally I am interested in polynomial systems. Please let me know if you succeed in installing the ada compiler for Mac from the above link. On Friday, June 20, 2014 11:36:01 PM UTC+2, Tony Kelman wrote: That sounds like the best plan for the PHCpack code. Have you looked at or are you familiar with whether HOMPACK as Hans mentioned would be able to provide similar functionality? I say that just because more of us are used to building Fortran code than Ada. Ada should be reasonable to work with on Linux, and maybe even in MinGW or Cygwin, but it doesn't look like it's set up in Homebrew for Mac users. If you know of a standard way to install GNAT and can get the library building on at least your platform of choice, go for it. On Friday, June 20, 2014 2:14:18 PM UTC-7, Andrei Berceanu wrote: I have contacted the author (https://github.com/janverschelde/PHCpack/issues/3 https://github.com/janverschelde/PHCpack/issues/3) and it seems redistribution under a different license is not really an option. However, if what Milan says is correct, then we should be able to include it 'as-is'. Now for the interface, I was thinking that, since there already exists a comprehensive C API to the Ada code, we could call that from Julia, what do you guys reckon? On Friday, June 6, 2014 2:18:33 PM UTC+2, Milan Bouchet-Valat wrote: Le vendredi 06 juin 2014 à 03:43 -0700, Hans W Borchers a écrit : Please notice that PHCpack is distributed under GPL license, so your first step should be to contact the author and ask for his approval to distribute it under a lesser license such as MIT. Though since it's a package rather than code to be included in Julia Base, GPL is fine too. Regards
Re: [julia-users] obscure error in Julia 0.3.3
Ok, so here is the output from versioninfo() from inside the Julia REPL: *Julia Version 0.3.3Commit b24213b (2014-11-23 20:19 UTC)Platform Info: System: Linux (x86_64-unknown-linux-gnu) CPU: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz WORD_SIZE: 64 BLAS: libblas LAPACK: liblapack LIBM: libm LLVM: libLLVM-3.3* and here is the output of `pacman -Qi julia blas lapack` *Name : juliaVersion: 2:0.3.3-1Description: High-level, high-performance, dynamic programming languageArchitecture : x86_64URL: http://julialang.org/Licenses : GPLGroups : NoneProvides : NoneDepends On : arpack fftw git gmp libunwind mpfr pcre zlib lapackOptional Deps : gnuplot: If using the Gaston Package from julia [installed]Required By: NoneOptional For : NoneConflicts With : NoneReplaces : NoneInstalled Size : 54741.00 KiBPackager : Alexander F Rødseth rods...@gmail.comBuild Date : Thu 27 Nov 2014 01:54:38 PM CETInstall Date : Thu 11 Dec 2014 05:47:45 PM CETInstall Reason : Explicitly installedInstall Script : YesValidated By : SignatureName : blasVersion: 3.5.0-1Description: Basic Linear Algebra SubprogramsArchitecture : x86_64URL: http://www.netlib.org/lapackLicenses : customGroups : NoneProvides : NoneDepends On : gcc-libsOptional Deps : NoneRequired By: lapack suitesparseOptional For : NoneConflicts With : NoneReplaces : NoneInstalled Size : 375.00 KiBPackager : Ronald van Haren ron...@archlinux.orgBuild Date : Mon 27 Jan 2014 09:46:21 PM CETInstall Date : Tue 06 May 2014 05:38:07 PM CESTInstall Reason : Installed as a dependency for another packageInstall Script : NoValidated By : SignatureName : lapackVersion: 3.5.0-1Description: Linear Algebra PACKageArchitecture : x86_64URL: http://www.netlib.org/lapackLicenses : customGroups : NoneProvides : NoneDepends On : blas=3.5.0Optional Deps : NoneRequired By: arpack julia python-numpy python2-numpy suitesparseOptional For : NoneConflicts With : NoneReplaces : NoneInstalled Size : 15612.00 KiBPackager : Ronald van Haren ron...@archlinux.orgBuild Date : Mon 27 Jan 2014 09:46:09 PM CETInstall Date : Tue 06 May 2014 05:38:07 PM CESTInstall Reason : Installed as a dependency for another packageInstall Script : NoValidated By : Signature* On Tuesday, December 16, 2014 2:16:10 AM UTC+1, Elliot Saba wrote: If you didn't compile, then ignore my second message and Joao's. Running `versioninfo()` from the julia prompt will give some information about your system configuration, and Valentin's question, (running `pacman -Qi julia blas lapack`) will be helpful to know the answer to as well. -E On Mon, Dec 15, 2014 at 10:54 AM, Valentin Churavy v.ch...@gmail.com javascript: wrote: A fellow archuser here. Under which circumstances does the error occur? Eg. what code are you executing? And what does pacman -Qi julia blas lapack output On Monday, 15 December 2014 19:14:22 UTC+1, Andrei Berceanu wrote: Where do i need to type all this? I must mention that I did not compile Julia from source, but used my distribution's (arch linux) package manager (pacman). On December 15, 2014 6:15:09 PM CET, Elliot Saba stati...@gmail.com wrote: Ah, yes. If you haven't, try a `make -C deps distclean arpack-julia distclean-openblas distclean-suitesparse`, then `make cleanall` and finally `make`. -E On Mon, Dec 15, 2014 at 9:11 AM, João Felipe Santos joao...@gmail.com wrote: You may need to clean and rebuild the dependencies as well as core Julia. On Dec 15, 2014, at 12:08 PM, Andrei Berceanu andreib...@gmail.com wrote: Hi all, I recently upgraded to Julia Version 0.3.3 on my Arch Linux box and sometimes get this strange error, followed by a kernel crash - what gives? julia: symbol lookup error: /usr/bin/../lib/julia/libcholmod.so: undefined symbol: zpotrf_ //A -- Sent from my Android device with K-9 Mail. Please excuse my brevity.
Re: [julia-users] obscure error in Julia 0.3.3
I now have a more accurate description of when the error happens. If I try to solve the following linear system *A* *1681x1681 sparse matrix with 8321 Complex{Float64} entries: [1 ,1] = -10.95+0.001im [2 ,1] = 0.415415-0.909632im [42 ,1] = 1.0+0.0im [1 ,2] = 0.415415+0.909632im [2 ,2] = -10.56+0.001im [3 ,2] = 0.415415-0.909632im [43 ,2] = 1.0+0.0im [2 ,3] = 0.415415+0.909632im [3 ,3] = -10.19+0.001im [4 ,3] = 0.415415-0.909632im ⋮ [1638, 1679] = 1.0+0.0im [1678, 1679] = 0.415415-0.909632im [1679, 1679] = -10.19+0.001im [1680, 1679] = 0.415415+0.909632im [1639, 1680] = 1.0+0.0im [1679, 1680] = 0.415415-0.909632im [1680, 1680] = -10.56+0.001im [1681, 1680] = 0.415415+0.909632im [1640, 1681] = 1.0+0.0im [1680, 1681] = 0.415415-0.909632im [1681, 1681] = -10.95+0.001im* *B* *1681-element Array{Complex{Float64},1}: 0.525444+0.850828im 0.644642+0.764485im -0.658926-0.752208im -0.653119+0.757256im -0.684803+0.728728im 0.499568-0.866275im -0.362176-0.93211im 0.87001+0.493034im -0.616929-0.787019im 0.698366-0.715741im -0.275131-0.961407im -0.984546-0.175127im -0.857186+0.515007im ⋮ -0.148487-0.988914im 0.860544-0.509376im -0.929042+0.369975im -0.812528-0.582923im -0.972683-0.232138im -0.449449+0.893306im -0.929623-0.368512im 0.950785+0.309852im -0.309421-0.950925im 0.115447+0.993314im 0.685855+0.727738im -0.215699+0.97646im * *A\B* *julia: symbol lookup error: /usr/bin/../lib/julia/libcholmod.so: undefined symbol: zpotrf_* This is the output in REPL (followed by a crash), in IJulia I simply get a popup saying the kernel died. On Tuesday, December 16, 2014 10:34:27 AM UTC+1, Andrei Berceanu wrote: Ok, so here is the output from versioninfo() from inside the Julia REPL: *Julia Version 0.3.3Commit b24213b (2014-11-23 20:19 UTC)Platform Info: System: Linux (x86_64-unknown-linux-gnu) CPU: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz WORD_SIZE: 64 BLAS: libblas LAPACK: liblapack LIBM: libm LLVM: libLLVM-3.3* and here is the output of `pacman -Qi julia blas lapack` *Name : juliaVersion: 2:0.3.3-1Description: High-level, high-performance, dynamic programming languageArchitecture : x86_64URL: http://julialang.org/ http://julialang.org/Licenses : GPLGroups : NoneProvides : NoneDepends On : arpack fftw git gmp libunwind mpfr pcre zlib lapackOptional Deps : gnuplot: If using the Gaston Package from julia [installed]Required By: NoneOptional For : NoneConflicts With : NoneReplaces : NoneInstalled Size : 54741.00 KiBPackager : Alexander F Rødseth rods...@gmail.com rods...@gmail.comBuild Date : Thu 27 Nov 2014 01:54:38 PM CETInstall Date : Thu 11 Dec 2014 05:47:45 PM CETInstall Reason : Explicitly installedInstall Script : YesValidated By : SignatureName : blasVersion: 3.5.0-1Description: Basic Linear Algebra SubprogramsArchitecture : x86_64URL: http://www.netlib.org/lapack http://www.netlib.org/lapackLicenses : customGroups : NoneProvides : NoneDepends On : gcc-libsOptional Deps : NoneRequired By: lapack suitesparseOptional For : NoneConflicts With : NoneReplaces : NoneInstalled Size : 375.00 KiBPackager : Ronald van Haren ron...@archlinux.org ron...@archlinux.orgBuild Date : Mon 27 Jan 2014 09:46:21 PM CETInstall Date : Tue 06 May 2014 05:38:07 PM CESTInstall Reason : Installed as a dependency for another packageInstall Script : NoValidated By : SignatureName : lapackVersion: 3.5.0-1Description: Linear Algebra PACKageArchitecture : x86_64URL: http://www.netlib.org/lapack http://www.netlib.org/lapackLicenses : customGroups : NoneProvides : NoneDepends On : blas=3.5.0Optional Deps : NoneRequired By: arpack julia python-numpy python2-numpy suitesparseOptional For : NoneConflicts With : NoneReplaces : NoneInstalled Size : 15612.00 KiBPackager : Ronald van Haren ron...@archlinux.org ron...@archlinux.orgBuild Date : Mon 27 Jan 2014 09:46:09 PM CETInstall Date : Tue 06 May 2014 05:38:07 PM CESTInstall Reason : Installed as a dependency for another packageInstall Script : NoValidated By : Signature* On Tuesday, December 16, 2014 2:16:10 AM UTC+1, Elliot Saba wrote: If you didn't compile, then ignore my second message and Joao's. Running `versioninfo()` from the julia prompt will give some information about your system configuration, and Valentin's question
[julia-users] obscure error in Julia 0.3.3
Hi all, I recently upgraded to Julia Version 0.3.3 on my Arch Linux box and sometimes get this strange error, followed by a kernel crash - what gives? julia: symbol lookup error: /usr/bin/../lib/julia/libcholmod.so: undefined symbol: zpotrf_ //A
Re: [julia-users] julia emacs support
Hi Tamas, thanks for your answer! So ESS has taken over all the emacs-Julia functionality then, effectively replacing the emacs mode from the Julia repository? Or is that still under development? Also, about point 1, is IJulia supported or just the REPL? Where could I find some instruction on setting that up? //A On Monday, October 13, 2014 9:06:31 AM UTC+2, Tamas Papp wrote: Hi Andrei, Check out ESS (Emacs Speaks Statistics), which already has some support for Julia. 1, 3, and 4 definitely work, for 2 I think you need to build a tags table which I have not tried yet with Julia. If you are running Linux, I would recommend that you install the ESS package from an emacs repository (eg ELPA), not from your distribution's ESS package which might be lagging the latest version. Installing ESS from git is also a good option if you are comfortable with it. Best, Tamas On Sun, Oct 12 2014, Andrei Berceanu andreib...@gmail.com javascript: wrote: I was wondering what the status of Julia support in Emacs is. I assume it can do syntax highlighting, but can it 1. connect and send code to the REPL and/or IJulia 2. jump to a specific function definition (like, for instance, Juno, the LightTable plugin) 3. autocomplete code and 4. show help for a certain function Is there any active development in any of these areas? Tnx, //A
[julia-users] Re: Interact.jl + matplotlib, refresh only part of figure
Ok, thanks a lot! :) On Saturday, October 18, 2014 9:31:02 PM UTC+2, Steven G. Johnson wrote: In order to display something in IJulia, you don't have much choice but to redraw the whole figure I think, since it needs to render a new PNG image and send it to the front-end. On the other hand, if you are displaying in a separate Matplotlib GUI window (via pygui(true)), then there are various matplotlib functions to change some but not all of the data, which might be faster. But this is more of a matplotlib question than a Julia/@manipulate question.
[julia-users] julia emacs support
I was wondering what the status of Julia support in Emacs is. I assume it can do syntax highlighting, but can it 1. connect and send code to the REPL and/or IJulia 2. jump to a specific function definition (like, for instance, Juno, the LightTable plugin) 3. autocomplete code and 4. show help for a certain function Is there any active development in any of these areas? Tnx, //A
[julia-users] multiple functions sharing common keywords
I often find myself passing long lists of parameters from one function to another. A simple, contrived example would be the following *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4)fun2(; kw1 = kw1, kw2 = kw2)endfunction fun2(; kw1 = 1, kw2 = 2)fun1(; kw1 = kw1, kw2 = kw2)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)kw1 + kw2 + kw3end*This results in code which is not easy to maintain. Notice that kw1 and kw2 are common to all 3 functions. Is there a way to pass the two of them (or more!) automatically? The way the code is written now, if I decide I want kw3 of fun1 to be changeable from fun3, I need to change the code in various places (in bold) -- very bug prone: *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4* *, kw3=3)fun2(; kw1 = kw1, kw2 = kw2* *, kw3=kw3)endfunction fun2(; kw1 = 1, kw2 = 2, kw3=3)fun1(; kw1 = kw1, kw2 = kw2, kw3=kw3)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)kw1 + kw2 + kw3end* Tnx, //A
Re: [julia-users] multiple functions sharing common keywords
Tim, what do you mean by people have moved away from it now that we have keywords? In my example I do use keywords (in fact that is the only thing I use), notice the ; at the begining of each function argument list. //A On Thursday, October 9, 2014 9:33:00 PM UTC+2, Tim Holy wrote: While people have moved away from it now that we have keywords (for some good reasons), the Options.jl package might be worth a look in this specific case. --Tim On Thursday, October 09, 2014 03:14:52 PM Stefan Karpinski wrote: Yes, this is a major problem, but I'm not sure what the fix is. It's a serious language design issue and I'm not aware of any languages that have good solutions. On Thu, Oct 9, 2014 at 3:09 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: I often find myself passing long lists of parameters from one function to another. A simple, contrived example would be the following *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4)fun2(; kw1 = kw1, kw2 = kw2)endfunction fun2(; kw1 = 1, kw2 = 2)fun1(; kw1 = kw1, kw2 = kw2)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)kw1 + kw2 + kw3end*This results in code which is not easy to maintain. Notice that kw1 and kw2 are common to all 3 functions. Is there a way to pass the two of them (or more!) automatically? The way the code is written now, if I decide I want kw3 of fun1 to be changeable from fun3, I need to change the code in various places (in bold) -- very bug prone: *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4* *, kw3=3)fun2(; kw1 = kw1, kw2 = kw2* *, kw3=kw3)endfunction fun2(; kw1 = 1, kw2 = 2, kw3=3)fun1(; kw1 = kw1, kw2 = kw2, kw3=kw3)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3) kw1 + kw2 + kw3end* Tnx, //A
Re: [julia-users] multiple functions sharing common keywords
Ah ok, I read that as if keywords were the solution to my problem, but alas, no. Are there any design plans for this? Should I open an issue? //A On Thursday, October 9, 2014 10:05:26 PM UTC+2, Stefan Karpinski wrote: The Options package was developed before keywords existed. On Thu, Oct 9, 2014 at 4:02 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Tim, what do you mean by people have moved away from it now that we have keywords? In my example I do use keywords (in fact that is the only thing I use), notice the ; at the begining of each function argument list. //A On Thursday, October 9, 2014 9:33:00 PM UTC+2, Tim Holy wrote: While people have moved away from it now that we have keywords (for some good reasons), the Options.jl package might be worth a look in this specific case. --Tim On Thursday, October 09, 2014 03:14:52 PM Stefan Karpinski wrote: Yes, this is a major problem, but I'm not sure what the fix is. It's a serious language design issue and I'm not aware of any languages that have good solutions. On Thu, Oct 9, 2014 at 3:09 PM, Andrei Berceanu andreib...@gmail.com wrote: I often find myself passing long lists of parameters from one function to another. A simple, contrived example would be the following *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4)fun2(; kw1 = kw1, kw2 = kw2)endfunction fun2(; kw1 = 1, kw2 = 2)fun1(; kw1 = kw1, kw2 = kw2)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)kw1 + kw2 + kw3end*This results in code which is not easy to maintain. Notice that kw1 and kw2 are common to all 3 functions. Is there a way to pass the two of them (or more!) automatically? The way the code is written now, if I decide I want kw3 of fun1 to be changeable from fun3, I need to change the code in various places (in bold) -- very bug prone: *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4* *, kw3=3)fun2(; kw1 = kw1, kw2 = kw2* *, kw3=kw3)endfunction fun2(; kw1 = 1, kw2 = 2, kw3=3)fun1(; kw1 = kw1, kw2 = kw2, kw3=kw3)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3) kw1 + kw2 + kw3end* Tnx, //A
Re: [julia-users] multiple functions sharing common keywords
Done. See https://github.com/JuliaLang/julia/issues/8643 On Thursday, October 9, 2014 10:11:40 PM UTC+2, Stefan Karpinski wrote: Sure. It will serve as a good place for discussion of ideas. On Thu, Oct 9, 2014 at 4:09 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Ah ok, I read that as if keywords were the solution to my problem, but alas, no. Are there any design plans for this? Should I open an issue? //A On Thursday, October 9, 2014 10:05:26 PM UTC+2, Stefan Karpinski wrote: The Options package was developed before keywords existed. On Thu, Oct 9, 2014 at 4:02 PM, Andrei Berceanu andreib...@gmail.com wrote: Tim, what do you mean by people have moved away from it now that we have keywords? In my example I do use keywords (in fact that is the only thing I use), notice the ; at the begining of each function argument list. //A On Thursday, October 9, 2014 9:33:00 PM UTC+2, Tim Holy wrote: While people have moved away from it now that we have keywords (for some good reasons), the Options.jl package might be worth a look in this specific case. --Tim On Thursday, October 09, 2014 03:14:52 PM Stefan Karpinski wrote: Yes, this is a major problem, but I'm not sure what the fix is. It's a serious language design issue and I'm not aware of any languages that have good solutions. On Thu, Oct 9, 2014 at 3:09 PM, Andrei Berceanu andreib...@gmail.com wrote: I often find myself passing long lists of parameters from one function to another. A simple, contrived example would be the following *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4)fun2(; kw1 = kw1, kw2 = kw2)endfunction fun2(; kw1 = 1, kw2 = 2)fun1(; kw1 = kw1, kw2 = kw2)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)kw1 + kw2 + kw3end*This results in code which is not easy to maintain. Notice that kw1 and kw2 are common to all 3 functions. Is there a way to pass the two of them (or more!) automatically? The way the code is written now, if I decide I want kw3 of fun1 to be changeable from fun3, I need to change the code in various places (in bold) -- very bug prone: *function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4* *, kw3=3)fun2(; kw1 = kw1, kw2 = kw2* *, kw3=kw3)endfunction fun2(; kw1 = 1, kw2 = 2, kw3=3)fun1(; kw1 = kw1, kw2 = kw2, kw3=kw3)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3) kw1 + kw2 + kw3end* Tnx, //A
[julia-users] Interact.jl + matplotlib, refresh only part of figure
I would like to have a slider controlling a vertical bar on my plot. Changing the value of the slider should only move the bar, not replot the whole figure. So far I have come up with this code *using Reactive, Interactusing PyPlotf = figure();x = linspace(0,10,1000)vertval=slider(0:1:10)replot = button(Replot) # Commit your changesmap(display, [vertval, replot]) # optionalcoeffs = sampleon(replot, lift(tuple, vertval))@manipulate for val=coeffs; withfig(f) doPyPlot.plot(x, sin(x))axvline(val[1]) endend*but, judging by the time it takes it to replot I am guessing it redraws the whole figure, not just the vertical bar. In this particular example this is not such a big problem, but in a real-world example where drawing the figure takes a long time it quickly becomes unusable. So the idea is to move the *PyPlot.plot(x, sin(x)) *out of the loop somehow, without losing the plot and ending up with just the vertical line (this is what happens atm). Any ideas? Tnx, //A
[julia-users] Re: help with generation of sparse matrix
Hi Iain, First of all thanks for your effort! I am using Julia 0.3.0 on Linux. The reason i wasn't preallocating was because I did not know the array sizes beforehand, but your suggestion of computing it works very well :) I just noticed that in my original post I put 1000 instead of 1. So, the problem is that for such a large value, Julia crashes. And if I'm not mistaken the 3 allocated arrays only occupy around 12GB (out of my 24GB RAM). //A On Tuesday, October 7, 2014 5:23:11 PM UTC+2, Iain Dunning wrote: OK, on Julia 0.3.0 on OSX, for N=1001 elapsed time: 0.722537543 seconds (960169036 bytes allocated, 11.71% gc time) elapsed time: 0.703546159 seconds (955424928 bytes allocated, 26.01% gc time) elapsed time: 0.692751989 seconds (955424928 bytes allocated, 23.39% gc time) (first run includes JIT) So I'm not sure whats going on for you? Anyway, I tried to improve the speed, again for N=1001 elapsed time: 0.256739122 seconds (321392500 bytes allocated, 23.75% gc time) elapsed time: 0.259208305 seconds (320464768 bytes allocated, 17.49% gc time) elapsed time: 0.212410743 seconds (320464768 bytes allocated, 32.42% gc time) By preallocating everything: https://gist.github.com/IainNZ/c7dd570ffedbf629a81d All the effort is in `sparse` (you can check with profiler) Thanks, Iain On Tuesday, October 7, 2014 11:01:05 AM UTC-4, Iain Dunning wrote: At a glance, why build list only to just add it to J? Why not add it directly to J, and add i to I. If I have a chance I'll look further. Which Julia? On Monday, October 6, 2014 1:51:36 PM UTC-4, Andrei Berceanu wrote: I have written the following Julia code to build a sparse matrix of dimension N^2xN^2 https://gist.github.com/berceanu/fe7e26840637517383d8 The code works (probably in a very suboptimal way) for small enough matrices, but for example if I set N=1000, genspmat(1000) quickly eats up my RAM and crashes Julia. I doubt that this is related to the storage of the sparse matrix itself, and suspect it has to do with the garbage collection inside the main loop of genspmat, but I have no idea of fixing it. Any suggestions? Thanks!
[julia-users] Autoreload usage
I created a file called MyModule.jl with the following content module MyModule export x, y x() = x y() = y p() = p end from the REPL, i can do using MyModule x() -- x Now I would like to use the Autoreload package for easy hacking on my fancy new module. So in the REPL I do using Autoreload arequire(MyModule) x() -- ERROR: x not defined What gives? //A
[julia-users] Re: Autoreload usage
I see that MyModule.x() does work, but since I exported the x function in MyModule, I expected x() to just work. Besides, writing MyModule.stuff everytime is quite cumbersome. //A On Saturday, October 4, 2014 7:55:40 PM UTC+2, Andrei Berceanu wrote: I created a file called MyModule.jl with the following content module MyModule export x, y x() = x y() = y p() = p end from the REPL, i can do using MyModule x() -- x Now I would like to use the Autoreload package for easy hacking on my fancy new module. So in the REPL I do using Autoreload arequire(MyModule) x() -- ERROR: x not defined What gives? //A
Re: [julia-users] external editor from IJulia
I changed the EDITOR environment variable in my profile, and now IJulia returns ENV[EDITOR] gvim However this does not seem to affect the @edit macro, which still tries to call Vim and complains about not being in a terminal window. //A On Wednesday, October 1, 2014 3:00:27 PM UTC+2, Isaiah wrote: try changing your EDITOR variable to something that starts own window / can run outside of terminal. On Sep 29, 2014 6:08 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Is there a way to open an external text editor (say gvim) from within IJulia? More specifically, I would like to be able to edit the definition of a function. In the REPL I can use @edit fun() and this opens the module where fun() is defined at the specific line. However in IJulia I get @edit fun() Vim: Warning: Output is not to a terminal Vim: Warning: Input is not from a terminal Thanks! //A
Re: [julia-users] external editor from IJulia
export JULIA_EDITOR=gvim did the trick, tnx :) //A On Wednesday, October 1, 2014 3:32:48 PM UTC+2, Valentin Churavy wrote: After looking at https://github.com/JuliaLang/julia/blob/1c4e8270646f7d5cab3d259f0464e6ea66e3574a/base/interactiveutil.jl#L11 it seems that you should set JULIA_EDITOR. It might be that your VISUAL variable is still set to Vim. V On Wednesday, 1 October 2014 15:24:30 UTC+2, Andrei Berceanu wrote: I changed the EDITOR environment variable in my profile, and now IJulia returns ENV[EDITOR] gvim However this does not seem to affect the @edit macro, which still tries to call Vim and complains about not being in a terminal window. //A On Wednesday, October 1, 2014 3:00:27 PM UTC+2, Isaiah wrote: try changing your EDITOR variable to something that starts own window / can run outside of terminal. On Sep 29, 2014 6:08 PM, Andrei Berceanu andreib...@gmail.com wrote: Is there a way to open an external text editor (say gvim) from within IJulia? More specifically, I would like to be able to edit the definition of a function. In the REPL I can use @edit fun() and this opens the module where fun() is defined at the specific line. However in IJulia I get @edit fun() Vim: Warning: Output is not to a terminal Vim: Warning: Input is not from a terminal Thanks! //A
[julia-users] Re: multi-panel interactive figure with PyPlot
I just submitted https://github.com/stevengj/PyPlot.jl/issues/84. //A On Monday, September 8, 2014 1:31:21 PM UTC+2, Andrei Berceanu wrote: I'm trying to create a two-panel interactive figure using Interact.jl and PyPlot.jl. Based on the example notebooks from Interact.jl, I came up with the following: using Reactive, Interact using PyPlot x = linspace(0,2π,1000); f, axes = plt.subplots(1,2, figsize=(4, 4)) @manipulate for α=1:0.1:3, β=1:0.1:3, γ=1:0.1:3; withfig(f) do y = cos(α*x + sin(β*x + γ)) axes[1][:plot](x, y) axes[2][:plot](x, 1/y) end end which gives me: PyError (PyObject_Call) class 'ValueError' ValueError('Axes instance argument was not found in a figure.',) Anyone knows how to fix this? Tnx!
Re: [julia-users] Interact + PyPlot: only update when releasing slider
Thank you both for the suggestions! I am currently trying the Replot button approach, but ran into some errors, as follows: using Reactive, Interact using PyPlot fun(α, β, γ) = cos(α + sin(β+γ)) #example function f = figure(); α=slider(1:0.1:3) β=slider(1:0.1:3) γ=slider(1:0.1:3) replot = button(Replot) # Commit your changes map(display, α, β, γ, replot) # optional -- `start` has no method matching start(::Slider{Float64}) sampled_coeffs = sampleon(redo, lift(tuple, α, β, γ)) -- redo not defined withfig(f) @lift plot(apply(fun, sampled_coeffs)) -- `withfig` has no method matching withfig(::Figure) On Monday, September 8, 2014 6:10:59 PM UTC+2, Shashi Gowda wrote: John's suggestion is also a good way to do this. You can sample the signals at a specific interval instead of on button clicks: # At 2 fps, with repeats dropped. sampled_coeffs = droprepeats(sampleon(fps(2), lift(tuple, α, β, γ))) On Mon, Sep 8, 2014 at 9:36 PM, Shashi Gowda shashi...@gmail.com javascript: wrote: Unfortunately, the @manipulate macro can only rerun the expression at every update of any of its input. What you need here is Reactive http://julialang.org/Reactive.jl/api.html#sample-and-merge's `sampleon` function: using Reactive, Interact f = figure(); α=slider(1:0.1:3) β=slider(1:0.1:3) γ=slider(1:0.1:3) replot = button(Replot) # Commit your changes map(display, α, β, γ, replot) # optional sampled_coeffs = sampleon(redo, lift(tuple, α, β, γ)) withfig(f) @lift plot(apply(fun, sampled_coeffs)) IPython doesn't do update on release, Interact, in fact, uses the same widgets. What it does do is have at most 4 updates at any given time in the processing pipeline (any more updates replace the last update in the queue). On Mon, Sep 8, 2014 at 8:45 PM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Another option would be to use drop-down boxes with selectable values or custom text boxes instead of sliders, at least as a temporary fix. Anyone knows how I can do that? By the way, iirc, IPython does have the update-on-release mechanism implemented in their interactive widget functionality. On Monday, September 8, 2014 4:10:05 PM UTC+2, John Myles White wrote: I suspect the only way to do this is to change Interact so that it exposes a minimum time threshold before it registers a state change. — John On Sep 8, 2014, at 4:16 AM, Andrei Berceanu andreib...@gmail.com wrote: I have some code along the lines of f = figure() @manipulate for α=1:0.1:3, β=1:0.1:3, γ=1:0.1:3; withfig(f) do y = fun(α,β,γ) PyPlot.plot(x, y) end end where fun is a *very slow* function to evaluate. Is there any way to tell @manipulate to update the resulting plot only after I release the sliders? Otherwise what I get is, I release them to the desised values and then have to wait ages for all the intermediate plots to be drawn. Tnx!
[julia-users] Interact + PyPlot: only update when releasing slider
I have some code along the lines of f = figure() @manipulate for α=1:0.1:3, β=1:0.1:3, γ=1:0.1:3; withfig(f) do y = fun(α,β,γ) PyPlot.plot(x, y) end end where fun is a *very slow* function to evaluate. Is there any way to tell @manipulate to update the resulting plot only after I release the sliders? Otherwise what I get is, I release them to the desised values and then have to wait ages for all the intermediate plots to be drawn. Tnx!
[julia-users] multi-panel interactive figure with PyPlot
I'm trying to create a two-panel interactive figure using Interact.jl and PyPlot.jl. Based on the example notebooks from Interact.jl, I came up with the following: using Reactive, Interact using PyPlot x = linspace(0,2π,1000); f, axes = plt.subplots(1,2, figsize=(4, 4)) @manipulate for α=1:0.1:3, β=1:0.1:3, γ=1:0.1:3; withfig(f) do y = cos(α*x + sin(β*x + γ)) axes[1][:plot](x, y) axes[2][:plot](x, 1/y) end end which gives me: PyError (PyObject_Call) class 'ValueError' ValueError('Axes instance argument was not found in a figure.',) Anyone knows how to fix this? Tnx!
Re: [julia-users] Interact + PyPlot: only update when releasing slider
Another option would be to use drop-down boxes with selectable values or custom text boxes instead of sliders, at least as a temporary fix. Anyone knows how I can do that? By the way, iirc, IPython does have the update-on-release mechanism implemented in their interactive widget functionality. On Monday, September 8, 2014 4:10:05 PM UTC+2, John Myles White wrote: I suspect the only way to do this is to change Interact so that it exposes a minimum time threshold before it registers a state change. — John On Sep 8, 2014, at 4:16 AM, Andrei Berceanu andreib...@gmail.com javascript: wrote: I have some code along the lines of f = figure() @manipulate for α=1:0.1:3, β=1:0.1:3, γ=1:0.1:3; withfig(f) do y = fun(α,β,γ) PyPlot.plot(x, y) end end where fun is a *very slow* function to evaluate. Is there any way to tell @manipulate to update the resulting plot only after I release the sliders? Otherwise what I get is, I release them to the desised values and then have to wait ages for all the intermediate plots to be drawn. Tnx!
[julia-users] Re: Kronecker Delta functions and block matrices
This is what I came up with for the full matrix calculation: https://github.com/berceanu/notebooks/blob/master/julia/macros.ipynb I now have a macro for the elements of M, another for the elements of Q and yet another for the elements of L. In the end I define the genmatL function which loops over the dimensions of L and calculates all the matrix elements. Does this look sound to you? A few things that are still unclear: 1. Can this approach be optimized further? I can't help the feeling that it contains a fair amount of redundancy, especially looking at the quote $var end kind of expressions. I can replace the macros with functions as you suggest, but then it's not clear to me when to use a function and when a macro. 2. I would like to see the functional form of the full matrix L (not just element by element, but the whole matrix of expressions), in terms of the functions \epsilon, \gamma and X. I tried with macroexpand acting on genmatL, but that doesn't seem to work. This is basically just to convince myself that the approach indeed works as intended. Thanks again! On Friday, August 29, 2014 10:14:10 PM UTC+2, Steven G. Johnson wrote: I think you want quote @M($i,$j, $ε1, ) end in order for your L macro to return an expression (that in turn calls the M macro). Macros are not functions. When you call @M(i,j,...), it doesn't pass the *value* of the arguments i,j, etcetera, it passes the symbolic expressions :i, :j, and so on. Of course, if you are only calling M from inside another macro, it is perfectly valid to just change M from a macro to an ordinary function (returning an expression) ... just change macro to function in the definition of M, and call it without the @ inside L.
[julia-users] Re: Kronecker Delta functions and block matrices
On a more general note, I am thinking that with a bit of cleanup, this code could make a good Julia metaprogramming example, especially since I haven't seen many of those around :) //A On Saturday, August 30, 2014 10:52:49 AM UTC+2, Andrei Berceanu wrote: This is what I came up with for the full matrix calculation: https://github.com/berceanu/notebooks/blob/master/julia/macros.ipynb I now have a macro for the elements of M, another for the elements of Q and yet another for the elements of L. In the end I define the genmatL function which loops over the dimensions of L and calculates all the matrix elements. Does this look sound to you? A few things that are still unclear: 1. Can this approach be optimized further? I can't help the feeling that it contains a fair amount of redundancy, especially looking at the quote $var end kind of expressions. I can replace the macros with functions as you suggest, but then it's not clear to me when to use a function and when a macro. 2. I would like to see the functional form of the full matrix L (not just element by element, but the whole matrix of expressions), in terms of the functions \epsilon, \gamma and X. I tried with macroexpand acting on genmatL, but that doesn't seem to work. This is basically just to convince myself that the approach indeed works as intended. Thanks again! On Friday, August 29, 2014 10:14:10 PM UTC+2, Steven G. Johnson wrote: I think you want quote @M($i,$j, $ε1, ) end in order for your L macro to return an expression (that in turn calls the M macro). Macros are not functions. When you call @M(i,j,...), it doesn't pass the *value* of the arguments i,j, etcetera, it passes the symbolic expressions :i, :j, and so on. Of course, if you are only calling M from inside another macro, it is perfectly valid to just change M from a macro to an ordinary function (returning an expression) ... just change macro to function in the definition of M, and call it without the @ inside L.
[julia-users] Re: Kronecker Delta functions and block matrices
Thanks a lot for the detailed answer. I changed a bit your macro, introducing conj() instead of ' and splicing the Kronecker sum to get a functional version: macro M(m,n, ε1,ε2,ε3, X1,X2,X3, A1,A2,A3) ε = [ε1,ε2,ε3] X = [X1,X2,X3] A = [A1,A2,A3] Asum = {:+} for q=1:3, t=1:3 if m+q == n+t push!(Asum, :(conj($(A[q])) * $(A[t]))) end end if m == n :($(ε[m]) + 2*abs2($(X[m])) * $(Expr(:call, Asum...))) else :(2 * conj($(X[m])) * $(X[n]) * $(Expr(:call, Asum...))) end end I also defined a macro for the elements of Q: macro Q(m,n, X1,X2,X3, A1,A2,A3) X = [X1,X2,X3] A = [A1,A2,A3] Asum = {:+} for q=1:3, t=1:3 if m+n == q+t push!(Asum, :($(A[q]) * $(A[t]))) end end :(conj($(X[m])) * conj($(X[n])) * $(Expr(:call, Asum...))) end and now I'm a bit stuck on putting it all together to get the full L matrix. Im trying to calculated L(i,j) based on M and Q for the 4 separate blocks. I only implemented the upper left block but I get an error macro L(i,j, ε1,ε2,ε3, X1,X2,X3, A1,A2,A3) if i4 if j4 @M(i,j, ε1,ε2,ε3, X1,X2,X3, A1,A2,A3) end end end `+` has no method matching +(::Symbol, ::Int64) It seems that the @M macro needs a value for the m,n indices for the comparison if m+q == n+t Any ideas how to solve this? The end-result I want is a function L(k, A1, A2, A3, etc) which would return the full 6x6 matrix. //A On Thursday, August 28, 2014 10:42:29 PM UTC+2, Steven G. Johnson wrote: On Thursday, August 28, 2014 6:36:16 AM UTC-4, Andrei Berceanu wrote: Steven, could you detail your macro proposal please? What exactly do you have in mind? e.g. you could have a macro like (caution: untested): macro M(m,n, ε1, ε2, ε3, X1,X2,X3, A1,A2,A3) ε = [ε1, ε2, ε3] X = [X1,X2,X3] A = [A1,A2,A3] Asum = {:+} for q=1:3, t=1:3 if m+q == n+t push!(Asum, :($(A[q])' * $(A[t]))) end end if m == n :($(ε[m]) + 2*abs2($(X[m])) * $(Expr(:call, Asum))) else :(2 * $(X[m])' $(X[n]) * $(Expr(:call, Asum))) end end Then calling e.g. @M(1,2,ε1, ε2, ε3, X1,X2,X3, A1,A2,A3) would insert a hard-coded expression for M[1,2] according to your formula, with only the nonzero delta terms. Here εm denotes the m'th case of your expression [ε(k_m+k) ] in brackets, Xm denotes X(k_m+k), and Am denotes Ã_m. Macros are essentially functions evaluated at parse-time, not at runtime, so they are exactly what you want in order to auto-generate fast inlined code resulting from some complicated symbolic expression that is known in advance, with whatever simplifications you can devise. You could write another macro for the entries of Q, and another macro to put it all together and evaluate the whole matrix if you want.
[julia-users] Kronecker Delta functions and block matrices
Hi guys, I am trying to programatically generate a Julia function that calculates a 6x6 matrix. I have written a short LaTeX description of the problem at: http://nbviewer.ipython.org/github/berceanu/notebooks/blob/master/OPODrag/block_matrix.ipynb The basic idea is, I have an analytical expression for the matrix elements of the 3x3 matrices M and Q, M_{m,n} representing the element on row m, column n. The problem is that these depend on sums over Kronecker symbols, which need to be contracted. Once I build the M and Q matrices, I need to join them in the block-form given in the above notebook. A working strategy that I have so far is to generate the matrix L in Mathematica, and copy-paste the resulting (huge) expression to Julia. I would now like to bypass Mathematica completely, and thought of using Sympy. While it has the capability of contracting the sums over the delta symbols, it is not clear to me how to then export the resulting function to Julia. If this can be done without Sympy, i.e. in pure Julia, that would be awesome! On a last note, performance of the resulting function is important, because I will need to digonalize a lot of these 6x6 matrices, calculated for different parameter values (eg. varying k_p, k_s, omega_p, etc).
[julia-users] Re: Kronecker Delta functions and block matrices
Steven, could you detail your macro proposal please? What exactly do you have in mind? On Thursday, August 28, 2014 12:18:54 PM UTC+2, Tomas Lycken wrote: Maybe https://github.com/Jutho/TensorOperations.jl can be helpful here? I've never used it myself, but just by the name and the description (Julia package for tensor contractions and related operations) it sounds like exactly what you're looking for... // T On Thursday, August 28, 2014 12:11:43 PM UTC+2, Steven G. Johnson wrote: It should be straightforward to write a macro that simplifies the Kronecker sums to give you an efficient Julia expression.
[julia-users] array doubling
Whats the easiest way of going from an array [1,2,3] - [1,1,2,2,3,3] i.e. repeating all elements 2 (or more generally, n) times? A
Re: [julia-users] array doubling
nice, ty! btw, the manual at http://julia.readthedocs.org/en/latest/stdlib/linalg/#Base.repeat says repeat(*A*, *inner = Int*, []*outer = Int*[]) shouldn't that be repeat(*A*, *inner = Int*[], *outer = Int*[]) i.e isn't the comma in the wrong position? On Tuesday, July 29, 2014 4:06:22 PM UTC+2, John Myles White wrote: repeat([1, 2, 3], inner = [2]) On Jul 29, 2014, at 7:03 AM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Whats the easiest way of going from an array [1,2,3] - [1,1,2,2,3,3] i.e. repeating all elements 2 (or more generally, n) times? A
Re: [julia-users] array doubling
That explains why the github page showed the right syntax! *head bump A On Tuesday, July 29, 2014 5:10:42 PM UTC+2, Matt Bauman wrote: That's because Sphinx identifies [] as optional arguments in the ..function macro-thingy, and it does funny re-arrangements with it. The source is correct; it's the output that is wrong. It's annoying, but I've not dug into Sphinx enough to determine how we might disable it. On Tuesday, July 29, 2014 10:24:01 AM UTC-4, John Myles White wrote: Yeah, that’s a typo. Could you fix it? — John On Jul 29, 2014, at 7:23 AM, Andrei Berceanu andreib...@gmail.com wrote: nice, ty! btw, the manual at http://julia.readthedocs.org/en/latest/stdlib/linalg/#Base.repeat says repeat(*A*, *inner = Int*, []*outer = Int*[]) shouldn't that be repeat(*A*, *inner = Int*[], *outer = Int*[]) i.e isn't the comma in the wrong position? On Tuesday, July 29, 2014 4:06:22 PM UTC+2, John Myles White wrote: repeat([1, 2, 3], inner = [2]) On Jul 29, 2014, at 7:03 AM, Andrei Berceanu andreib...@gmail.com wrote: Whats the easiest way of going from an array [1,2,3] - [1,1,2,2,3,3] i.e. repeating all elements 2 (or more generally, n) times? A
[julia-users] numpy equivalent functionality
Hi guys, I have 2 short numpy-related questions. In numpy, if one can invert an arbitrary array *arr* along a given axis using the syntax *arr[::-1,...]* What is the equivalent idiom in Julia? The other issue is, how can I truncate an array between a lower and upper bound? In numpy, this is easily done with np.clip: http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html Tnx! A
Re: [julia-users] numpy equivalent functionality
Thanks guys, works like a charm! A On Wednesday, July 23, 2014 4:32:56 PM UTC+2, Tim Holy wrote: A[end:-1:1, ...] On Wednesday, July 23, 2014 07:07:20 AM Andrei Berceanu wrote: Hi guys, I have 2 short numpy-related questions. In numpy, if one can invert an arbitrary array *arr* along a given axis using the syntax *arr[::-1,...]* What is the equivalent idiom in Julia? The other issue is, how can I truncate an array between a lower and upper bound? In numpy, this is easily done with np.clip: http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html Tnx! A
[julia-users] what is the recommended way of including images in an IJulia notebook?
Hi guys, I would like to include a couple of .png images in a notebook with IJulia - what is the simplest way of doing that? On one hand there is the ImageView package, but that seems to be geared towards the terminal? Perhaps I can include them directly in a markdown cell? ty, A
[julia-users] reading data file using fortran's D scientific notation
Hi all, I have a lot of datafiles containing numbers in Fortran's double precision notation (http://math.hawaii.edu/wordpress/fortran-3/#double), i.e. 1.23D-3, instead of the usual E scientific notation. Is there a simple way to import the data as Float64? Tnx! Andrei
[julia-users] Re: finding all roots of complex function
Say I would like to do the integral using quadgk. There are 2 caveats, however. Quoting from the Julia manual These quadrature rules work best for smooth functions within each interval, so if your function has a known discontinuity or other singularity, it is best to subdivide your interval to put the singularity at an endpoint. My function does have singularities (i.e. poles) inside of the integration contour, and it is not clear to me how I should split the interval. Am I missinterpreting this? The other issue is that quadgk seems to only accept function of one variable, wheres mine are 2-variable functions. On Thursday, July 17, 2014 7:53:38 PM UTC+2, Steven G. Johnson wrote: On Thursday, July 17, 2014 9:19:04 AM UTC-4, Andrei Berceanu wrote: I should perhaps mention that this is part of a bigger scheme, to first find all the poles of G(x,y)/F(x,y) and then use the residue theorem for solving a complex integral of the type integral( G(x,y)/F(x,y), (x,y)) Unless F(x,y) is very special (e.g. a polynomial), I suspect that it would be much faster to just do the integral. Since you have analytic functions, 1d/contour integration is very efficient (with an appropriate algorithm, e.g. the built-in quadgk function) unless you have poles lying very close to your integration contour (and even then it is not too bad with an adaptive scheme like quadgk.) In contrast, finding *all* the zeros of an arbitrary analytic function is hard, usually harder than integrating it unless you have a good idea of where the zeros are. In general, it's not practical to guarantee that you have found all the zeros unless you can restrict your search to some finite portion of the complex plane. For finding the roots of analytic functions inside a given contour, some of the best algorithms actually involve doing a sequence of integrals ( http://www.chebfun.org/examples/roots/ComplexRoots.html) that are just as hard as your original integral above. So, you might as well just do the integral to begin with.
[julia-users] Re: reading data file using fortran's D scientific notation
I would prefer to keep my original files intact. In Python I can do *import stringimport numpy as nprule = string.maketrans('D', 'E')data = np.loadtxt(fname, usecols=(2,3),\ converters = {2: lambda val: float(val.translate(rule)),\3: lambda val: float(val.translate(rule))})* By the way, is there a Julia equivalent to numpy's *loadtxt*? Because the files are in 3-column format with multiple spaces separating the 3 entries on each line and eol chars to separate the lines. On Friday, July 18, 2014 12:33:23 PM UTC+2, Ivar Nesje wrote: If you have a reasonable editor, you should be able to open all your files and issue a global search and replace operation that changes D to E. If you have many files you can use sed to automate the process. kl. 11:41:12 UTC+2 fredag 18. juli 2014 skrev Andrei Berceanu følgende: Hi all, I have a lot of datafiles containing numbers in Fortran's double precision notation (http://math.hawaii.edu/wordpress/fortran-3/#double), i.e. 1.23D-3, instead of the usual E scientific notation. Is there a simple way to import the data as Float64? Tnx! Andrei
[julia-users] Re: reading data file using fortran's D scientific notation
First, thank you both for your time. Space is an issue, yes, but I agree, I can process them one by one using some sed scripting. I just thought there is a simple idiom corresponding to Python's 2-liner above. In fact, I am wondering, how difficult would it be to make julia accept the Fortran double precision format natively - is that a big change in Base? On a separate issue, is there an equivalent to numpy's *loadtxt*? ps: Tomas, how do you get the nice code-boxes? On Friday, July 18, 2014 1:01:55 PM UTC+2, Tomas Lycken wrote: Although you could, probably, do this in pure Julia, is there a reason to not write a small preprocessing script using sed (or your OS’s equivalent) to create altered *copies* of the data before reading it? If HDD space is an issue, you could do this one file at a time using Julia’s run method, i.e. something like dfile = your-data-file.dat run(`copy_and_replace.sh $dfile`) data = readdlm($dfile.copy) run(`rm $dfile.copy`) where the shell script copy_and_replace.sh copies the raw data (with file name given in the first argument) into a new file with the string “.copy” appended to the name, and then replaces all occurences of D with E (or e, or whatever you need) using sed. // T On Friday, July 18, 2014 12:51:32 PM UTC+2, Andrei Berceanu wrote: I would prefer to keep my original files intact. In Python I can do *import stringimport numpy as nprule = string.maketrans('D', 'E')data = np.loadtxt(fname, usecols=(2,3),\ converters = {2: lambda val: float(val.translate(rule)),\3: lambda val: float(val.translate(rule))})* By the way, is there a Julia equivalent to numpy's *loadtxt*? Because the files are in 3-column format with multiple spaces separating the 3 entries on each line and eol chars to separate the lines. On Friday, July 18, 2014 12:33:23 PM UTC+2, Ivar Nesje wrote: If you have a reasonable editor, you should be able to open all your files and issue a global search and replace operation that changes D to E. If you have many files you can use sed to automate the process. kl. 11:41:12 UTC+2 fredag 18. juli 2014 skrev Andrei Berceanu følgende: Hi all, I have a lot of datafiles containing numbers in Fortran's double precision notation (http://math.hawaii.edu/wordpress/fortran-3/#double), i.e. 1.23D-3, instead of the usual E scientific notation. Is there a simple way to import the data as Float64? Tnx! Andrei
Re: [julia-users] Re: reading data file using fortran's D scientific notation
Here is 1 line from one of my files, after sed-magic: -70.0 -70.0 3.098203380460164E-010 -69.453125000 -70.0 2.548160684589544E-010 -68.90625 -70.0 2.234061987906998E-010 There are 2 spaces at the start of each line and then the column are separated by spaces as well. I tried readdlm(pumppath, ' ', Float64, '\n') and get file entry cannot be converted to Float64 On Friday, July 18, 2014 1:57:00 PM UTC+2, Mauro wrote: Space is an issue, yes, but I agree, I can process them one by one using some sed scripting. I just thought there is a simple idiom corresponding to Python's 2-liner above. In fact, I am wondering, how difficult would it be to make julia accept the Fortran double precision format natively - is that a big change in Base? I had a look: base/datafmt.jl does the file reading but it is quite cryptic and I didn't quite figure out where the conversion from string to float occurs. But probably it's done with the float64 function in base/string.jl which calls into C: src/builtins.c function jl_strtod. So, if my digging is right then it's not so easy to change and would change how strings are parsed into floats everywhere. Thus probably easiest to write a function which does the parsing. On a separate issue, is there an equivalent to numpy's *loadtxt*? readdlm or readcsv do this. How did you do it?
Re: [julia-users] Re: reading data file using fortran's D scientific notation
Here are a few lines from one of my files, after sed preprocessing: -70.0 -70.0 3.098203380460164E-010 -69.453125000 -70.0 2.548160684589544E-010 -68.90625 -70.0 2.234061987906998E-010 There are 2 spaces at the start of each line and then the column are separated by spaces as well. I tried readdlm(pumppath, ' ', Float64, '\n') and get file entry cannot be converted to Float64 On Friday, July 18, 2014 1:57:00 PM UTC+2, Mauro wrote: Space is an issue, yes, but I agree, I can process them one by one using some sed scripting. I just thought there is a simple idiom corresponding to Python's 2-liner above. In fact, I am wondering, how difficult would it be to make julia accept the Fortran double precision format natively - is that a big change in Base? I had a look: base/datafmt.jl does the file reading but it is quite cryptic and I didn't quite figure out where the conversion from string to float occurs. But probably it's done with the float64 function in base/string.jl which calls into C: src/builtins.c function jl_strtod. So, if my digging is right then it's not so easy to change and would change how strings are parsed into floats everywhere. Thus probably easiest to write a function which does the parsing. On a separate issue, is there an equivalent to numpy's *loadtxt*? readdlm or readcsv do this. How did you do it?
Re: [julia-users] Re: reading data file using fortran's D scientific notation
Seems like my files also contained blank lines periodically. I added blank line removal to the sed script and now it all works. Thanks a lot! On Friday, July 18, 2014 2:35:18 PM UTC+2, Mauro wrote: on julia0.3 this works: julia readdlm(fl) 3x3 Array{Float64,2}: -70.0 -70.0 3.0982e-10 -69.4531 -70.0 2.54816e-10 -68.9063 -70.0 2.23406e-10 julia readdlm(fl, Float64) 3x3 Array{Float64,2}: -70.0 -70.0 3.0982e-10 -69.4531 -70.0 2.54816e-10 -68.9063 -70.0 2.23406e-10 On Fri, 2014-07-18 at 13:15, Andrei Berceanu andreib...@gmail.com javascript: wrote: Here is 1 line from one of my files, after sed-magic: -70.0 -70.0 3.098203380460164E-010 -69.453125000 -70.0 2.548160684589544E-010 -68.90625 -70.0 2.234061987906998E-010 There are 2 spaces at the start of each line and then the column are separated by spaces as well. I tried readdlm(pumppath, ' ', Float64, '\n') and get file entry cannot be converted to Float64 On Friday, July 18, 2014 1:57:00 PM UTC+2, Mauro wrote: Space is an issue, yes, but I agree, I can process them one by one using some sed scripting. I just thought there is a simple idiom corresponding to Python's 2-liner above. In fact, I am wondering, how difficult would it be to make julia accept the Fortran double precision format natively - is that a big change in Base? I had a look: base/datafmt.jl does the file reading but it is quite cryptic and I didn't quite figure out where the conversion from string to float occurs. But probably it's done with the float64 function in base/string.jl which calls into C: src/builtins.c function jl_strtod. So, if my digging is right then it's not so easy to change and would change how strings are parsed into floats everywhere. Thus probably easiest to write a function which does the parsing. On a separate issue, is there an equivalent to numpy's *loadtxt*? readdlm or readcsv do this. How did you do it? --
[julia-users] finding all roots of complex function
Hi guys, I would like to know if Julia (itself or though some existing package) can be used to find all the roots of a *complex*, 2 variable function F(x,y). Here x and y are real, so F:R - C. Thanks, Andrei
[julia-users] Re: finding all roots of complex function
I should perhaps mention that this is part of a bigger scheme, to first find all the poles of G(x,y)/F(x,y) and then use the residue theorem for solving a complex integral of the type integral( G(x,y)/F(x,y), (x,y)) On Thursday, July 17, 2014 3:15:45 PM UTC+2, Andrei Berceanu wrote: Hi guys, I would like to know if Julia (itself or though some existing package) can be used to find all the roots of a *complex*, 2 variable function F(x,y). Here x and y are real, so F:R - C. Thanks, Andrei
[julia-users] metaprogramming example
Just wondering, can metaprogramming be used to shorten code such as this one: *for i = 1:2axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange)axes[1][:scatter](kx, real([OnePump.λ2(0., momx, np) for momx in kx]), s=15, alpha=0.2) axes[2][:scatter](kx, imag([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange)axes[2][:scatter](kx, imag([OnePump.λ2(0., momx, np) for momx in kx]), s=15, alpha=0.2)end*
Re: [julia-users] metaprogramming example
Jacob, tnx for the quick reply and sorry about the redundant for loop. This is how I decided to do it: macro scatter(axno, reim, λno, col) :(*axes[$axno][:scatter](sbox.kx, $reim([OnePump.λ$λno(0., momx, np) for momx in sbox.kx]), s=15, alpha=0.2, color=$col) )* end fig, axes = plt.subplots(2,1, figsize=(8,6)) @scatter(1, real, 1, orange) @scatter(1, real, 2, blue) @scatter(2, imag, 1, orange) @scatter(2, imag, 2, blue) but i get `missing separator in tuple` when I define the macro. Any clues why that might be? On Monday, July 7, 2014 3:40:58 PM UTC+2, Jacob Quinn wrote: I'm not sure I quite understand your example (your `i` variable is never used?), but macros just take zero or more expression/symbol arguments and return expressions, so you could easily do. macro orangeaxes() :(*axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange) )* end macro axes() :(*axes[1][:scatter](kx, real([OnePump.λ2(0., momx, np) for momx in kx]), s=15, alpha=0.2) )* end for i = 1:2 @orangeaxes @axes @orangeaxes @axes end Note the use of the `quoteend` shorthand `:(...)` in the macro definitions so that an expression is returned. -Jacob On Mon, Jul 7, 2014 at 6:04 AM, Andrei Berceanu andreib...@gmail.com javascript: wrote: axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange)
Re: [julia-users] metaprogramming example
The asterisks were an artefact of the copy-pasting it seems :) Anyway, you're right about the symbol construction, it failed. So I tried macro scatter(axno, reim, λno, col) :(axes[$axno][:scatter](sbox.kx, $reim([symbol(OnePump.λ * string($λno))(0., momx, np) for momx in sbox.kx]), s=15, alpha=0.2, color=$col)) end but this also fails with type: anonymous: in apply, expected Function, got Symbol On Monday, July 7, 2014 5:14:50 PM UTC+2, Jacob Quinn wrote: Why do you have the asterisks (`*`) in your macro definition? I'm pretty sure the OnePump.λ$λno interpolation isn't going to work. I don't think you can't interpolate into a symbol like that. You may have to try renaming those variables more generically, or do some manual symbol construction; i.e. symbol(OnePump.λ * string($λno)) On Mon, Jul 7, 2014 at 11:05 AM, Andrei Berceanu andreib...@gmail.com javascript: wrote: Jacob, tnx for the quick reply and sorry about the redundant for loop. This is how I decided to do it: macro scatter(axno, reim, λno, col) :(*axes[$axno][:scatter](sbox.kx, $reim([OnePump.λ$λno(0., momx, np) for momx in sbox.kx]), s=15, alpha=0.2, color=$col) )* end fig, axes = plt.subplots(2,1, figsize=(8,6)) @scatter(1, real, 1, orange) @scatter(1, real, 2, blue) @scatter(2, imag, 1, orange) @scatter(2, imag, 2, blue) but i get `missing separator in tuple` when I define the macro. Any clues why that might be? On Monday, July 7, 2014 3:40:58 PM UTC+2, Jacob Quinn wrote: I'm not sure I quite understand your example (your `i` variable is never used?), but macros just take zero or more expression/symbol arguments and return expressions, so you could easily do. macro orangeaxes() :(*axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange) )* end macro axes() :(*axes[1][:scatter](kx, real([OnePump.λ2(0., momx, np) for momx in kx]), s=15, alpha=0.2) )* end for i = 1:2 @orangeaxes @axes @orangeaxes @axes end Note the use of the `quoteend` shorthand `:(...)` in the macro definitions so that an expression is returned. -Jacob On Mon, Jul 7, 2014 at 6:04 AM, Andrei Berceanu andreib...@gmail.com wrote: axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange)
Re: [julia-users] metaprogramming example
Yup, that will do just fine it seems, ty! On Monday, July 7, 2014 5:27:24 PM UTC+2, Mauro wrote: Couldn't you just use a function? (If possible use functions and not macros.) function scatter(axes, axno, reim::Function, λno::Symbol, col) axes[axno][:scatter](sbox.kx, reim([OnePump.(λno)(0., momx, np) for momx in sbox.kx]), s=15, alpha=0.2, color=col) end On Mon, 2014-07-07 at 16:05, andreib...@gmail.com javascript: wrote: Jacob, tnx for the quick reply and sorry about the redundant for loop. This is how I decided to do it: macro scatter(axno, reim, λno, col) :(*axes[$axno][:scatter](sbox.kx, $reim([OnePump.λ$λno(0., momx, np) for momx in sbox.kx]), s=15, alpha=0.2, color=$col) )* end fig, axes = plt.subplots(2,1, figsize=(8,6)) @scatter(1, real, 1, orange) @scatter(1, real, 2, blue) @scatter(2, imag, 1, orange) @scatter(2, imag, 2, blue) but i get `missing separator in tuple` when I define the macro. Any clues why that might be? On Monday, July 7, 2014 3:40:58 PM UTC+2, Jacob Quinn wrote: I'm not sure I quite understand your example (your `i` variable is never used?), but macros just take zero or more expression/symbol arguments and return expressions, so you could easily do. macro orangeaxes() :(*axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange) )* end macro axes() :(*axes[1][:scatter](kx, real([OnePump.λ2(0., momx, np) for momx in kx]), s=15, alpha=0.2) )* end for i = 1:2 @orangeaxes @axes @orangeaxes @axes end Note the use of the `quoteend` shorthand `:(...)` in the macro definitions so that an expression is returned. -Jacob On Mon, Jul 7, 2014 at 6:04 AM, Andrei Berceanu andreib...@gmail.com javascript: wrote: axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), s=15, alpha=0.4, color=orange) --
[julia-users] Re: ANN: Contour.jl
So what would be the easiest way of plotting the contours obtained with contour(x, y, Z, h) using PyPlot?