[julia-users] Re: f(x)=ax2+bx+c ; if b = 0; ERROR: syntax: malformed expression

2014-11-27 Thread Alex
Julia is probably expecting you to give a hex-number (like 0x01). This 
collides with the syntactic sugar for multiplication. You can use another 
variable name though:
f(y) = 3y^2 - 0y + 2

Best,

Alex.



[julia-users] Re: f(x)=ax2+bx+c ; if b = 0; ERROR: syntax: malformed expression

2014-11-27 Thread elextr
0x is the prefix for hexadecimal numbers, eg 0xff 

Since zero times anything is zero, it makes little sense to actually 
include such a term so the syntactic ambiguity seems acceptable.

Cheers
Lex

On Friday, November 28, 2014 5:30:25 PM UTC+10, paul analyst wrote:
>
> Sometimes in ax2+bx+c b is as parameter and can be zero .
>
> Version 0.4.0-dev+1642 (2014-11-17 08:38 UTC)
> Commit aa1f53b (10 days old master)
> x86_64-w64-mingw32
> julia> using HDF5
>
>
> julia> f(x) = (3x^2 - 4x + 2); fplot(f, [-5,5])
>
> julia> f(x) = (3x^2 - 0x + 2); fplot(f, [-5,5])
> (type-error uint8 number #f)
> unexpected error: #0 (sized-uint-literal #f "0x" 4)
> ...
> ...
> ...
> parse-RtoL/lambda (call f x) = #t)
> #41 (parse-eq [#f # #f #f])
> ERROR: syntax: malformed expression
>
> julia>
> Paul
>


[julia-users] f(x)=ax2+bx+c ; if b = 0; ERROR: syntax: malformed expression

2014-11-27 Thread paul analyst
Sometimes in ax2+bx+c b is as parameter and can be zero .

Version 0.4.0-dev+1642 (2014-11-17 08:38 UTC)
Commit aa1f53b (10 days old master)
x86_64-w64-mingw32
julia> using HDF5


julia> f(x) = (3x^2 - 4x + 2); fplot(f, [-5,5])

julia> f(x) = (3x^2 - 0x + 2); fplot(f, [-5,5])
(type-error uint8 number #f)
unexpected error: #0 (sized-uint-literal #f "0x" 4)
...
...
...
parse-RtoL/lambda (call f x) = #t)
#41 (parse-eq [#f # #f #f])
ERROR: syntax: malformed expression

julia>
Paul


Re: [julia-users] [Offtopic:] Why you did choose the name "Julia"?

2014-11-27 Thread Kevin Squire
Repeating myself, but searching for "julialang" works well.

Cheers,
   Kevin

On Thursday, November 27, 2014, ivo welch  wrote:

>
> I with it had been something more unique...like JuliaL .  too many google
> hits on julia.
>
> /iaw
>
> On Wednesday, November 26, 2014 6:19:04 AM UTC-8, Neal Becker wrote:
>>
>> All the good names were taken :)
>>
>> Pileas wrote:
>>
>> > Is there a specific reason you guys chose this name?
>> >
>> > It kinda reminds me Linux Mint where each distro. has a girl's name ...
>> --
>> -- Those who don't understand recursion are doomed to repeat it
>>
>>


[julia-users] Very basic problem with Gadfly

2014-11-27 Thread Alexander Gruber
I have a big list of rectangles I'd like to draw. What I want is to end up 
with something that looks like ArrayPlot 
 in Mathematica.

I have it the data the form of an Array{(Int64,Int64),1}, where each entry 
is the center of the rectangle.  I have figured out that I can get a Vector 
of rectangles by
map(x->rectangle(x[1],y[1],1,1))
but I can't figure out how to actually plot these once I have them.  How do 
I turn the array of rectangles into an image?  I've used the following 
before (calling my list of points L)
draw(SVG("output.svg",20cm,20cm),plot(x=map(x->x[1],L),y=map(x->x[2],L)))
to output the points as point objects to a file, but I can't seem to modify 
this syntax to work for the rectangle objects.

(As a side note, I would also be interested in knowing how to get the 
rasterized version of this, i.e. convert single pixels at coordinates 
corresponding to L to black and leave the rest white.  But even the vector 
graphics part is turning out to be harder than expected, so maybe that will 
have to be an adventure for another day...)


[julia-users] about - website (and kindle docs)

2014-11-27 Thread ivo welch

I was trying to figure out who is running julia and the website, and 
noticed that there is no "about us" that gives information on who the julia 
people are.  (it says on the front page that julia is mostly under the MIT 
license.)  would it make sense for someone to add this information?

I wanted to suggest to the julia foundation, if such a thing exists, to 
post the documentation on kindle for $9.99.  the library, reader, and 
auto-update feature makes this useful for some readers, esp those who want 
to donate a little to the foundation.

I am hoping that julia will soon mature to the point where I do not have to 
inflict R on my students.  (I am more bothered by R's obscure errors and 
lack of simplicity than by its slow speed.  It's not easy for students even 
to figure out on which lines their problem occurred.  without R mailing 
lists, kind souls, and search engines, R would have died long ago.)

/iaw



[julia-users] Re: [Offtopic:] Why you did choose the name "Julia"?

2014-11-27 Thread ivo welch

I with it had been something more unique...like JuliaL .  too many google 
hits on julia.

/iaw

On Wednesday, November 26, 2014 6:19:04 AM UTC-8, Neal Becker wrote:
>
> All the good names were taken :) 
>
> Pileas wrote: 
>
> > Is there a specific reason you guys chose this name? 
> > 
> > It kinda reminds me Linux Mint where each distro. has a girl's name ... 
> -- 
> -- Those who don't understand recursion are doomed to repeat it 
>
>

[julia-users] Julia and Microsoft Visual Studio

2014-11-27 Thread Pileas
I am experimenting a bit with different text editors and IDEs.

So far I have been quite happy with Atom editor, but there you need to 
always use the command line to execute the code (I have installed a 
`terminal` package that calls the bash quite quickly in Atom).

I was wondering if there is a package or something for Julia that we can 
install so that Visual Studio recognizes the language, like the one that 
exists for Python. 

I believe that this may help a lot in the debigging as well, since it will 
be easier to see and will save some time.


[julia-users] Re: Parametric type with user define type

2014-11-27 Thread elextr
The parameter to MyType{} needs to be a type, but Joker() is an instance. 
 Just use  MyType{Joker}(4)

Cheers
Lex

On Friday, November 28, 2014 9:50:08 AM UTC+10, sebastien.fa...@gmail.com 
wrote:
>
> Hello,
>
> Say I have a parametric type:
>
> type MyType{T}
>  var1
> end
>
>
>
> In the most of the case T is a simple integer, and there is no problem 
> with that. However, sometimes T is an instance of an singleton type, like:
>
>   
>   type Joker end
>
>
> Thus I would like to instantiate
>
> MyType{Joker()}(4)
>
> but I have the following error message:
>
> ERROR: type: apply_type: in MyType, expected Type{T<:Top}, got Joker
>
>
>
> Reading this message, I understand that the parameters of the types have 
> to be define "at the top"... This seems true while 
> MyType{MyType{4}(3)}(2)
> throw a similar error message.
>
> In the documentation : 
> http://julia.readthedocs.org/en/latest/manual/types/#man-parametric-types 
> there is no mention of such a restriction (or I didn't find it!).
>
> How can I make `MyType{Joker()}(4)` work the way I want ?
>
> Regards,
> Sébastien
>


[julia-users] Parametric type with user define type

2014-11-27 Thread sebastien . fabrice . besnier
Hello,

Say I have a parametric type:

type MyType{T}
 var1
end



In the most of the case T is a simple integer, and there is no problem with 
that. However, sometimes T is an instance of an singleton type, like:

  
  type Joker end


Thus I would like to instantiate

MyType{Joker()}(4)

but I have the following error message:

ERROR: type: apply_type: in MyType, expected Type{T<:Top}, got Joker



Reading this message, I understand that the parameters of the types have to 
be define "at the top"... This seems true while 
MyType{MyType{4}(3)}(2)
throw a similar error message.

In the documentation : 
http://julia.readthedocs.org/en/latest/manual/types/#man-parametric-types 
there is no mention of such a restriction (or I didn't find it!).

How can I make `MyType{Joker()}(4)` work the way I want ?

Regards,
Sébastien


Re: [julia-users] Animation with Gadfly and IJulia?

2014-11-27 Thread Sheehan Olver

I use GLPlot.jl for 3D, which is very fast as the update manipulates 
the data on the GPU directly, I believe.

It’s a bit finicky to setup and rough around the edges though.  I tried 
to set it up on another persons computer and it failed.

If you want example usage, see 

ApproxFun/src/plot/GLPlot.jl 

glsurf(xx::Array,yy::Array,vals::Matrix) on line 52 shows the setup for a 
non-tensor grid (which you want if your grid corresponds to a triangular mesh). 
 This returns a tuple (obj,window) that is updated by 
glsurfupdate(vals::Matrix,obj,window) on line 24.  This assumes the grid is 
fixed.  







> On 27 Nov 2014, at 3:05 pm, Christoph Ortner  
> wrote:
> 
> Hi Sheehan,
> 
> Thanks - I did see your post, and that is how I am currently using it. But 
> I'd prefer to do animations in the notebook if at all possible.
> 
> I'm happy to switch to Gadfly for 2D; what do you use for 3D plotting though?
> 
> Christoph
> 
> On Thursday, 27 November 2014 17:18:31 UTC, Sheehan Olver wrote:
> 
>   Hi Christoph!  Glad to hear that you are jumping on the Julia bandwagon.
> 
> 
> In principle it should work with PyPlot, since @manipulate works with PyPlot, 
> though some setup involving figure() is probably necessary, and I couldn’t 
> figure it out.
> 
>   PyPlot is a lot slower than Gadfly (not counting compile time!!) so I 
> would recommend using Gadfly for animation.
> 
> If you look at my previous posts, at some point I did figure out a way to do 
> animation in PyPlot using pygui(true).  It was a bit complicated and also 
> slow (the plotting was most of the computation time).
> 
> 
> Sheehan
> 
> 
> 
> 
> 
> 
>> On 27 Nov 2014, at 10:22 am, Christoph Ortner > > wrote:
>> 
>> Does this work with PyPlot?
>> Christoph
>> 
>> 
>> On Thursday, 27 November 2014 16:05:25 UTC, Sheehan Olver wrote:
>> You're right, I had interact as well
>> 
>> Sent from my iPhone
>> 
>> On 27 Nov 2014, at 5:59 am, Cristóvão Duarte Sousa > 
>> wrote:
>> 
>>> That is really nice!
>>> 
>>> But let me alert that, at least in my case (Julia 3.2), I had to add using 
>>> Interact so that the plot is correctly displayed.
>>> 
>>> Cheers,
>>> Cristóvão
>>> 
>>> On Thursday, November 27, 2014 4:59:00 AM UTC, Sheehan Olver wrote:
>>> I figured out an approach that works for animation, thanks to Jiahao Chen, 
>>> using 2 IJulia inputs:
>>> 
>>> 
>>> # In[1]
>>> using ApproxFun,Gadfly,Reactive
>>> x=Input(Fun(exp))
>>> lift(ApproxFun.plot, x)
>>> 
>>> # In[2]
>>> for k=1:10
>>> push!(x,Fun(x->cos(k*x)))
>>> end
>>> 
>>> 
>>> 
>>> On Tuesday, November 4, 2014 2:46:44 AM UTC-6, Sheehan Olver wrote:
>>> 
>>> 
>>> I'm wondering whether there's an example of doing animation directly in 
>>> IJulia with Gadfly.  Where by animation I mean plotting a sequence of 
>>> functions, lets say each frame is calculated from the previous frame and 
>>> wants to be plotted as soon as calculated.
>>> 
>>> Its clearly possible as its possible with Interact.jl: the code below does 
>>> work, but is not elegant and seems to run into problems if the calculation 
>>> is slow.  There is also the extra unneeded slide bar for k.   I can't seem 
>>> to figure out how to get ride of the @manipulate.
>>> 
>>> @manipulate for k=1:1, t_dt=timestamp(fps(30.))
>>> # calculate plot
>>> end
>>> 
>>> 
> 



Re: [julia-users] Re: Animation with Gadfly and IJulia?

2014-11-27 Thread Christoph Ortner
Steven Johnson helped me figure it out; here is a working code; see also
   https://groups.google.com/forum/#!topic/julia-users/Wb5hgyj2PMY

[1]
using Gadfly,Reactive,Interact,PyPlot
myfig = figure()
function myplot(data)
withfig(myfig) do
PyPlot.plot(data[1], data[2])
axis([0,1,-.3,.3])
end
end
x = linspace(0,1,100)
myinput=Input((x,0*x))
lift(myplot, myinput)

[2]
x = linspace(0,1,100)
for t = -1:.1:1
y = t * x .*(1-x)
push!(myinput,(x, y))
end


[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner
And here is the working code:

[1]
using Gadfly,Reactive,Interact,PyPlot
myfig = figure()
function myplot(data)
withfig(myfig) do
PyPlot.plot(data[1], data[2])
axis([0,1,-.3,.3])
end
end
x = linspace(0,1,100)
myinput=Input((x,0*x))
lift(myplot, myinput)

[2]
x = linspace(0,1,100)
for t = -1:.1:1
y = t * x .*(1-x)
push!(myinput,(x, y))
end


On Thursday, 27 November 2014 21:11:22 UTC, Christoph Ortner wrote:
>
> Hi Steven,
>
> That worked! Thank you.
>
> (Though admittedly I did not fully understand your explanation.)
>
> All the best, 
> Christoph
>
> On Thursday, 27 November 2014 19:04:12 UTC, Steven G. Johnson wrote:
>>
>> PyPlot, like the Python package of the same name, plots as a side effect. 
>> You can use the withfig function to wrap PyPlot commands and make them 
>> functional (returning the figure object as the withfig return value rather 
>> than displaying it as a side effect). This allows Pyplot to be used with 
>> @manipulate, but should also work with other Reactive functions. 
>
>

[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner
Hi Steven,

That worked! Thank you.

(Though admittedly I did not fully understand your explanation.)

All the best, 
Christoph

On Thursday, 27 November 2014 19:04:12 UTC, Steven G. Johnson wrote:
>
> PyPlot, like the Python package of the same name, plots as a side effect. 
> You can use the withfig function to wrap PyPlot commands and make them 
> functional (returning the figure object as the withfig return value rather 
> than displaying it as a side effect). This allows Pyplot to be used with 
> @manipulate, but should also work with other Reactive functions. 



Re: [julia-users] Re: Animation with Gadfly and IJulia?

2014-11-27 Thread Christoph Ortner
Hi Sheehan,

Thanks - I did see your post, and that is how I am currently using it. But 
I'd prefer to do animations in the notebook if at all possible.

I'm happy to switch to Gadfly for 2D; what do you use for 3D plotting 
though?

Christoph

On Thursday, 27 November 2014 17:18:31 UTC, Sheehan Olver wrote:
>
>
> Hi Christoph!  Glad to hear that you are jumping on the Julia bandwagon.
>
>
> In principle it should work with PyPlot, since @manipulate works with 
> PyPlot, though some setup involving figure() is probably necessary, and I 
> couldn’t figure it out.
>
> PyPlot is a lot slower than Gadfly (not counting compile time!!) so I 
> would recommend using Gadfly for animation.
>
> If you look at my previous posts, at some point I did figure out a way to 
> do animation in PyPlot using pygui(true).  It was a bit complicated and 
> also slow (the plotting was most of the computation time).
>
>
> Sheehan
>
>
>
>
>
>
> On 27 Nov 2014, at 10:22 am, Christoph Ortner  > wrote:
>
> Does this work with PyPlot?
> Christoph
>
>
> On Thursday, 27 November 2014 16:05:25 UTC, Sheehan Olver wrote:
>>
>> You're right, I had interact as well
>>
>> Sent from my iPhone
>>
>> On 27 Nov 2014, at 5:59 am, Cristóvão Duarte Sousa  
>> wrote:
>>
>> That is really nice!
>>
>> But let me alert that, at least in my case (Julia 3.2), I had to add *using 
>> Interact* so that the plot is correctly displayed.
>>
>> Cheers,
>> Cristóvão
>>
>> On Thursday, November 27, 2014 4:59:00 AM UTC, Sheehan Olver wrote:
>>>
>>> I figured out an approach that works for animation, thanks to Jiahao 
>>> Chen, using 2 IJulia inputs:
>>>
>>>
>>> # In[1]
>>> using ApproxFun,Gadfly,Reactive
>>> x=Input(Fun(exp))
>>> lift(ApproxFun.plot, x)
>>>
>>> # In[2]
>>> for k=1:10
>>> push!(x,Fun(x->cos(k*x)))
>>> end
>>>
>>>
>>>
>>> On Tuesday, November 4, 2014 2:46:44 AM UTC-6, Sheehan Olver wrote:



 I'm wondering whether there's an example of doing animation directly in 
 IJulia with Gadfly.  Where by animation I mean plotting a sequence of 
 functions, lets say each frame is calculated from the previous frame and 
 wants to be plotted as soon as calculated.

 Its clearly possible as its possible with Interact.jl: the code below 
 does work, but is not elegant and seems to run into problems if the 
 calculation is slow.  There is also the extra unneeded slide bar for k.   
 I 
 can't seem to figure out how to get ride of the @manipulate.

 @manipulate for k=1:1, t_dt=timestamp(fps(30.))
 # calculate plot
 end



>

[julia-users] Re: Thanks to the Julia developers

2014-11-27 Thread Ivar Nesje
Thanks for the kind words (and for being mentioned twice)

Currently we actually have 299 contributors, so next time we merge a PR 
from a new person, we hit the 300 mark. That's definitely exciting! 

Ivar

kl. 20:12:54 UTC+1 torsdag 27. november 2014 skrev Arch Call følgende:
>
> As the colonists gave thanks 393 years ago for their one year survival in 
> the Plymouth Colony, I give thanks to all those Julia Developers who have 
> created, or are nurturing this wonderful scientific programming language 
> called - Julia.
>
> Here is a short list of major contributors to the Julia code base (surely 
> I've missed many)
>
>- JeffB, StefanK, ViralB, vtjnash, Keno, nolta, carlobaldassi, 
>timholy, staticfloat, stevangj, andreasnoack, kmsquire, tkelman, boyers, 
>lindahua, simonster, ihnorton, dmbates
>- pao, quinnj, simonbyrne, androni, amitmurthy, ivarne, tanmaykm, 
>jakebolewski, aviks, mbauman, GeorgeXing, rfourquet, JohnMylesWhite, 
>ArchRobinson, HarlanH, dcjones
>- Wilfred, one-more-minute, eschnett, blakejohnson, Jutho, brk00, 
>tknopp, nalimilan, ianNZ, mlubin, milktrader, tonyhffong, jverzani, 
>rennis250, scidom, WestleyArgentum, joehuchette
>- strieanna, diegozea, shasi, felipcruz, zachallaun, 
>powerdistribution, acroy, ivarne, glenn-sweeney, m-hohmann, fperez, 
>malmaud, Carreau, pozovlok, deinst, rsofar, nfati, wsliang
>- dpsanders, AlanEdelman
>
>
> Thanks for all that you have done to sustain Julia!
>
> ...Archie Call -  (a Julia newbie user in the Bioinformatics & Genetics 
> arena)
>


[julia-users] Thanks to the Julia developers

2014-11-27 Thread Arch Call
As the colonists gave thanks 393 years ago for their one year survival in 
the Plymouth Colony, I give thanks to all those Julia Developers who have 
created, or are nurturing this wonderful scientific programming language 
called - Julia.

Here is a short list of major contributors to the Julia code base (surely 
I've missed many)

   - JeffB, StefanK, ViralB, vtjnash, Keno, nolta, carlobaldassi, timholy, 
   staticfloat, stevangj, andreasnoack, kmsquire, tkelman, boyers, lindahua, 
   simonster, ihnorton, dmbates
   - pao, quinnj, simonbyrne, androni, amitmurthy, ivarne, tanmaykm, 
   jakebolewski, aviks, mbauman, GeorgeXing, rfourquet, JohnMylesWhite, 
   ArchRobinson, HarlanH, dcjones
   - Wilfred, one-more-minute, eschnett, blakejohnson, Jutho, brk00, 
   tknopp, nalimilan, ianNZ, mlubin, milktrader, tonyhffong, jverzani, 
   rennis250, scidom, WestleyArgentum, joehuchette
   - strieanna, diegozea, shasi, felipcruz, zachallaun, powerdistribution, 
   acroy, ivarne, glenn-sweeney, m-hohmann, fperez, malmaud, Carreau, 
   pozovlok, deinst, rsofar, nfati, wsliang
   - dpsanders, AlanEdelman


Thanks for all that you have done to sustain Julia!

...Archie Call -  (a Julia newbie user in the Bioinformatics & Genetics 
arena)


[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Steven G. Johnson
PyPlot, like the Python package of the same name, plots as a side effect. You 
can use the withfig function to wrap PyPlot commands and make them functional 
(returning the figure object as the withfig return value rather than displaying 
it as a side effect). This allows Pyplot to be used with @manipulate, but 
should also work with other Reactive functions. 

Re: [julia-users] Function to check monotonicity

2014-11-27 Thread Stefan Karpinski
It seems to me that generalizing the Base.issorted function makes sense. Of
course you need to be able to indicate that you want to check for sorted
columns, rows, etc.

On Thu, Nov 27, 2014 at 12:43 PM, Kevin Squire 
wrote:

> issorted(A) works for vectors.  I don't believe there is a version which
> exists for arrays with dimension N>1.
>
> Cheers,
>Kevin
>
> On Thursday, November 27, 2014, Nils Gudat  wrote:
>
>> Before I start putting something crude together myself, I thought I'd ask
>> here: is there a simple function in Julia that checks monotonicity of
>> vectors/arrays?
>> Ideally, I would like a function that takes an Array{Float64},N and
>> checks monotonicity for each of the N dimensions separately.
>>
>


Re: [julia-users] Parallel programming weird overhead

2014-11-27 Thread Amit Murthy
I tried after factoring out the cost of sending A and v over, but no dice.

See https://gist.github.com/amitmurthy/3206a4f61cf6cd6000ee

Even with a loop of 4 within do_stuff, same behavior.

I think I found the reason in an old thread -
https://groups.google.com/d/msg/julia-users/jlKoEtErRL4/UTN7FSlZDgoJ

To confirm the same, save


const A = randn(1000, 1000);
const numx = 10_000;
const v = randn(1000, numx);

do_stuff(r::UnitRange) = ([do_stuff(mm) for mm in r]; nothing)
function do_stuff(mm::Int64)
for x in 1:4
sum( A * v[:, mm] )
end
end

chunks = Base.splitrange(numx, 4)

do_stuff(chunks[1]);


in a new file p.jl and from the command line first run them in parallel
like this

julia p.jl &

four times quickly.

The performance is heavily degraded compared to the serial version



On Thu, Nov 27, 2014 at 10:35 PM, Erik Schnetter 
wrote:

> You need to use addprocs before the first @everywhere. I assume you
> actually did this, since otherwise you'd have received an error.
>
> It seems that your variable A and v are stored on the master, not on
> the workers. Since they are inputs to do_stuff, they need to be copied
> there every time. Note that the whole array v is copied although only
> part of it is accessed. Maybe sending data to 4 processes
> simultaneously has an overhead, and is somehow much slower than
> sending the data one at a time.
>
> To check whether this is true, you can add a loop within do_stuff to
> execute the routine multiple times. This would increase the workload,
> but keep the communication overhead the same.
>
> If this is the case, then to remedy this, you would store A and v
> (better: only the necessary part of v) on all processes instead of
> copying them.
>
> -erik
>
>
> On Thu, Nov 27, 2014 at 10:20 AM,   wrote:
> > Hey everyone,
> >
> > I've been looking at parallel programming in julia and was getting some
> very
> > unexpected results and rather bad performance because of this.
> > Sadly I ran out of ideas of what could be going on, disproving all ideas
> I
> > had. Hence this post :)
> >
> > I was able to construct a similar (simpler) example which exhibits the
> same
> > behavior (attached file).
> > The example is a very naive and suboptimal implementation in many ways
> (the
> > actual code is much more optimal), but that's not the issue.
> >
> > The issue I'm trying to investigate is the big difference in worker time
> > when a single worker is active and when multiple are active.
> >
> > Ideas I disproved:
> >   - julia processes pinned to a single core
> >   - julia process uses multiple threads to do the work, and processes are
> > fighting for the cores
> >   - not enough cores on the machine (there are plenty)
> >   - htop nicely shows 4 julia processes working on different cores
> >   - there is no communication at the application level stalling anyone
> >
> > All I'm left with now is that julia is doing some hidden synchronization
> > somewhere.
> > Any input is appreciated. Thanks in advance.
> >
> > Kind regards,
> > Tom
>
>
>
> --
> Erik Schnetter 
> http://www.perimeterinstitute.ca/personal/eschnetter/
>


Re: [julia-users] Parallel programming weird overhead

2014-11-27 Thread tom . haber
Hey Eric,

The addprocs() is indeed in the wrong place, I must have made a mistake 
copy-pasting the example.

The overhead in copying A and v is obviously very naive and suboptimal as I 
pointed out. The real implementation I'm focused on is much more efficient 
in this regard.
The problem I wanted to point out isn't regarding this however. The @time 
on the workers actually runs after all communication and serialization work 
is finished and should time just the actual execution.
At least this is the behavior I expect/hope it has :) The issue is then 
that this runtime of the actual execution (without overhead) is 2x larger 
somehow.

Tom

On Thursday, November 27, 2014 6:06:06 PM UTC+1, Erik Schnetter wrote:
>
> You need to use addprocs before the first @everywhere. I assume you 
> actually did this, since otherwise you'd have received an error. 
>
> It seems that your variable A and v are stored on the master, not on 
> the workers. Since they are inputs to do_stuff, they need to be copied 
> there every time. Note that the whole array v is copied although only 
> part of it is accessed. Maybe sending data to 4 processes 
> simultaneously has an overhead, and is somehow much slower than 
> sending the data one at a time. 
>
> To check whether this is true, you can add a loop within do_stuff to 
> execute the routine multiple times. This would increase the workload, 
> but keep the communication overhead the same. 
>
> If this is the case, then to remedy this, you would store A and v 
> (better: only the necessary part of v) on all processes instead of 
> copying them. 
>
> -erik 
>
>
> On Thu, Nov 27, 2014 at 10:20 AM,  > 
> wrote: 
> > Hey everyone, 
> > 
> > I've been looking at parallel programming in julia and was getting some 
> very 
> > unexpected results and rather bad performance because of this. 
> > Sadly I ran out of ideas of what could be going on, disproving all ideas 
> I 
> > had. Hence this post :) 
> > 
> > I was able to construct a similar (simpler) example which exhibits the 
> same 
> > behavior (attached file). 
> > The example is a very naive and suboptimal implementation in many ways 
> (the 
> > actual code is much more optimal), but that's not the issue. 
> > 
> > The issue I'm trying to investigate is the big difference in worker time 
> > when a single worker is active and when multiple are active. 
> > 
> > Ideas I disproved: 
> >   - julia processes pinned to a single core 
> >   - julia process uses multiple threads to do the work, and processes 
> are 
> > fighting for the cores 
> >   - not enough cores on the machine (there are plenty) 
> >   - htop nicely shows 4 julia processes working on different cores 
> >   - there is no communication at the application level stalling anyone 
> > 
> > All I'm left with now is that julia is doing some hidden synchronization 
> > somewhere. 
> > Any input is appreciated. Thanks in advance. 
> > 
> > Kind regards, 
> > Tom 
>
>
>
> -- 
> Erik Schnetter > 
> http://www.perimeterinstitute.ca/personal/eschnetter/ 
>


Re: [julia-users] Function to check monotonicity

2014-11-27 Thread Kevin Squire
issorted(A) works for vectors.  I don't believe there is a version which
exists for arrays with dimension N>1.

Cheers,
   Kevin

On Thursday, November 27, 2014, Nils Gudat  wrote:

> Before I start putting something crude together myself, I thought I'd ask
> here: is there a simple function in Julia that checks monotonicity of
> vectors/arrays?
> Ideally, I would like a function that takes an Array{Float64},N and checks
> monotonicity for each of the N dimensions separately.
>


[julia-users] trouble using Cxx.jl

2014-11-27 Thread Max Suster
I am using Cxx.jl on Mac OSX 10.9.5 (64 bit).
Cxx requires Julia v0.4.0-dev (i.e., staged functions).  I have rebuilt Cxx 
many times and the only trouble I encountered was due to not updating Clang in 
deps/llvm-svn and related directories.

I think it is best to file an issue in Cxx.jl and hopefully someone can help 
you with linux-specific issues.



Re: [julia-users] Re: Animation with Gadfly and IJulia?

2014-11-27 Thread Sheehan Olver

Hi Christoph!  Glad to hear that you are jumping on the Julia bandwagon.


In principle it should work with PyPlot, since @manipulate works with PyPlot, 
though some setup involving figure() is probably necessary, and I couldn’t 
figure it out.

PyPlot is a lot slower than Gadfly (not counting compile time!!) so I 
would recommend using Gadfly for animation.

If you look at my previous posts, at some point I did figure out a way to do 
animation in PyPlot using pygui(true).  It was a bit complicated and also slow 
(the plotting was most of the computation time).


Sheehan






> On 27 Nov 2014, at 10:22 am, Christoph Ortner  
> wrote:
> 
> Does this work with PyPlot?
> Christoph
> 
> 
> On Thursday, 27 November 2014 16:05:25 UTC, Sheehan Olver wrote:
> You're right, I had interact as well
> 
> Sent from my iPhone
> 
> On 27 Nov 2014, at 5:59 am, Cristóvão Duarte Sousa  > wrote:
> 
>> That is really nice!
>> 
>> But let me alert that, at least in my case (Julia 3.2), I had to add using 
>> Interact so that the plot is correctly displayed.
>> 
>> Cheers,
>> Cristóvão
>> 
>> On Thursday, November 27, 2014 4:59:00 AM UTC, Sheehan Olver wrote:
>> I figured out an approach that works for animation, thanks to Jiahao Chen, 
>> using 2 IJulia inputs:
>> 
>> 
>> # In[1]
>> using ApproxFun,Gadfly,Reactive
>> x=Input(Fun(exp))
>> lift(ApproxFun.plot, x)
>> 
>> # In[2]
>> for k=1:10
>> push!(x,Fun(x->cos(k*x)))
>> end
>> 
>> 
>> 
>> On Tuesday, November 4, 2014 2:46:44 AM UTC-6, Sheehan Olver wrote:
>> 
>> 
>> I'm wondering whether there's an example of doing animation directly in 
>> IJulia with Gadfly.  Where by animation I mean plotting a sequence of 
>> functions, lets say each frame is calculated from the previous frame and 
>> wants to be plotted as soon as calculated.
>> 
>> Its clearly possible as its possible with Interact.jl: the code below does 
>> work, but is not elegant and seems to run into problems if the calculation 
>> is slow.  There is also the extra unneeded slide bar for k.   I can't seem 
>> to figure out how to get ride of the @manipulate.
>> 
>> @manipulate for k=1:1, t_dt=timestamp(fps(30.))
>> # calculate plot
>> end
>> 
>> 



[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner
A naive attempt at this failed I just replaced Winston.plot with 
PyPlot.plot in Cristovao's example; see below. The result is that Pyplot 
plots in the [2] output instead of the [1] output.

Why is it ok with Winston but not with PyPlot?

I am obsessing about PyPlot because I need the 3D plotting capabilities.

Thank you,
Christoph

  
In [1] 
using Gadfly,Reactive,Interact,PyPlot
function myplot(data)
PyPlot.plot(data[1], data[2])
axis([0,1,-.3,.3])
end
x = linspace(0,1,100)
myinput=Input((x,0*x))
lift(myplot, my input)

In [2]
x = linspace(0,1,100)
for t = -1:.1:1
y = t * x .*(1-x)
push!(myinput,(x, y))
end



[julia-users] Beginner problems with parallelization

2014-11-27 Thread Nils Gudat
I'm trying to get my head around parallelization in Julia, but nothing 
seems to work as I expect. I've read the Parallel Computing part of the 
docs quite a few times, but I'm just not able to apply the principles there 
to my problem.
As a simple example, consider the following problem: I have three grids of 
values and want to compute the value of a function for each combination of 
values on these grids.

grid1 = linspace(1.1, 1.2, 10)
grid2 = linspace(2.1, 2.2, 100)
grid3 = linspace(3.1, 3.3, 100)
results = Array(Float64, (100, 100, 100))

function f(i, j, k, grid1, grid2, grid3)
  grid1[i]*grid2[j]*grid3[k]
end

for i = 1:10
  for j = 1:100
for k = 1:100
   results[i, j, k] = f(i, j, k, grid1, grid2, grid3)
end
  end
end

I've tried parallelizing this by using addprocs(3), then defining f using 
@everywhere 
and turning the array holding the results into a distributed array using 
distribute(results). Then I do
@parallel for k=1:100 
  results[i, j, k] = f(i, j, k, grid1, grid2, grid3)
end

for the inner part of the loop. Still, I find that the results of the 
calculations are not sent to be stored in a distributed array. How do I get 
the results out of a parallel for loop?


Re: [julia-users] Parallel programming weird overhead

2014-11-27 Thread Erik Schnetter
You need to use addprocs before the first @everywhere. I assume you
actually did this, since otherwise you'd have received an error.

It seems that your variable A and v are stored on the master, not on
the workers. Since they are inputs to do_stuff, they need to be copied
there every time. Note that the whole array v is copied although only
part of it is accessed. Maybe sending data to 4 processes
simultaneously has an overhead, and is somehow much slower than
sending the data one at a time.

To check whether this is true, you can add a loop within do_stuff to
execute the routine multiple times. This would increase the workload,
but keep the communication overhead the same.

If this is the case, then to remedy this, you would store A and v
(better: only the necessary part of v) on all processes instead of
copying them.

-erik


On Thu, Nov 27, 2014 at 10:20 AM,   wrote:
> Hey everyone,
>
> I've been looking at parallel programming in julia and was getting some very
> unexpected results and rather bad performance because of this.
> Sadly I ran out of ideas of what could be going on, disproving all ideas I
> had. Hence this post :)
>
> I was able to construct a similar (simpler) example which exhibits the same
> behavior (attached file).
> The example is a very naive and suboptimal implementation in many ways (the
> actual code is much more optimal), but that's not the issue.
>
> The issue I'm trying to investigate is the big difference in worker time
> when a single worker is active and when multiple are active.
>
> Ideas I disproved:
>   - julia processes pinned to a single core
>   - julia process uses multiple threads to do the work, and processes are
> fighting for the cores
>   - not enough cores on the machine (there are plenty)
>   - htop nicely shows 4 julia processes working on different cores
>   - there is no communication at the application level stalling anyone
>
> All I'm left with now is that julia is doing some hidden synchronization
> somewhere.
> Any input is appreciated. Thanks in advance.
>
> Kind regards,
> Tom



-- 
Erik Schnetter 
http://www.perimeterinstitute.ca/personal/eschnetter/


Re: [julia-users] Installing IJulia

2014-11-27 Thread stonebig34
Hi Abram, (sorry for the keyboard error)
 
I wrote "last resort" as I supposed you were relying on Anaconda for other 
purposes.

If the only goal for you is to get Ijulia working on windows, this solution 
as the advantage of working since a few months.

On Thursday, November 27, 2014 9:59:05 AM UTC+1, Abram Demski wrote:
>
> Pileas,
>
> Atom looks very cool, but it appears existing Julia customization is very 
> minimal. Do you know if there is an easy way to have a command to run the 
> current file in a julia terminal? (I miiight be tempted into trying to 
> build it, seeing as the Atom customization stuff looks fun...)
>
> On Wed, Nov 26, 2014 at 3:26 PM, Abram Demski  > wrote:
>
>> Pileas,
>>
>> Given that I've still been unable to install IJulia, that's very helpful, 
>> thanks.
>>
>> On Tue, Nov 25, 2014 at 6:29 PM, Pileas > > wrote:
>>
>>> I have to suggest a very good editor that supports "Julia" and it is 
>>> called Atom. It becomes better each day:
>>>
>>> Give it a try if you have time: https://atom.io/
>>>
>>> Τη Τρίτη, 25 Νοεμβρίου 2014 6:12:52 μ.μ. UTC-5, ο χρήστης Abram Demski 
>>> έγραψε:

 Thanks! I figured out how to do it in the default shell:

 julia> print(ENV["PATH"])
 C:\Users\abram\AppData\Local\Julia-0.3.3\bin;C:\Users\
 abram\AppData\Local\Julia-
 0.3.3\bin\..\Git\bin;C:\Program Files (x86)\Intel\iCLS 
 Client\;C:\Program Files\
 Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\
 Wbem;C:\wi
 ndows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) 
 Managemen
 t Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management 
 Engine Compon
 ents\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine 
 Components\DAL;
 C:\Program Files (x86)\Intel\Intel(R) Management Engine 
 Components\IPT;C:\Progra
 m Files\Intel\WiFi\bin\;C:\Program Files\Common 
 Files\Intel\WirelessCommon\;C:\P
 rogram Files\Condusiv Technologies\ExpressCache\;C:\Program Files 
 (x86)\Common F
 iles\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps;
 C:\Anaconda;C:\Anaco
 nda\Scripts

 (I have not used windows much since Windows 98! ;p)

 On Tue, Nov 25, 2014 at 3:02 PM, cdm  wrote:

>
> if you have access to the PowerShell in Windows 8 ( ... and similar, 
> new-ish, MS OSs ...),
> then highlighting a block of text from the PowerShell and right 
> clicking should rip it to the
> clipboard for pasting else-where ...
>
> best,
>
> cdm
>
>
>
> On Tuesday, November 25, 2014 2:42:51 PM UTC-8, Abram Demski wrote:
>>
>>
>> Julia shows a similar PATH when I run ENV["PATH"], but with more 
>> julia-specific things. (It seems that command prompts in Windows 8.1 do 
>> not 
>> allow one to copy text out of them directly.. otherwise I'd copy.)
>>
>>  


 -- 
 Abram Demski
 Blog: http://lo-tho.blogspot.com/
  
>>>
>>
>>
>> -- 
>> Abram Demski
>> Blog: http://lo-tho.blogspot.com/
>>  
>
>
>
> -- 
> Abram Demski
> Blog: http://lo-tho.blogspot.com/
>  


Re: [julia-users] Installing IJulia

2014-11-27 Thread stonebig34
Hi Adam,

I wrote "last resort" as I supposed you were relying on Anaconda for other 
purposes.

If the only goal for you is to get Ijulia working on windows, this solution 
as the advantage of working since a few months.



On Thursday, November 27, 2014 9:58:44 AM UTC+1, Abram Demski wrote:
>
> Stonebig34,
>
> "If all else fails" makes me think this is a last resort. Should I be wary?
>
> So, this approach requires WinPython as opposed to the Anaconda install of 
> IPython I've currently got? (I'm not attached if there aren't any big 
> downsides; I used Anaconda only because the instructions for installing 
> IJulia said to.)
>
> Thanks,
>
> Abram
>
> On Wed, Nov 26, 2014 at 10:00 PM, > 
> wrote:
>
>> Hi Abram,
>>
>> If all else fails, you have still this alternative
>>
>>
>> http://nbviewer.ipython.org/github/winpython/winpython_afterdoc/blob/master/examples/installing_julia_and_ijulia.ipynb
>>
>>
>> On Thursday, November 27, 2014 6:57:41 AM UTC+1, cdm wrote:
>>>
>>>
>>> if you are not averse to trying IJulia in your browser, then have a look 
>>> at this post ...
>>>
>>>https://groups.google.com/forum/#!searchin/julia-users/
>>> tmpnb|sort:relevance/julia-users/zEp8pKkEYHk/qY7tPqrOp9gJ
>>>
>>>
>>> there are other ways to work with IJulia on kernels hosted elsewhere; 
>>> let me know
>>> if you are interested.
>>>
>>> best,
>>>
>>> cdm
>>>
>>>
>>> On Wednesday, November 26, 2014 3:26:51 PM UTC-8, Abram Demski wrote:

 Pileas,

 Given that I've still been unable to install IJulia, that's very 
 helpful, thanks.


>
>
> -- 
> Abram Demski
> Blog: http://lo-tho.blogspot.com/
>  


Re: [julia-users] Re: Meshgrid in Julia: a working example and possible alternatives

2014-11-27 Thread David Smith
Sorry, forgot the version.  That was 

matplotlib1.4.0np19py27_0 


Re: [julia-users] Re: Meshgrid in Julia: a working example and possible alternatives

2014-11-27 Thread David Smith
 
julia> include("plotnan.jl") 
INFO: Loading help data... 
/Users/dss/anaconda/lib/python2.7/site-packages/matplotlib/colors.py:583: 
RuntimeWarning: invalid value encountered in less 
cbook._putmask(xa, xa < 0.0, -1) 
PyObject 


This is the code:
  
using PyPlot 
x = rand(8,8)
x[1] = NaN 
pcolor(x)

On Wednesday, November 26, 2014 8:05:32 AM UTC-6, Steven G. Johnson wrote:
>
>
>
> On Wednesday, November 26, 2014 12:45:09 AM UTC-5, David Smith wrote:
>>
>> My up-to-date version of Matplotlib won't plot NaNs either.
>>
>
> That's weird; it works fine for me in Matplotlib 1.4.0.
>
> In any case, you can always zero out the NaN values in W via:
> W[isnan(W)] = 0
> before plotting. 
>


Re: [julia-users] Re: Animation with Gadfly and IJulia?

2014-11-27 Thread Christoph Ortner
Does this work with PyPlot?
Christoph


On Thursday, 27 November 2014 16:05:25 UTC, Sheehan Olver wrote:
>
> You're right, I had interact as well
>
> Sent from my iPhone
>
> On 27 Nov 2014, at 5:59 am, Cristóvão Duarte Sousa  > wrote:
>
> That is really nice!
>
> But let me alert that, at least in my case (Julia 3.2), I had to add *using 
> Interact* so that the plot is correctly displayed.
>
> Cheers,
> Cristóvão
>
> On Thursday, November 27, 2014 4:59:00 AM UTC, Sheehan Olver wrote:
>>
>> I figured out an approach that works for animation, thanks to Jiahao 
>> Chen, using 2 IJulia inputs:
>>
>>
>> # In[1]
>> using ApproxFun,Gadfly,Reactive
>> x=Input(Fun(exp))
>> lift(ApproxFun.plot, x)
>>
>> # In[2]
>> for k=1:10
>> push!(x,Fun(x->cos(k*x)))
>> end
>>
>>
>>
>> On Tuesday, November 4, 2014 2:46:44 AM UTC-6, Sheehan Olver wrote:
>>>
>>>
>>>
>>> I'm wondering whether there's an example of doing animation directly in 
>>> IJulia with Gadfly.  Where by animation I mean plotting a sequence of 
>>> functions, lets say each frame is calculated from the previous frame and 
>>> wants to be plotted as soon as calculated.
>>>
>>> Its clearly possible as its possible with Interact.jl: the code below 
>>> does work, but is not elegant and seems to run into problems if the 
>>> calculation is slow.  There is also the extra unneeded slide bar for k.   I 
>>> can't seem to figure out how to get ride of the @manipulate.
>>>
>>> @manipulate for k=1:1, t_dt=timestamp(fps(30.))
>>> # calculate plot
>>> end
>>>
>>>
>>>

[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner
On second thought, the scheme using `Input` might actually work for this. 
I'll have a go.
 Christoph


On Thursday, 27 November 2014 15:36:28 UTC, Christoph Ortner wrote:
>
>
>
> Thank you both for your replies. 
>
> Since the purpose is to plot the current state of a numerical simulation 
> every few iterations (of some nonlinear iteration or time-stepping scheme) 
> I don't think either these are suitable though. 
>
> Re the @manipulate approach: I just get a slider this way? I've tried to 
> follow the examples in the @manipulate docs, but no luck really to get 
> these to run either. + All this is much too complicated for my test.
>
> Is there no way to simple force IJulia to draw the current plot command?
>
> Thanks,
> Christoph
>
>
>
> On Thursday, 27 November 2014 14:20:36 UTC, Steven G. Johnson wrote:
>>
>> using PyPlot, Interact 
>>
>> f = figure() 
>> @manipulate for p in 1:10 
>>   withfig(f) do 
>> ...plot commands with parameter p... 
>>   end 
>> end 
>>
>> There are some other plotting examples with @manipulate in the Interact 
>> docs. 
>
>

Re: [julia-users] Re: Animation with Gadfly and IJulia?

2014-11-27 Thread Sheehan Olver
You're right, I had interact as well

Sent from my iPhone

> On 27 Nov 2014, at 5:59 am, Cristóvão Duarte Sousa  wrote:
> 
> That is really nice!
> 
> But let me alert that, at least in my case (Julia 3.2), I had to add using 
> Interact so that the plot is correctly displayed.
> 
> Cheers,
> Cristóvão
> 
>> On Thursday, November 27, 2014 4:59:00 AM UTC, Sheehan Olver wrote:
>> I figured out an approach that works for animation, thanks to Jiahao Chen, 
>> using 2 IJulia inputs:
>> 
>> 
>> # In[1]
>> using ApproxFun,Gadfly,Reactive
>> x=Input(Fun(exp))
>> lift(ApproxFun.plot, x)
>> 
>> # In[2]
>> for k=1:10
>> push!(x,Fun(x->cos(k*x)))
>> end
>> 
>> 
>> 
>>> On Tuesday, November 4, 2014 2:46:44 AM UTC-6, Sheehan Olver wrote:
>>> 
>>> 
>>> I'm wondering whether there's an example of doing animation directly in 
>>> IJulia with Gadfly.  Where by animation I mean plotting a sequence of 
>>> functions, lets say each frame is calculated from the previous frame and 
>>> wants to be plotted as soon as calculated.
>>> 
>>> Its clearly possible as its possible with Interact.jl: the code below does 
>>> work, but is not elegant and seems to run into problems if the calculation 
>>> is slow.  There is also the extra unneeded slide bar for k.   I can't seem 
>>> to figure out how to get ride of the @manipulate.
>>> 
>>> @manipulate for k=1:1, t_dt=timestamp(fps(30.))
>>> # calculate plot
>>> end
>>> 
>>> 


[julia-users] Parallel programming weird overhead

2014-11-27 Thread tom . haber
Hey everyone,

I've been looking at parallel programming in julia and was getting some 
very unexpected results and rather bad performance because of this. 
Sadly I ran out of ideas of what could be going on, disproving all ideas I 
had. Hence this post :)

I was able to construct a similar (simpler) example which exhibits the same 
behavior (attached file).
The example is a very naive and suboptimal implementation in many ways (the 
actual code is much more optimal), but that's not the issue.

The issue I'm trying to investigate is the big difference in worker time 
when a single worker is active and when multiple are active.

Ideas I disproved:
  - julia processes pinned to a single core
  - julia process uses multiple threads to do the work, and processes are 
fighting for the cores
  - not enough cores on the machine (there are plenty)
  - htop nicely shows 4 julia processes working on different cores
  - there is no communication at the application level stalling anyone

All I'm left with now is that julia is doing some hidden synchronization 
somewhere.
Any input is appreciated. Thanks in advance.

Kind regards,
Tom


parallel-test.jl
Description: Binary data


[julia-users] Function to check monotonicity

2014-11-27 Thread Nils Gudat
Before I start putting something crude together myself, I thought I'd ask 
here: is there a simple function in Julia that checks monotonicity of 
vectors/arrays?
Ideally, I would like a function that takes an Array{Float64},N and checks 
monotonicity for each of the N dimensions separately. 


[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner


Thank you both for your replies. 

Since the purpose is to plot the current state of a numerical simulation 
every few iterations (of some nonlinear iteration or time-stepping scheme) 
I don't think either these are suitable though. 

Re the @manipulate approach: I just get a slider this way? I've tried to 
follow the examples in the @manipulate docs, but no luck really to get 
these to run either. + All this is much too complicated for my test.

Is there no way to simple force IJulia to draw the current plot command?

Thanks,
Christoph



On Thursday, 27 November 2014 14:20:36 UTC, Steven G. Johnson wrote:
>
> using PyPlot, Interact 
>
> f = figure() 
> @manipulate for p in 1:10 
>   withfig(f) do 
> ...plot commands with parameter p... 
>   end 
> end 
>
> There are some other plotting examples with @manipulate in the Interact 
> docs. 



[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Steven G. Johnson
using PyPlot, Interact

f = figure()
@manipulate for p in 1:10
  withfig(f) do
...plot commands with parameter p...
  end
end

There are some other plotting examples with @manipulate in the Interact docs. 

[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Cristóvão Duarte Sousa
Hi,

I was able to do it using Interact, Reactive and Winston in IJulia.

For example, in one input cell run

using Interact, Reactive, Winston

p = Input(0.0:0.0)
function f(x)
plot(sin(5*x), sin(2π*x))
xlim(-1, 1)
ylim(-1, 1)
end
lift(f, p)



and then, in another cell, run your updating loop:

for i=0:0.05:10
sleep(1/60)
push!(p, 0.0:0.01:i)
end

I'm pretty sure this is inefficient and can be very slow for more 
elaborated plots though.

On Thursday, November 27, 2014 11:20:54 AM UTC, Christoph Ortner wrote:
>
> I could not find it, but apologies if this has previously been discussed.
>
> I am interested in outputting numerical results on the fly - not in 
> generating movie files. (I have found some nice examples on how to do the 
> latter.) The following code snippet, run in IJulia opens an external plot 
> window and then displays the animation I want to see.
>
> using PyPlot
> pygui(true)
> x = linspace(0,1,100)
> PyPlot.hold(false)
> for t = -1:.1:1
> plot(x, t*(1-x).*x)
> axis([0,1, -.3, .3])
> PyPlot.draw()
> end
>
> But if I change to pygui(false)  to see the plots within IJulia, then I 
> only get the final graph. Can it be done? What am I missing?
>
> (Strangly, I think I did have it working before, but somehow broke it and 
> cannot figure out again what I did.)
>
> Many thanks,
>Christoph
>
>
>

[julia-users] Re: Parallel Programming in Julia

2014-11-27 Thread Erno Scheiber


Again, let be 


 addprocs(4)

a=[1,2,3,4]

b=zeros(4)


 @parallel for i=1:4

b[i]=a[i]^3

end


 b will be not changed (b=[0,0,0,0]).


 After running successfully the codes of my initial post, we resume


 @parallel for i=1:4

b[i]=a[i]^3

end


 Now we obtain the correct results !?!

Further, in this Julia session, the @parallel for... end statements will 
give the expected result, regardless of the computation code.


 If we drop out the first setting (addprocs) then there is no problem, but 
I thing that the @parallel macro is ineffective, the computation is 
sequential on a multicore machine.




[julia-users] Re: julia vs cython benchmark

2014-11-27 Thread Andre Bieler
alright!
did the @inbounds and @simd and benchmarked again 
(for different light source position, thats why numbers dont match exactly 
with the ones above)

cython original code:   27.5 s
julia original code:28.3 s

julia with @inbounds:   21.3 s

julia 
with @inbounds & @simd: 19.0 s

Looks like a nice speed up to me! :)
I ll look into the column-major issue later.

Thanks for the input guys!





On Thursday, November 27, 2014 3:17:28 AM UTC-5, Ariel Keselman wrote:
>
> in the Cython code you turned off bounds checking. This can be done for 
> Julia with the @inbounds macro. Just use it in your loops like this:
>
> @inbounds for i in whatever
> ...
> end
>
> also @simd may help, sems you can use it in a couple of the innrmost 
> loops. It sems also simple to parallelize with a shared array and a 
> @parallel for
>


[julia-users] Re: Animation with Gadfly and IJulia?

2014-11-27 Thread Cristóvão Duarte Sousa
That is really nice!

But let me alert that, at least in my case (Julia 3.2), I had to add *using 
Interact* so that the plot is correctly displayed.

Cheers,
Cristóvão

On Thursday, November 27, 2014 4:59:00 AM UTC, Sheehan Olver wrote:
>
> I figured out an approach that works for animation, thanks to Jiahao Chen, 
> using 2 IJulia inputs:
>
>
> # In[1]
> using ApproxFun,Gadfly,Reactive
> x=Input(Fun(exp))
> lift(ApproxFun.plot, x)
>
> # In[2]
> for k=1:10
> push!(x,Fun(x->cos(k*x)))
> end
>
>
>
> On Tuesday, November 4, 2014 2:46:44 AM UTC-6, Sheehan Olver wrote:
>>
>>
>>
>> I'm wondering whether there's an example of doing animation directly in 
>> IJulia with Gadfly.  Where by animation I mean plotting a sequence of 
>> functions, lets say each frame is calculated from the previous frame and 
>> wants to be plotted as soon as calculated.
>>
>> Its clearly possible as its possible with Interact.jl: the code below 
>> does work, but is not elegant and seems to run into problems if the 
>> calculation is slow.  There is also the extra unneeded slide bar for k.   I 
>> can't seem to figure out how to get ride of the @manipulate.
>>
>> @manipulate for k=1:1, t_dt=timestamp(fps(30.))
>> # calculate plot
>> end
>>
>>
>>

Re: [julia-users] simplex in Julia is very slow

2014-11-27 Thread Emerson Vitor Castelani

In my test, I change the code and define Xb::Vector, o::Vector,... etc but 
the result doesn't change. Is there some special way to define them?

Regards 

Em quarta-feira, 26 de novembro de 2014 17h50min04s UTC-2, Stefan Karpinski 
escreveu:
>
> It turns out that doesn't actually matter but there are other unrelated 
> ill-typed variables in the code:
>
> Xb, o, y, r, e, Nj, ind, q, t
>
>
> I haven't determined why this is happening, but something is ill-typed 
> here.
>
> On Wed, Nov 26, 2014 at 1:20 PM, Tim Holy 
> > wrote:
>
>> Stefan's point is more relevant than you realize; if the type of the 
>> variable
>> is uncertain, the loop will be very slow. You can make that resize 
>> operation a
>> separate function, from which you call your main routine.
>>
>> --Tim
>>
>> On Wednesday, November 26, 2014 09:26:35 AM Emerson Vitor Castelani wrote:
>> > Humm, It's useful but I guess that the problem is something in loop 
>> while...
>> >
>> > Em quarta-feira, 26 de novembro de 2014 15h05min03s UTC-2, Stefan 
>> Karpinski
>> >
>> > escreveu:
>> > > I'm not sure if this is the problem, but changing the type of a 
>> variable
>> > > in a function body causes problems for type inference. For that 
>> reason,
>> > > the
>> > > first two lines of this code may cause performance issue if you call 
>> this
>> > > with b and c as matrices. A more Julian idiom for this is to do 
>> something
>> > > like this:
>> > >
>> > > function simplex(A::Matrix, b::Vector, c::Vector)
>> > >
>> > > (m,n) = size(A);
>> > > ...
>> > >
>> > > end
>> > > simplex(A::Matrix, b::Matrix, c::Matrix) = simplex(A, vec(b), vec(c))
>> > >
>> > >
>> > > This also avoids copying the data of b and c needlessly.
>> > >
>> > > On Wednesday, November 26, 2014, Emerson Vitor Castelani <
>> > >
>> > > emerso...@gmail.com > wrote:
>> > >> Have you considered the example scsd8.mat?
>> > >>
>> > >> Em quarta-feira, 26 de novembro de 2014 14h39min14s UTC-2, Pileas
>> > >>
>> > >> escreveu:
>> > >>> Result with tic() toc() at the very beginning and at the very end:
>> > >>>
>> > >>> elapsed time: 0.025719973 seconds
>> > >>>
>> > >>>
>> > >>> Τη Τετάρτη, 26 Νοεμβρίου 2014 11:06:26 π.μ. UTC-5, ο χρήστης Emerson
>> > >>>
>> > >>> Vitor Castelani έγραψε:
>> >  Well, I am tried to implement a simple version of simplex in Julia 
>> and
>> >  I have had some troubles. In Julia, my algorithm spends about 30 
>> sec
>> >  and in
>> >  matlab/octave 3 sec for the same problem. So, I saw some tips in 
>> order
>> >  to
>> >  get a better performance but the best that I got in Julia was 17-20
>> >  sec.
>> >  The codes are in attachment. I am new in Julia and the algorithms 
>> are
>> >  little roughly implemented but they are very similar.
>> > 
>> >  Thanks
>>
>>
>

[julia-users] Re: Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner

UPDATE: I did find a discussion on this / copied below. So my new question 
is: 

Can I achieve what I want *without* modifying the pyplot source code?

Thanks,
Christoph


OK This worked (after modifying by hand matplotlib/pyplot.py to change 
plt.show(block=False) to plt.ion(), possibly updating matplotlib would 
work):

PyPlot.show()

for k=1:20
PyPlot.plot([1:10],1+k*[1:10])
PyPlot.draw()
PyPlot.pause(0.05)
end
- hide quoted text -


On 20 Aug 2014, at 4:02 am, Steven G. Johnson  wrote:



On Tuesday, August 19, 2014 11:09:21 AM UTC-4, g wrote:
>
> You could try adapting this python stack overflow answer.  I've only ever 
> done it with qt4 and the matplotlib api from python, but it is certainly 
> possible.
>
>
> http://stackoverflow.com/questions/11874767/real-time-plotting-in-while-loop-with-matplotlib
>
> The key suggestions seem to be
>
>1. Call plt.ion() in order to enable interactive plotting. 
>plt.show(block=False) is no longer available.
>2. Call plt.show() initially, then update the plot with plt.draw()
>
>
In PyPlot, use pygui(true) to switch to the Python GUI if you are using 
IJulia. 





[julia-users] Interactive Animated PyPlot in IJulia

2014-11-27 Thread Christoph Ortner
I could not find it, but apologies if this has previously been discussed.

I am interested in outputting numerical results on the fly - not in 
generating movie files. (I have found some nice examples on how to do the 
latter.) The following code snippet, run in IJulia opens an external plot 
window and then displays the animation I want to see.

using PyPlot
pygui(true)
x = linspace(0,1,100)
PyPlot.hold(false)
for t = -1:.1:1
plot(x, t*(1-x).*x)
axis([0,1, -.3, .3])
PyPlot.draw()
end

But if I change to pygui(false)  to see the plots within IJulia, then I 
only get the final graph. Can it be done? What am I missing?

(Strangly, I think I did have it working before, but somehow broke it and 
cannot figure out again what I did.)

Many thanks,
   Christoph




[julia-users] trouble using Cxx.jl

2014-11-27 Thread David Gonzales
When trying to build Cxx.jl I get all sorts of errors.
If there are people on the list which have been using Cxx.jl, I would 
appreciate if they would report on their machines and software versions.

My setup is using Linux Mint 17 on an intel 64-bit machine.

I am concerned about:
LLVM version
LLDB version
clang version
julia version
julia build make target (debug?)
Make.user modifications?

because after wasting some time recompiling again and again things are 
still not working for me.



Re: [julia-users] Memory allocation issue

2014-11-27 Thread Tim Holy
I should have read the rest of the thread. By "similar timings" do you mean 
now that they both are fast and neither allocates any significant memory? (This 
is how it should be.) If not, you're still using a global variable.

--Tim

On Wednesday, November 26, 2014 01:46:22 PM Colin Lea wrote:
> Ah, ok. Thanks! I ran those as functions and got similar timings.
> 
> > On Nov 26, 2014, at 1:35 PM, John Myles White 
> > wrote:
> > 
> > Yes, the global scope is scarcely optimized and doesn't provide useful
> > information about performance.> 
> >  -- John
> > 
> > On Nov 26, 2014, at 10:33 AM, Colin Lea mailto:colin...@gmail.com>> wrote:
> >> That was in global scope. Should that matter?
> >> 
> >>> On Nov 26, 2014, at 1:30 PM, John Myles White  >>> > wrote:
> >>> 
> >>> ?



Re: [julia-users] Memory allocation issue

2014-11-27 Thread Tim Holy
It's the whole "global variable" thing. Put all this in a function (with 
locally-defined T and n_classes), and you won't see any difference.

--Tim

On Wednesday, November 26, 2014 10:28:31 AM Colin Lea wrote:
> Thanks to you both! However, there is still another odd issue.
> 
> These two functions should be the same, but take very different amounts of
> time/memory. Both 'T' and 'n_classes' are both of type Int64.
> 
> @time (
> for t = 2:T
> for n = 1:n_classes
> for j = 1:n_classes
> end
> end
> end
> )
> 
> @time (
> for t = 2:5000
> for n = 1:10
> for j = 1:10
> end
> end
> end
> )
> 
> elapsed time: 0.063186286 seconds (18190040 bytes allocated)
> elapsed time: 0.002261641 seconds (71824 bytes allocated)
> 
> Any insight on this?
> 
> On Wednesday, November 26, 2014 12:37:12 PM UTC-5, Tim Holy wrote:
> > Nice job using track-allocation to figure out where the problem is.
> > 
> > If you really don't want allocation, then you should investigate Devec.jl
> > or
> > InPlaceOps.jl, or write out these steps using loops to access each element
> > of
> > those matrices.
> > 
> > --Tim
> > 
> > On Wednesday, November 26, 2014 07:55:59 AM Colin Lea wrote:
> > > I'm implementing an inference algorithm and am running into memory
> > > allocation issues that are slowing it down. I created a minimal example
> > > that resembles my algorithm and see that the problem persists.
> > > 
> > > The issue is that Julia is allocating a lot of extra memory when adding
> > > matrices together. This happens regardless of whether or not I
> > 
> > preallocate
> > 
> > > the output matrix.
> > > 
> > > Minimal example:
> > > https://gist.github.com/colincsl/ab44884c5542539f813d
> > > 
> > > Memory output of minimal example (using julia --track-allocation=user):
> > > https://gist.github.com/colincsl/c9c9dd86fca277705873
> > > 
> > > Am I misunderstanding something? Should I be performing the operation
> > > differently?
> > > 
> > > One thing I've played with is the matrix C. The indices are a sliding
> > > window (e.g. use C[t-10:t] for all t). When I remove C from the equation
> > > the performance increases by a factor of 2.5. However, it still uses
> > 
> > more
> > 
> > > memory than expected. Could this be the primary issue?



Re: [julia-users] Re: SharedArray no longer shared after loading from jld file

2014-11-27 Thread Tim Holy
Moving discussion to the issue you opened.

--Tim

On Wednesday, November 26, 2014 10:39:08 AM Ariel Keselman wrote:
> One more issue: The example above can be fixed by reassigning `a` to a new
> shared array. But in my case this won't work since I have this array within
> a wrapper type... seems like another semi related issue?



Re: [julia-users] simplex in Julia is very slow

2014-11-27 Thread Gunnar Farnebäck
It does have issues. I tracked down a part of the story to 
https://github.com/JuliaLang/julia/pull/9086

Den onsdagen den 26:e november 2014 kl. 20:52:57 UTC+1 skrev Stefan 
Karpinski:
>
> I wonder if \ might be type unstable.
>


Re: [julia-users] Installing IJulia

2014-11-27 Thread Abram Demski
Pileas,

Atom looks very cool, but it appears existing Julia customization is very
minimal. Do you know if there is an easy way to have a command to run the
current file in a julia terminal? (I miiight be tempted into trying to
build it, seeing as the Atom customization stuff looks fun...)

On Wed, Nov 26, 2014 at 3:26 PM, Abram Demski  wrote:

> Pileas,
>
> Given that I've still been unable to install IJulia, that's very helpful,
> thanks.
>
> On Tue, Nov 25, 2014 at 6:29 PM, Pileas 
> wrote:
>
>> I have to suggest a very good editor that supports "Julia" and it is
>> called Atom. It becomes better each day:
>>
>> Give it a try if you have time: https://atom.io/
>>
>> Τη Τρίτη, 25 Νοεμβρίου 2014 6:12:52 μ.μ. UTC-5, ο χρήστης Abram Demski
>> έγραψε:
>>>
>>> Thanks! I figured out how to do it in the default shell:
>>>
>>> julia> print(ENV["PATH"])
>>> C:\Users\abram\AppData\Local\Julia-0.3.3\bin;C:\Users\
>>> abram\AppData\Local\Julia-
>>> 0.3.3\bin\..\Git\bin;C:\Program Files (x86)\Intel\iCLS
>>> Client\;C:\Program Files\
>>> Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\
>>> Wbem;C:\wi
>>> ndows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R)
>>> Managemen
>>> t Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management
>>> Engine Compon
>>> ents\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine
>>> Components\DAL;
>>> C:\Program Files (x86)\Intel\Intel(R) Management Engine
>>> Components\IPT;C:\Progra
>>> m Files\Intel\WiFi\bin\;C:\Program Files\Common
>>> Files\Intel\WirelessCommon\;C:\P
>>> rogram Files\Condusiv Technologies\ExpressCache\;C:\Program Files
>>> (x86)\Common F
>>> iles\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps;
>>> C:\Anaconda;C:\Anaco
>>> nda\Scripts
>>>
>>> (I have not used windows much since Windows 98! ;p)
>>>
>>> On Tue, Nov 25, 2014 at 3:02 PM, cdm  wrote:
>>>

 if you have access to the PowerShell in Windows 8 ( ... and similar,
 new-ish, MS OSs ...),
 then highlighting a block of text from the PowerShell and right
 clicking should rip it to the
 clipboard for pasting else-where ...

 best,

 cdm



 On Tuesday, November 25, 2014 2:42:51 PM UTC-8, Abram Demski wrote:
>
>
> Julia shows a similar PATH when I run ENV["PATH"], but with more
> julia-specific things. (It seems that command prompts in Windows 8.1 do 
> not
> allow one to copy text out of them directly.. otherwise I'd copy.)
>
>
>>>
>>>
>>> --
>>> Abram Demski
>>> Blog: http://lo-tho.blogspot.com/
>>>
>>
>
>
> --
> Abram Demski
> Blog: http://lo-tho.blogspot.com/
>



-- 
Abram Demski
Blog: http://lo-tho.blogspot.com/


Re: [julia-users] Installing IJulia

2014-11-27 Thread Abram Demski
Stonebig34,

"If all else fails" makes me think this is a last resort. Should I be wary?

So, this approach requires WinPython as opposed to the Anaconda install of
IPython I've currently got? (I'm not attached if there aren't any big
downsides; I used Anaconda only because the instructions for installing
IJulia said to.)

Thanks,

Abram

On Wed, Nov 26, 2014 at 10:00 PM,  wrote:

> Hi Abram,
>
> If all else fails, you have still this alternative
>
>
> http://nbviewer.ipython.org/github/winpython/winpython_afterdoc/blob/master/examples/installing_julia_and_ijulia.ipynb
>
>
> On Thursday, November 27, 2014 6:57:41 AM UTC+1, cdm wrote:
>>
>>
>> if you are not averse to trying IJulia in your browser, then have a look
>> at this post ...
>>
>>https://groups.google.com/forum/#!searchin/julia-users/
>> tmpnb|sort:relevance/julia-users/zEp8pKkEYHk/qY7tPqrOp9gJ
>>
>>
>> there are other ways to work with IJulia on kernels hosted elsewhere; let
>> me know
>> if you are interested.
>>
>> best,
>>
>> cdm
>>
>>
>> On Wednesday, November 26, 2014 3:26:51 PM UTC-8, Abram Demski wrote:
>>>
>>> Pileas,
>>>
>>> Given that I've still been unable to install IJulia, that's very
>>> helpful, thanks.
>>>
>>>


-- 
Abram Demski
Blog: http://lo-tho.blogspot.com/


[julia-users] Re: julia vs cython benchmark

2014-11-27 Thread Ariel Keselman
in the Cython code you turned off bounds checking. This can be done for 
Julia with the @inbounds macro. Just use it in your loops like this:

@inbounds for i in whatever
...
end

also @simd may help, sems you can use it in a couple of the innrmost loops. 
It sems also simple to parallelize with a shared array and a @parallel for


[julia-users] Re: PyPlot.plot_date: How do I alter the time format?

2014-11-27 Thread RecentConvert
That's it! It should help with translating more things as well. It hadn't 
crossed my mind that I could access matplotlib in this manner.

# Julia 0.3.2
# 27.11.2014

using PyPlot
using Dates

# Create Data
dt = Millisecond(100)
time = [DateTime(2014,11,20):dt:DateTime(2014,11,22)]
y = fill!(Array(Float64,length(time)),42)
#y = floor(100*rand(length(time))) # Fails unless the time span is very 
short

font1 = ["fontname"=>"Sans","style"=>"normal"]
time2 = float64(time)/1000/60/60/24 # Convert time from milliseconds from 
day 0 to days from day 0
timespan = "\n" * Dates.format(minimum(time),"-mm-dd HH:MM:SS") * " - " 
* Dates.format(maximum(time),"-mm-dd HH:MM:SS")

majorformatter = matplotlib[:dates][:DateFormatter]("%d.%m.%Y")
minorformatter = matplotlib[:dates][:DateFormatter]("%H:%M")
majorlocator = matplotlib[:dates][:DayLocator](interval=1)
minorlocator = matplotlib[:dates][:HourLocator](byhour=(8, 16))

# Plot
fig = figure("Test Plot",figsize=(16,10)) # Create a figure and save the 
handle
ax1 = axes()
p1 = plot_date(time2,y,linestyle="-",marker="None",label="test")
axis("tight")
title("Random Data Against Time\n" * timespan)
grid("on")
xlabel("Time")
ylabel("Stuff",fontdict=font1)
ax1[:xaxis][:set_major_formatter](majorformatter)
ax1[:xaxis][:set_minor_formatter](minorformatter)
ax1[:xaxis][:set_major_locator](majorlocator)
ax1[:xaxis][:set_minor_locator](minorlocator)
fig[:autofmt_xdate](bottom=0.2,rotation=30,ha="right")
fig[:canvas][:draw]() # Update the figure
PyPlot.tight_layout()