[julia-users] Re: Exponential function approximation

2015-03-04 Thread Dejan Miljkovic
Thanks,

Using reinterpret julia version is

function exp_approx(val::Float64)
return reinterpret(Float64, int(1512775 * val + 1072632447)<<32)
end

Dejan

On Wednesday, March 4, 2015 at 9:59:53 PM UTC-8, Ivar Nesje wrote:
>
> Casting is called reinterpret in Julia. 



[julia-users] Exponential function approximation

2015-03-04 Thread Ivar Nesje
Casting is called reinterpret in Julia. 

Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread Eric Davies


On Wednesday, 4 March 2015 20:15:31 UTC-6, ele...@gmail.com wrote:
>
>
>
> On Thursday, March 5, 2015 at 10:16:30 AM UTC+10, Eric Davies wrote:
>>
>>
>>
>>
>>> I don't have Matlab so I can't try anything, but as a general comment I 
>>> would say that if Julia is going to support embedding in the same process 
>>> it has to cooperate with its host on usage of shared resources like 
>>> signals.  If Julia is simply initialized, runs some code, shuts down and 
>>> returns then saving the sigactions before jl_init and restoring the 
>>> sigactions after Julia shuts down (and before returning to Matlab), for all 
>>> signals Julia uses, should be sufficient, but initializing and shutting 
>>> down each time is expensive.
>>>
>>
>> This is not sufficient, so maybe something else is going wrong, or I'm 
>> not doing it right. It's not that expensive if you're not calling Julia 
>> very often (and not for my purposes). 
>>
>
> Fair enough, note your gist doesn't show you saving and restoring any 
> sigactions, can you post the version where you try to do that?
>

Right, gist now updated with the signal-handling file.
 

>  
>
>>  
>>
>>>
>>> If Julia is to remain initialized then for signals it probably should 
>>> add its actions as Tim pointed out, keeping the old action and, when a 
>>> signal occurs, do something like:
>>>
>>>if in_a_Julia_function then do Julia handler
>>>else do host action
>>>
>>> Of course this doesn't help if Matlab then changes the sigaction again. 
>>>  As its not open its not possible to know if this happens.
>>>
>>> So in the end it may turn out to be more effective to run Julia in 
>>> another process communicating via shared memory. That would probably 
>>> (unbenchmarked of course :) be better performing than re-initalizing Julia 
>>> every time a piece of Julia code is run.
>>>
>>
>> I would agree, but the Julia devs appear to want to make embedding 
>> possible, so that effort may be available. In any case, the overhead of 
>> having to program the communication on both ends is a factor in addition to 
>> performance.
>>
>
> Indeed the communication coding and runtime overhead is an issue,  but it 
> needs to be weighed against issues like:
>
> - IO sharing, Julia/libuv and the host cannot both do a select/poll on the 
> same FDs (eg stdin, stdout, stderr)
>

Admittedly I don't fully understand this. Regardless, PyCall doesn't handle 
this and it has been very popular.

- error/exception handling, preventing them escaping from Julia and/or 
> raising a host exception/error instead
>

This is actually wonderfully easy with the Julia API! One can just check 
`jl_exception_occurred()` after a call and then throw a MATLAB exception if 
something happened.

>
> - signals sharing (as in the OP)
>
> - making sure all the process state is restored when Julia exits, eg 
> rounding modes
>

Rounding modes can be handled pretty easily, and I'm fairly confident we 
can deal with new things as they pop up. At this point I just want a 
non-crashing version of what I have at the moment, which is pretty good!
 

>
> - the opposite of the above, making sure Julia sets up the process state 
> fully, not assuming its a new default process
>

This is definitely harder. But this is a goal for the Julia project given 
that embedding is a goal :)
 

>
> - callbacks into the host, best to forget about that for now :)
>

I can't imagine it would be that hard to write C callbacks given all the 
other interop work that will have already been done. But perhaps I'm naive?
 

>
> Don't underestimate any of those, especially for an opaque host like 
> Matlab.
>
> Cheers
> Lex
>


[julia-users] Exponential function approximation

2015-03-04 Thread Dejan Miljkovic
Any idea how to port below java code to Julia.

Thanks

Dejan

public static double exp(double val) {
 final long tmp = (long) (1512775 * val + 1072632447);
 return Double.longBitsToDouble(tmp << 32);
}


Re: [julia-users] Re: Julia T-shirt and Sticker

2015-03-04 Thread Sorami Hisamoto
It would be nice if Julia T-shirt is on sale to fund JuliaCon 2015. I
guess there are a certain number of people who would buy these Julia
goods if they are on sale.

On Thu, Feb 26, 2015 at 1:01 PM, Aero_flux  wrote:
> How about organising something to help fund JuliaCon 2015 if funding is
> needed. www.spreadshirt.com/ maybe? I would be up for buying one. Would it
> be alright to reproduce one for myself?
>
> On Monday, June 9, 2014 at 10:55:06 PM UTC+1, Rich Morin wrote:
>>
>> I've been looking around for a Julia shirt and wouldn't mind getting a
>> sticker, either. Might there be a way to make these available for resale,
>> letting the proceeds go to the donut fund or somesuch?


Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread elextr


On Thursday, March 5, 2015 at 10:16:30 AM UTC+10, Eric Davies wrote:
>
>
>
>
>> I don't have Matlab so I can't try anything, but as a general comment I 
>> would say that if Julia is going to support embedding in the same process 
>> it has to cooperate with its host on usage of shared resources like 
>> signals.  If Julia is simply initialized, runs some code, shuts down and 
>> returns then saving the sigactions before jl_init and restoring the 
>> sigactions after Julia shuts down (and before returning to Matlab), for all 
>> signals Julia uses, should be sufficient, but initializing and shutting 
>> down each time is expensive.
>>
>
> This is not sufficient, so maybe something else is going wrong, or I'm not 
> doing it right. It's not that expensive if you're not calling Julia very 
> often (and not for my purposes). 
>

Fair enough, note your gist doesn't show you saving and restoring any 
sigactions, can you post the version where you try to do that?
 

>  
>
>>
>> If Julia is to remain initialized then for signals it probably should add 
>> its actions as Tim pointed out, keeping the old action and, when a signal 
>> occurs, do something like:
>>
>>if in_a_Julia_function then do Julia handler
>>else do host action
>>
>> Of course this doesn't help if Matlab then changes the sigaction again. 
>>  As its not open its not possible to know if this happens.
>>
>> So in the end it may turn out to be more effective to run Julia in 
>> another process communicating via shared memory. That would probably 
>> (unbenchmarked of course :) be better performing than re-initalizing Julia 
>> every time a piece of Julia code is run.
>>
>
> I would agree, but the Julia devs appear to want to make embedding 
> possible, so that effort may be available. In any case, the overhead of 
> having to program the communication on both ends is a factor in addition to 
> performance.
>

Indeed the communication coding and runtime overhead is an issue,  but it 
needs to be weighed against issues like:

- IO sharing, Julia/libuv and the host cannot both do a select/poll on the 
same FDs (eg stdin, stdout, stderr)

- error/exception handling, preventing them escaping from Julia and/or 
raising a host exception/error instead

- signals sharing (as in the OP)

- making sure all the process state is restored when Julia exits, eg 
rounding modes

- the opposite of the above, making sure Julia sets up the process state 
fully, not assuming its a new default process

- callbacks into the host, best to forget about that for now :)

Don't underestimate any of those, especially for an opaque host like Matlab.

Cheers
Lex


[julia-users] Re: Using ModX: Can scope avoid collisions & improve readability?

2015-03-04 Thread MA Laforge
Indeed this appears to be the intent: "export" tells the user what you want 
to be his/her interface.

But I have also noticed myself omitting "exports" in order to avoid 
collisions with elements that cannot be resolved by multi-dispatch (like 
type constructors):

module Electronics
type Circuit ... end #Name is very common... don't "export"
end

module RailSystem
type Circuit ... end #Name is very common... don't "export"
end

using Electronics
using RailSystem #No collision with Circuit: because it is not exported

eckt = Electronics.Circuit("rectifier")
railckt = RailSystem.Circuit("Line A")

Otherwise, I would have to use more verbose names (which just seems silly 
to me):
Electronics.Circuit -> Electronics.ElectronicCircuit #Not a common name: 
should be ok to export
RailSystem.Circuit -> RailSystem.RailCircuit #Not a common name: should be 
ok to export


...And maybe that's simply how modules should be defined: Never export 
elements that cannot be resolved by multi-dispatch.

On Tuesday, March 3, 2015 at 8:52:20 AM UTC-5, Patrick O'Leary wrote:
>
> On Monday, March 2, 2015 at 7:45:02 PM UTC-6, MA Laforge wrote:
>>
>> Your comment sounds alot like what Stefan said:
>> https://groups.google.com/d/msg/julia-users/UvBff9QVKaA/P10-LRLezCUJ
>>
>> I admit I don't fully appreciate why this is a *technical* problem.  Most 
>> scoping rules would dictate that you should be referring to the *most 
>> local* version of the value.  In your case bar would come from module Foo.
>>
>
> One counterargument to that is that it makes the most local thing 
> nonlocal--it's an unexported part of Foo. The export list is in part a 
> declaration of "I'm okay with these things sharing namespace if you want," 
> and if you did `export bar` from Foo, then `import Foo`, you'd get what you 
> wanted.
>
> (There's a side discussion about things happening inside functions; I'm 
> not concerned about that here because that can only make things more 
> complicated.)
>


[julia-users] Re: Using ModX: Can scope avoid collisions & improve readability?

2015-03-04 Thread MA Laforge
Josh:
I do not fully appreciate the details of how modules get imported either.  
Here is what I can gather:

module moda
export modvar, setmodvar
modvar = 1
setmodvar(x) = (global modvar=x)
end

module modb
export modvar, setmodvar
modvar = 2
setmodvar(x) = (global modvar=x)
end

module modc
using moda
import modb
println("using moda")
@show modvar, moda.modvar, modb.modvar
@show setmodvar(5)
@show modvar, moda.modvar, modb.modvar
@show modb.setmodvar(3)
@show modvar, moda.modvar, modb.modvar
end

module modd
import moda
using modb
println("using modb")
@show modvar, moda.modvar, modb.modvar
@show setmodvar(8)
@show modvar, moda.modvar, modb.modvar
end

This gives the following results:
using moda
(modvar,moda.modvar,modb.modvar) => (1,1,2)
setmodvar(5) => 5
(modvar,moda.modvar,modb.modvar) => (5,5,2)
modb.setmodvar(3) => 3
(modvar,moda.modvar,modb.modvar) => (5,5,3)
using modb
(modvar,moda.modvar,modb.modvar) => (3,5,3)
setmodvar(8) => 8
(modvar,moda.modvar,modb.modvar) => (8,5,8)

So it looks like it is the same code in the background (at least the 
variables appear to be in a common address space).

So... it looks like import merely "makes visible"  the code at a module 
level...
And "using" first "imports", then "provides a shortcut" to the exported 
variables/functions...

But as far as I can tell, compilation is done "on demand".  I believe that 
the "real" compile step is done when we call a particular version of the 
code.  Compilation is actually a separate step from "using" and "import"


On Tuesday, March 3, 2015 at 11:48:53 AM UTC-5, Josh Langsfeld wrote:
>
> I'm curious about that workaround suggested in the FAQ, where you wrap the 
> function inside its own module. What is happening under the hood there? 
> Does it reinitialize the desired module entirely inside of the wrapper 
> module or does it just make a reference to some other compiled and 
> initialized top-level area? This is assuming the module has already been 
> built elsewhere and you just want easy local access to the exported symbols.
>
> On Monday, March 2, 2015 at 5:59:30 PM UTC-5, ele...@gmail.com wrote:
>>
>> The C++ "using namespace" and Julia "using module" are not quite the same 
>> thing.  The C++ namespace is a top level entity that is created and 
>> initialized as part of the C++ startup code and the "using" just makes the 
>> names of these global entities available within the scope.   The Julia 
>> "using" imports, and thus creates, the module for the first time, and Julia 
>> modules can contain statements that run at initialization, whereas C++ 
>> namespaces can only contain declarations.  
>>
>> But if the Julia "using" is within the function, when should the actual 
>> import and initialize and execute the statements be done?  Every time the 
>> function is called is very expensive.  Hoist the import out of the function 
>> to the top level, but doing this naively (ie putting the hoisted import 
>> just before the function) will then affect all code following the function 
>>  Have a "pseudo" top- level visible only to the function adds a complete 
>> new complication to the name management code.  But then what happens if the 
>> module is imported into two functions, how is its initialization managed? 
>> Or the top level and the function?
>>
>> So for now the "simpler is better" approach is to have the user manage 
>> importing at the top level only.
>>
>> Cheers
>> Lex
>>
>> On Tuesday, March 3, 2015 at 7:23:33 AM UTC+10, Josh Langsfeld wrote:
>>>
>>> It's discussed in the FAQ so there must be a good reason for it, though 
>>> no rationale is mentioned.
>>>
>>>
>>> http://docs.julialang.org/en/latest/manual/faq/#can-i-use-using-or-import-inside-a-function
>>>
>>> On Monday, March 2, 2015 at 3:00:21 PM UTC-5, Patrick O'Leary wrote:

 On Saturday, February 28, 2015 at 11:06:38 AM UTC-6, MA Laforge wrote:
>
> C++ provides "using namespace X" to "make available" the contents of X 
> to the current scope.  This even works on un-named scopes within a 
> function:
>

 (etc.)

 I know this is something that's come up before, and I think rejected--I 
 think because it causes conflicts with multiple dispatch? But I can't seem 
 to find the thread(s).

 I can't create a hard conflict in a quick mental search for an example, 
 but I can create some level of confusion:

 module Foo
 bar::Int = 1
 end

 module Baz
 bar::Float64 = 27.3
 with module Foo # not current Julia syntax
 bar #which bar is this?
 end
 end

>>>

Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread Eric Davies



> I don't have Matlab so I can't try anything, but as a general comment I 
> would say that if Julia is going to support embedding in the same process 
> it has to cooperate with its host on usage of shared resources like 
> signals.  If Julia is simply initialized, runs some code, shuts down and 
> returns then saving the sigactions before jl_init and restoring the 
> sigactions after Julia shuts down (and before returning to Matlab), for all 
> signals Julia uses, should be sufficient, but initializing and shutting 
> down each time is expensive.
>

This is not sufficient, so maybe something else is going wrong, or I'm not 
doing it right. It's not that expensive if you're not calling Julia very 
often (and not for my purposes). 
 

>
> If Julia is to remain initialized then for signals it probably should add 
> its actions as Tim pointed out, keeping the old action and, when a signal 
> occurs, do something like:
>
>if in_a_Julia_function then do Julia handler
>else do host action
>
> Of course this doesn't help if Matlab then changes the sigaction again. 
>  As its not open its not possible to know if this happens.
>
> So in the end it may turn out to be more effective to run Julia in another 
> process communicating via shared memory. That would probably (unbenchmarked 
> of course :) be better performing than re-initalizing Julia every time a 
> piece of Julia code is run.
>

I would agree, but the Julia devs appear to want to make embedding 
possible, so that effort may be available. In any case, the overhead of 
having to program the communication on both ends is a factor in addition to 
performance.


Re: [julia-users] Re: Functions in degrees

2015-03-04 Thread MA Laforge
Fair enough.  I don't want to stifle the adoption of Julia by other 
developers.

Maybe Ivar is correct: This might be better suited to be implemented as a 
3rd party library.  Maybe SIUnits (https://github.com/Keno/SIUnits.jl)

On Wednesday, March 4, 2015 at 9:04:30 AM UTC-5, Patrick O'Leary wrote:
>
> On Tuesday, March 3, 2015 at 2:57:28 PM UTC-6, Stuart Brorson wrote:
>>
>> Since types should be used sparingly, I don't think it a good idea to 
>> replace convenience functions like sind and cosd with a type-driven 
>> invocation mechanism -- ordinary users will be confused.
>>
>
> You also can't replace all of them, since the inverse functions can't be 
> dispatched in this way. Anecdotally, I use atan2d more than any of the 
> other *d functions, typically as a step on the way to making a plot. 
>


Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread elextr
This is a hard problem to solve generally, in another context I worked on, 
it took a huge amount of effort to embed (in the same process) a previously 
standalone language whose runtime assumed it had sole use of all resources.

I don't have Matlab so I can't try anything, but as a general comment I 
would say that if Julia is going to support embedding in the same process 
it has to cooperate with its host on usage of shared resources like 
signals.  If Julia is simply initialized, runs some code, shuts down and 
returns then saving the sigactions before jl_init and restoring the 
sigactions after Julia shuts down (and before returning to Matlab), for all 
signals Julia uses, should be sufficient, but initializing and shutting 
down each time is expensive.

If Julia is to remain initialized then for signals it probably should add 
its actions as Tim pointed out, keeping the old action and, when a signal 
occurs, do something like:

   if in_a_Julia_function then do Julia handler
   else do host action

Of course this doesn't help if Matlab then changes the sigaction again.  As 
its not open its not possible to know if this happens.

So in the end it may turn out to be more effective to run Julia in another 
process communicating via shared memory. That would probably (unbenchmarked 
of course :) be better performing than re-initalizing Julia every time a 
piece of Julia code is run.

Cheers
Lex

On Thursday, March 5, 2015 at 8:51:19 AM UTC+10, Eric Davies wrote:
>
> It appears as if that did not solve the problem, though I verified that it 
> did what was intended. This is unfortunate. I'll continue looking at this 
> for a day or two but I'm not confident I can find a solution alone. Here is 
> a minimal set of code to replicate: 
> https://gist.github.com/iamed2/e883c6b0b8ff4220d946
>
> On Wednesday, 4 March 2015 06:06:19 UTC-6, Tim Holy wrote:
>>
>> It seems possible we should add a second "boolean" argument to 
>> _julia_init (in 
>> init.c) that controls whether the signal handlers get set. But as a 
>> workaround: 
>>
>> http://stackoverflow.com/questions/9495113/how-to-get-the-handlers-name-address-for-some-signals-e-g-sigint-in-postgres
>>  
>>
>> You could at least test whether that solves the problem, and then if so 
>> perhaps it would be worth opening an issue in julia about whether we need 
>> a 
>> better solution. 
>>
>> BTW, I'm interested in this topic too; see also 
>> https://groups.google.com/d/msg/julia-users/dP_J5KilsEs/4CIERQ14vdgJ. We 
>> should collaborate on a single solution (and it sounds like you're 
>> farther 
>> along and perhaps more invested). I'm happy to pitch in if code gets 
>> posted 
>> somewhere. 
>>
>> --Tim 
>>
>> On Tuesday, March 03, 2015 09:18:04 PM Eric Davies wrote: 
>> > Hi all, 
>> > 
>> > I'm attempting to embed julia in a MATLAB MEX file. Everything is going 
>> > great, but MATLAB will sometimes segfault after having run some code 
>> > calling Julia.* I believe I have narrowed it down to this 
>> > issue: http://ubuntuforums.org/showthread.php?t=2093057 . Basically, I 
>> > believe Julia is registering a SIGSEGV (or maybe other signal?) handler 
>> > that overwrites the default for the JVM set by MATLAB. after the Julia 
>> > function is done, that memory is freed. Then a segfault (or maybe other 
>> > signal?) happens in the JVM and it tries to call Julia's handler but 
>> > segfaults (again) as it is no longer there. 
>> > 
>> > Can anyone help me find a workaround? Perhaps if there's a way to 
>> > "deregister" the handler, or if someone knows a way to get the current 
>> > handler (before calling into Julia) and then setting it back to that 
>> after 
>> > Julia is done. 
>> > 
>> > I've never dealt with signals in C before so I apologize if I'm 
>> describing 
>> > things incorrectly or missing something. 
>> > 
>> > Thanks, 
>> > Eric 
>> > 
>> > *I am able to reliably reproduce this by running any MEX function 
>> linking 
>> > to Julia and calling jl_init, then calling `help clear` in MATLAB. 
>> > 
>> > P.S.: I'm on Mac OS X 10.10 with MATLAB R2012b and Julia 
>> v0.3.6/v0.4.0-dev 
>>
>>

[julia-users] Re: Equivalent of MATLAB's nargout in Julia

2015-03-04 Thread Pooya
Thanks for your response. I am not sure what you mean by a lower-level 
subroutine. Is that a function inside another one? If yes, How does the 
scope of variables work for that? 

Also, if I have what you called the lower level subroutine for output 1 in 
addition to passing the necessary data for output 2, why do I need to write 
two other functions? Isn't it enough to just write one more to do the 
computations for output 2 ?

On Wednesday, March 4, 2015 at 2:16:11 PM UTC-5, Steven G. Johnson wrote:
>
>
>
> On Wednesday, March 4, 2015 at 11:48:28 AM UTC-5, Pooya wrote:
>>
>> I have a function with two outputs. The second one is computationally 
>> expensive, so I want to avoid the computation unless the user needs it. I 
>> read on another post in the group that the solution in this case is usually 
>> to define two functions, but in this case I basically need to do all the 
>> computations for the first output to compute the second. Is there any nicer 
>> way to do this in julia? In MATLAB, I would just say:
>>
>
> Refactorize the code: write a lower-level subroutine that does all the 
> computations for the first output and returns the data needed to compute 
> the second output.   Then write two functions, one which computes and 
> returns only the first output, and one which computes both the first and 
> second outputs.
>
> As others have mentioned, Julia doesn't have nargout.   You could use an 
> optional input argument or a keyword or something to decide whether to 
> compute the second output, but this is usually a bad idea: making the 
> number of output arguments depend on the values of the input arguments 
> makes the function type-unstable, and could screw up performance of 
> anything that calls your function.
>


Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread Eric Davies
It appears as if that did not solve the problem, though I verified that it 
did what was intended. This is unfortunate. I'll continue looking at this 
for a day or two but I'm not confident I can find a solution alone. Here is 
a minimal set of code to 
replicate: https://gist.github.com/iamed2/e883c6b0b8ff4220d946

On Wednesday, 4 March 2015 06:06:19 UTC-6, Tim Holy wrote:
>
> It seems possible we should add a second "boolean" argument to _julia_init 
> (in 
> init.c) that controls whether the signal handlers get set. But as a 
> workaround: 
>
> http://stackoverflow.com/questions/9495113/how-to-get-the-handlers-name-address-for-some-signals-e-g-sigint-in-postgres
>  
>
> You could at least test whether that solves the problem, and then if so 
> perhaps it would be worth opening an issue in julia about whether we need 
> a 
> better solution. 
>
> BTW, I'm interested in this topic too; see also 
> https://groups.google.com/d/msg/julia-users/dP_J5KilsEs/4CIERQ14vdgJ. We 
> should collaborate on a single solution (and it sounds like you're farther 
> along and perhaps more invested). I'm happy to pitch in if code gets 
> posted 
> somewhere. 
>
> --Tim 
>
> On Tuesday, March 03, 2015 09:18:04 PM Eric Davies wrote: 
> > Hi all, 
> > 
> > I'm attempting to embed julia in a MATLAB MEX file. Everything is going 
> > great, but MATLAB will sometimes segfault after having run some code 
> > calling Julia.* I believe I have narrowed it down to this 
> > issue: http://ubuntuforums.org/showthread.php?t=2093057 . Basically, I 
> > believe Julia is registering a SIGSEGV (or maybe other signal?) handler 
> > that overwrites the default for the JVM set by MATLAB. after the Julia 
> > function is done, that memory is freed. Then a segfault (or maybe other 
> > signal?) happens in the JVM and it tries to call Julia's handler but 
> > segfaults (again) as it is no longer there. 
> > 
> > Can anyone help me find a workaround? Perhaps if there's a way to 
> > "deregister" the handler, or if someone knows a way to get the current 
> > handler (before calling into Julia) and then setting it back to that 
> after 
> > Julia is done. 
> > 
> > I've never dealt with signals in C before so I apologize if I'm 
> describing 
> > things incorrectly or missing something. 
> > 
> > Thanks, 
> > Eric 
> > 
> > *I am able to reliably reproduce this by running any MEX function 
> linking 
> > to Julia and calling jl_init, then calling `help clear` in MATLAB. 
> > 
> > P.S.: I'm on Mac OS X 10.10 with MATLAB R2012b and Julia 
> v0.3.6/v0.4.0-dev 
>
>

Re: [julia-users] Unevenly distributed arrays

2015-03-04 Thread Simone Ulzega
Thank you Andreas. Is there any plan to implement something more flexible 
in the near future? 
 

On Wednesday, March 4, 2015 at 10:09:41 PM UTC+1, Andreas Noack wrote:
>
> I don't think it is possible right now. We have been discussing more 
> flexible solutions, but so far nothing has been done.
>
> 2015-03-04 9:22 GMT-05:00 Simone Ulzega 
> >:
>
>> Is it possible to construct a DArray with unevenly distributed chunks? 
>> For example, I want to create a distributed array with size (5*n,), where 
>> n is an integer, on 4 processes. 
>> For some reasons I want uneven chunks of sizes n, 2*n, n and n.
>>
>> The syntax 
>>
>> DArray(size) do I  end  
>>
>> doesn't seem to work as I is automatically generated to have, obviously, 
>> evenly distributed chunks on the available processes. 
>>
>
>

Re: [julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Robert
Dear Mike, thanks a lot for your reply! I will study Juno again, in a 
couple of days when I calmed down from my frustrating 2 weeks to get 
started with Julia. I here would like to express to you my big THANK YOU! I 
really appreciate your efforts in the Juno development, and with my (only) 
two years of more serious programming experience (mainly MATLAB, some few 
Python, some few C++) I am absolutely aware about the high quality of your 
work.
My problem with Juno actually is a problem with the concept of the Light 
Table user interface, and not with your Juno plugin: to me it appears that 
you can only use LightTable effective, if you learned about a bunch of 
shortcuts and are able to handle in your head the work you want to do so 
much that you don't worry anymore about the tool (the editor) to be 
configured to the one or the other appearance. Like it is also with using a 
shell, a bash shell, or the windows command line. But if your brain (I 
actually speak here about _my_ brain) is not as good in abstracting and 
memorizing things, then a visual guidance helps a lot(!) to still get 
complicated tasks done. This visual guidance is missing in LightTable, 
subsequently is missing in Juno. It has a good reason that the graphical 
user interface with mouse control has been developed, and especially that 
it became such a success: click on a drop down menu to see what 
possibilities are offered by the software, call it by a click, and by time 
use the shortcut for that function, or rightclick somewhere for a context 
menu and proceed alike. Tile a tab horizontally and keep visible some 
example text i.e. in the upper part while typing far away in the file in 
the lower part of the tiled tab. Write at a place which appears at a 
certain position on your computer screen, and receive some ouptut always at 
some other certain position at the screen, without the output affecting the 
position on the screen where you would like to just go ahead with writing 
something more. That is a perfectly foreseeable and and guiding behaviour, 
and is what makes the other IDEs (Visual Study, Eclipse, Spyder) so 
successful, if not speaking about their powerful engines to take work load 
regarding house keeping the project and build process automation off from 
the user. Well, Juno at LightTable is a powerful engine as well, but the 
frontend of LightTable is - let´s say much different. I know that there are 
also the emacs and the vim users, and LightTable might be an interesting 
tool for those users. But there are also many people who are not so much in 
favour with emacs or vim, using those editors only if no other option is 
available, and the same people might then not be so much in favour with a 
LightTable based IDE neither. Although the interactive engine of Juno is 
impressive, I just couldn't get warm with the allover (almost) mouse-less 
design of LightTable and the at the same time vast amount of vertical 
scrolling needed. While I am absolutely aware about LightTable being an 
extremely powerful tool for many programmers, I still would wish to find 
enhanced Julia handling by a SPYDER or MATLAB alike IDE. Fortunately for 
LightTable liking programmers you made Juno available, and I see that it is 
some great work. Unfortunately nothing alike is available for SPYDER by 
now. 
O.K., I will take a break now for some days, and next week pick up again 
the fight for setting up a for me comfortable Julia programming environment.


Re: [julia-users] Re: create directory from a julia script

2015-03-04 Thread Diego Tapias
Thanks Jack.

2015-03-04 14:02 GMT-06:00 Jack Minardi :

> help?> mkdir
>
> INFO: Loading help data...
>
> Base.mkdir(path[, mode])
>
>
>Make a new directory with name "path" and permissions "mode".
>
>"mode" defaults to 0o777, modified by the current file creation
>
>mask.
>
>
> On Wednesday, March 4, 2015 at 2:39:18 PM UTC-5, Diego Tapias wrote:
>>
>> Is there a way to create a directory from a julia script? I am thinking
>> in something like os.mkdirs(dir) of Python.
>> ​
>>
>


Re: [julia-users] Unevenly distributed arrays

2015-03-04 Thread Andreas Noack
I don't think it is possible right now. We have been discussing more
flexible solutions, but so far nothing has been done.

2015-03-04 9:22 GMT-05:00 Simone Ulzega :

> Is it possible to construct a DArray with unevenly distributed chunks?
> For example, I want to create a distributed array with size (5*n,), where
> n is an integer, on 4 processes.
> For some reasons I want uneven chunks of sizes n, 2*n, n and n.
>
> The syntax
>
> DArray(size) do I  end
>
> doesn't seem to work as I is automatically generated to have, obviously,
> evenly distributed chunks on the available processes.
>


Re: [julia-users] Can I use Julia to read/modify/write LLVM IR?

2015-03-04 Thread Isaiah Norton
>
> I was under the impression that the LLVM language was actually pretty
> stable across versions
>

A little bit? Not really something I would want to try to debug though...
http://stackoverflow.com/questions/15836430/how-stable-is-the-llvm-assembly-language

It is definitely not portable across platforms even at the same version,
which is where this usually comes up.





On Mon, Mar 2, 2015 at 11:21 AM, Stefan Karpinski 
wrote:

> On Thu, Feb 26, 2015 at 10:03 AM, Isaiah Norton 
> wrote:
>
>> Is LLVM IR code portable across different LLVM and Clang versions?
>>
>>
>> No.
>>
>
> I was under the impression that the LLVM language was actually pretty
> stable across versions, although the C++ API for creating and manipulating
> it is not.
>


[julia-users] Re: create directory from a julia script

2015-03-04 Thread Jack Minardi


help?> mkdir

INFO: Loading help data...

Base.mkdir(path[, mode])


   Make a new directory with name "path" and permissions "mode".

   "mode" defaults to 0o777, modified by the current file creation

   mask.


On Wednesday, March 4, 2015 at 2:39:18 PM UTC-5, Diego Tapias wrote:
>
> Is there a way to create a directory from a julia script? I am thinking in 
> something like os.mkdirs(dir) of Python.
> ​
>


[julia-users] Re: PyPlot figures

2015-03-04 Thread Josh Langsfeld
Ok, I got it working by doing pygui(:qt) or pygui(:gtk) before the 'using 
PyPlot' call and mentioned in your docs.

I'm not totally clear what 'non-interactive' means for the backend. Working 
directly in the REPL, is that not a default setting? And is that what I 
ended up changing with either of those pygui calls?

Thanks!

On Wednesday, March 4, 2015 at 2:12:35 PM UTC-5, Steven G. Johnson wrote:
>
> Maybe use a non-interactive backend?   Does it do what you want if you use 
> Python?
>


[julia-users] create directory from a julia script

2015-03-04 Thread Diego Tapias
Is there a way to create a directory from a julia script? I am thinking in
something like os.mkdirs(dir) of Python.
​


[julia-users] Re: How to satisfy this deprecation warning?

2015-03-04 Thread Steven G. Johnson
You can also use "fill", e.g.:

  fill(convert(Ptr{Uint8},0), 2)


[julia-users] Re: PyPlot figures

2015-03-04 Thread Steven G. Johnson
Maybe use a non-interactive backend?   Does it do what you want if you use 
Python?


[julia-users] Re: Equivalent of MATLAB's nargout in Julia

2015-03-04 Thread Steven G. Johnson


On Wednesday, March 4, 2015 at 11:48:28 AM UTC-5, Pooya wrote:
>
> I have a function with two outputs. The second one is computationally 
> expensive, so I want to avoid the computation unless the user needs it. I 
> read on another post in the group that the solution in this case is usually 
> to define two functions, but in this case I basically need to do all the 
> computations for the first output to compute the second. Is there any nicer 
> way to do this in julia? In MATLAB, I would just say:
>

Refactorize the code: write a lower-level subroutine that does all the 
computations for the first output and returns the data needed to compute 
the second output.   Then write two functions, one which computes and 
returns only the first output, and one which computes both the first and 
second outputs.

As others have mentioned, Julia doesn't have nargout.   You could use an 
optional input argument or a keyword or something to decide whether to 
compute the second output, but this is usually a bad idea: making the 
number of output arguments depend on the values of the input arguments 
makes the function type-unstable, and could screw up performance of 
anything that calls your function.


Re: [julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Mike Innes
Robert, I think it might be helpful to point you towards the Juno docs:

http://junolab.org/docs/

If you look over it you should find references for the basic commands
you'll need (really you shouldn't need many at all), and if there's
anything missing I'm happy to help out / add things in. Should help take
the guesswork out of things.

That said, I appreciate that Juno isn't for everyone right now. I do
eventually want for it to be a great tool for new users (and old ones), so
hopefully when you come back things will look up a bit.

So I think that Julia is fantastic, but you sell people on packages, not
> the language. The language enables better packages to be made.


This can't really be emphasised enough, I think. Julia is nothing short of
freakin' awesome for building APIs and libraries, but at the user level
it's often a painful experience compared to Python and friends. You don't
realise this until you're doing a hackathon and realise you don't have time
to (re-) implement all the libraries you need ;)

Of course, the former point will mean that the latter one will change with
time, and I think we're beginning to see that.

On 4 March 2015 at 17:42, Robert  wrote:

> I tried to use Julia, but give up. Right now.
> I just came here to search again for posts about IDEs for Julia and found
> this thread. So let me comment why I am giving up: because there is no IDE
> available which would really support me to get my things done.
>
> MATLAB speed can be slow, and Julia might be faster, but my limited
> programming skills are by far the most significant factor lowering progress
> speed. MATLAB, as you all know, is not just a language, it is a very
> advanced programming environment, with rich documentation, including
> tutorials and code examples for beginners. It is a useful tool also for
> people who are not first hand programmers, but just people who need to get
> a solution for a problem glued together. Nothing against the Julia REPL,
> but that is just not a straight forward environment like the IDE of MATLAB
> with a "variable" browser, an editor with code folding and cell evaluation,
> etc, tools for data inspection and IDE and data output configure
> possibilities, and File Exchange and Help forums serving you with whatever
> you might need. Although Julia is an impressive language project, its
> infrastructure is not. Not at all. I just tried to get warm with Juno, for
> several days. No way, it is not intuitive to handle. I have -as a not
> native english speaker- to guess english words for putting them into the
> CTRL+Space command line just to hope that maybe some useful link to a
> function appears. If not, then I wonder if my search term was not the
> correct one or if a function does not exist. Simple tasks like changing the
> background and foreground colors of the editor are not available. Maybe
> such functionality is available, but first you have to study for a week how
> LightTable is programmed, and learn how to program its configuration files.
> And things which work on my Win7 computer do not work on my WinXP notebook.
> Eclipse integration of Julia is costly and still not rich, Spyder
> integration is hard to find, IJulia is not really comparable with a full
> featured editor or IDE neither.
>
> Conclusion: in order to get my programming work done, I either would have
> to spend a lot of time to study too many new tools without finding in them
> convenient and known workflow offered as in MATLAB, SPYDER, ECLIPSE or MS
> Visual Studio, or I just don't start to use Julia by now and better wait
> until the infrastructure supporting the language became built as well.
> Don't get me wrong, I am impressed by the Julia project, and all of you out
> there designing tools like Juno for sure are far ahead of me in your
> programming skills and it is my fault to not have gained skills enough to
> support the Julia world myself with some useful utility. Well, I am just a
> user. A user looking forward to come back to Julia when the infrastructure
> more addresses also the not-professional-programmer and the
> not-million-key-shortcut-knowing scientist who just needs to get some
> algorithm up and running. I guess that is why you find it hard to attract
> new, "normal" users to use Julia. Julia to me still appears to be only made
> for geeks, not because of the language, not because of programming
> something in Julia, but because you have to be a geek to handle Julia, you
> have to be a geek to first get a whole programming environment set up by
> yourself - instead of just using one and concentrate on you Julia algorithm.
>


Re: [julia-users] Re: Complex matches in strings

2015-03-04 Thread Tamas Papp
Sorry, then I misunderstood. In that case, regular expressions are
probably your best option.

HTH,

Tamas

On Wed, Mar 04 2015, Nils Gudat  wrote:

> Hi Tamas,
>
> Not sure I'm correct, but I think what you're suggesting won't work, as I 
> can't split by string2 separately - I only want to find substrings, that 
> are in between the combination "string1[10-15 characters]string2" and 
> "string3". As an example, I would need to find:
>
> string1Xstring2DATAstring3
> string1string2DATAstring3
>
> but there's lots more mentions of string1 and string2 in the data set that 
> don't follow this pattern, for which I don't want to extract the following 
> substring.



[julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Robert
I tried to use Julia, but give up. Right now.
I just came here to search again for posts about IDEs for Julia and found 
this thread. So let me comment why I am giving up: because there is no IDE 
available which would really support me to get my things done.

MATLAB speed can be slow, and Julia might be faster, but my limited 
programming skills are by far the most significant factor lowering progress 
speed. MATLAB, as you all know, is not just a language, it is a very 
advanced programming environment, with rich documentation, including 
tutorials and code examples for beginners. It is a useful tool also for 
people who are not first hand programmers, but just people who need to get 
a solution for a problem glued together. Nothing against the Julia REPL, 
but that is just not a straight forward environment like the IDE of MATLAB 
with a "variable" browser, an editor with code folding and cell evaluation, 
etc, tools for data inspection and IDE and data output configure 
possibilities, and File Exchange and Help forums serving you with whatever 
you might need. Although Julia is an impressive language project, its 
infrastructure is not. Not at all. I just tried to get warm with Juno, for 
several days. No way, it is not intuitive to handle. I have -as a not 
native english speaker- to guess english words for putting them into the 
CTRL+Space command line just to hope that maybe some useful link to a 
function appears. If not, then I wonder if my search term was not the 
correct one or if a function does not exist. Simple tasks like changing the 
background and foreground colors of the editor are not available. Maybe 
such functionality is available, but first you have to study for a week how 
LightTable is programmed, and learn how to program its configuration files. 
And things which work on my Win7 computer do not work on my WinXP notebook. 
Eclipse integration of Julia is costly and still not rich, Spyder 
integration is hard to find, IJulia is not really comparable with a full 
featured editor or IDE neither.

Conclusion: in order to get my programming work done, I either would have 
to spend a lot of time to study too many new tools without finding in them 
convenient and known workflow offered as in MATLAB, SPYDER, ECLIPSE or MS 
Visual Studio, or I just don't start to use Julia by now and better wait 
until the infrastructure supporting the language became built as well. 
Don't get me wrong, I am impressed by the Julia project, and all of you out 
there designing tools like Juno for sure are far ahead of me in your 
programming skills and it is my fault to not have gained skills enough to 
support the Julia world myself with some useful utility. Well, I am just a 
user. A user looking forward to come back to Julia when the infrastructure 
more addresses also the not-professional-programmer and the 
not-million-key-shortcut-knowing scientist who just needs to get some 
algorithm up and running. I guess that is why you find it hard to attract 
new, "normal" users to use Julia. Julia to me still appears to be only made 
for geeks, not because of the language, not because of programming 
something in Julia, but because you have to be a geek to handle Julia, you 
have to be a geek to first get a whole programming environment set up by 
yourself - instead of just using one and concentrate on you Julia algorithm.


[julia-users] Re: Complex matches in strings

2015-03-04 Thread Nils Gudat
Hi Tamas,

Not sure I'm correct, but I think what you're suggesting won't work, as I 
can't split by string2 separately - I only want to find substrings, that 
are in between the combination "string1[10-15 characters]string2" and 
"string3". As an example, I would need to find:

string1Xstring2DATAstring3
string1string2DATAstring3

but there's lots more mentions of string1 and string2 in the data set that 
don't follow this pattern, for which I don't want to extract the following 
substring.


Re: [julia-users] Type for eigs result

2015-03-04 Thread Jiahao Chen
I believe the syntax of eigs() was meant to mimic MATLAB. In principle
we could return a custom-purpose type as the result. Note, however,
that not all fields will be populated, depending on what was
requested.

> Any function that depends only on the eigenvalues and eigenvectors can take 
> either an Eigen or an EigsResult because they have the same field names.

No, it is not sufficient to have the same field names if you truly
meant to have EigsResult be a drop-in replacement for Eigen. The
fields have to have the same dimensions as well. Note that eigs by
default only returns 6 eigenpairs, which could confuse any code
expecting to have all of them computed. Worse if you specify
ritzvec=false, in which case you would get a Nx0 array of
EigsResults.vectors and any code expecting the presence of
eigenvectors would fail. You could insert runtime checks in all the
functions you use that want to use both Eigen and EigsResults to check
for all these cases, but at that point you might as well write
specialized methods that use EigResults.
Thanks,

Jiahao Chen
Staff Research Scientist
MIT Computer Science and Artificial Intelligence Laboratory


On Wed, Mar 4, 2015 at 8:48 AM, James Fairbanks  wrote:
> We have Base.LinAlg.eig return a tuple of (values,vectors) and
> Base.LinAlg.eigfact returns a type for the result Base.LinAlg.Eigen. But
> Base.LinAlg.eigs returns a tuple would it be worth having a variant of eigs
> that returns a type such as EigsResult?
>
> @doc """a type for the output of eigs
>
>
>"eigs" returns the "nev" requested eigenvalues in "d", the
>corresponding Ritz vectors "v" (only if "ritzvec=true"), the
>number of converged eigenvalues "nconv", the number of iterations
>"niter" and the number of matrix vector multiplications
>"nmult", as well as the final residual vector "resid".
>
>
>""" ->
> type EigsResult{T, R}
>  values::Array{T,1}
>  vectors::Array{T,2}
>  nconv::Int64
>  niter::Int64
>  nmult::Int64
>  resid::Array{R,1}
> end
>
>
> function EigsResult(A; args...)
>  @show args
>  tupl = eigs(A; args...)
>  T = eltype(tupl[1])
>  R = eltype(tupl[end])
>  EigsResult{T,R}(tupl...)
> end
>
> Any function that depends only on the eigenvalues and eigenvectors can take
> either an Eigen or an EigsResult because they have the same field names.
>
> James Fairbanks


Re: [julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Jiahao Chen
Quoth Haskell: avoid success at all costs.


[julia-users] Re: PyPlot figures

2015-03-04 Thread Josh Langsfeld
Ah of course all I needed was pygui(false). I should have tried that but my 
brain kept thinking it had something to do with not blocking julia.

But now it seems that I can't control the figure size at all. No matter 
what I say in figure(figsize=(w,h)), the output file has the same 
dimensions. Any idea how I can fix this?

On Wednesday, March 4, 2015 at 11:32:01 AM UTC-5, Josh Langsfeld wrote:
>
> In PyPlot.jl, is there a way to create my figures and render them without 
> a figure window getting created? My window manager is interfering with the 
> size hint in the figure() function so it would be nice if I can go straight 
> to a file.
>
> Thanks,
> Josh
>


[julia-users] Re: Complex matches in strings

2015-03-04 Thread Tamas Papp
Maybe something like

function mysplit(s)
  a = split(s, "string1")
  b = split(a[2], "string2")
  c = split(b[2], "string3")
  (b[1],c[1])
end

julia> s = "string1[10-15 characters]string2[string I need to 
extract]string3"
julia> mysplit(s)
("[10-15 characters]","[string I need to extract]")

HTH,

Tamas

On Wednesday, March 4, 2015 at 5:58:41 PM UTC+1, Nils Gudat wrote:
>
> I'm trying to do some web scraping in Julia and have downloaded a web page 
> as a UTF8String via Requests.jl. Now I need to extract some data from this, 
> but unfortunately the structure of the page is a bit messy, and it seems 
> the only way to get what I need is to extract a substring between two other 
> substrings. The structure would look something like
>
> "string1"[10-15 characters]"string2"[string I need to extract]"string3"
>
> Do I need to use regular expressions for this or is there an easier option 
> in Julia to match these sorts of more complex string patterns?
>
> Thanks!
>


Re: [julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Isaiah Norton
>
> For this reason, while I am happy to talk about how nice Julia is, I
> will not try to convince people to switch to it. IMO the people who are
> potential switchers at this stage have already looked at Julia, and
> evangelizing more aggressively could be counterproductive at this stage.


Big +1 to this. Raising awareness is fine, but at this stage we have a
fairly healthy
rate of organic growth. Overselling will at best just be annoying and at
worst lead to
people burning out and flaming us, when they maybe shouldn't have been
using Julia
yet in the first place.

Also, in most open source communities the bug-fixers and question-answerers
are a small fraction of the total users. If the userbase grows too quickly,
without
the infrastructure and non-technical processes in place to spread out the
load,
then it can lead to frustration for both end-users (who don't get timely
responses)
and active contributors (who have other things to do with their time).

On Wed, Mar 4, 2015 at 11:52 AM, Tamas Papp  wrote:

> Even outside stats, Julia is a moving target, with nontrivial changes in
> syntax and semantics in the core language, and large changes in library
> code.
>
> While this is natural (and beneficial) in a new language, one has to
> have a preference for other benefits (eg the clarity and the design of
> the language) to be an early adopter, so I can fully understand if
> someone would rather wait for things to stabilize a bit more -- nothing
> wrong or irrational about that.
>
> For this reason, while I am happy to talk about how nice Julia is, I
> will not try to convince people to switch to it. IMO the people who are
> potential switchers at this stage have already looked at Julia, and
> evangelizing more aggressively could be counterproductive at this stage.
>
> Best,
>
> Tamas
>
> On Wed, Mar 04 2015, Iain Dunning  wrote:
>
> > Related to that, we haven't convinced anyone to move away from R for
> > stats/data analysis, and I personally haven't tried. The tooling isn't as
> > good yet, so I can't advocate for it in good faith to the average
> person. I
> > think John Myles White's POV on this is basically that you should use
> Julia
> > for stats at this stage only if you are willing to actually get your
> hands
> > quite dirty with fixing and improving packages, and I'd agree.
>


[julia-users] Re: Equivalent of MATLAB's nargout in Julia

2015-03-04 Thread Pooya
Thanks. I thought of using a boolean variable as an input indicating if I 
need the second output or not, which is exactly like what you mentioned, 
but was wondering if this is idiomatic or not!

On Wednesday, March 4, 2015 at 11:59:57 AM UTC-5, Avik Sengupta wrote:
>
> Yes, Julia doesnt have "nargout". The idiomatic way to do this would be to 
> use optional arguments:
>
> http://julia.readthedocs.org/en/latest/manual/functions/#optional-arguments
>
> So:
>
> function f(a, b=0)
>   if b > 0
>  #do the computations for second argument
>end
>#rest of computation
> end
>
> Use a default value that makes sense in your domain. 
>
> On Wednesday, 4 March 2015 16:48:28 UTC, Pooya wrote:
>>
>> I have a function with two outputs. The second one is computationally 
>> expensive, so I want to avoid the computation unless the user needs it. I 
>> read on another post in the group that the solution in this case is usually 
>> to define two functions, but in this case I basically need to do all the 
>> computations for the first output to compute the second. Is there any nicer 
>> way to do this in julia? In MATLAB, I would just say:
>>
>> If nargout > 1
>> # do all the computations for second output
>> end
>>
>

[julia-users] Re: Equivalent of MATLAB's nargout in Julia

2015-03-04 Thread Pooya
Thanks. I thought of using a boolean variable indicating if I need the 
second output or not, which is exactly like what you mentioned, but was 
wondering if this is idiomatic or not!

On Wednesday, March 4, 2015 at 11:59:57 AM UTC-5, Avik Sengupta wrote:
>
> Yes, Julia doesnt have "nargout". The idiomatic way to do this would be to 
> use optional arguments:
>
> http://julia.readthedocs.org/en/latest/manual/functions/#optional-arguments
>
> So:
>
> function f(a, b=0)
>   if b > 0
>  #do the computations for second argument
>end
>#rest of computation
> end
>
> Use a default value that makes sense in your domain. 
>
> On Wednesday, 4 March 2015 16:48:28 UTC, Pooya wrote:
>>
>> I have a function with two outputs. The second one is computationally 
>> expensive, so I want to avoid the computation unless the user needs it. I 
>> read on another post in the group that the solution in this case is usually 
>> to define two functions, but in this case I basically need to do all the 
>> computations for the first output to compute the second. Is there any nicer 
>> way to do this in julia? In MATLAB, I would just say:
>>
>> If nargout > 1
>> # do all the computations for second output
>> end
>>
>

[julia-users] Re: Equivalent of MATLAB's nargout in Julia

2015-03-04 Thread Avik Sengupta
Yes, Julia doesnt have "nargout". The idiomatic way to do this would be to 
use optional arguments:

http://julia.readthedocs.org/en/latest/manual/functions/#optional-arguments

So:

function f(a, b=0)
  if b > 0
 #do the computations for second argument
   end
   #rest of computation
end

Use a default value that makes sense in your domain. 

On Wednesday, 4 March 2015 16:48:28 UTC, Pooya wrote:
>
> I have a function with two outputs. The second one is computationally 
> expensive, so I want to avoid the computation unless the user needs it. I 
> read on another post in the group that the solution in this case is usually 
> to define two functions, but in this case I basically need to do all the 
> computations for the first output to compute the second. Is there any nicer 
> way to do this in julia? In MATLAB, I would just say:
>
> If nargout > 1
> # do all the computations for second output
> end
>


[julia-users] Complex matches in strings

2015-03-04 Thread Nils Gudat
I'm trying to do some web scraping in Julia and have downloaded a web page 
as a UTF8String via Requests.jl. Now I need to extract some data from this, 
but unfortunately the structure of the page is a bit messy, and it seems 
the only way to get what I need is to extract a substring between two other 
substrings. The structure would look something like

"string1"[10-15 characters]"string2"[string I need to extract]"string3"

Do I need to use regular expressions for this or is there an easier option 
in Julia to match these sorts of more complex string patterns?

Thanks!


[julia-users] Equivalent of MATLAB's nargout in Julia

2015-03-04 Thread Pooya
I have a function with two outputs. The second one is computationally 
expensive, so I want to avoid the computation unless the user needs it. I 
read on another post in the group that the solution in this case is usually 
to define two functions, but in this case I basically need to do all the 
computations for the first output to compute the second. Is there any nicer 
way to do this in julia? In MATLAB, I would just say:

If nargout > 1
# do all the computations for second output
end


Re: [julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Tamas Papp
Even outside stats, Julia is a moving target, with nontrivial changes in
syntax and semantics in the core language, and large changes in library
code.

While this is natural (and beneficial) in a new language, one has to
have a preference for other benefits (eg the clarity and the design of
the language) to be an early adopter, so I can fully understand if
someone would rather wait for things to stabilize a bit more -- nothing
wrong or irrational about that.

For this reason, while I am happy to talk about how nice Julia is, I
will not try to convince people to switch to it. IMO the people who are
potential switchers at this stage have already looked at Julia, and
evangelizing more aggressively could be counterproductive at this stage.

Best,

Tamas

On Wed, Mar 04 2015, Iain Dunning  wrote:

> Related to that, we haven't convinced anyone to move away from R for 
> stats/data analysis, and I personally haven't tried. The tooling isn't as 
> good yet, so I can't advocate for it in good faith to the average person. I 
> think John Myles White's POV on this is basically that you should use Julia 
> for stats at this stage only if you are willing to actually get your hands 
> quite dirty with fixing and improving packages, and I'd agree.


[julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Páll Haraldsson
On Wednesday, March 4, 2015 at 2:20:38 PM UTC, Iain Dunning wrote:
>
> I guess I (or rather, we) have had disproportional success recruiting new 
> Julia users.
>

You may have one more user..

>[your competion] "either proprietary or slow"

I forget the name of the package our professor used but yes, it was 
proprietary, as most software at the time used in teaching (unlike now, 
except for MATLAB).

>BTW, if you want help selling an operations research person on Julia, we 
have some materials :)

I was a little too pessimistic, from that OR professor I got this answer, 
in May, "I’ve tried Julia and am thinking about using it some more." to a 
very long post of mine that included:

http://iaindunning.com/2013/sudoku-as-a-service.html

The Julia package JuMP is an algebraic modeling language for linear (and 
integer and quadratic) programming

[..]Julia's fantastic metaprogramming functionality has allowed us to 
create a particularily fast and expressive modeling language.


At the time I thought I might try to program A* in Julia.. See now other 
interesting stuff on your site and that you've been around and seemed you 
like:

http://iaindunning.com/2013/an-icelandic-adventure.html

-- 

Palli.


[julia-users] Re: How to satisfy this deprecation warning?

2015-03-04 Thread J Luis
Thanks, that does it.

quarta-feira, 4 de Março de 2015 às 16:11:49 UTC, J Luis escreveu:
>
>
> julia> zeros(Ptr{Uint8},2)
> WARNING: zero{T}(::Type{Ptr{T}}) is deprecated, use Ptr{T}(0) instead.
>  in zero at deprecated.jl:29
>  in zeros at array.jl:202
> 2-element Array{Ptr{UInt8},1}:
>  Ptr{UInt8} @0x
>  Ptr{UInt8} @0x
>
> write, I can do 
>
> julia> Ptr{Uint8}(0)
> Ptr{UInt8} @0x
>
> but I don't want that. I want an array of pointers and I can't create them 
> neither with
>
> julia> Array(Ptr{Uint8}(0),2)
> ERROR: MethodError: `convert` has no method matching convert(::Type{Array{
> T,N}}, ::Ptr{UInt8}, ::Int64)
>
>
>
>

[julia-users] PyPlot figures

2015-03-04 Thread Josh Langsfeld
In PyPlot.jl, is there a way to create my figures and render them without a 
figure window getting created? My window manager is interfering with the 
size hint in the figure() function so it would be nice if I can go straight 
to a file.

Thanks,
Josh


[julia-users] Re: How to satisfy this deprecation warning?

2015-03-04 Thread Simon Danisch
How about:
Ptr{Uint8}[0,0]?
For more complicated arrays:
Ptr{Uint8}[ 0 for i=1:10, j=1:2]

Am Mittwoch, 4. März 2015 17:11:49 UTC+1 schrieb J Luis:
>
>
> julia> zeros(Ptr{Uint8},2)
> WARNING: zero{T}(::Type{Ptr{T}}) is deprecated, use Ptr{T}(0) instead.
>  in zero at deprecated.jl:29
>  in zeros at array.jl:202
> 2-element Array{Ptr{UInt8},1}:
>  Ptr{UInt8} @0x
>  Ptr{UInt8} @0x
>
> write, I can do 
>
> julia> Ptr{Uint8}(0)
> Ptr{UInt8} @0x
>
> but I don't want that. I want an array of pointers and I can't create them 
> neither with
>
> julia> Array(Ptr{Uint8}(0),2)
> ERROR: MethodError: `convert` has no method matching convert(::Type{Array{
> T,N}}, ::Ptr{UInt8}, ::Int64)
>
>
>
>

[julia-users] How to satisfy this deprecation warning?

2015-03-04 Thread J Luis

julia> zeros(Ptr{Uint8},2)
WARNING: zero{T}(::Type{Ptr{T}}) is deprecated, use Ptr{T}(0) instead.
 in zero at deprecated.jl:29
 in zeros at array.jl:202
2-element Array{Ptr{UInt8},1}:
 Ptr{UInt8} @0x
 Ptr{UInt8} @0x

write, I can do 

julia> Ptr{Uint8}(0)
Ptr{UInt8} @0x

but I don't want that. I want an array of pointers and I can't create them 
neither with

julia> Array(Ptr{Uint8}(0),2)
ERROR: MethodError: `convert` has no method matching convert(::Type{Array{T,
N}}, ::Ptr{UInt8}, ::Int64)





Re: [julia-users] Re: Package Dependencies

2015-03-04 Thread Duane Johnson
Looks good, thanks.

On Wed, Mar 4, 2015 at 12:09 AM, René Donner  wrote:

> While not built-in, this might do what you want:
> https://github.com/rened/DeclarativePackages.jl
>
>
> Am 03.03.2015 um 23:58 schrieb Duane Johnson :
>
> > Reviving this thread from almost exactly a year ago. Has the package
> situation changed?
> >
> > Specifically, I'm wondering if there's a way to take advantage of a
> REQUIRES file in a local directory. Consider this use case:
> >
> > - I'm starting a new project, which may some day be a package but is not
> there yet
> > - I have my dependencies in a REQUIRES file
> > - I'd like to run some command, like "bundle install" or "npm install"
> and make sure my Pkg manager installs the dependencies, or at least, the
> global state is up to date with the specified requirements.
> >
> > Is this possible?
> >
> > Thanks,
> > Duane
> >
> > On Sunday, February 23, 2014 at 1:22:21 PM UTC-7, Dave Bettin wrote:
> > First, I have recently enjoyed the use of both Clojure's and Node's
> package management facilities.
> >
> > I am trying to understand how local project dependencies in Julia
> compare. So far what I can gather is most of Julia's intrinsic package
> handling is global.
> >
> > Is it possible to download a private and/or public package and only
> manage its dependencies? Can one store these dependencies local to the
> package, akin to 'node_modules' in npm?
> >
> > Thanks!
> > Dave
>
>


Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread Tracy Wadleigh
I had a working mex connection (on Windows) to julia a while back that I've
been trying to resuscitate this week, but to no avail.

Whatever is going wrong, it's pretty nasty. I can't even get to the point
of calling a function in libjulia. Merely linking to libjulia causes it to
crash. For instance, I can write a simple hello world mexFunction that
works fine. But if I put in the same module a function that refers to a
julia function, but which is never called, I see this behavior.

And gdb isn't giving me much to go on. I never hit any breakpoint in my
module, and here's the error and backtrace I receieve:

warning: Critical error detected c374

Program received signal SIGTRAP, Trace/breakpoint trap.
0x77c140d0 in ntdll!RtlUnhandledExceptionFilter () from
/cygdrive/c/Windows/SYSTEM32/ntdll.dll
(gdb) backtrace
#0  0x77c140d0 in ntdll!RtlUnhandledExceptionFilter () from
/cygdrive/c/Windows/SYSTEM32/ntdll.dll
#1  0x77c14746 in ntdll!EtwEnumerateProcessRegGuids () from
/cygdrive/c/Windows/SYSTEM32/ntdll.dll
#2  0x77c15952 in ntdll!RtlQueryProcessLockInformation () from
/cygdrive/c/Windows/SYSTEM32/ntdll.dll
#3  0x77c17604 in ntdll!RtlLogStackBackTrace () from
/cygdrive/c/Windows/SYSTEM32/ntdll.dll
#4  0x77bbdc1f in ntdll!RtlIsDosDeviceName_U () from
/cygdrive/c/Windows/SYSTEM32/ntdll.dll
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

The solution I had did work at one point. At some point I may attempt to
see if I can reproduce this with a vanilla exe embedding and/or do a git
bisect to find out what commit caused it to stop working. Meanwhile I'm
just sad and discouraged.

On Wed, Mar 4, 2015 at 9:53 AM, Eric Davies  wrote:

> Thanks, hopefully that solves it!
>
> I've got a pretty good solution currently. It requires no Julia code and
> seems pretty fast. My favourite part is that the Julia workspace persists
> across calls, through some sort of MEX magic that I don't fully understand.
> The one downside is that it requires all input data to be copied (MATLAB
> will segfault if you don't; I had the same problem in my MEX PostgreSQL
> wrapper). I'll check with work next week--I expect it to be pretty much
> done then--whether I can post this as a public repo. I am optimistic.
>
> Overall I love the Julia API! My only complaints are being fixed by Jeff's
> latest PR :)
>
>
> On Wednesday, 4 March 2015 06:06:19 UTC-6, Tim Holy wrote:
>>
>> It seems possible we should add a second "boolean" argument to
>> _julia_init (in
>> init.c) that controls whether the signal handlers get set. But as a
>> workaround:
>> http://stackoverflow.com/questions/9495113/how-to-get-
>> the-handlers-name-address-for-some-signals-e-g-sigint-in-postgres
>>
>> You could at least test whether that solves the problem, and then if so
>> perhaps it would be worth opening an issue in julia about whether we need
>> a
>> better solution.
>>
>> BTW, I'm interested in this topic too; see also
>> https://groups.google.com/d/msg/julia-users/dP_J5KilsEs/4CIERQ14vdgJ. We
>> should collaborate on a single solution (and it sounds like you're
>> farther
>> along and perhaps more invested). I'm happy to pitch in if code gets
>> posted
>> somewhere.
>>
>> --Tim
>>
>> On Tuesday, March 03, 2015 09:18:04 PM Eric Davies wrote:
>> > Hi all,
>> >
>> > I'm attempting to embed julia in a MATLAB MEX file. Everything is going
>> > great, but MATLAB will sometimes segfault after having run some code
>> > calling Julia.* I believe I have narrowed it down to this
>> > issue: http://ubuntuforums.org/showthread.php?t=2093057 . Basically, I
>> > believe Julia is registering a SIGSEGV (or maybe other signal?) handler
>> > that overwrites the default for the JVM set by MATLAB. after the Julia
>> > function is done, that memory is freed. Then a segfault (or maybe other
>> > signal?) happens in the JVM and it tries to call Julia's handler but
>> > segfaults (again) as it is no longer there.
>> >
>> > Can anyone help me find a workaround? Perhaps if there's a way to
>> > "deregister" the handler, or if someone knows a way to get the current
>> > handler (before calling into Julia) and then setting it back to that
>> after
>> > Julia is done.
>> >
>> > I've never dealt with signals in C before so I apologize if I'm
>> describing
>> > things incorrectly or missing something.
>> >
>> > Thanks,
>> > Eric
>> >
>> > *I am able to reliably reproduce this by running any MEX function
>> linking
>> > to Julia and calling jl_init, then calling `help clear` in MATLAB.
>> >
>> > P.S.: I'm on Mac OS X 10.10 with MATLAB R2012b and Julia
>> v0.3.6/v0.4.0-dev
>>
>>


[julia-users] Unevenly distributed arrays

2015-03-04 Thread Simone Ulzega
Is it possible to construct a DArray with unevenly distributed chunks? 
For example, I want to create a distributed array with size (5*n,), where n 
is an integer, on 4 processes. 
For some reasons I want uneven chunks of sizes n, 2*n, n and n.

The syntax 

DArray(size) do I  end  

doesn't seem to work as I is automatically generated to have, obviously, 
evenly distributed chunks on the available processes. 


Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread Eric Davies
Thanks, hopefully that solves it!

I've got a pretty good solution currently. It requires no Julia code and 
seems pretty fast. My favourite part is that the Julia workspace persists 
across calls, through some sort of MEX magic that I don't fully understand. 
The one downside is that it requires all input data to be copied (MATLAB 
will segfault if you don't; I had the same problem in my MEX PostgreSQL 
wrapper). I'll check with work next week--I expect it to be pretty much 
done then--whether I can post this as a public repo. I am optimistic.

Overall I love the Julia API! My only complaints are being fixed by Jeff's 
latest PR :)

On Wednesday, 4 March 2015 06:06:19 UTC-6, Tim Holy wrote:
>
> It seems possible we should add a second "boolean" argument to _julia_init 
> (in 
> init.c) that controls whether the signal handlers get set. But as a 
> workaround: 
>
> http://stackoverflow.com/questions/9495113/how-to-get-the-handlers-name-address-for-some-signals-e-g-sigint-in-postgres
>  
>
> You could at least test whether that solves the problem, and then if so 
> perhaps it would be worth opening an issue in julia about whether we need 
> a 
> better solution. 
>
> BTW, I'm interested in this topic too; see also 
> https://groups.google.com/d/msg/julia-users/dP_J5KilsEs/4CIERQ14vdgJ. We 
> should collaborate on a single solution (and it sounds like you're farther 
> along and perhaps more invested). I'm happy to pitch in if code gets 
> posted 
> somewhere. 
>
> --Tim 
>
> On Tuesday, March 03, 2015 09:18:04 PM Eric Davies wrote: 
> > Hi all, 
> > 
> > I'm attempting to embed julia in a MATLAB MEX file. Everything is going 
> > great, but MATLAB will sometimes segfault after having run some code 
> > calling Julia.* I believe I have narrowed it down to this 
> > issue: http://ubuntuforums.org/showthread.php?t=2093057 . Basically, I 
> > believe Julia is registering a SIGSEGV (or maybe other signal?) handler 
> > that overwrites the default for the JVM set by MATLAB. after the Julia 
> > function is done, that memory is freed. Then a segfault (or maybe other 
> > signal?) happens in the JVM and it tries to call Julia's handler but 
> > segfaults (again) as it is no longer there. 
> > 
> > Can anyone help me find a workaround? Perhaps if there's a way to 
> > "deregister" the handler, or if someone knows a way to get the current 
> > handler (before calling into Julia) and then setting it back to that 
> after 
> > Julia is done. 
> > 
> > I've never dealt with signals in C before so I apologize if I'm 
> describing 
> > things incorrectly or missing something. 
> > 
> > Thanks, 
> > Eric 
> > 
> > *I am able to reliably reproduce this by running any MEX function 
> linking 
> > to Julia and calling jl_init, then calling `help clear` in MATLAB. 
> > 
> > P.S.: I'm on Mac OS X 10.10 with MATLAB R2012b and Julia 
> v0.3.6/v0.4.0-dev 
>
>

Re: [julia-users] [code review] "atomic units" implementationf for AHN-algorithm.

2015-03-04 Thread Mauro
> I still don't have a clear picture of how to implement the other more 
> complex components: "compounds" and "mixtures". I'm experienced in Python 
> which leds me to think in terms inheritance for the concrete types, which 
> is the only part that is causing me troubles to grasp for now in Julia. I 
> wonder if Traits.jl  could help me or 
> confuse me even more.

Traits.jl confuses me ;-) It would be great if you give Traits.jl a
spin, it hasn't really been used yet.  (And there is a reason for that,
as it will most likely break sometime down the road.)  Traits basically
gives you the ability to group types (or tuples of types) into sets
which are outside of the type hierarchy.  The most common way to define
the grouping is by a set of functions (+signatures) which all types
contained in the trait have to provide.  Although other groupings are
possible too, e.g. mutable-vs-immutable.  You can then use traits for
dispatch as well, just like types.  Does that fit your bill?


[julia-users] Re: Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Iain Dunning
I guess I (or rather, we) have had disproportional success recruiting new 
Julia users. "We" are a group of PhD students at the MIT Operations 
Research Center, and we basically made tools that we wanted (JuliaOpt) - 
and even better, found others elsewhere who also had tools they wanted. 
Now, the recruiting part went as follows: the existing tooling was flawed 
in a variety of ways (either proprietary or slow) so we were able to 
basically offer a sufficiently strong value proposition to overcome the 
inertia of learning a new language. We were helped by two things, as well: 
generally not strong programmers who had some MATLAB familiarity, and the 
ability to provide courses. By that I mean, we basically volunteered to 
teach Julia and JuliaOpt to incoming students, and we also taught some of 
the current students too.

Now, that doesn't scale perfectly, but we're already seeing some network 
effects and natural adoption. So I think that Julia is fantastic, but you 
sell people on packages, not the language. The language enables better 
packages to be made.

I think this is one reason why Julia can and is eating MATLAB already for 
many people - if you don't need things like Simulink or some other MATLAB 
package thats hard to recreate, I'm not really sure there is a good reason 
to start large new endeavors there.

Related to that, we haven't convinced anyone to move away from R for 
stats/data analysis, and I personally haven't tried. The tooling isn't as 
good yet, so I can't advocate for it in good faith to the average person. I 
think John Myles White's POV on this is basically that you should use Julia 
for stats at this stage only if you are willing to actually get your hands 
quite dirty with fixing and improving packages, and I'd agree.

BTW, if you want help selling an operations research person on Julia, we 
have some materials :)

On Wednesday, March 4, 2015 at 8:19:39 AM UTC-5, Páll Haraldsson wrote:
>
>
> Hi,
>
> Have you guys tried to influence others to use Julia, and failed, for 
> research or teaching and/or production? What has been your best argument(s) 
> (or the most difficult counter-argument)? Do people just have to discover 
> Julia at their own pace?
>
> Note, I have convinced myself, *I* would use Julia, almost for 
> everything (but have no big project planned). And I am not even the target 
> audience for Julia. At least the first three on my list seem to be. I just 
> envy that they have such a good language and community available for them.. 
> while not using it. I feel you guys are unfairly keeping Julia to 
> yourselves and think Julia could/should benefit others soon. I thought I 
> could and did make a good case for Julia to others, while not knowing much 
> about their specific problems/domains.
>
> At some point I mentioned here that Julia could be a good first language, 
> and it was pointed out that there was no book. I see now there is (while 
> not for beginners).
>
> The statistical probability of success for a new computer language is 
> somewhere between slim to none. It seems to me Julia *should* beat the odds 
> (at this point) at least for the target audience. But maybe not, if I can't 
> convince people.. or if everyone wants to be a "late adopter"..
>
> If people would be waiting for an even *better* language or can't decide 
> between alternative newer languages, I would also like to know of possible 
> ones on the horizon. Chapel? X10? Fortress seems dead. None of these have 
> the "dynamic"-aspect. I haven't looked too much into these alternative 
> parallel languages (or Haskell..), do they have any advantage over Julia, 
> now? Any language better to harness GPUs? [I'm not convinced a language 
> should be implicitly parallel be default (as opposed to optional) or 
> pure-functional/immutable-only.]
>
>
> I've been asked what is Julia's "killer application". That is, programming 
> languages need something special too. For Julia, I think it is the speed 
> plus "dynamic"/REPL. And it's easy to use. Is the learning curve low enough 
> for users (compared to the benefit)? Multiple dispatch might be, really the 
> only new thing for users (while also rewarding). (Perceived) lack of 
> library might be a problem? I just point to, say, JuliaQuant. Any specific 
> high-quality libraries I can point to for finance or biology? Are the 
> libraries immature?
>
>
> [In a recent MATLAB-thread here, there was something mentioned about 
> Windows issues w/Julia, should those below be worried? Solved in 0.4 or 
> soon (in 0.3)?]
>
>
> 1. A friend, a PhD physicist, now (sadly..) a quant/finance guy, top dog 
> in his department at one of the major US bank, who could use Julia (and 
> probably influence his subordinates in his New York department and the 
> lower ranked guys he hires for Florida).
>
> Uses Python and NumPy (and C++ for performance); nothing else I gather for 
> performance in Python such as Numba or PyPy. Asked me, when disappointed 
> with the par

[julia-users] Re: [Attn package devs] PackageEvaluator/pkg.julialang.org changes

2015-03-04 Thread Iain Dunning
An update, things seem to be running mostly smoothly again now. If your 
package is still not working, please file an issue (and try to diagnose it 
yourself using the virtual machine).

On Sunday, March 1, 2015 at 11:17:15 AM UTC-5, Iain Dunning wrote:
>
> Hi James and Seth,
>
> Dependency networks definitely interest me (see my blog post on the topic: 
> http://iaindunning.com/2014/pkg-deps.html)
>
> The code is all there, so my plan is to hook it up to the website next so 
> its automatically generated nightly.
>
> As for function call analysis, definitely possible (using JuliaParser.jl?) 
> although too much of a project for me. I'd be happy to help someone with it 
> though.
>
> Cheers,
> Iain
>
>
> On Sunday, March 1, 2015 at 10:56:55 AM UTC-5, Seth wrote:
>>
>> This is a really fantastic idea, and one that I'd love to help with. The 
>> lack of information about which packages rely on which others means 1) 
>> we've made breaking changes that were totally unanticipated, and 2) we're 
>> hesitant to make changes because we don't know who to notify.
>>
>> Seth.
>>
>> On Saturday, February 28, 2015 at 7:57:56 PM UTC-8, James Fairbanks wrote:
>>>
>>>
>>> Also I am interested in the dependency network, which we can get out of 
>>> the REQUIRE files. Which packages are providing functionality that many 
>>> others depend on in an indirect way? These would be important packages to 
>>> keep well maintained because if they fail many other packages will fail. 
>>> What are the clusters of packages? 
>>>
>>> James Fairbanks 
>>
>>

Re: [julia-users] Re: Functions in degrees

2015-03-04 Thread Patrick O'Leary
On Tuesday, March 3, 2015 at 2:57:28 PM UTC-6, Stuart Brorson wrote:
>
> Since types should be used sparingly, I don't think it a good idea to 
> replace convenience functions like sind and cosd with a type-driven 
> invocation mechanism -- ordinary users will be confused.
>

You also can't replace all of them, since the inverse functions can't be 
dispatched in this way. Anecdotally, I use atan2d more than any of the 
other *d functions, typically as a step on the way to making a plot. 


Re: [julia-users] vector vs column matrix

2015-03-04 Thread Jutho
The rational would be that people often want to construct matrices (i.e. 
even where the elements are themselves arrays and they do not want 
concatenation) and that there is no syntax for this. All the tricks with 
reshape or transposing are not very feature proof, as e.g. transposing 
might change at some point to return a dedicated Transpose wrapper type 
that doesn't actually tranpose anything and reshape is currently also being 
reconsidered for returning an explicit view in the form of a wrapper 
ReshapedArray. 


Re: [julia-users] Re: 3D interactive plots in IJulia

2015-03-04 Thread j verzani
There are some examples of doing just this 
here: 
http://nbviewer.ipython.org/url/mth229.github.io/233-projects/multivariable.ipynb?create=1

On Wednesday, March 4, 2015 at 2:10:45 AM UTC-5, Shashi Gowda wrote:
>
> It should be possible to use 3D (surf etc) plots from PyPlot with 
> Interact.jl in IJulia.
>
> On Wed, Mar 4, 2015 at 7:06 AM, Jack Minardi  > wrote:
>
>> I've used matplotlib's 3D plotting capabilities successfully through 
>> PyPlot.jl in the past.
>>
>> On Tuesday, March 3, 2015 at 10:38:32 AM UTC-5, Andrei Berceanu wrote:
>>>
>>> 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] Type for eigs result

2015-03-04 Thread James Fairbanks
We have Base.LinAlg.eig return a tuple of (values,vectors) and 
Base.LinAlg.eigfact returns a type for the result Base.LinAlg.Eigen. But 
Base.LinAlg.eigs returns a tuple would it be worth having a variant of eigs 
that returns a type such as EigsResult?

@doc """a type for the output of eigs


   "eigs" returns the "nev" requested eigenvalues in "d", the
   corresponding Ritz vectors "v" (only if "ritzvec=true"), the
   number of converged eigenvalues "nconv", the number of iterations
   "niter" and the number of matrix vector multiplications
   "nmult", as well as the final residual vector "resid".


   """ ->
type EigsResult{T, R}
 values::Array{T,1}
 vectors::Array{T,2}
 nconv::Int64
 niter::Int64
 nmult::Int64
 resid::Array{R,1}
end


function EigsResult(A; args...)
 @show args
 tupl = eigs(A; args...)
 T = eltype(tupl[1])
 R = eltype(tupl[end])
 EigsResult{T,R}(tupl...)
end

Any function that depends only on the eigenvalues and eigenvectors can take 
either an Eigen or an EigsResult because they have the same field names.

James Fairbanks


Re: [julia-users] vector vs column matrix

2015-03-04 Thread Jutho


Op woensdag 4 maart 2015 11:54:27 UTC+1 schreef Tamas Papp:
>
> Surely I am missing something, but how would this relate to 
> concatenation? 
>
>
The point of proposal 2 in issue 10338 would be that concatenation would 
receive a new pair of brackets and that spaces and semicolons would be used 
as dedicated syntax for building matrices, i.e.
[1,2,3] is a vector, i.e. an array of size (3,)
[1;2;3] is a matrix, i.e. an array of size (3,1)


[julia-users] Getting people to switch to Julia - tales of no(?) success

2015-03-04 Thread Páll Haraldsson

Hi,

Have you guys tried to influence others to use Julia, and failed, for 
research or teaching and/or production? What has been your best argument(s) 
(or the most difficult counter-argument)? Do people just have to discover 
Julia at their own pace?

Note, I have convinced myself, *I* would use Julia, almost for 
everything (but have no big project planned). And I am not even the target 
audience for Julia. At least the first three on my list seem to be. I just 
envy that they have such a good language and community available for them.. 
while not using it. I feel you guys are unfairly keeping Julia to 
yourselves and think Julia could/should benefit others soon. I thought I 
could and did make a good case for Julia to others, while not knowing much 
about their specific problems/domains.

At some point I mentioned here that Julia could be a good first language, 
and it was pointed out that there was no book. I see now there is (while 
not for beginners).

The statistical probability of success for a new computer language is 
somewhere between slim to none. It seems to me Julia *should* beat the odds 
(at this point) at least for the target audience. But maybe not, if I can't 
convince people.. or if everyone wants to be a "late adopter"..

If people would be waiting for an even *better* language or can't decide 
between alternative newer languages, I would also like to know of possible 
ones on the horizon. Chapel? X10? Fortress seems dead. None of these have 
the "dynamic"-aspect. I haven't looked too much into these alternative 
parallel languages (or Haskell..), do they have any advantage over Julia, 
now? Any language better to harness GPUs? [I'm not convinced a language 
should be implicitly parallel be default (as opposed to optional) or 
pure-functional/immutable-only.]


I've been asked what is Julia's "killer application". That is, programming 
languages need something special too. For Julia, I think it is the speed 
plus "dynamic"/REPL. And it's easy to use. Is the learning curve low enough 
for users (compared to the benefit)? Multiple dispatch might be, really the 
only new thing for users (while also rewarding). (Perceived) lack of 
library might be a problem? I just point to, say, JuliaQuant. Any specific 
high-quality libraries I can point to for finance or biology? Are the 
libraries immature?


[In a recent MATLAB-thread here, there was something mentioned about 
Windows issues w/Julia, should those below be worried? Solved in 0.4 or 
soon (in 0.3)?]


1. A friend, a PhD physicist, now (sadly..) a quant/finance guy, top dog in 
his department at one of the major US bank, who could use Julia (and 
probably influence his subordinates in his New York department and the 
lower ranked guys he hires for Florida).

Uses Python and NumPy (and C++ for performance); nothing else I gather for 
performance in Python such as Numba or PyPy. Asked me, when disappointed 
with the parallel speed-up he was getting in Python. Would like to harness 
GPUs and/or the cluster they have. Says he got past the parallel problems 
(may have done so only at the C++ side?).

