[julia-users] How to find if a variable is empty or not?
How do I test if a variable has something or if it's empty? What I need is something that behaves like the Matalb's isempty() Julia isempty() is no good because it only tests collections. e.g julia type foo a end julia t=foo(1) foo(1) julia isempty(t) ERROR: `start` has no method matching start(::foo) isnan() is no good either for a similar reason julia isnan(t) ERROR: `isnan` has no method matching isnan(::foo) It's a petty that these two don't behave like in Matlab
[julia-users] disable @inbounds in tests?
Is there a way to disable @inbounds in tests? I made a change that's causing a segfault, and can't figure out where the error is.
[julia-users] Re: Considering posting SDE solver package
Alex, Thanks for pointing out SDE.jl. If I continue, a name like StochasticDifferentialEquations.jl or Stochastic.jl would do. I should have found that earlier. The author clearly knows much more about the material than I do and has spent a lot of time developing the package. SDE.jl also seems to have a fairly broad set of functionality more tailored to the scientific community. However, it looks largely abandoned at the moment. The documentation looks pretty good, and it provides a simiilar implementation of Euler Maruyama. Avik, This really just comes down to a matter of preference. I personally prefer a more self-contained solution such as used with most ODE solvers, but that may be just a matter of naivete. Mostly, it just seems thin to me. I had considered wrapping Ito at the time, but it didn't seem that I would gain much by doing so. In retrospect, I did not understand Julia as well at the time, and the usage of StochasticProcess made less sense to me at the time. My personal use cases will tend toward simulation of control systems and multi-robot systems. These use cases are likely simpler with less strict requirements than other applications. In my case speed is the biggest issue as I have been working with simulations having tens of thousands of variables but otherwise just having a linear system with noise. Thus, although I have made an effort to get to know the theory better (and will continue to if I decide to continue to pursue this project) my understanding of SDEs is probably still fairly simplistic. It looks to me, like much of what I would be able to provide has already been done. The need that I thought existed might just be a matter of lack of publicity. If anyone still sees a need for a different package for any of the reasons I mentioned (or otherwise for that matter) I will consider continued development. Otherwise, I will either leave as-is or continue development with a focus on personal use. Thanks for all the help. Micah On Sunday, January 18, 2015 at 5:57:59 PM UTC-7, Avik Sengupta wrote: Hi Micah, I intend Ito to only contain specific financial products/algos. My thinking has been that all core math should be in external packages. Having said that, I'd be happy for any feedback on Ito itself. Please feel free to open issues with any comments on taste or correctness. Regards - Avik On Sunday, 18 January 2015 06:21:41 UTC, Micah Corah wrote: I have been working on a project involving large systems of stochastic differential equations. I considered using Ito.jl (to my knowledge the only package with features for SDEs), but it was not quite to my tastes and did not seem to offer much. In response, I wrote my own solver based on the tutorial An Algorithmic Introduction to Numerical Simulation of Equations by Desmond Higham (Euler-Maruyama) and have spent some time optimizing it. Would this be something that people would be interested in using? There are some small changes that I would have to make for theoretical correctness, but otherwise it looks fairly nice to me. If I do turn this into its own package I will fix any of these latent issues and also work on adding support for features such as different algorithms and distributions. Then we would have Ito.jl for quantitative finance and SDE.jl (or whatever I call it) for controls, dynamical systems, etc. Currently this code is on github with the code for a personal project I am working on at https://github.com/mcorah/MultiQuadLift
[julia-users] Re: How to find if a variable is empty or not?
but this is uggly And it will change in 0.4 (I think)
[julia-users] simple I/O question
trying to learn some basics of IO in julia. All I want for now is to read tabular part of following file in two separate arrays: # gamma-ray energies and probability # of emission for 56Ni from # Ambwani Sutherland (1988) Table#1 # E[Mev] f 0.158 1.00 0.270 0.36 0.480 0.36 0.750 0.50 0.812 0.87 1.562 0.14 After skimming the manual this is what I've come up with: ign = 4 # how many lines to ignore from top lines=String[] f=open(fname,r) do f for line in eachline(f) push!(lines,line) end end col1 = zeros(length(l)-ign) col2 = zeros(length(l)-ign) for i=(ign+1):length(l) (col1[i-ign],col2[i-ign])=readdlm(IOBuffer(l[i]),Float64) end Obviously I don't like what I have at all: (1) what is a proper way to convert the String into a Float64 type? IOBuffer works but terribly slow. (2) how do I create the script such that I don't specify how many lines to ignore from top (ign not manually defined)? BTW, is there an equivalent to IDL's readcol.pro http://idlastro.gsfc.nasa.gov/ftp/pro/misc/readcol.pro in Julia? using this procedure in IDL it is just: readcol,fname,col1,col2,format='d,d' thanks,
[julia-users] Re: How to find if a variable is empty or not?
OK, I found that: julia try isempty(t) end false julia try isempty([]) end true but this is uggly segunda-feira, 19 de Janeiro de 2015 às 02:42:09 UTC, J Luis escreveu: How do I test if a variable has something or if it's empty? What I need is something that behaves like the Matalb's isempty() Julia isempty() is no good because it only tests collections. e.g julia type foo a end julia t=foo(1) foo(1) julia isempty(t) ERROR: `start` has no method matching start(::foo) isnan() is no good either for a similar reason julia isnan(t) ERROR: `isnan` has no method matching isnan(::foo) It's a petty that these two don't behave like in Matlab
[julia-users] Re: comparing compilation times for matlab and julia
I guess the idea of automatic reloading of files after modification has been reviewed at https://github.com/JuliaLang/julia/issues/265 and https://groups.google.com/forum/?fromgroups=#!topic/julia-users/38pKvFP0ynM So instead of asking if it's possible to skip the 'include', I'll just add my support for making this change. On Sunday, January 18, 2015 at 8:04:58 PM UTC-8, Christian Peel wrote: I'm enjoying learning Julia. I have the same toy script written in Matlab and Julia at the following URL: https://github.com/ChristianPeel/toySims/tree/master/mimoToys Running the following in matlab tic; mimoUPtoy(200,4,4,4,0,12,12,[-10:5:30]); toc takes about 0.82 seconds on a specific machine. In contrast, with Julia I first need to 'include' it, then the first time through the compiler takes around 7 seconds to compile the code and execute it. Subsequent executions of the code have speed similar to Matlab. julia tic(); include(mimoUPtoy.jl); toc() elapsed time: 0.348886314 seconds 0.348886314 julia tic(); mimoUPtoy(200,4,4,4,0,12,12,[-10.0:5:30]); toq() ...output... 7.002885787 julia tic(); mimoUPtoy(200,4,4,4,0,12,12,[-10.0:5:30]); toq() ...output... 0.860070365 Some questions are (1) is there is some improvement in 0.4 or otherwise which would improve the initial JIT time? (2) is there any way to only recompile the parts of a file that have changed? Say by using a hash on a function to see if it has changed? (3) I'm used to the Matlab development cycle in which I don't need to 'include' anything (it's done automatically) and also any JIT compilation that Matlab does is very fast and is essentially not noticable. So even though Matlab may be slower for code execution, it feels faster for code development. Is there anything that can be done to Julia to make the code writing process quicker? Is there a way to automate the 'include' process? I acknowledge that one option to speed compilation time is to break mimoUPtoy.jl into separate files. I'm also sure that there are things that can be improved in both my Matlab and Julia code. Finally; this function is similar to that which I refered to in a previous post (I was busy at the time and didn't get the code posted) https://groups.google.com/forum/?fromgroups=#!searchin/julia-users/peel/julia-users/thR_80jtE2Q/ymV5i-AXmKkJ
Re: [julia-users] disable @inbounds in tests?
In general, a useful strategy is to make a debug build then attach a debugger. A simple usage pattern: make debug #builds julia-debug gdb julia-debug #or lldb julia-debug #gdb will load r #short for run program #do stuff in julia to cause segfault bt #print backtrace Once you have trapped the segfault you can also do fancier things like print variables in individual stack frames. But you can get quite far just by obtaining the backtrace. Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory On Mon, Jan 19, 2015 at 1:09 AM, Ivar Nesje iva...@gmail.com wrote: Pretty much anything. Compiler bugs are certainly possible, but also bugs in the standard library. Generally pure Julia code shouldn't segfault, unless you're using ccall or the unsafe_ family. If you can post a link to a reasonably short segfaulting example here, there is a good chance that someone will look at it and find the bug.
Re: [julia-users] disable @inbounds in tests?
julia --check-bounds=yes On Sun, Jan 18, 2015 at 11:37 PM, Sheehan Olver dlfivefi...@gmail.com wrote: Is there a way to disable @inbounds in tests? I made a change that's causing a segfault, and can't figure out where the error is.
Re: [julia-users] disable @inbounds in tests?
If I’m still getting a segfault, what else could it be? On 18 Jan 2015, at 9:53 pm, Isaiah Norton isaiah.nor...@gmail.com wrote: julia --check-bounds=yes On Sun, Jan 18, 2015 at 11:37 PM, Sheehan Olver dlfivefi...@gmail.com mailto:dlfivefi...@gmail.com wrote: Is there a way to disable @inbounds in tests? I made a change that's causing a segfault, and can't figure out where the error is.
Re: [julia-users] disable @inbounds in tests?
Pretty much anything. Compiler bugs are certainly possible, but also bugs in the standard library. Generally pure Julia code shouldn't segfault, unless you're using ccall or the unsafe_ family. If you can post a link to a reasonably short segfaulting example here, there is a good chance that someone will look at it and find the bug.
[julia-users] comparing compilation times for matlab and julia
I'm enjoying learning Julia. I have the same toy script written in Matlab and Julia at the following URL: https://github.com/ChristianPeel/toySims/tree/master/mimoToys Running the following in matlab tic; mimoUPtoy(200,4,4,4,0,12,12,[-10:5:30]); toc takes about 0.82 seconds on a specific machine. In contrast, with Julia I first need to 'include' it, then the first time through the compiler takes around 7 seconds to compile the code and execute it. Subsequent executions of the code have speed similar to Matlab. julia tic(); include(mimoUPtoy.jl); toc() elapsed time: 0.348886314 seconds 0.348886314 julia tic(); mimoUPtoy(200,4,4,4,0,12,12,[-10.0:5:30]); toq() ...output... 7.002885787 julia tic(); mimoUPtoy(200,4,4,4,0,12,12,[-10.0:5:30]); toq() ...output... 0.860070365 Some questions are (1) is there is some improvement in 0.4 or otherwise which would improve the initial JIT time? (2) is there any way to only recompile the parts of a file that have changed? Say by using a hash on a function to see if it has changed? (3) I'm used to the Matlab development cycle in which I don't need to 'include' anything (it's done automatically) and also any JIT compilation that Matlab does is very fast and is essentially not noticable. So even though Matlab may be slower for code execution, it feels faster for code development. Is there anything that can be done to Julia to make the code writing process quicker? Is there a way to automate the 'include' process? I acknowledge that one option to speed compilation time is to break mimoUPtoy.jl into separate files. I'm also sure that there are things that can be improved in both my Matlab and Julia code. Finally; this function is similar to that which I refered to in a previous post (I was busy at the time and didn't get the code posted) https://groups.google.com/forum/?fromgroups=#!searchin/julia-users/peel/julia-users/thR_80jtE2Q/ymV5i-AXmKkJ
Re: [julia-users] Re: ANN node-julia 1.0.0
On Sunday, January 18, 2015 at 7:11:01 PM UTC-5, Eric Forgy wrote: I am probably confused, but in the link, they are talking about running Node in Nashorn and it even points to a list of Node modules they are currently able to run. https://avatar-js.java.net https://www.google.com/url?q=https%3A%2F%2Favatar-js.java.netsa=Dsntz=1usg=AFQjCNHMI3W_0OOsDI0vObGlBAH2X87e4g That's Oracle being tricksy. That framework uses a different JavaScript interpreter (Nashorn) built on top of a Java JVM. Supported so long as the module is 100% Javascript but it looks like it's EMCAScript 5, not 6. But modules that make use of v8 native can not be. Here's a blog from StrongLoop http://strongloop.com/strongblog/how-to-run-node-js-on-the-jvm-with-avatar-js-and-loopback/; those guys are trustworthy. I was hoping node-julia could be added to the list. I guess not? Unfortunately, it needs v8. By the way, as I was reading up on Nashorn, I learned that it is intended to be more general than just Javascript in Java. It is supposed to be an architecture for scripting languages in general to run on JVM, i.e. an LLVM for JVM, which begs the question if it now starts to make sense thinking about compiling Julia directly to bytecode for JVM? The Javascript performance seems pretty good. I think that would be a big boost to Julia if you're able to get Java developers on board. I think Nashorn represents Oracle's fear of a future where most Java programmers become Javascript programmers. But for right now anyway, I don't know of an alternative to Hadoop. Would love to learn about it.
[julia-users] Re: How to find if a variable is empty or not?
Julia 0.4 has Nullable types http://docs.julialang.org/en/latest/manual/types/?highlight=nullable#nullable-types-representing-missing-values Cheers Lex On Monday, January 19, 2015 at 1:14:03 PM UTC+10, J Luis wrote: OK, I found that: julia try isempty(t) end false julia try isempty([]) end true but this is uggly segunda-feira, 19 de Janeiro de 2015 às 02:42:09 UTC, J Luis escreveu: How do I test if a variable has something or if it's empty? What I need is something that behaves like the Matalb's isempty() Julia isempty() is no good because it only tests collections. e.g julia type foo a end julia t=foo(1) foo(1) julia isempty(t) ERROR: `start` has no method matching start(::foo) isnan() is no good either for a similar reason julia isnan(t) ERROR: `isnan` has no method matching isnan(::foo) It's a petty that these two don't behave like in Matlab
[julia-users] Re: Considering posting SDE solver package
Hi Micah, I intend Ito to only contain specific financial products/algos. My thinking has been that all core math should be in external packages. Having said that, I'd be happy for any feedback on Ito itself. Please feel free to open issues with any comments on taste or correctness. Regards - Avik On Sunday, 18 January 2015 06:21:41 UTC, Micah Corah wrote: I have been working on a project involving large systems of stochastic differential equations. I considered using Ito.jl (to my knowledge the only package with features for SDEs), but it was not quite to my tastes and did not seem to offer much. In response, I wrote my own solver based on the tutorial An Algorithmic Introduction to Numerical Simulation of Equations by Desmond Higham (Euler-Maruyama) and have spent some time optimizing it. Would this be something that people would be interested in using? There are some small changes that I would have to make for theoretical correctness, but otherwise it looks fairly nice to me. If I do turn this into its own package I will fix any of these latent issues and also work on adding support for features such as different algorithms and distributions. Then we would have Ito.jl for quantitative finance and SDE.jl (or whatever I call it) for controls, dynamical systems, etc. Currently this code is on github with the code for a personal project I am working on at https://github.com/mcorah/MultiQuadLift
[julia-users] Re: Creating a type to store parameters in, and constructors with keyword arguments
This seems to be more useful(depending on your use cases): function Parameters( eta = 3, sigma = 1, rho = 5, xi = 2, agrid = linrange(1,10,10), beta = 4 ) @CallDefaultConstructor Parameters end Like this, you can replace parts of the defaults ;) And if you're at it, you could just have a macro like this *@with_keywordconstructor* begin immutabe Parameters{T : Real} sigma::T = 1 xi::T = 2 ... end end And If you're already at it, you could write a macro, which lets you define defaults for every field Am Samstag, 17. Januar 2015 01:34:19 UTC+1 schrieb Andrew: Suppose I have a model which contains many parameters. I'd like to store my parameters in a type, for example type Parameters sigma::Real xi::Real eta::Real beta::Real rho::Real agrid::FloatRange end and then I need to assign some values to my parameters. The natural way I see to do this is params = Parameters(1,2,3,4,5,linrange(1,10,10)) or something like that. However, the fact that I need to remember the order in which I defined these parameters means there is some chance of error. In reality I have about 20 parameters, so defining them this way would be quite annoying. It would be nice if there was a constructor that would let me use keyword arguments, as in params = Parameters(sigma=1,xi=2,eta=3,beta=4,rho=5,agrid=linrange(1,10,10 )) . I know I could write my own constructor and use keyword arguments, but then I think I'd still need to use the ordered constructor to write that one. Is there an easy way to do this? Maybe a macro that could automatically define a constructor with keyword arguments?(I don't know much about metaprogramming). Alternatively, is there is a cleaner way to store parameters that doesn't use types? --- I did find a related post here. https://groups.google.com/forum/#!searchin/julia-users/constructor$20keyword$20arguments/julia-users/xslxrihfO30/jV2awP5tbpEJ . Someone suggests that you can define a constructor like, Foo(;bar=1, baz=2) = new(bar, baz) which does what I want. Is there a way to macro that so that it's automatically defined for every field in the type?
Re: [julia-users] Re: julia unable to install on Ubuntu 13.10
Oh nice, I have installed cmake and that works. Wasn't cmake required before ? I'm surprised it was not installed. Le dimanche 18 janvier 2015 13:11:35 UTC+1, Stéphane Laurent a écrit : Hello, Currently my pc always freezes, so I use the console mode and I don't know how to copy-paste the output. I remember something like cmake not found, but I'm not sure. Isn't it better to install the latest 0.3 version rather than 0.4 ? Le dimanche 18 janvier 2015 12:56:16 UTC+1, Milan Bouchet-Valat a écrit : Le dimanche 18 janvier 2015 à 03:54 -0800, 'Stéphane Laurent' via julia-users a écrit : Hello, he Since Julia version 0.4 this way does not work anymore : git pull make clean make There are some errors when doing make. Can I simply delete my julia folder and reinstall ? Of course you can, but there are probably other ways too. Can you post the output you get somewhere? Regards Le mardi 20 mai 2014 12:46:41 UTC+2, Ivo Balbaert a écrit : Sorry, message was posted too quickly: Here is my report of the build: in /home/ivo/julia: git clone git://github.com/JuliaLang/julia.git cd julia in /home/ivo/julia/julia: make /bin/sh: 2: g++: not found make[2]: *** [/home/ivo/julia/julia/usr/lib/libgrisu.so] Error 127 make[1]: *** [julia-release] Error 2 make: *** [release] Error 2 -- sudo ap-get install build-essential make gfortran: command not found -- sudo apt-get install gfortran make checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons). -- sudo apt-get install m4 make ./julia OK! To install latest version of Julia: git pull make clean make ./julia Cheers, Ivo Op zaterdag 25 januari 2014 04:30:18 UTC+1 schreef Rajn: After my several failed attempts to run PyPlot through Julia in Windows, I decided to give up and try Linux. Guess it was even worse. First I added to regular repository (not the nightlybuild) then added the dep-repository then updated and then installed julia Here's the latest: Unpacking librmath-dev (from .../librmath-dev_2.15.2-juliadeps2~raring_amd64.deb) ... dpkg: error processing /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb (--unpack): trying to overwrite '/usr/include/Rmath.h', which is also in package r-mathlib 3.0.1-3ubuntu1 No apport report written because MaxReports is reached already Selecting previously unselected package julia. Unpacking julia (from .../julia_0.2.0~saucyfinal1_amd64.deb) ... Processing triggers for man-db ... Errors were encountered while processing: /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) Have no clue absolutely how to proceed. The same issue occurs when I try nightly builds.
Re: [julia-users] Re: julia unable to install on Ubuntu 13.10
Le dimanche 18 janvier 2015 à 05:43 -0800, 'Stéphane Laurent' via julia-users a écrit : Oh nice, I have installed cmake and that works. Wasn't cmake required before ? I'm surprised it was not installed. I think this requirement was added recently to build libgit2. Anyway it's quite weird it made you computer freeze... Regarding 0.3 vs 0.4, it depends on what you want to do. If you need a stable (working) environment, use 0.3. Regards Le dimanche 18 janvier 2015 13:11:35 UTC+1, Stéphane Laurent a écrit : Hello, Currently my pc always freezes, so I use the console mode and I don't know how to copy-paste the output. I remember something like cmake not found, but I'm not sure. Isn't it better to install the latest 0.3 version rather than 0.4 ? Le dimanche 18 janvier 2015 12:56:16 UTC+1, Milan Bouchet-Valat a écrit : Le dimanche 18 janvier 2015 à 03:54 -0800, 'Stéphane Laurent' via julia-users a écrit : Hello, he Since Julia version 0.4 this way does not work anymore : git pull make clean make There are some errors when doing make. Can I simply delete my julia folder and reinstall ? Of course you can, but there are probably other ways too. Can you post the output you get somewhere? Regards Le mardi 20 mai 2014 12:46:41 UTC+2, Ivo Balbaert a écrit : Sorry, message was posted too quickly: Here is my report of the build: in /home/ivo/julia: git clone git://github.com/JuliaLang/julia.git cd julia in /home/ivo/julia/julia: make /bin/sh: 2: g++: not found make[2]: *** [/home/ivo/julia/julia/usr/lib/libgrisu.so] Error 127 make[1]: *** [julia-release] Error 2 make: *** [release] Error 2 -- sudo ap-get install build-essential make gfortran: command not found -- sudo apt-get install gfortran make checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons). -- sudo apt-get install m4 make ./julia OK! To install latest version of Julia: git pull make clean make ./julia Cheers, Ivo Op zaterdag 25 januari 2014 04:30:18 UTC+1 schreef Rajn: After my several failed attempts to run PyPlot through Julia in Windows, I decided to give up and try Linux. Guess it was even worse. First I added to regular repository (not the nightlybuild) then added the dep-repository then updated and then installed julia Here's the latest: Unpacking librmath-dev (from .../librmath-dev_2.15.2-juliadeps2~raring_amd64.deb) ... dpkg: error processing /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb (--unpack): trying to overwrite
[julia-users] Re: Error: zeros(UTF8String, 5)
On Friday, January 16, 2015 at 2:44:51 PM UTC+1, Steven G. Johnson wrote: On Friday, January 16, 2015 at 6:59:19 AM UTC-5, K leo wrote: I want the array to be initialized with every element being . Can't say about 0.3.4, but it definitely worked under 0.3.3. Are there any other easy ways for what I want? If anything, this should be ones(UTF8String, n). Since * is the string-concatenation operator, then and is the identity element for concatenation, then one(UTF8String) should give . This makes sense, but what was the original argument to choose * as string concatenation, and not, for instance, +, like in some other languages? ---david
Re: [julia-users] Send composite type to C and get it back
I should also emphasize the difference: pointer_from_objref returns a jl_value_t*, which includes the type tag found at the beginning of all (well, most) Julia value instances. With Ptr{T} and v in ccall, you get a pointer to the memory after the type tag, which is C-compatible (provided isbits(T) == true) On Sun, Jan 18, 2015 at 10:12 AM, Isaiah Norton isaiah.nor...@gmail.com wrote: - if you want to pass a pointer to the *complete* Julia type, including the type tag, use pointer_from_objref. From the manual: Julia values v can be converted to jl_value_t*pointers, as Ptr{Void}, by calling pointer_from_objref(v). - if you want to pass a pointer to a C-compatible struct, tell ccall that is what you want, and use the symbol before the variable. From the manual: struct T* (where T represents an appropriately defined bits type)Ptr{T} (call using variable_name in the parameter list) Here is an example: https://gist.github.com/ihnorton/1c1338a22fb3d143fa7f Really the best way to work through these things is to write small examples where you can control everything, and see what happens. Trying to figure it out on the go in a large system with many moving pieces is a recipe for frustration. On Sun, Jan 18, 2015 at 9:28 AM, J Luis jmfl...@gmail.com wrote: Thank you very much Jiahao. That's indeed the result I want ... but sorry, I'm still confused. Why doesn't the other way work too? At the end it also gets composite type with the same members but with a whatever in their values. Also, I have here a case where it worked with unsafe_load() but crashes if I use unsafe_pointer_to_objref() (note that 'image' is a pointer to a composite type) https://github.com/joa-quim/IUP.jl/blob/master/examples/im_view_.jl#L106 I read and reread the docs but find confusing what is a *memory address of a Julia object* is that apparently is different to the pointer obtained with convert() domingo, 18 de Janeiro de 2015 às 06:17:11 UTC, Jiahao Chen escreveu: I don't think the conversion does what you want. Instead you may be looking for this: julia type foo a::Int; b::Int end julia tp=foo(2,3) foo(2,3) julia p=pointer_from_objref(tp) Ptr{Void} @0x7fa70872e188 julia pt=unsafe_pointer_to_objref(p) foo(2,3) Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory
Re: [julia-users] Package installation on a Windows machine?
If Jiahao's suggestion does not work, there may be a permissions issue with your home directory. In particular, we have seen this kind of error when a user's home directory is located on a managed network drive without write permission. You can get around this by setting an environment variable JULIA_PKGDIR to some local path where you have write access. On Sat, Jan 17, 2015 at 3:49 PM, CaitlinG bioprogram...@gmail.com wrote: Hi all. Using Julia 0.3.5 on a Windows XP (sp3) machine, I attempted to install the following package, please see below, which resulted in the given error message: julia Pkg.add(PyPlot) INFO: Cloning cache of Color from git://github.com/JuliaLang/Color.jl.git ERROR: chmod: no such file or directory (ENOENT) in wait at task.jl:51 in sync_end at task.jl:311 in add at pkg/entry.jl:319 in add at pkg/entry.jl:71 in anonymous at pkg/dir.jl:28 in cd at file.jl:30 in cd at pkg/dir.jl:28 in add at pkg.jl:20 I don't understand how to resolve this issue since I am inexperienced with regard to both github and Julia. Thanks, ~Caitlin
Re: [julia-users] Send composite type to C and get it back
- if you want to pass a pointer to the *complete* Julia type, including the type tag, use pointer_from_objref. From the manual: Julia values v can be converted to jl_value_t*pointers, as Ptr{Void}, by calling pointer_from_objref(v). - if you want to pass a pointer to a C-compatible struct, tell ccall that is what you want, and use the symbol before the variable. From the manual: struct T* (where T represents an appropriately defined bits type)Ptr{T} (call using variable_name in the parameter list) Here is an example: https://gist.github.com/ihnorton/1c1338a22fb3d143fa7f Really the best way to work through these things is to write small examples where you can control everything, and see what happens. Trying to figure it out on the go in a large system with many moving pieces is a recipe for frustration. On Sun, Jan 18, 2015 at 9:28 AM, J Luis jmfl...@gmail.com wrote: Thank you very much Jiahao. That's indeed the result I want ... but sorry, I'm still confused. Why doesn't the other way work too? At the end it also gets composite type with the same members but with a whatever in their values. Also, I have here a case where it worked with unsafe_load() but crashes if I use unsafe_pointer_to_objref() (note that 'image' is a pointer to a composite type) https://github.com/joa-quim/IUP.jl/blob/master/examples/im_view_.jl#L106 I read and reread the docs but find confusing what is a *memory address of a Julia object* is that apparently is different to the pointer obtained with convert() domingo, 18 de Janeiro de 2015 às 06:17:11 UTC, Jiahao Chen escreveu: I don't think the conversion does what you want. Instead you may be looking for this: julia type foo a::Int; b::Int end julia tp=foo(2,3) foo(2,3) julia p=pointer_from_objref(tp) Ptr{Void} @0x7fa70872e188 julia pt=unsafe_pointer_to_objref(p) foo(2,3) Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory
[julia-users] Re: Error: zeros(UTF8String, 5)
And why isn't this most frequently asked question covered in our FAQ? http://docs.julialang.org/en/latest/manual/faq/
Re: [julia-users] Re: Error: zeros(UTF8String, 5)
If you have plenty of time, try scanning these conversations for an answer: https://groups.google.com/forum/#!msg/julia-dev/4K6S7tWnuEs/RF6x-f59IaoJ https://groups.google.com/forum/#!topic/julia-users/nQg_d_n0t1Q https://github.com/JuliaLang/julia/issues/1771 https://github.com/JuliaLang/julia/issues/2301 If you're up for it, an update to the FAQ section of the docs http://julia.readthedocs.org/en/latest/manual/faq/ with this information would probably be welcome! Cheers, Kevin On Sun, Jan 18, 2015 at 7:01 AM, David van Leeuwen david.vanleeu...@gmail.com wrote: On Friday, January 16, 2015 at 2:44:51 PM UTC+1, Steven G. Johnson wrote: On Friday, January 16, 2015 at 6:59:19 AM UTC-5, K leo wrote: I want the array to be initialized with every element being . Can't say about 0.3.4, but it definitely worked under 0.3.3. Are there any other easy ways for what I want? If anything, this should be ones(UTF8String, n). Since * is the string-concatenation operator, then and is the identity element for concatenation, then one(UTF8String) should give . This makes sense, but what was the original argument to choose * as string concatenation, and not, for instance, +, like in some other languages? ---david
Re: [julia-users] Send composite type to C and get it back
Thank you very much Jiahao. That's indeed the result I want ... but sorry, I'm still confused. Why doesn't the other way work too? At the end it also gets composite type with the same members but with a whatever in their values. Also, I have here a case where it worked with unsafe_load() but crashes if I use unsafe_pointer_to_objref() (note that 'image' is a pointer to a composite type) https://github.com/joa-quim/IUP.jl/blob/master/examples/im_view_.jl#L106 I read and reread the docs but find confusing what is a *memory address of a Julia object* is that apparently is different to the pointer obtained with convert() domingo, 18 de Janeiro de 2015 às 06:17:11 UTC, Jiahao Chen escreveu: I don't think the conversion does what you want. Instead you may be looking for this: julia type foo a::Int; b::Int end julia tp=foo(2,3) foo(2,3) julia p=pointer_from_objref(tp) Ptr{Void} @0x7fa70872e188 julia pt=unsafe_pointer_to_objref(p) foo(2,3) Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory
Re: [julia-users] Re: SLOW sortrows?
If you can reduce this to a standalone, runnable test case that uses only code from Base, it would be helpful to file an issue. --Tim On Saturday, January 17, 2015 05:36:36 PM Arch Call wrote: Give alg=MergeSort a whirl. The doc says this is slower than alg=QuickSort for numeric arrays, but who knows until you try. On Saturday, January 17, 2015 at 4:57:20 PM UTC-5, Petr Krysl wrote: Hi guys, This one has me scratching my head. Matlab code: function Out =myunique(A) sA=sort(A,2); [sA,rix] = sortrows(sA);; d=sA(1:end-1,:)~=sA(2:end,:); ad=[true; any(d,2)]; iu =find((ad[ad(2:end);true])==true); Out =A(rix(iu),:); end was rewritten in Julia. Since some of the functionality is different (or slower) as written, I had to rewrite a bit. The surprise was that even after the rewrite the Julia code runs in around 24 seconds whereas the Matlab code gets it done in two seconds. As I went poking around to find what is slow, I found that 95% of the time were spent in the sort() and sortrrows() functions. Any idea of what could cause this slowness? By the way, @code_warntype gives the code a clean bill... So are those two functions somehow slow by themselves? The Julia version of this is posted at https://gist.github.com/PetrKryslUCSD/cde67dfa0f1b0a1f98ac Thanks, Petr
[julia-users] Re: julia unable to install on Ubuntu 13.10
Hello, Since Julia version 0.4 this way does not work anymore : *git pull* *make clean* *make* There are some errors when doing make. Can I simply delete my julia folder and reinstall ? Le mardi 20 mai 2014 12:46:41 UTC+2, Ivo Balbaert a écrit : Sorry, message was posted too quickly: Here is my report of the build: in /home/ivo/julia: git clone git://github.com/JuliaLang/julia.git cd julia in /home/ivo/julia/julia: make /bin/sh: 2: g++: not found make[2]: *** [/home/ivo/julia/julia/usr/lib/libgrisu.so] Error 127 make[1]: *** [julia-release] Error 2 make: *** [release] Error 2 -- sudo ap-get install build-essential make gfortran: command not found -- sudo apt-get install gfortran make checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons). -- sudo apt-get install m4 make ./julia OK! To install latest version of Julia: git pull make clean make ./julia Cheers, Ivo Op zaterdag 25 januari 2014 04:30:18 UTC+1 schreef Rajn: After my several failed attempts to run PyPlot through Julia in Windows, I decided to give up and try Linux. Guess it was even worse. First I added to regular repository (not the nightlybuild) then added the dep-repository then updated and then installed julia Here's the latest: Unpacking librmath-dev (from .../librmath-dev_2.15.2-juliadeps2~raring_amd64.deb) ... dpkg: error processing /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb (--unpack): trying to overwrite '/usr/include/Rmath.h', which is also in package r-mathlib 3.0.1-3ubuntu1 No apport report written because MaxReports is reached already Selecting previously unselected package julia. Unpacking julia (from .../julia_0.2.0~saucyfinal1_amd64.deb) ... Processing triggers for man-db ... Errors were encountered while processing: /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) Have no clue absolutely how to proceed. The same issue occurs when I try nightly builds.
Re: [julia-users] Re: julia unable to install on Ubuntu 13.10
Le dimanche 18 janvier 2015 à 03:54 -0800, 'Stéphane Laurent' via julia-users a écrit : Hello, Since Julia version 0.4 this way does not work anymore : git pull make clean make There are some errors when doing make. Can I simply delete my julia folder and reinstall ? Of course you can, but there are probably other ways too. Can you post the output you get somewhere? Regards Le mardi 20 mai 2014 12:46:41 UTC+2, Ivo Balbaert a écrit : Sorry, message was posted too quickly: Here is my report of the build: in /home/ivo/julia: git clone git://github.com/JuliaLang/julia.git cd julia in /home/ivo/julia/julia: make /bin/sh: 2: g++: not found make[2]: *** [/home/ivo/julia/julia/usr/lib/libgrisu.so] Error 127 make[1]: *** [julia-release] Error 2 make: *** [release] Error 2 -- sudo ap-get install build-essential make gfortran: command not found -- sudo apt-get install gfortran make checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons). -- sudo apt-get install m4 make ./julia OK! To install latest version of Julia: git pull make clean make ./julia Cheers, Ivo Op zaterdag 25 januari 2014 04:30:18 UTC+1 schreef Rajn: After my several failed attempts to run PyPlot through Julia in Windows, I decided to give up and try Linux. Guess it was even worse. First I added to regular repository (not the nightlybuild) then added the dep-repository then updated and then installed julia Here's the latest: Unpacking librmath-dev (from .../librmath-dev_2.15.2-juliadeps2~raring_amd64.deb) ... dpkg: error processing /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb (--unpack): trying to overwrite '/usr/include/Rmath.h', which is also in package r-mathlib 3.0.1-3ubuntu1 No apport report written because MaxReports is reached already Selecting previously unselected package julia. Unpacking julia (from .../julia_0.2.0~saucyfinal1_amd64.deb) ... Processing triggers for man-db ... Errors were encountered while processing: /var/cache/apt/archives/librmath-dev_2.15.2-juliadeps2~raring_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) Have no clue absolutely how to proceed. The same issue occurs when I try nightly builds.
[julia-users] Re: ANN node-julia 1.0.0
Hi Jeff, I really like this idea and look forward to giving node-julia (and Julia for that matter) a spin. As I explain here https://groups.google.com/forum/#!topic/julia-users/umHiBwVLQ4g, I'm building a web app with a Spring MVC backend and d3-based front end and trying to figure out how to squeeze Julia in between the two somehow. I'm learning all this as I go and I just stumbled onto Nashorn https://blogs.oracle.com/java-platform-group/entry/nashorn_the_rhino_in_the. The linked article talks about running Node applications on Nashorn through Project Avatar https://avatar.java.net/. If I understand, this combination should allow me to run node-julia side-by-side with my Java code. Is that correct? That would be awesome. Can you foresee any difficulties? Best regards, Eric On Saturday, January 17, 2015 at 5:06:00 AM UTC+8, Jeff Waller wrote: So I'm happy to announce version 1.0.0 of node-julia, a Julia engine embedded in node, and io.js now too. It's been a pretty long road and I owe many people (perhaps reading this now) a lot. I've said many times (maybe not on this forum) that enabling people is the important part and I hope this tool does that.
[julia-users] Re: Considering posting SDE solver package
Hi Micah, This sounds great! I would be very interested in a dedicated SDE package and I guess others would be as well. At some point I wrote a solver based on the Heun method, but it needs some cleanup before I dare to post it. AFAIK the name SDE.jl https://github.com/mschauer/SDE.jl is already taken ... Best, Alex. On Sunday, 18 January 2015 07:21:41 UTC+1, Micah Corah wrote: I have been working on a project involving large systems of stochastic differential equations. I considered using Ito.jl (to my knowledge the only package with features for SDEs), but it was not quite to my tastes and did not seem to offer much. In response, I wrote my own solver based on the tutorial An Algorithmic Introduction to Numerical Simulation of Equations by Desmond Higham (Euler-Maruyama) and have spent some time optimizing it. Would this be something that people would be interested in using? There are some small changes that I would have to make for theoretical correctness, but otherwise it looks fairly nice to me. If I do turn this into its own package I will fix any of these latent issues and also work on adding support for features such as different algorithms and distributions. Then we would have Ito.jl for quantitative finance and SDE.jl (or whatever I call it) for controls, dynamical systems, etc. Currently this code is on github with the code for a personal project I am working on at https://github.com/mcorah/MultiQuadLift
Re: [julia-users] Re: SLOW sortrows?
Certainly do file an issue with an easy to produce test case. I am pretty sure we have not paid much attention to sortrows, and there is room for improvement. -viral On Sunday, January 18, 2015 at 5:30:38 PM UTC+5:30, Tim Holy wrote: If you can reduce this to a standalone, runnable test case that uses only code from Base, it would be helpful to file an issue. --Tim On Saturday, January 17, 2015 05:36:36 PM Arch Call wrote: Give alg=MergeSort a whirl. The doc says this is slower than alg=QuickSort for numeric arrays, but who knows until you try. On Saturday, January 17, 2015 at 4:57:20 PM UTC-5, Petr Krysl wrote: Hi guys, This one has me scratching my head. Matlab code: function Out =myunique(A) sA=sort(A,2); [sA,rix] = sortrows(sA);; d=sA(1:end-1,:)~=sA(2:end,:); ad=[true; any(d,2)]; iu =find((ad[ad(2:end);true])==true); Out =A(rix(iu),:); end was rewritten in Julia. Since some of the functionality is different (or slower) as written, I had to rewrite a bit. The surprise was that even after the rewrite the Julia code runs in around 24 seconds whereas the Matlab code gets it done in two seconds. As I went poking around to find what is slow, I found that 95% of the time were spent in the sort() and sortrrows() functions. Any idea of what could cause this slowness? By the way, @code_warntype gives the code a clean bill... So are those two functions somehow slow by themselves? The Julia version of this is posted at https://gist.github.com/PetrKryslUCSD/cde67dfa0f1b0a1f98ac Thanks, Petr
[julia-users] Need help on failure of make testall
Today I am building julia on my debian wheezy machine. On my first build all went apparently ok except for the failure with handling LinAlg. So, I looked at the README.md and set the contents of the Make.user file to be OPENBLAS_TARGET_ARCH=BARCELONA and did a make again. Oh, I should add that when I did the initial build I had used the Make.user file with USE_SYSTEM_BLAS=1 as I had done on my macbook pro running Yosemite. So the second build went through and so I did make testall again. This time I copy below the last part of the output: From worker 2: * spawn From worker 2: [stdio passthrough ok] From worker 3: * backtrace From worker 3: * priorityqueue From worker 3: * arpack From worker 2: * file exception on 3: ERROR: LoadError: mismatch of non-finite elements: a * v[:,2] = Complex{Float64}[0.3510708184533124 - 0.8448075765452452im,0.5409098805390047 + 0.4169280633379024im,1.601725134028458 - 0.3900766044198073im,-0.9287342657831045 + 0.5772334426822694im,-0.3562087668733587 + 0.22025403456360376im,0.09986508846344075 + 0.7106414642389014im,0.323809543105644 + 0.19834819844597995im,0.6536841226089468 - 1.041708885232234im,-0.6831321692699663 - 0.2844116648988878im,0.24339386054695047 + 0.24964567036597263im] d[2] * v[:,2] = Complex{Float64}[NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im] in test_approx_eq at test.jl:125 in anonymous at no file:29 in runtests at /home/comer/julia/test/testdefs.jl:5 in anonymous at multi.jl:852 in run_work_thunk at multi.jl:603 in anonymous at task.jl:852 while loading arpack.jl, in expression starting on line 1 ERROR: LoadError: LoadError: mismatch of non-finite elements: a * v[:,2] = Complex{Float64}[0.3510708184533124 - 0.8448075765452452im,0.5409098805390047 + 0.4169280633379024im,1.601725134028458 - 0.3900766044198073im,-0.9287342657831045 + 0.5772334426822694im,-0.3562087668733587 + 0.22025403456360376im,0.09986508846344075 + 0.7106414642389014im,0.323809543105644 + 0.19834819844597995im,0.6536841226089468 - 1.041708885232234im,-0.6831321692699663 - 0.2844116648988878im,0.24339386054695047 + 0.24964567036597263im] d[2] * v[:,2] = Complex{Float64}[NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im] in anonymous at task.jl:1616 while loading arpack.jl, in expression starting on line 1 while loading /home/comer/julia/test/runtests.jl, in expression starting on line 42 make[1]: *** [all] Error 1 make: *** [testall] Error 2 Can you please help me see what to do to get a clean make testall? Thanks very much! Comer
Re: [julia-users] Need help on failure of make testall
try a make -C deps distclean-arpack and then run the tests again. If it still fails, please provide the output form versioninfo(). 2015-01-18 13:49 GMT-05:00 Comer Duncan comer.dun...@gmail.com: Today I am building julia on my debian wheezy machine. On my first build all went apparently ok except for the failure with handling LinAlg. So, I looked at the README.md and set the contents of the Make.user file to be OPENBLAS_TARGET_ARCH=BARCELONA and did a make again. Oh, I should add that when I did the initial build I had used the Make.user file with USE_SYSTEM_BLAS=1 as I had done on my macbook pro running Yosemite. So the second build went through and so I did make testall again. This time I copy below the last part of the output: From worker 2: * spawn From worker 2: [stdio passthrough ok] From worker 3: * backtrace From worker 3: * priorityqueue From worker 3: * arpack From worker 2: * file exception on 3: ERROR: LoadError: mismatch of non-finite elements: a * v[:,2] = Complex{Float64}[0.3510708184533124 - 0.8448075765452452im,0.5409098805390047 + 0.4169280633379024im,1.601725134028458 - 0.3900766044198073im,-0.9287342657831045 + 0.5772334426822694im,-0.3562087668733587 + 0.22025403456360376im,0.09986508846344075 + 0.7106414642389014im,0.323809543105644 + 0.19834819844597995im,0.6536841226089468 - 1.041708885232234im,-0.6831321692699663 - 0.2844116648988878im,0.24339386054695047 + 0.24964567036597263im] d[2] * v[:,2] = Complex{Float64}[NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im] in test_approx_eq at test.jl:125 in anonymous at no file:29 in runtests at /home/comer/julia/test/testdefs.jl:5 in anonymous at multi.jl:852 in run_work_thunk at multi.jl:603 in anonymous at task.jl:852 while loading arpack.jl, in expression starting on line 1 ERROR: LoadError: LoadError: mismatch of non-finite elements: a * v[:,2] = Complex{Float64}[0.3510708184533124 - 0.8448075765452452im,0.5409098805390047 + 0.4169280633379024im,1.601725134028458 - 0.3900766044198073im,-0.9287342657831045 + 0.5772334426822694im,-0.3562087668733587 + 0.22025403456360376im,0.09986508846344075 + 0.7106414642389014im,0.323809543105644 + 0.19834819844597995im,0.6536841226089468 - 1.041708885232234im,-0.6831321692699663 - 0.2844116648988878im,0.24339386054695047 + 0.24964567036597263im] d[2] * v[:,2] = Complex{Float64}[NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im,NaN + NaN*im] in anonymous at task.jl:1616 while loading arpack.jl, in expression starting on line 1 while loading /home/comer/julia/test/runtests.jl, in expression starting on line 42 make[1]: *** [all] Error 1 make: *** [testall] Error 2 Can you please help me see what to do to get a clean make testall? Thanks very much! Comer
[julia-users] Re: What's your favourite editor?
On Saturday, January 17, 2015 at 8:34:46 AM UTC-8, Terry Seaward wrote: Hi, Just curious to know what people use to write/edit their Julia code (os/app)? Atom (www.atom.io) with the minimap, julia language plugin and a bunch of git stuff - this editor has replaced Sublime for me.
Re: [julia-users] Send composite type to C and get it back
Le dimanche 18 janvier 2015 à 10:15 -0500, Isaiah Norton a écrit : I should also emphasize the difference: pointer_from_objref returns a jl_value_t*, which includes the type tag found at the beginning of all (well, most) Julia value instances. With Ptr{T} and v in ccall, you get a pointer to the memory after the type tag, which is C-compatible (provided isbits(T) == true) I think this deserves to be in the manual, and in relevant documentation for functions in stdlib. ?pointer_from_objref and ?pointer do not really allow grasping the difference between the two functions. Regards On Sun, Jan 18, 2015 at 10:12 AM, Isaiah Norton isaiah.nor...@gmail.com wrote: - if you want to pass a pointer to the *complete* Julia type, including the type tag, use pointer_from_objref. From the manual: Julia values v can be converted to jl_value_t*pointers, as Ptr{Void}, by calling pointer_from_objref(v). - if you want to pass a pointer to a C-compatible struct, tell ccall that is what you want, and use the symbol before the variable. From the manual: struct T* (where T represents an appropriately defined bits type) Ptr{T} (call using variable_name in the parameter list) Here is an example: https://gist.github.com/ihnorton/1c1338a22fb3d143fa7f Really the best way to work through these things is to write small examples where you can control everything, and see what happens. Trying to figure it out on the go in a large system with many moving pieces is a recipe for frustration. On Sun, Jan 18, 2015 at 9:28 AM, J Luis jmfl...@gmail.com wrote: Thank you very much Jiahao. That's indeed the result I want ... but sorry, I'm still confused. Why doesn't the other way work too? At the end it also gets composite type with the same members but with a whatever in their values. Also, I have here a case where it worked with unsafe_load() but crashes if I use unsafe_pointer_to_objref() (note that 'image' is a pointer to a composite type) https://github.com/joa-quim/IUP.jl/blob/master/examples/im_view_.jl#L106 I read and reread the docs but find confusing what is a memory address of a Julia object is that apparently is different to the pointer obtained with convert() domingo, 18 de Janeiro de 2015 às 06:17:11 UTC, Jiahao Chen escreveu: I don't think the conversion does what you want. Instead you may be looking for this: julia type foo a::Int; b::Int end julia tp=foo(2,3) foo(2,3) julia p=pointer_from_objref(tp) Ptr{Void} @0x7fa70872e188 julia pt=unsafe_pointer_to_objref(p) foo(2,3) Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory
[julia-users] Re: ANN node-julia 1.0.0
On Sunday, January 18, 2015 at 5:47:51 AM UTC-5, Eric Forgy wrote: Hi Jeff, I really like this idea and look forward to giving node-julia (and Julia for that matter) a spin. As I explain here https://groups.google.com/forum/#!topic/julia-users/umHiBwVLQ4g, I'm building a web app with a Spring MVC backend and d3-based front end and trying to figure out how to squeeze Julia in between the two somehow. I'm learning all this as I go and I just stumbled onto Nashorn https://blogs.oracle.com/java-platform-group/entry/nashorn_the_rhino_in_the. The linked article talks about running Node applications on Nashorn through Project Avatar https://avatar.java.net/. If I understand, this combination should allow me to run node-julia side-by-side with my Java code. Is that correct? That would be awesome. Can you foresee any difficulties? Hi Eric, I like your d3 idea, my friends advise that projects that are based on d3 like bokeh http://bokeh.pydata.org/en/latest/docs/gallery.html go a long way and then get bogged down in details, so heads up, but it's too cool to not try. Unfortunately, incorporating Julia via node-julia will not work when using Nashorn and Avatar.js as they are projects to replace node and v8 not work with them. Nor will node-webkit or atom-shell if you are wanting to go browser-as-desktop-app route, but d3 in a browser still will of course.
Re: [julia-users] Re: switch case statement?
very interesting! El 18/01/2015 15:50, Ismael VC ismael.vc1...@gmail.com escribió: There is also a Switch package for Julia: https://github.com/dcjones/Switch.jl El domingo, 16 de diciembre de 2012, 5:00:17 (UTC-6), Erik Engheim escribió: I can not seem to find any type of *switch case* statement in Julia. What is the alternative? I know I could always use *elseif *but that is cumbersome. My thinking was that perhaps due to the type system one does not need switch case as often. Usually we use swith case with enums, but I guess in Julia one could use types, and just define a bunch of short functions. But this is just speculation on my side I would have loved to hear what the thinking is behind leaving out *switch-case* functionality.
[julia-users] Re: switch case statement?
There is also a Switch package for Julia: https://github.com/dcjones/Switch.jl El domingo, 16 de diciembre de 2012, 5:00:17 (UTC-6), Erik Engheim escribió: I can not seem to find any type of *switch case* statement in Julia. What is the alternative? I know I could always use *elseif *but that is cumbersome. My thinking was that perhaps due to the type system one does not need switch case as often. Usually we use swith case with enums, but I guess in Julia one could use types, and just define a bunch of short functions. But this is just speculation on my side I would have loved to hear what the thinking is behind leaving out *switch-case* functionality.
Re: [julia-users] Send composite type to C and get it back
Thanks. Yes, have had my dose of frustrations. Even when trying to reduce things to simple pieces. BTW, there is no ccal involved in this specific C-talk (store data as attributes in IUP functions) but the recipe is the same. domingo, 18 de Janeiro de 2015 às 15:13:00 UTC, Isaiah escreveu: - if you want to pass a pointer to the *complete* Julia type, including the type tag, use pointer_from_objref. From the manual: Julia values v can be converted to jl_value_t*pointers, as Ptr{Void}, by calling pointer_from_objref(v). - if you want to pass a pointer to a C-compatible struct, tell ccall that is what you want, and use the symbol before the variable. From the manual: struct T* (where T represents an appropriately defined bits type)Ptr{T} (call using variable_name in the parameter list) Here is an example: https://gist.github.com/ihnorton/1c1338a22fb3d143fa7f Really the best way to work through these things is to write small examples where you can control everything, and see what happens. Trying to figure it out on the go in a large system with many moving pieces is a recipe for frustration. On Sun, Jan 18, 2015 at 9:28 AM, J Luis jmf...@gmail.com javascript: wrote: Thank you very much Jiahao. That's indeed the result I want ... but sorry, I'm still confused. Why doesn't the other way work too? At the end it also gets composite type with the same members but with a whatever in their values. Also, I have here a case where it worked with unsafe_load() but crashes if I use unsafe_pointer_to_objref() (note that 'image' is a pointer to a composite type) https://github.com/joa-quim/IUP.jl/blob/master/examples/im_view_.jl#L106 I read and reread the docs but find confusing what is a *memory address of a Julia object* is that apparently is different to the pointer obtained with convert() domingo, 18 de Janeiro de 2015 às 06:17:11 UTC, Jiahao Chen escreveu: I don't think the conversion does what you want. Instead you may be looking for this: julia type foo a::Int; b::Int end julia tp=foo(2,3) foo(2,3) julia p=pointer_from_objref(tp) Ptr{Void} @0x7fa70872e188 julia pt=unsafe_pointer_to_objref(p) foo(2,3) Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory
Re: [julia-users] Re: ANN node-julia 1.0.0
Thanks Jeff :) I like your d3 idea, my friends advise that projects that are based on d3 like bokeh go a long way and then get bogged down in details, so heads up, but it's too cool to not try. Hehe. Yes. I have spent a lot of time doing things in SVG that would have been much easier using HTML, e.g. I built an SVG textbox widget because I didn't want to use foreignObject :) Now I just finished a serializer to allow me to save the GUI state, which isn't completely trivial for Javascript modules. This will allow me to do things like undo/redo and I can imagine sharing the GUI display across multiple clients for training and/or streaming, e.g, market data. Unfortunately, incorporating Julia via node-julia will not work when using Nashorn and Avatar.js as they are projects to replace node and v8 not work with them. Nor will node-webkit or atom-shell if you are wanting to go browser-as-desktop-app route, but d3 in a browser still will of course. That does not sound encouraging :) I am probably confused, but in the link, they are talking about running Node in Nashorn and it even points to a list of Node modules they are currently able to run. https://avatar-js.java.net I was hoping node-julia could be added to the list. I guess not? By the way, as I was reading up on Nashorn, I learned that it is intended to be more general than just Javascript in Java. It is supposed to be an architecture for scripting languages in general to run on JVM, i.e. an LLVM for JVM, which begs the question if it now starts to make sense thinking about compiling Julia directly to bytecode for JVM? The Javascript performance seems pretty good. I think that would be a big boost to Julia if you're able to get Java developers on board.
Re: [julia-users] Send composite type to C and get it back
pointer_from_objref is mentioned as a parenthetical, and actually I'm not sure if it needs to be mentioned at all in the manual because this usage is covered by specifying a type of `Any` to ccall. I agree it could be better documented in the stdlib docs. On Sun, Jan 18, 2015 at 11:36 AM, Milan Bouchet-Valat nalimi...@club.fr wrote: Le dimanche 18 janvier 2015 à 10:15 -0500, Isaiah Norton a écrit : I should also emphasize the difference: pointer_from_objref returns a jl_value_t*, which includes the type tag found at the beginning of all (well, most) Julia value instances. With Ptr{T} and v in ccall, you get a pointer to the memory after the type tag, which is C-compatible (provided isbits(T) == true) I think this deserves to be in the manual, and in relevant documentation for functions in stdlib. ?pointer_from_objref and ?pointer do not really allow grasping the difference between the two functions. Regards On Sun, Jan 18, 2015 at 10:12 AM, Isaiah Norton isaiah.nor...@gmail.com wrote: - if you want to pass a pointer to the *complete* Julia type, including the type tag, use pointer_from_objref. From the manual: Julia values v can be converted to jl_value_t*pointers, as Ptr{Void}, by calling pointer_from_objref(v). - if you want to pass a pointer to a C-compatible struct, tell ccall that is what you want, and use the symbol before the variable. From the manual: struct T* (where T represents an appropriately defined bits type) Ptr{T} (call using variable_name in the parameter list) Here is an example: https://gist.github.com/ihnorton/1c1338a22fb3d143fa7f Really the best way to work through these things is to write small examples where you can control everything, and see what happens. Trying to figure it out on the go in a large system with many moving pieces is a recipe for frustration. On Sun, Jan 18, 2015 at 9:28 AM, J Luis jmfl...@gmail.com wrote: Thank you very much Jiahao. That's indeed the result I want ... but sorry, I'm still confused. Why doesn't the other way work too? At the end it also gets composite type with the same members but with a whatever in their values. Also, I have here a case where it worked with unsafe_load() but crashes if I use unsafe_pointer_to_objref() (note that 'image' is a pointer to a composite type) https://github.com/joa-quim/IUP.jl/blob/master/examples/im_view_.jl#L106 I read and reread the docs but find confusing what is a memory address of a Julia object is that apparently is different to the pointer obtained with convert() domingo, 18 de Janeiro de 2015 às 06:17:11 UTC, Jiahao Chen escreveu: I don't think the conversion does what you want. Instead you may be looking for this: julia type foo a::Int; b::Int end julia tp=foo(2,3) foo(2,3) julia p=pointer_from_objref(tp) Ptr{Void} @0x7fa70872e188 julia pt=unsafe_pointer_to_objref(p) foo(2,3) Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory