Re: [julia-users] The function "sum"

2014-11-16 Thread Tamas Papp
If one needs completely accurate floating point summation, I guess they can just convert to Rational{BigInt} and sum them -- it will be expensive, but accurate. But I am wondering why anyone would expect "complete accuracy" from floating point anyway. Best, Tamas On Sat, Nov 15 2014, Stefan Kar

Re: [julia-users] @DSL Domain """ code """

2014-11-16 Thread Kevin Squire
Just as a minor point, Match.jl handles most of the pattern matching functionality of scala (although to match it fully would probably require more support in the parser, or something like what Simon proposes here). Cheers, Kevin On Saturday, November 15, 2014, Simon Danisch wrote: > Hi, > I

Re: [julia-users] @DSL Domain """ code """

2014-11-16 Thread Simon Danisch
I know, it's a pretty awesome package... Macros are already very powerful! The first time were I really thought "oh, we could use some pre AST representation" was rather in the domain of first order logic terms, or intervals. Something like this would be quite hard to implement right now: [image: (

Re: [julia-users] The function "sum"

2014-11-16 Thread Dahua Lin
The current implementation of the sum goes in this way, For arrays longer than a certain threshold (1024, 2048?), it recursively divide the array into two halves, and sum different halves respectively. As the part to be summed gets shorter, it resorts to a four-way sequential summing algorithm

[julia-users] BinDeps: How to access include path?

2014-11-16 Thread Erik Schnetter
I want to wrap a library (hwloc) for Julia. This is working fine. The library defines some C structs that are part of the API. My current approach uses wrapper C functions to access struct elements. Is there a better way? I thus I need to build this wrapper file as well. I created a SimpleBuild r

[julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Johan Sigfrids
Would it be impossible to simply have something like: @Scala begin person *match* { *case* Person("Hans","Meyer",7) => "Found: Hans Meyer" * case* Person("Heinz","Mustermann",28) => "Found: Heinz Mustermann" * case* *_* => "Unknown Person" } end Without having to h

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Simon Danisch
No! The expression between *begin ... end* must still be valid Julia syntax, which is why you need to tell Julia, not to parse it into a Julia AST, but into some intermediate representation. @Scala begin person match { ERROR: syntax: extra token "match" after end of expression 2014-11-

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Isaiah Norton
> > No! The expression between *begin ... end* must still be valid Julia > syntax, which is why you need to tell Julia, not to parse it into a Julia > AST, but into some intermediate representation. > Well, in the examples you showed the command block is passed as string anyway, so the more accura

[julia-users] Re: BinDeps: How to access include path?

2014-11-16 Thread Avik Sengupta
If you redefine the struct as a julia immutable, you can unsafe_load() a pointer to that struct to read off the values in Julia. You can also use it to pass a pointer to the struct into C. This trick can take you quite a way without resorting to a C wrapper. For one example, see: https://g

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Isaiah Norton
> > The library defines some C structs that are part of the API. My > current approach uses wrapper C functions to access struct elements. > Is there a better way? It depends how complicated are the structs. Structs can often be reflected as Julia types, as long as isbits(TypeName) == true, and a

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Iain Dunning
I'd argue (and in fact we have in the academic literature) that JuMP.jl is a DSL for mathematical programming, e.g. m = Model() @defVar(m, x[1:5], Bin) @addConstraint(m, sum{x[i], i=1:5; iseven(i)} <= 2) solve(m) Notice the sum{ } On Sunday, November 16, 2014 10:45:57 AM UTC-5, Isaiah wrote: >

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Erik Schnetter
Thanks for the pointers on immutable types. Is it possible to access structs inside structs this way? That a struct inside a struct, not a pointer inside a struct. Is an immutable type again a bits type? Or do I need to flatten the structs to make this work? -erik On Sun, Nov 16, 2014 at 11:16 A

[julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Simon Danisch
I'd also argue that JuMP is a DSL ;) And I guess it would also profit from having less constraints on the actual syntax and custom syntax highlighting, which doesn't need to be explicitly defined. Keno seems to do a lot of things, which would also be needed for easier DSL generation, like integ

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Tim Holy
AFAIK no need to flatten. Since Isaiah didn't advertise it himself, I'll mention his Clang.jl package, which I've found to be a big help in such situations. It's just possible you may not need any C glue code. --Tim On Sunday, November 16, 2014 12:15:50 PM Erik Schnetter wrote: > Thanks for th

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Jake Bolewski
No need to flatten if everything is immutable. This file has some examples of wrapping structs of structs https://github.com/jakebolewski/LibGit2.jl/blob/cac78b5c03531b5afbcb0ae042538dd351527752/src/types.jl#L19. On Sunday, November 16, 2014 12:33:39 PM UTC-5, Tim Holy wrote: > > AFAIK no need

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Erik Schnetter
Thanks for all the pointers! Things are now working fine without wrapper functions but with 120 lines of immutable type declarations. Clang.jl sounds interesting, but would probably make hwloc.jl too difficult to use if it is a prerequisite. Let's see how often the structs of hwloc change with futu

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Johan Sigfrids
Your right. That is a problem. Is there no way to extend Julia so that you can create a macro that automatically uses a custom parser? On Sunday, November 16, 2014 5:26:26 PM UTC+2, Simon Danisch wrote: > > No! The expression between *begin ... end* must still be valid Julia > syntax, which is w

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Simon Danisch
Well, the DSL macro I sketched out would allow for that. Maybe, if time comes and people think this is a good idea, this could become an extension to normal macros? But first of all, a prototype is needed anyways... How deeply the prototype will be integrated later on depends on the feedback, I gue

[julia-users] sundials does not load

2014-11-16 Thread Michele Zaffalon
With commit https://github.com/JuliaLang/Sundials.jl/commit/9048a493436edf327d884932aa10958297060612, sundials-2.5.0 should be downloaded from the ftp server, but when I do Pkg.add("Sundials"), Julia tries to download from the old URL, computation.llnl.gov. (Manually downloading the tar.gz f

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Tim Holy
The only person who needs to use Clang.jl is the package developer. Clang writes *.jl files that save you the trouble of keyboarding all the julia equivalents of the C structs. It also generates the ccall wrappers. You then write your package on top of those generated files. Clang is therefore o

[julia-users] Re: sundials does not load

2014-11-16 Thread Ivar Nesje
It will be when someone discovers that it is broken and someone updates METADATA.jl with a new version. Asking for help on julia-users is a great way to start. It should work immediately if you do Pkg.checkout("Sundials") Ivar kl. 20:53:07 UTC+1 søndag 16. november 2014 skrev Michele Zaffalon

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Johan Sigfrids
Yeah, that's fair. Its just something inside me that rebels against having code inside strings. On Sunday, November 16, 2014 9:40:07 PM UTC+2, Simon Danisch wrote: > > Well, the DSL macro I sketched out would allow for that. > Maybe, if time comes and people think this is a good idea, this could

[julia-users] How should I structure my code?

2014-11-16 Thread Justas _
Lets say I have this kind of code. How could I access variable M in compute() function? function algoX(data) M,N = size(data) param = 20 computeSomething() end export function computeSomething() a = compute() end function compute() # Needs variable M M * param end I do not want to

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Ivar Nesje
You'd need some sort of special delimiters anyway, and """ is pretty good because it is unlikely to occur in a DSL. It depends on how you look at it, but I'd actually argue that a string macro isn't more like a string than the rest of the code file is a string. Good editors will have a much bet

[julia-users] Re: How should I structure my code?

2014-11-16 Thread Justas _
Updated code snippet: export algoX function algoX(data) M,N = size(data) param = 20 computeSomething() end export computeSomething function computeSomething() a = compute() end export compute function compute() # Needs variable M M * param end

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Simon Danisch
Hehe, yeah I'm not a big fan either. But I've pinned the awkwardness down to the missing syntax highlighting and weird argument passing. Syntax could come "for free" with a good parser design, but argument passing is still a little bit sketchy. But I'm pretty sure, that we can find something satisf

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Erik Schnetter
I see. I was afraid that the C structs may change in between different versions of the library. If the structs are re-analyzed when the wrapper is installed, this would not be an issue. -erik On Sun, Nov 16, 2014 at 2:58 PM, Tim Holy wrote: > The only person who needs to use Clang.jl is the pac

[julia-users] Re: sundials does not load

2014-11-16 Thread Ivar Nesje
This should be fixed now . kl. 21:03:56 UTC+1 søndag 16. november 2014 skrev Ivar Nesje følgende: > > It will be when someone discovers that it is broken and someone updates > METADATA.jl with a new version. Asking for help on julia-users is a

Re: [julia-users] Viewing package code

2014-11-16 Thread Frank Davidson
Thanks, all! On Fri Nov 14 2014 at 6:00:31 PM Isaiah Norton wrote: > somehow screwed up Git so I couldn't Pkg.update() anymore... > > > Use `Pkg.status()` to figure out which are dirty. Then you can do: > > julia> Pkg.cd("PkgName") > shell> git stash # safer, will save changes to a hash outsid

[julia-users] Help with metaprogramming

2014-11-16 Thread Greg Plowman
Hi I'm trying to automate some code and thought Julia's metaprogramming might help, but I've got myself very confused. I have a user-defined composite type, which for different applications, I change the fields. I also want to define some functions for this user type (+, copy, == etc) because

Re: [julia-users] BinDeps: How to access include path?

2014-11-16 Thread Tim Holy
You could indeed have BinDeps generate the wrapper for you, using Clang. But that will require the user to have a full-blown development environment installed. VideoIO is one project I know of that is taking multiple library versions very seriously. --Tim On Sunday, November 16, 2014 03:41:11

[julia-users] Re: Help with metaprogramming

2014-11-16 Thread Simon Danisch
This is not a very good use case for meta programming. Here are two version using dicts and arrays: https://gist.github.com/SimonDanisch/c01235254451f8234e29 Am Sonntag, 16. November 2014 22:09:57 UTC+1 schrieb Greg Plowman: > > Hi > > I'm trying to automate some code and thought Julia's metapro

[julia-users] Re: How should I structure my code?

2014-11-16 Thread Simon Danisch
Why can't you export them? *export foo* exports every method from function foo, so it doesn't matter how many arguments foo has. If *compute *does a calculation depending on m, it's very good design to pass m as an argument to that method. I'm pretty sure you'll find it acceptable to carry your v

Re: [julia-users] Re: Help with metaprogramming

2014-11-16 Thread Tim Holy
julia> type MyType a_1::Float64 a_2::Float64 end julia> using Base.Cartesian julia> function plus(m1::MyType, m2::MyType) @nexprs 2 d->(s_d = m1.a_d + m2.a_d) MyType(s_1, s_2) end plus (generic function with 1 method) julia> m1 = MyType(1

[julia-users] Re: How should I structure my code?

2014-11-16 Thread Justas _
I totally agree that it is good to pass variable M to compute(). But to do that, I need to pass M to computeSomething(), which does not use M at all, and then pass it down to compute. I think it is the best to use Type and pass it as a holder of M and param. Also I tried this export foo fun

[julia-users] SymTridiagonal

2014-11-16 Thread Eka Palamadai
SymTridiagonal does not seem to work properly. For e.g, the following snippet fails. julia> n=10 ; A=SymTridiagonal(2*ones(n,1), -1*ones(n-1)); ERROR: `convert` has no method matching convert(::Type{SymTridiagonal{T}}, ::Array{Float64,2}, ::Array{Float64,1}) in call at base.jl:34 Any thoughts

Re: [julia-users] SymTridiagonal

2014-11-16 Thread Andreas Noack
The input should be two Vectors, but your first argument is a Matrix 2014-11-16 19:25 GMT-05:00 Eka Palamadai : > SymTridiagonal does not seem to work properly. > > For e.g, the following snippet fails. > > julia> n=10 ; > A=SymTridiagonal(2*ones(n,1), -1*ones(n-1)); > ERROR: `convert` has no met

Re: [julia-users] Re: @DSL Domain """ code """

2014-11-16 Thread Jeff Waller
> Its just something inside me that rebels against having code inside strings. Yea, I don't like it either. If feels half-done. New token? @@

[julia-users] Propose making Optim docs more explicit for gradient specification

2014-11-16 Thread Salman Haider
‘Very’ new Julia user here. I wanted to highlight and maybe suggest a modification to the Optim documentation. From the perspective of a new user it isn’t really clear how to specify the gradient. I know the rosenbrock function is the standard way to explain optimization docs but in my opinion

[julia-users] Concrete parametric types

2014-11-16 Thread i . costigan
I've got a parametric type: immutable SplineInterpolator{N<:Integer} <: Interpolator1D end NB: abstract Interpolator abstract Interpolator1D <: Interpolator Now, when I try to create the concrete type... SplineInterpolator{3} ...I get the following error message: ERROR: type: SplineInterpola

[julia-users] Array comparison with float

2014-11-16 Thread Ras Jon
Hej, I've already posted this as issue on Github and got sent here. """ Hej, I was expecting the second command to have the same output as the third. Is this feasible? julia> X=rand(3,1) 3x1 Array{Float64,2}: 0.371312 0.438901 0.767117 julia> X<0.5 ERROR: `isless` has no method matching isle

Re: [julia-users] Array comparison with float

2014-11-16 Thread Andreas Noack
I think you can do tt = 2 .== (EDGES[ii] .<= X) + (X .< EDGES[ii+1]) which I find clearer because the dots signal a broadcast operation. 2014-11-16 19:24 GMT-05:00 Ras Jon : > Hej, > I've already posted this as issue on Github and got sent here. > > """ > Hej, > I was expecting the second command

Re: [julia-users] Concrete parametric types

2014-11-16 Thread Jameson Nash
<: is the subtype operator :: is the isa operator You can't (currently) express conditions of the form you want (except as assertions in the constructor) On Sun, Nov 16, 2014 at 8:03 PM wrote: > I've got a parametric type: > > immutable SplineInterpolator{N<:Integer} <: Interpolator1D end > > NB:

Re: [julia-users] Concrete parametric types

2014-11-16 Thread Isaiah Norton
Aside from the question: there are several interpolation packages that you might be interested in. See: https://github.com/timholy/Grid.jl https://github.com/kbarbary/Dierckx.jl On Sat, Nov 15, 2014 at 5:31 PM, wrote: > I've got a parametric type: > > immutable SplineInterpolator{N<:Integer} <:

Re: [julia-users] Propose making Optim docs more explicit for gradient specification

2014-11-16 Thread Isaiah Norton
One of the best ways to get doc improvements is to send a pull-request with your suggestions. This is especially true for examples, where, as a new (Julia/Optim) user, you can bring a fresh perspective. To do this, create (or log in to) a GitHub account, and navigate to this page: https://github.c

Re: [julia-users] help() doesn't work in REPL in julia-0.4.0-1439 from julianightlies PPA

2014-11-16 Thread Isaiah Norton
If this is not fixed now, please file an issue. On Thu, Nov 13, 2014 at 5:30 PM, Omar Antolín Camarena < omar.anto...@gmail.com> wrote: > The julianightlies PPA at some point moved the documentation into a > separate package, julia-doc, that seems to have a slight problem: > > julia> help(help) >

Re: [julia-users] Re: sundials does not load

2014-11-16 Thread Michele Zaffalon
On Sun, Nov 16, 2014 at 9:03 PM, Ivar Nesje wrote: > It will be when someone discovers that it is broken and someone updates > METADATA.jl with a new version. Asking for help on julia-users is a great > way to start. > > It should work immediately if you do Pkg.checkout("Sundials") > As the manua

[julia-users] Re: Arrayfire and Julia

2014-11-16 Thread Viral Shah
Wow, I did not know about this. We certainly should leverage this. The API looks easy to call too from C, from the examples on their github page, and that is good news for us. -viral On Saturday, November 15, 2014 5:22:17 AM UTC+5:30, Zahirul ALAM wrote: > > thanks. I have been using Julia for