He isn't sure the learning curve of Julia is worth it; Python "good enough" 
now. It seems to me the learning curve is not that high and he's not a 
beginner and while not a CompSci guy, he is very bright and should manage. 
Still, he though he had a firewall/admin problem at work (I assume the git 
problem).

[He says, over at Goldman Sacks, they have their own home made language..]

Going to point him to this..:
http://quant-econ.net/python_or_julia.html
"Learn both — you won’t regret it"

Should I point him to a NYC meet-up? I see it was yesterday.. will be again 
- when?


2. A friend, a guy I consider a programmer wizard from my youth, MS in 
engineering/PhD computer science, now working in systems biology and 
teaches computer science classes in my university.

Uses MATLAB (and C++ for performance) for his systems biology. Hates R.. 
doesn't use. Uses Python when teaching (say general construction/object 
oriented).


Says MATLAB is standard in the scientific world, what you use when 
publishing articles.. Also isn't really too unsatisfied with the 
performance most of the time.


Managed to get him to try out Julia (or may have been one of his students). 
He says C++ was 100x faster.. so he's doing something wrong. Would get a 
student to look into it.. I asked if I could see the code but have not so 
far.


3. A guy I met at work (do not know him), working in bioinformatics using 
Python. Says he's a "late adopter of new languages". I said 
"understandable.. I'm sure you would be pleasantly surprised, but I do not 
really know about the available bioinformatics Julia package" (plural?) or 
too much about your field.


I understand Perl is/was popular in bioinformatics as really it's kind of 
string processing. Should Perl (or Python) be somehow superior to Julia for 
it?


[You could stop reading here..]


4. A young guy in the family 

Re: [julia-users] vector vs column matrix

2015-03-04 Thread Alan Edelman
I usually type, for example, 
[1 2 3]'





On Wednesday, March 4, 2015 at 5:54:27 AM UTC-5, Tamas Papp wrote:
>
> Surely I am missing something, but how would this relate to 
> concatenation? 
>
> Even if the concatenation syntax can be applied with some hack (eg 
> [1:3;]'' in current v0.4), I think that reshape conveys the intention 
> much better. 
>
> Best, 
>
> Tamas 
>
> On Wed, Mar 04 2015, Jutho > wrote: 
>
> > But feel free to discuss the need for a convenient syntax for this 
> > at https://github.com/JuliaLang/julia/issues/10338 
> > 
> > Op woensdag 4 maart 2015 10:32:12 UTC+1 schreef Tamas Papp: 
> >> 
> >> Assuming that you want to fill it with a sequence of integers as your 
> >> examples suggest, something like 
> >> 
> >> [i for i=1:3, j=1] 
> >> 
> >> or 
> >> 
> >> reshape(1:3,3,1) 
> >> 
> >> would also work. 
> >> 
> >> Best, 
> >> 
> >> Tamas 
> >> 
> >> On Wed, Mar 04 2015, Deniz Yuret > 
> >> wrote: 
> >> 
> >> > Is there a way to initialize a 2D column matrix? 
> >> > a=[1,2,3] gives me a 1D vector with size=(3,) 
> >> > a=[1;2;3] likewise 
> >> > a=[1 2 3] gives me a row matrix with size=(1,3) 
> >> > 
> >> > How do I initialize a column matrix with size=(3,1)?  (other than 
> >> > transposing a row matrix) 
> >> 
> >> 
>
>

Re: [julia-users] MATLAB MEX embedding signal handling segfault

2015-03-04 Thread Tim Holy
It seems possible we should add a second "boolean" argument to _julia_init (in 
init.c) that controls whether the signal handlers get set. But as a 
workaround:
http://stackoverflow.com/questions/9495113/how-to-get-the-handlers-name-address-for-some-signals-e-g-sigint-in-postgres

You could at least test whether that solves the problem, and then if so 
perhaps it would be worth opening an issue in julia about whether we need a 
better solution.

BTW, I'm interested in this topic too; see also 
https://groups.google.com/d/msg/julia-users/dP_J5KilsEs/4CIERQ14vdgJ. We 
should collaborate on a single solution (and it sounds like you're farther 
along and perhaps more invested). I'm happy to pitch in if code gets posted 
somewhere.

--Tim

On Tuesday, March 03, 2015 09:18:04 PM Eric Davies wrote:
> Hi all,
> 
> I'm attempting to embed julia in a MATLAB MEX file. Everything is going
> great, but MATLAB will sometimes segfault after having run some code
> calling Julia.* I believe I have narrowed it down to this
> issue: http://ubuntuforums.org/showthread.php?t=2093057 . Basically, I
> believe Julia is registering a SIGSEGV (or maybe other signal?) handler
> that overwrites the default for the JVM set by MATLAB. after the Julia
> function is done, that memory is freed. Then a segfault (or maybe other
> signal?) happens in the JVM and it tries to call Julia's handler but
> segfaults (again) as it is no longer there.
> 
> Can anyone help me find a workaround? Perhaps if there's a way to
> "deregister" the handler, or if someone knows a way to get the current
> handler (before calling into Julia) and then setting it back to that after
> Julia is done.
> 
> I've never dealt with signals in C before so I apologize if I'm describing
> things incorrectly or missing something.
> 
> Thanks,
> Eric
> 
> *I am able to reliably reproduce this by running any MEX function linking
> to Julia and calling jl_init, then calling `help clear` in MATLAB.
> 
> P.S.: I'm on Mac OS X 10.10 with MATLAB R2012b and Julia v0.3.6/v0.4.0-dev



Re: [julia-users] How to get template value of abstract type?

2015-03-04 Thread Tim Holy
Just add

Base.eltype{F<:Foo}(::Type{F})=eltype(super(F))

--Tim

On Tuesday, March 03, 2015 06:58:53 PM Sheehan Olver wrote:
> Suppose I have
> 
> abstract Foo{T}
> immutable Foo1{T} <:Foo{T} end
> immutable Foo2{T} <:Foo{T} end
> 
> 
> 
> How can I write a function that returns T given the type?  E.g.: I want to
> do
> 
> Base.eltype(::Type{Foo{T}})=T
> 
> 
> But this won't work for eltype(Foo1{T})



Re: [julia-users] vector vs column matrix

2015-03-04 Thread Tamas Papp
Surely I am missing something, but how would this relate to
concatenation?

Even if the concatenation syntax can be applied with some hack (eg
[1:3;]'' in current v0.4), I think that reshape conveys the intention
much better.

Best,

Tamas

On Wed, Mar 04 2015, Jutho  wrote:

> But feel free to discuss the need for a convenient syntax for this 
> at https://github.com/JuliaLang/julia/issues/10338
>
> Op woensdag 4 maart 2015 10:32:12 UTC+1 schreef Tamas Papp:
>>
>> Assuming that you want to fill it with a sequence of integers as your 
>> examples suggest, something like 
>>
>> [i for i=1:3, j=1] 
>>
>> or 
>>
>> reshape(1:3,3,1) 
>>
>> would also work. 
>>
>> Best, 
>>
>> Tamas 
>>
>> On Wed, Mar 04 2015, Deniz Yuret > 
>> wrote: 
>>
>> > Is there a way to initialize a 2D column matrix? 
>> > a=[1,2,3] gives me a 1D vector with size=(3,) 
>> > a=[1;2;3] likewise 
>> > a=[1 2 3] gives me a row matrix with size=(1,3) 
>> > 
>> > How do I initialize a column matrix with size=(3,1)?  (other than 
>> > transposing a row matrix) 
>>
>>



Re: [julia-users] vector vs column matrix

2015-03-04 Thread Jutho
But feel free to discuss the need for a convenient syntax for this 
at https://github.com/JuliaLang/julia/issues/10338

Op woensdag 4 maart 2015 10:32:12 UTC+1 schreef Tamas Papp:
>
> Assuming that you want to fill it with a sequence of integers as your 
> examples suggest, something like 
>
> [i for i=1:3, j=1] 
>
> or 
>
> reshape(1:3,3,1) 
>
> would also work. 
>
> Best, 
>
> Tamas 
>
> On Wed, Mar 04 2015, Deniz Yuret > 
> wrote: 
>
> > Is there a way to initialize a 2D column matrix? 
> > a=[1,2,3] gives me a 1D vector with size=(3,) 
> > a=[1;2;3] likewise 
> > a=[1 2 3] gives me a row matrix with size=(1,3) 
> > 
> > How do I initialize a column matrix with size=(3,1)?  (other than 
> > transposing a row matrix) 
>
>

Re: [julia-users] vector vs column matrix

2015-03-04 Thread Tamas Papp
Assuming that you want to fill it with a sequence of integers as your
examples suggest, something like

[i for i=1:3, j=1]

or

reshape(1:3,3,1)

would also work.

Best,

Tamas

On Wed, Mar 04 2015, Deniz Yuret  wrote:

> Is there a way to initialize a 2D column matrix?
> a=[1,2,3] gives me a 1D vector with size=(3,)
> a=[1;2;3] likewise
> a=[1 2 3] gives me a row matrix with size=(1,3)
>
> How do I initialize a column matrix with size=(3,1)?  (other than 
> transposing a row matrix)




[julia-users] vector vs column matrix

2015-03-04 Thread Deniz Yuret
Is there a way to initialize a 2D column matrix?
a=[1,2,3] gives me a 1D vector with size=(3,)
a=[1;2;3] likewise
a=[1 2 3] gives me a row matrix with size=(1,3)

How do I initialize a column matrix with size=(3,1)?  (other than 
transposing a row matrix)




[julia-users] Re: using repeat() function, and then using size()

2015-03-04 Thread Ranjan Anantharaman
Thanks, Mr. Simon. :)


>>

[julia-users] Re: 3D interactive plots in IJulia

2015-03-04 Thread Simon Danisch
@Steven Sagaert 
Well, what you say definitely holds true, if your goals are to have nice 
scientific visualizations as quickly available as possible.
My goals are somewhat different. I want to go more into the direction of 
visual debugging and interactive programming, while keeping everything in 
one fast, high-level language.
I think it's finally time to get away from C++ as the only acceptable 
language for high performance 3D graphics.
It is indeed a bumpy road as there are a lot of pieces missing and it 
manifests in the slow progress of GLPlot, but I think it'll pay off 
eventually.


Am Dienstag, 3. März 2015 16:38:32 UTC+1 schrieb Andrei Berceanu:
>
> 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] Re: 3D interactive plots in IJulia

2015-03-04 Thread Steven Sagaert
Hi Simon,
The screenshots looks nice but I have to ask: why build a high performance 
native 2D/3D scientific plotting lib based on openGL from scratch when you 
could wrap mature native libs like VTK or Mayavi? I mean in R you have RGL 
 which is also directly based on openGL. You can use it for some basic 3D 
interative scatterplots & surfaceplots but personally I don't find these 
plots very satisfactory. I mean "raw" openGL itself is mainly for 3D 
graphics not scientific visualization and hence a whole lot more work is 
needed to add this functionality on top of it.

On Tuesday, March 3, 2015 at 10:43:27 PM UTC+1, Simon Danisch wrote:
>
> Well there is GLPlot.jl , but 
> it might not be what you're looking for...
> Also it's on a feature freeze right now.
> I'm restructuring the architecture, before I add more advanced features.
>
> Am Dienstag, 3. März 2015 16:38:32 UTC+1 schrieb Andrei Berceanu:
>>
>> 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
>>
>