[julia-users] Re: Interfacing C++ function which takes structure and arrays

2016-04-07 Thread Jānis Erdmanis
Cool, even changing the values of array works :) Could you please also add 
type conversation for int and double type ASAP?  

On Thursday, April 7, 2016 at 12:41:06 AM UTC+3, Bart Janssens wrote:
>
> Hi,
>
> The problem is that the float* type was not mapped yet by CxxWrap. I have 
> just added it, so your example should work after you 
> Pkg.checkout("CxxWrap") and rebuild. Before rebuilding you may need to 
> remove the usr dir in .julia/v0.4/CxxWrap/deps. Also, you need to pass a 
> Float32 array to Hello.greet in Julia.
>
> Note that I am adding functionality as-needed, so if you hit other 
> problems like this feel free to create an issue on Github.
>
> Cheers,
>
> Bart
>
>
> On Wednesday, April 6, 2016 at 9:51:39 PM UTC+2, Jānis Erdmanis wrote:
>>
>> Hello,
>>
>> are anyone using CxxWrap.jl library? I am trying to figure out a way to 
>> pass array to the function. So far I have came up to to this nonworking 
>> (makes julia to crash) code
>>
>

[julia-users] eigenvalues for Matrix-Free problem

2016-04-07 Thread Dupont
Dear Users,

I would like to know if it is possible to find the first eigenvalues of a 
linear operator defined by a function like:
  
A=x->FFT(x)

This is achieved by 
eigs

in Matlab but my attempts in Julia fail. Can someone give me a hint please?

Thank you,

Best regards,


[julia-users] Re: Julia and Octave communication using MPI?

2016-04-07 Thread michael . creel
I have given this a shot. Using the two files testOctaveJulia.m and 
testOctaveJulia.jl

testOctaveJulia.m:

if not(MPI_Initialized) MPI_Init; end
CW = MPI_Comm_Load("NEWORLD");
myrank = MPI_Comm_rank(CW);
commsize = MPI_Comm_size(CW);
sleep(myrank*0.5);
printf("I am Octave rank %d\n", myrank);
if myrank == 0
MPI_Send([5], 3, 0, CW);
endif
MPI_Barrier(CW);
MPI_Finalize();

testOctaveJulia.jl:
import MPI

function main()
MPI.Init()
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
commsize = MPI.Comm_size(comm)
sleep(rank*0.5)
println("I am Julia rank ", rank)
contrib = [0]
if rank==3
println("contrib before receive: ", contrib)
MPI.Recv!(contrib, 0, 0, comm)
println("contrib after receive: ", contrib)
end
MPI.Barrier(comm)
MPI.Finalize()
end
main()

I can launch using 
mpirun -np 2 octave-cli --eval testOctaveJulia : -np 3 julia 
testOctaveJulia.jl

The result is 

michael@yosemite:~/Desktop/JO$ mpirun -np 2 octave-cli --eval 
testOctaveJulia : -np 3 julia testOctaveJulia.jl
I am Octave rank 0
I am Octave rank 1
I am Julia rank 2
I am Julia rank 3
contrib before receive: [0]
contrib after receive: [2]
I am Julia rank 4

If you look at the two files, you'll see that rank 0, Octave, sends the a 
scalar array containing the number 5 to rank 3. Rank 3 is a julia instance. 
On rank 3, the variable contrib is initialized as a scalar array containing 
0. After the receive, it contains a 2.

So... it seems to be possible to send messages from Octave to Julia, but 
the contents are not received correctly. I suppose that Octave and Julia 
have different methods of serializing contents when using MPI functions, 
and that's something I don't know about. Any ideas?

Note, the Octave code requires the MPI wrappers 
at http://octave.sourceforge.net/mpi/index.html
Julia is using MPI.jl on github. In my case, both are wrapping Open MPI 
functions.



On Tuesday, April 5, 2016 at 11:30:33 AM UTC+2, michae...@gmail.com wrote:
>
> I use MPI with both Julia (using MPI.jl) and Octave (using the MPI package 
> for Octave). For both Julia and Octave, the packages are wrapping (in my 
> case) Open MPI functions. I believe that it should be possible for Julia 
> and Octave to send information back and forth via MPI. Before trying this 
> myself, does anyone have an example of something similar? Any pointers 
> would be appreciated.
>


[julia-users] Re: How solve this issue when I run Pkg.add("xx") is broken?

2016-04-07 Thread Páll Haraldsson
On Tuesday, March 29, 2016 at 12:34:40 PM UTC, Qi Wei wrote:
>
> How solve this issue when I run Pkg.add("xx") is broken? Like Conda, I use 
> the command"conda clean --lock", these unfinished files are clean. I 
> want to know that how to use to clean cache files using Julia?
>

Since no one answered.. I'm not sure, but you could try moving/deleting 
your profile:

mv .julia .julia_old

-- 
Palli.



[julia-users] MXNet setting workspace, Convolutional layers, kernels etc

2016-04-07 Thread kleinsplash
Hi,

I have a memory error using Quadro K5000M which has 4GB global memory. I 
was wondering if there is some guide as to how to set my workspace and 
Convolutional layers.

My current settings: 

training_data =  128x128x1x800
batch_size = 128x128x1x8
workspace = 2048 (I think this can go up to 4096 because of the 
.deviceQuery)

This is my net (still to be designed so just basic ):

# first conv
conv1 = @mx.chain mx.Convolution(data=data, kernel=(5,5), num_filter=20, 
workspace=workspace)  =>
  mx.Activation(act_type=:relu) =>
  mx.Pooling(pool_type=:max, kernel=(2,2), stride=(2,2))
# second conv
conv2 = @mx.chain mx.Convolution(data=conv1, kernel=(5,5), num_filter=50, 
workspace=workspace) =>
  mx.Activation(act_type=:relu) =>
  mx.Pooling(pool_type=:max, kernel=(2,2), stride=(2,2))
  # first fully-connected
fc1   = @mx.chain mx.Flatten(data=conv2) =>
  mx.FullyConnected(num_hidden=500) =>
  mx.Activation(act_type=:relu)
# second fully-connected
fc2   = mx.FullyConnected(data=fc1, num_hidden=10) 
# third fully-connected
fc3   = mx.FullyConnected(data=fc2, num_hidden=2) 
# softmax loss
net = mx.SoftmaxOutput(data=fc3, name=:softmax)

So far if I reduce my image to 28x28 it all works - but I need to up the 
resolution to pick out features. Anyone have any ideas on thumb sucking 
initial values for at least getting past memory issues to the design of the 
net? 


Thx



[julia-users] Re: How solve this issue when I run Pkg.add("xx") is broken?

2016-04-07 Thread kleinsplash

I havent found a way to do this through Julia - I go into the 
~/.julia/vX.X/Package/ file and use git rebase or stash and checkout etc.. 

On Tuesday, 29 March 2016 14:34:40 UTC+2, Qi Wei wrote:
>
> How solve this issue when I run Pkg.add("xx") is broken? Like Conda, I use 
> the command"conda clean --lock", these unfinished files are clean. I 
> want to know that how to use to clean cache files using Julia?
>


[julia-users] Re: How solve this issue when I run Pkg.add("xx") is broken?

2016-04-07 Thread kleinsplash

That is when its a new package I get the source and check it out to Julia's 
directory.. and then update etc.. 

On Thursday, 7 April 2016 12:15:13 UTC+2, kleinsplash wrote:
>
>
> I havent found a way to do this through Julia - I go into the 
> ~/.julia/vX.X/Package/ file and use git rebase or stash and checkout etc.. 
>
> On Tuesday, 29 March 2016 14:34:40 UTC+2, Qi Wei wrote:
>>
>> How solve this issue when I run Pkg.add("xx") is broken? Like Conda, I 
>> use the command"conda clean --lock", these unfinished files are clean. 
>> I want to know that how to use to clean cache files using Julia?
>>
>

[julia-users] assignment form function with empty body

2016-04-07 Thread Tamas Papp
Hi,

What's the most compact form of writing a function in assignment form
with an empty body? Eg is

foo(x) = begin end

the shortest?

(context: I am using a local function for iterating over a collection in
a function. for a particular set of argument types, it does nothing,
hence the need. I am aware that I could be using Match.jl)

Best,

Tamas


[julia-users] Re: assignment form function with empty body

2016-04-07 Thread Lutfullah Tomak
foo(x)=return works for me.

On Thursday, April 7, 2016 at 2:04:52 PM UTC+3, Tamas Papp wrote:
>
> Hi, 
>
> What's the most compact form of writing a function in assignment form 
> with an empty body? Eg is 
>
> foo(x) = begin end 
>
> the shortest? 
>
> (context: I am using a local function for iterating over a collection in 
> a function. for a particular set of argument types, it does nothing, 
> hence the need. I am aware that I could be using Match.jl) 
>
> Best, 
>
> Tamas 
>


Re: [julia-users] assignment form function with empty body

2016-04-07 Thread Mauro
Use:

foo(x) = nothing

Note, you're suggestion also returns `nothing`.

On Thu, 2016-04-07 at 13:04, Tamas Papp  wrote:
> Hi,
>
> What's the most compact form of writing a function in assignment form
> with an empty body? Eg is
>
> foo(x) = begin end
>
> the shortest?
>
> (context: I am using a local function for iterating over a collection in
> a function. for a particular set of argument types, it does nothing,
> hence the need. I am aware that I could be using Match.jl)
>
> Best,
>
> Tamas


[julia-users] Re: assignment form function with empty body

2016-04-07 Thread Jeffrey Sarnoff
foo(x) = nothing

gives a function that returns nothing, unexceptionally.

foo(x) = begin end

gives a function that generates an exceptional opcode for `unreachable`

On Thursday, April 7, 2016 at 7:04:52 AM UTC-4, Tamas Papp wrote:
>
> Hi, 
>
> What's the most compact form of writing a function in assignment form 
> with an empty body? Eg is 
>
> foo(x) = begin end 
>
> the shortest? 
>
> (context: I am using a local function for iterating over a collection in 
> a function. for a particular set of argument types, it does nothing, 
> hence the need. I am aware that I could be using Match.jl) 
>
> Best, 
>
> Tamas 
>


Re: [julia-users] Re: assignment form function with empty body

2016-04-07 Thread Tamas Papp
On Thu, Apr 07 2016, Jeffrey Sarnoff wrote:

> foo(x) = nothing
>
> gives a function that returns nothing, unexceptionally.
>
> foo(x) = begin end
>
> gives a function that generates an exceptional opcode for `unreachable`

I think it simply returns nothing:

foo(x) = begin end
isa(foo(9),Void)

so the two are equivalent (at least in 0.4.6, I haven't checked 0.5, but
I don't recall seeing this change).

Best,

Tamas


[julia-users] Macro expansion for ccall with tuple argument

2016-04-07 Thread Laurent Bartholdi
Hi,
I'm trying to understand macro expansion, and am a bit stuck. I would like, 
in distilled form, to have a macro "@do_ccall" which calls its argument 
with Int type. Thus I would like

julia> macroexpand(:(@do_ccall(f,1,2,3)))
:(ccall(f,Int,(Int64,Int64,Int64),args...))

and I programmed it as
julia> macro do_ccall(f,args...) 
:(ccall(f,Int,$(ntuple(i->Int,length(args))),args...)) end
@do_ccall (macro with 1 method)

Now the tuple argument just doesn't seem to get interpreted properly:

julia> @do_ccall(C_NULL,1,2,3)
ERROR: syntax: ccall argument types must be a tuple; try "(T,)"
 in eval(::Module, ::Any) at ./boot.jl:237

(note: calling the routine at C_NULL would have crashed Julia; it's just 
for demonstration purposes)

Thanks in advance! Laurent


Re: [julia-users] assignment form function with empty body

2016-04-07 Thread Tamas Papp
Thanks, I always forget that empty blocks return nothing.

Best,

Tamas

On Thu, Apr 07 2016, Mauro wrote:

> Use:
>
> foo(x) = nothing
>
> Note, you're suggestion also returns `nothing`.
>
> On Thu, 2016-04-07 at 13:04, Tamas Papp  wrote:
>> Hi,
>>
>> What's the most compact form of writing a function in assignment form
>> with an empty body? Eg is
>>
>> foo(x) = begin end
>>
>> the shortest?
>>
>> (context: I am using a local function for iterating over a collection in
>> a function. for a particular set of argument types, it does nothing,
>> hence the need. I am aware that I could be using Match.jl)
>>
>> Best,
>>
>> Tamas



[julia-users] How to specify only concrete subtype of abstract supertype in a parametric function?

2016-04-07 Thread Martin Kuzma
Hello,
Lets say I want to somehow implement loading of a file. I have used only 
dummy types for simplicity.

The first experiment:

abstract File

immutable FileA <: File end

immutable FileB <: File end

function load{F <: File}(t::Type{F}, path::ASCIIString) 
 ios::IOStream = open(path, "r")
 f::File = load(t, ios)
 close(ios)
 f
end

load(::Type{FileA}, ios::IOStream) = FileA()

load(::Type{FileB}, ios::IOStream) = FileB()

This implementation works great, but it allows the user to pass the 
abstract type File to the function load, because of File <: File. Is there 
a way to allow only concrete types of File for function load?

I could use:

if typeof(t) == File
 error("Not allowed.")
end

But without it, it's much cleaner.

So comming from OOP backgroud i used this:


abstract File

immutable FileA <: File end

immutable FileB <: File end

abstract FileLoader

immutable FileALoader <: FileLoader end

immutable FileBLoader <: FileLoader end

function load(l::FileLoader, path::ASCIIString) 
 ios::IOStream = open(path, "r")
 f::File = load(l, ios)
 close(ios)
 f
end

load(l::FileALoader, ios::IOStream) = FileA()

load(l::FileBLoader, ios::IOStream) = FileB()

This code works as desired. Since instances of abstract types cant be 
created. But it requires creation of empty objects that do nothing.

The first code is better suited for julia as types are only data 
containers. I think :D  That brings me to my question:

Is there a way to allow only concrete types of abstract supertype for 
parametric function such as:

load{F <: File}(t::Type{F}, path::ASCIIString)

Thanks Martin.






[julia-users] Redirecting println output

2016-04-07 Thread Alex Dowling
Hello,

I have a Julia script that does some analysis and includes println() 
statements. When I use julia my_code.jl > output.txt 2>&1 from a Linux 
command line, output from optimization solvers (IPOPT, Gurobi) are 
redirected to output.txt but output from println() just vanishes. They 
aren't in output.txt or printed to the console.

One option I found (haven't tested) is using redirect_stout() and 
redirect_sterr(): https://github.com/JuliaLang/julia/issues/12050. Ideally 
I'd like to redirect println output without modifying the script.

Thanks,
Alex


Re: [julia-users] Ubuntu, do I have to install libfftw to use conv?

2016-04-07 Thread Gerson J. Ferreira
The generic binary did the trick, thanks!

The PPA seems fine to me on my Ubuntu 15.10. Just got an update to Julia 
0.4.5 today.

The problem might be that in the classroom the computers still have Ubuntu 
12.10, or that libfftw is not installed. 

So I'm guessing that the generic library comes with libfftw built in 
"statically". 

Since I don't have root access at the classroom to update Ubuntu or install 
the libfftw, I'll stick with the generic binary for now.

Thanks for the help.

Regards.


[julia-users] Dropping or replacing NaNs from array

2016-04-07 Thread jw3126
I have an array, which has some NaNs and I want to do things like replace 
them by 42 or delete them. What is the canonical way to do this?


[julia-users] Re: Macro expansion for ccall with tuple argument

2016-04-07 Thread Andreas Lobinger
Hello colleague,

i'm not an expert on macros, but if you try to learn correct macroexpansion 
you should use a different target than ccall. ccall looks like a regular 
function call but has special handling (you could see this in lowered code) 
and that's the reason the arguments are expected to be constants. In my own 
examples to build ccalls from paramters i build the expressions manually 
and eval-ed.

On Thursday, April 7, 2016 at 1:29:06 PM UTC+2, Laurent Bartholdi wrote:
>
> Hi,
> I'm trying to understand macro expansion, and am a bit stuck. I would 
> like, in distilled form, to have a macro "@do_ccall" which calls its 
> argument with Int type. Thus I would like
>
> julia> macroexpand(:(@do_ccall(f,1,2,3)))
> :(ccall(f,Int,(Int64,Int64,Int64),args...))
>
> and I programmed it as
> julia> macro do_ccall(f,args...) 
> :(ccall(f,Int,$(ntuple(i->Int,length(args))),args...)) end
> @do_ccall (macro with 1 method)
>
> Now the tuple argument just doesn't seem to get interpreted properly:
>
> julia> @do_ccall(C_NULL,1,2,3)
> ERROR: syntax: ccall argument types must be a tuple; try "(T,)"
>  in eval(::Module, ::Any) at ./boot.jl:237
>
> (note: calling the routine at C_NULL would have crashed Julia; it's just 
> for demonstration purposes)
>
> Thanks in advance! Laurent
>


Re: [julia-users] Macro expansion for ccall with tuple argument

2016-04-07 Thread Yichao Yu
> and I programmed it as
> julia> macro do_ccall(f,args...)
> :(ccall(f,Int,$(ntuple(i->Int,length(args))),args...)) end

I belive the arguments should be a tuple expression which you can
generate with Expr(:tuple, [Int for i in 1:length(args)]...)

> julia> macroexpand(:(@do_ccall(f,1,2,3)))
> :(ccall(f,Int,(Int64,Int64,Int64),args...))
>

In general you can use `Meta.show_sexpr` (or `dump`/`xdump`) to see
more precisely what the expression is.


Re: [julia-users] Re: Macro expansion for ccall with tuple argument

2016-04-07 Thread Yichao Yu
On Thu, Apr 7, 2016 at 8:55 AM, Andreas Lobinger  wrote:
> Hello colleague,
>
> i'm not an expert on macros, but if you try to learn correct macroexpansion
> you should use a different target than ccall. ccall looks like a regular
> function call but has special handling (you could see this in lowered code)
> and that's the reason the arguments are expected to be constants. In my own
> examples to build ccalls from paramters i build the expressions manually and
> eval-ed.
>
>

Also note that you are missing a number of interpolations, the
following should work

:(ccall($f, Int, $(Expr(:tuple, [Int for i in 1:length(args)]...)), $(args...)))

> On Thursday, April 7, 2016 at 1:29:06 PM UTC+2, Laurent Bartholdi wrote:
>>
>> Hi,
>> I'm trying to understand macro expansion, and am a bit stuck. I would
>> like, in distilled form, to have a macro "@do_ccall" which calls its
>> argument with Int type. Thus I would like
>>
>> julia> macroexpand(:(@do_ccall(f,1,2,3)))
>> :(ccall(f,Int,(Int64,Int64,Int64),args...))
>>
>> and I programmed it as
>> julia> macro do_ccall(f,args...)
>> :(ccall(f,Int,$(ntuple(i->Int,length(args))),args...)) end
>> @do_ccall (macro with 1 method)
>>
>> Now the tuple argument just doesn't seem to get interpreted properly:
>>
>> julia> @do_ccall(C_NULL,1,2,3)
>> ERROR: syntax: ccall argument types must be a tuple; try "(T,)"
>>  in eval(::Module, ::Any) at ./boot.jl:237
>>
>> (note: calling the routine at C_NULL would have crashed Julia; it's just
>> for demonstration purposes)
>>
>> Thanks in advance! Laurent


Re: [julia-users] Redirecting println output

2016-04-07 Thread Yichao Yu
On Thu, Apr 7, 2016 at 8:12 AM, Alex Dowling  wrote:
> Hello,
>
> I have a Julia script that does some analysis and includes println()
> statements. When I use julia my_code.jl > output.txt 2>&1 from a Linux
> command line, output from optimization solvers (IPOPT, Gurobi) are
> redirected to output.txt but output from println() just vanishes. They
> aren't in output.txt or printed to the console.

Are they vanished or delayed? The output is buffered.

>
> One option I found (haven't tested) is using redirect_stout() and
> redirect_sterr(): https://github.com/JuliaLang/julia/issues/12050. Ideally
> I'd like to redirect println output without modifying the script.

http://man7.org/linux/man-pages/man1/script.1.html

>
> Thanks,
> Alex


[julia-users] Re: New package: MixtureModels.jl

2016-04-07 Thread Ben Arthur
any plans to update this package?  sure would be nice to have it work for 
julia 0.4


[julia-users] Re: Dropping or replacing NaNs from array

2016-04-07 Thread Kristoffer Carlsson
to replace with 42, maybe:

map!((i) -> isnan(i)? 42 : i, a)

to delete:

deleteat!(a, find(isnan, a))




On Thursday, April 7, 2016 at 2:33:56 PM UTC+2, jw3126 wrote:
>
> I have an array, which has some NaNs and I want to do things like replace 
> them by 42 or delete them. What is the canonical way to do this?
>


[julia-users] Re: How to specify only concrete subtype of abstract supertype in a parametric function?

2016-04-07 Thread Jeffrey Sarnoff
Martin,

If you want to implement file loading, and you care that only entities of 
type File get accepted through the loading function's function signature 
(excluding the Type File as an accepted entity), Julia does that naturally.
All you were overlooking is the part where an actual File entity is 
constructed by applying a concrete type. 

abstract AbstractFile

immutable ConcreteFile <: AbstractFile 
fileSpecs ..
end

function fileLoader{F<:AbstractFile}(file::F)
loadfile(f)
end

myFileDescriptor = ConcreteFile( filespecs... )

myFileContents = fileLoader( myFileDescriptor )

# fileLoader( AbstractFile, .. ) will throw an error 
# fileLoader( ConcreteFile, .. ) will throw an error
# fileLoader( myFileDescriptor ) will not







On Thursday, April 7, 2016 at 7:34:52 AM UTC-4, Martin Kuzma wrote:
>
> Hello,
> Lets say I want to somehow implement loading of a file. I have used only 
> dummy types for simplicity.
>
> The first experiment:
>
> abstract File
>
> immutable FileA <: File end
>
> immutable FileB <: File end
>
> function load{F <: File}(t::Type{F}, path::ASCIIString) 
>  ios::IOStream = open(path, "r")
>  f::File = load(t, ios)
>  close(ios)
>  f
> end
>
> load(::Type{FileA}, ios::IOStream) = FileA()
>
> load(::Type{FileB}, ios::IOStream) = FileB()
>
> This implementation works great, but it allows the user to pass the 
> abstract type File to the function load, because of File <: File. Is there 
> a way to allow only concrete types of File for function load?
>
> I could use:
>
> if typeof(t) == File
>  error("Not allowed.")
> end
>
> But without it, it's much cleaner.
>
> So comming from OOP backgroud i used this:
>
>
> abstract File
>
> immutable FileA <: File end
>
> immutable FileB <: File end
>
> abstract FileLoader
>
> immutable FileALoader <: FileLoader end
>
> immutable FileBLoader <: FileLoader end
>
> function load(l::FileLoader, path::ASCIIString) 
>  ios::IOStream = open(path, "r")
>  f::File = load(l, ios)
>  close(ios)
>  f
> end
>
> load(l::FileALoader, ios::IOStream) = FileA()
>
> load(l::FileBLoader, ios::IOStream) = FileB()
>
> This code works as desired. Since instances of abstract types cant be 
> created. But it requires creation of empty objects that do nothing.
>
> The first code is better suited for julia as types are only data 
> containers. I think :D  That brings me to my question:
>
> Is there a way to allow only concrete types of abstract supertype for 
> parametric function such as:
>
> load{F <: File}(t::Type{F}, path::ASCIIString)
>
> Thanks Martin.
>
>
>
>
>

[julia-users] Re: Dropping or replacing NaNs from array

2016-04-07 Thread Matt Bauman
I'd use logical indexing for this:

a[isnan(a)] = 42
clean_a = a[!isnan(a)]


On Thursday, April 7, 2016 at 9:20:05 AM UTC-4, Kristoffer Carlsson wrote:
>
> to replace with 42, maybe:
>
> map!((i) -> isnan(i)? 42 : i, a)
>
> to delete:
>
> deleteat!(a, find(isnan, a))
>
>
>
>
> On Thursday, April 7, 2016 at 2:33:56 PM UTC+2, jw3126 wrote:
>>
>> I have an array, which has some NaNs and I want to do things like replace 
>> them by 42 or delete them. What is the canonical way to do this?
>>
>

Re: [julia-users] Redirecting println output

2016-04-07 Thread Alex Dowling
Hello Yichao,

Vanished. I expect println output between other output that is properly 
redirected. I should also mention println output is not properly redirected 
(i.e., vanishes) using nohup.

Alex

On Thursday, April 7, 2016 at 8:05:30 AM UTC-5, Yichao Yu wrote:
>
> On Thu, Apr 7, 2016 at 8:12 AM, Alex Dowling  > wrote: 
> > Hello, 
> > 
> > I have a Julia script that does some analysis and includes println() 
> > statements. When I use julia my_code.jl > output.txt 2>&1 from a Linux 
> > command line, output from optimization solvers (IPOPT, Gurobi) are 
> > redirected to output.txt but output from println() just vanishes. They 
> > aren't in output.txt or printed to the console. 
>
> Are they vanished or delayed? The output is buffered. 
>
> > 
> > One option I found (haven't tested) is using redirect_stout() and 
> > redirect_sterr(): https://github.com/JuliaLang/julia/issues/12050. 
> Ideally 
> > I'd like to redirect println output without modifying the script. 
>
> http://man7.org/linux/man-pages/man1/script.1.html 
>
> > 
> > Thanks, 
> > Alex 
>


[julia-users] Re: Dropping or replacing NaNs from array

2016-04-07 Thread jw3126
Thanks guys!

On Thursday, April 7, 2016 at 3:31:12 PM UTC+2, Matt Bauman wrote:
>
> I'd use logical indexing for this:
>
> a[isnan(a)] = 42
> clean_a = a[!isnan(a)]
>
>
> On Thursday, April 7, 2016 at 9:20:05 AM UTC-4, Kristoffer Carlsson wrote:
>>
>> to replace with 42, maybe:
>>
>> map!((i) -> isnan(i)? 42 : i, a)
>>
>> to delete:
>>
>> deleteat!(a, find(isnan, a))
>>
>>
>>
>>
>> On Thursday, April 7, 2016 at 2:33:56 PM UTC+2, jw3126 wrote:
>>>
>>> I have an array, which has some NaNs and I want to do things like 
>>> replace them by 42 or delete them. What is the canonical way to do this?
>>>
>>

Re: [julia-users] Re: Interfacing C++ function which takes structure and arrays

2016-04-07 Thread Stefan Karpinski
Probably best to continue this conversation on the CxxWrap issues.

On Thu, Apr 7, 2016 at 3:00 AM, Jānis Erdmanis  wrote:

> Cool, even changing the values of array works :) Could you please also add
> type conversation for int and double type ASAP?
>
> On Thursday, April 7, 2016 at 12:41:06 AM UTC+3, Bart Janssens wrote:
>>
>> Hi,
>>
>> The problem is that the float* type was not mapped yet by CxxWrap. I have
>> just added it, so your example should work after you
>> Pkg.checkout("CxxWrap") and rebuild. Before rebuilding you may need to
>> remove the usr dir in .julia/v0.4/CxxWrap/deps. Also, you need to pass a
>> Float32 array to Hello.greet in Julia.
>>
>> Note that I am adding functionality as-needed, so if you hit other
>> problems like this feel free to create an issue on Github.
>>
>> Cheers,
>>
>> Bart
>>
>>
>> On Wednesday, April 6, 2016 at 9:51:39 PM UTC+2, Jānis Erdmanis wrote:
>>>
>>> Hello,
>>>
>>> are anyone using CxxWrap.jl library? I am trying to figure out a way to
>>> pass array to the function. So far I have came up to to this nonworking
>>> (makes julia to crash) code
>>>
>>


[julia-users] Your experiences with Julia's parallel computing

2016-04-07 Thread Joost Vissers


Hello everyone, 

Recently I got introduced to Julia due to a research project with regards 
to its educational capabilities for teaching students about parallel 
computing. My group and I are wondering what you, the community, think of 
Julia’s parallel computing capabilities and would like to ask you the 
following questions:


   - What is the main reason that you started using Julia?
   - Have you used Julia’s parallel computing aspects?
   - What did you use for parallel programming before using Julia and how 
   do they compare? What made you switch? If applicable.
   - Would you say Julia’s approach to parallel computing is special or 
   unique in any way? Could you elaborate?
   - Lastly do you believe Julia is a suitable language to teach students 
   about parallel programming? Could you elaborate?

Our group and I would like to thank you in advance, and wish you a pleasant 
day.

Joost


Re: [julia-users] Redirecting println output

2016-04-07 Thread Yichao Yu
On Thu, Apr 7, 2016 at 9:45 AM, Alex Dowling  wrote:
> Hello Yichao,
>
> Vanished. I expect println output between other output that is properly
> redirected. I should also mention println output is not properly redirected
> (i.e., vanishes) using nohup.

So the output does not appear even when the whole script exit?
Also see my link about script below.

>
> Alex
>
> On Thursday, April 7, 2016 at 8:05:30 AM UTC-5, Yichao Yu wrote:
>>
>> On Thu, Apr 7, 2016 at 8:12 AM, Alex Dowling  wrote:
>> > Hello,
>> >
>> > I have a Julia script that does some analysis and includes println()
>> > statements. When I use julia my_code.jl > output.txt 2>&1 from a Linux
>> > command line, output from optimization solvers (IPOPT, Gurobi) are
>> > redirected to output.txt but output from println() just vanishes. They
>> > aren't in output.txt or printed to the console.
>>
>> Are they vanished or delayed? The output is buffered.
>>
>> >
>> > One option I found (haven't tested) is using redirect_stout() and
>> > redirect_sterr(): https://github.com/JuliaLang/julia/issues/12050.
>> > Ideally
>> > I'd like to redirect println output without modifying the script.
>>
>> http://man7.org/linux/man-pages/man1/script.1.html
>>
>> >
>> > Thanks,
>> > Alex


[julia-users] Re: Using @pyimport inside a module

2016-04-07 Thread Alex Mellnik
Hi Cedric,

Thanks for looking into this.  I just tried it again today and it's working 
-- I don't know what changed -- I think the only thing I have differently 
is that I restarted my jupyter process.  Not sure, but thanks again,

Alex  

On Wednesday, April 6, 2016 at 3:38:16 PM UTC-7, Cedric St-Jean wrote:
>
> Hi Alex, it looks like you're doing everything right. Just to make sure: 
> does  "TheModuleInJulia" have a final `end` statement? I just tried this 
> code in a notebook:
>
> module TheModuleInJulia
> using PyCall
> @pyimport numpy
> export geteverything 
>
> function geteverything()
> return collect(numpy.eye(10))
> end
> end
>
> TheModuleInJulia.geteverything()
>
> It worked for me. Does it work for you?
>
> On Wednesday, April 6, 2016 at 12:18:09 PM UTC-4, Alex Mellnik wrote:
>>
>> I rely on a small Python module which I am currently calling directly 
>> with @pyimport in a notebook:
>>
>> using PyCall
>> @pyimport datetime
>> @pyimport TheModule
>>
>> cursor = TheModule.connect() 
>>
>>
>> This works fine, but now I would like to wrap the Python module with some 
>> other functions in a julia package.  I tried 
>>
>> module TheModuleInJulia
>>
>> using PyCall
>> @pyimport TheModule
>>
>> export geteverything 
>>
>>
>> function geteverything()
>>
>> return collect(TheModule.connect())
>>
>> end
>>
>>
>> and several varaitions thereof.  In my main file I can
>>
>> using PyCall, TheModule
>>
>>
>> which works fine, but when I  
>>
>> geteverything()
>>
>>
>> I get an error saying that TheModule is not defined.  What's the correct 
>> way to import and use the python module within the julia module? I didn't 
>> see anything about this in the docs for PyCall. Thanks -A
>>
>

Re: [julia-users] Redirecting println output

2016-04-07 Thread Alex Dowling
I just tried script. That works.

On Thursday, April 7, 2016 at 9:43:43 AM UTC-5, Yichao Yu wrote:
>
> On Thu, Apr 7, 2016 at 9:45 AM, Alex Dowling  > wrote: 
> > Hello Yichao, 
> > 
> > Vanished. I expect println output between other output that is properly 
> > redirected. I should also mention println output is not properly 
> redirected 
> > (i.e., vanishes) using nohup. 
>
> So the output does not appear even when the whole script exit? 
> Also see my link about script below. 
>
> > 
> > Alex 
> > 
> > On Thursday, April 7, 2016 at 8:05:30 AM UTC-5, Yichao Yu wrote: 
> >> 
> >> On Thu, Apr 7, 2016 at 8:12 AM, Alex Dowling  
> wrote: 
> >> > Hello, 
> >> > 
> >> > I have a Julia script that does some analysis and includes println() 
> >> > statements. When I use julia my_code.jl > output.txt 2>&1 from a 
> Linux 
> >> > command line, output from optimization solvers (IPOPT, Gurobi) are 
> >> > redirected to output.txt but output from println() just vanishes. 
> They 
> >> > aren't in output.txt or printed to the console. 
> >> 
> >> Are they vanished or delayed? The output is buffered. 
> >> 
> >> > 
> >> > One option I found (haven't tested) is using redirect_stout() and 
> >> > redirect_sterr(): https://github.com/JuliaLang/julia/issues/12050. 
> >> > Ideally 
> >> > I'd like to redirect println output without modifying the script. 
> >> 
> >> http://man7.org/linux/man-pages/man1/script.1.html 
> >> 
> >> > 
> >> > Thanks, 
> >> > Alex 
>


[julia-users] Re: Your experiences with Julia's parallel computing

2016-04-07 Thread michael . creel

>
>
>- What is the main reason that you started using Julia?
>
> Free, fast, works on all popular operating systems, so good for teaching 
and portability of research 

>
>- Have you used Julia’s parallel computing aspects?
>
> Yes, but I mostly use the MPI.jl package. 

>
>- What did you use for parallel programming before using Julia and how 
>do they compare? 
>
> The MPI package for GNU Octave. Using MPI with Julia is very much like MPI 
with Octave. 

>
>- What made you switch? If applicable.
>
> Julia is faster, and I like the language better overall. 

>
>- Would you say Julia’s approach to parallel computing is special or 
>unique in any way? 
>
> I don't actually use the real "Julian" methods, as I'm familiar with MPI, 
which works well for me. 

>
>- Could you elaborate?
>- Lastly do you believe Julia is a suitable language to teach students 
>about parallel programming? Could you elaborate?
>
> Sure, it's a comfortable way to use MPI, at least. I expect that the other 
methods are good too, but I don't have much experience with them. 


[julia-users] Re: Using @pyimport inside a module

2016-04-07 Thread Steven G. Johnson


On Wednesday, April 6, 2016 at 12:18:09 PM UTC-4, Alex Mellnik wrote:
>
> I rely on a small Python module which I am currently calling directly with 
> @pyimport in a notebook:
>
> using PyCall
> @pyimport datetime
> @pyimport TheModule
>
> cursor = TheModule.connect() 
>
>
This won't work if you ever decide to enable precompilation of your module, 
because @pyimport defines constants that contain pointers (to Python 
objects at runtime), and these pointers won't be valid when you re-load a 
precompiled module.

I've updated the PyCall README to add some notes on using PyCall with 
precompiled modules:

   https://github.com/stevengj/PyCall.jl#using-pycall-from-julia-modules


[julia-users] Re: Pulling out residuals and fitted values from lmm in MixedModels

2016-04-07 Thread Douglas Bates
On Wednesday, April 6, 2016 at 6:05:04 PM UTC-5, Christina Castellani wrote:
>
> I am having difficulty figuring out how to pull out the residuals and 
> fitted values from the result of an lmm in Julia using the package 
> MixedModels.jl
>
> In R I would use "residuals(m)" or "fitted(m)", where m is the lme output, 
> to get the desired result. 
>
> Any advice would be greatly appreciated. 
>

I would need to add methods for fitted and residuals to the MixedModels 
package for that to work.

The tricky bit is deciding what fitted should return - the linear predictor 
from the fixed-effects and the random-effects or from the fixed-effects 
only.  Most people want the first of these. 


[julia-users] Re: Your experiences with Julia's parallel computing

2016-04-07 Thread Chris Rackauckas

>
>
>- What is the main reason that you started using Julia?
>
> To more quickly develop code for HPCs. I do stochastic numerical methods 
in developmental biology. When I am making methods, I want to show that it 
works, get a relatively fast prototype, and move on (I'll let "library 
builders" build C libraries from this, too much time for me). When I am 
using the method to study biology, I just want it to work, get a result, 
and move on. Other languages required that I use C/Fortran to do this (I 
need the codes fast). Julia lets me do it fast and all in one language. 

Another big plus is that I love its type system. It allows for 
"data-oriented" programming which works really well for big data, and is 
fast. Objects in R/Python tend to be slow, and basically non-existent in 
MATLAB and so it's nice to be able to use data structures in the intuitive 
CS way. Also its package system via Github is really easy to use and since 
you know the code is all Julia code you can change packages around to fit 
your needs. I can keep going if you want lol.

>
>- Have you used Julia’s parallel computing aspects?
>
> All the time. I documented some of it. Here's a tutorial I wrote for using 
Julia on XSEDE's Comet. 
http://www.stochasticlifestyle.com/multi-node-parallelism-in-julia-on-an-hpc/ 
. I have used it on UC Irvine's cluster and some other XSEDE computers as 
well. I have also used Julia with a Xeon Phi (on my blog) and also with 
GPUs (also on my blog). Its super easy to get it working.

>
>- What did you use for parallel programming before using Julia and how 
>do they compare? What made you switch? If applicable.
>
> MATLAB has licensing problems everywhere you go: you want to use it on an 
HPC, but you have to jump through hoops to do so. The end result isn't even 
good because the language is so slow that you're basically throwing 
computers at a slow code to hope it's fast enough. Python annoyed me with 
Global Interpreter Lock and having generally slow language features as 
well. In order to use it "correctly" for big data projects you have to use 
a bunch of packages to do it all in C, and write your own C code to 
compensate for things it can't do (and when writing your own stochastic 
numerical code is all about loop performance, this means the code is 
basically C). R had the same problem (but I liked that the statistical 
packages covered everything). I also used C with OpenMP and MPI but 
development times were slow...

Julia did all of that together and I haven't wanted to go back since. 

>
>- Would you say Julia’s approach to parallel computing is special or 
>unique in any way? Could you elaborate?
>
> To me it feels and operates like it's "OpenMP with MPI capabilities". 
Honestly I tend to setup my code to just @parallel or pmap and let the 
backend take care of it all. But doing that allows it to use multiple nodes 
on an HPC, so literally adding @parallel makes a program completely 
parallel in some of my cases (like Monte Carlo simulations). I don't think 
it really teaches one the "how" of the parallel/HPC computing like learning 
MPI does, but it gets the job done s much faster.

>
>- Lastly do you believe Julia is a suitable language to teach students 
>about parallel programming? Could you elaborate?
>
> I am on the fence for pedagogy via Julia. There are lots of in depth 
things about Julia. There's the LLVM, macros (generated functions), package 
system (understanding it's full use means you have to learn Git/Github, and 
in Julia's state that's pretty necessary since you need to change branches 
for many packages), type system (if someone's never done Object-oriented 
programming before, i find it confuses them but is really present and not 
hidden in the documentation), multiple dispatch, etc. For experienced 
programming, all of this stuff is right there to pick up and is easy to 
use. For beginners you have to tell them to ignore a lot of features when 
they want to learn how to loop (1:5 isn't an array, but it's like an array, 
and will index the loop just fine, trust me!). So honestly, there are 
easier languages like MATLAB for teaching at a beginner level, but with 
Julia you can go really deep.

Hope this post helps. My blog has a bunch of tutorials for doing 
HPC/parallel things in Julia. I may post some slides I'll be using to teach 
a Julia workshop as well.


[julia-users] Cov deprecated use covm instead but covm doesn't exists

2016-04-07 Thread Iacopo Poli
I'm using function cov in a program but I get this warning

*WARNING: cov(X::AbstractMatrix; 
vardim=1,corrected=true,mean=Base.mean(X,vardim)) is deprecated, use 
covm(X,mean,vardim,corrected) instead.*


then I looked for covm in help, but


but I get 


*help?> **covm*

search: *co*de_ll*vm* @*co*de_ll*vm* *cov* *co*n*v*2 *co*n*v* *co*n*v*ert de
*co*n*v* Sta*c*k*Ov*erflowError


Couldn't find covm

Perhaps you meant cov, conv, conv2, cool, cond, conj, copy, cor, cos or cosc

  No documentation found.


  Binding covm does not exist.


I don't know if this can be solved in some way. My version is *0.5.0-dev+2440 
*by the way


Re: [julia-users] Re: Macro expansion for ccall with tuple argument

2016-04-07 Thread Laurent Bartholdi
Thanks a lot!
There remains a weird issue about globals being mangled by the module name: 
say that all my code is written in a module called "GAP". Assuming I put 
this in the module:

macro do_ccall(f,args...) :(ccall($f, Int, $(Expr(:tuple, [Int for i in 
1:length(args)]...)), $(args...))) end


julia> using GAP

julia> x = GAP.Obj(0);

julia> GAP.@do_ccall(x,1,2,3)
ERROR: UndefVarError: x not defined

julia> macroexpand(:(GAP.@do_ccall(x,1,2,3)))
:(ccall(GAP.x,GAP.Int,(Int64,Int64,Int64),1,2,3))

Ahah... so x got treated as GAP.x. I tried then

:(ccall($(esc(f)), Int, $(Expr(:tuple, [Int for i in 1:length(args)]...)), 
$(args...))) 

and this works now; though if one of the arguments were also x the same 
problems would occur. How should I make sure the code emitted contains 
exactly the binding of its argument (x), and not something else (GAP.x)?


[julia-users] Re: Cov deprecated use covm instead but covm doesn't exists

2016-04-07 Thread Steven G. Johnson
Looks like someone forgot to export covm.   For now, you can use Base.covm, 
but I've commented in https://github.com/JuliaLang/julia/pull/13505/


Re: [julia-users] assignment form function with empty body

2016-04-07 Thread Jeffrey Sarnoff
thanks for the coverage Tamas; I did not check v0.4. from

 Julia Version 0.5.0-dev+3313 Commit 5e01b1a (2016-03-29 15:14 UTC) System: 
Windows (x86_64-w64-mingw32)  CPU: Intel(R) Core(TM) i7-4960X CPU @ 3.60GHz

Empty blocks, the ultimate in code compression. With v0.5.0-dev, used as he 
wrote, they do not behave as `pass`; they show up (llvm --> Intel) as 
opcode ud2 (Undefined/Invalid):

  f_nothing(x) = nothing   ;   
f_emptyblock(x) = begin end;
from code_llvm:   f_nothing(Int32) { return void  };   
f_emptyblock(Int32){ unreachable}  ;
from code_native: f_nothing(Int32) { push move pop return };   
f_emptyblock(Int32){ push move ud2  }  ;



UD2--Undefined Instruction
OpcodeInstructionDescription

0F 0B

UD2

Raise invalid opcode exception
Description

Generates an invalid opcode. This instruction is provided for software 
testing to explicitly generate an invalid opcode. The opcode for this 
instruction is reserved for this purpose.

Other than raising the invalid opcode exception, this instruction is the 
same as the NOP instruction.
Operation

#UD (* Generates invalid opcode exception *);
Flags Affected

None.
Exceptions (All Operating Modes)

#UD - Instruction is guaranteed to raise an invalid opcode exception in all 
operating modes.



On Thursday, April 7, 2016 at 7:29:18 AM UTC-4, Tamas Papp wrote:
>
> Thanks, I always forget that empty blocks return nothing. 
>
> Best, 
>
> Tamas 
>
> On Thu, Apr 07 2016, Mauro wrote: 
>
> > Use: 
> > 
> > foo(x) = nothing 
> > 
> > Note, you're suggestion also returns `nothing`. 
> > 
> > On Thu, 2016-04-07 at 13:04, Tamas Papp > 
> wrote: 
> >> Hi, 
> >> 
> >> What's the most compact form of writing a function in assignment form 
> >> with an empty body? Eg is 
> >> 
> >> foo(x) = begin end 
> >> 
> >> the shortest? 
> >> 
> >> (context: I am using a local function for iterating over a collection 
> in 
> >> a function. for a particular set of argument types, it does nothing, 
> >> hence the need. I am aware that I could be using Match.jl) 
> >> 
> >> Best, 
> >> 
> >> Tamas 
>
>

Re: [julia-users] Re: Macro expansion for ccall with tuple argument

2016-04-07 Thread Yichao Yu
On Thu, Apr 7, 2016 at 12:59 PM, Laurent Bartholdi
 wrote:
> Thanks a lot!
> There remains a weird issue about globals being mangled by the module name:
> say that all my code is written in a module called "GAP". Assuming I put
> this in the module:
>
> macro do_ccall(f,args...) :(ccall($f, Int, $(Expr(:tuple, [Int for i in
> 1:length(args)]...)), $(args...))) end
>
>
> julia> using GAP
>
> julia> x = GAP.Obj(0);
>
> julia> GAP.@do_ccall(x,1,2,3)
> ERROR: UndefVarError: x not defined
>
> julia> macroexpand(:(GAP.@do_ccall(x,1,2,3)))
> :(ccall(GAP.x,GAP.Int,(Int64,Int64,Int64),1,2,3))
>
> Ahah... so x got treated as GAP.x. I tried then
>
> :(ccall($(esc(f)), Int, $(Expr(:tuple, [Int for i in 1:length(args)]...)),
> $(args...)))
>
> and this works now; though if one of the arguments were also x the same
> problems would occur. How should I make sure the code emitted contains
> exactly the binding of its argument (x), and not something else (GAP.x)?

Correct, you need to escape all input...

:(ccall($(esc(f)), Int, $(Expr(:tuple, [Int for i in
1:length(args)]...)), $([esc(arg) for arg in args]...)))


Re: [julia-users] assignment form function with empty body

2016-04-07 Thread Yichao Yu
On Thu, Apr 7, 2016 at 1:14 PM, Jeffrey Sarnoff 
wrote:

> thanks for the coverage Tamas; I did not check v0.4. from
>
>  Julia Version 0.5.0-dev+3313 Commit 5e01b1a (2016-03-29 15:14 UTC) 
> System:
> Windows (x86_64-w64-mingw32)  CPU: Intel(R) Core(TM) i7-4960X CPU @
> 3.60GHz
>
> Empty blocks, the ultimate in code compression. With v0.5.0-dev, used as
> he wrote, they do not behave as `pass`; they show up (llvm --> Intel) as
> opcode ud2 (Undefined/Invalid):
>

There may be bugs but it is likely fixed on master. If not, please report a
bug.

>
>
>   f_nothing(x) = nothing   ;
> f_emptyblock(x) = begin end;
> from code_llvm:   f_nothing(Int32) { return void  };
> f_emptyblock(Int32){ unreachable}  ;
> from code_native: f_nothing(Int32) { push move pop return };
> f_emptyblock(Int32){ push move ud2  }  ;
>
>
>
> UD2--Undefined Instruction
> OpcodeInstructionDescription
>
> 0F 0B
>
> UD2
>
> Raise invalid opcode exception
> Description
>
> Generates an invalid opcode. This instruction is provided for software
> testing to explicitly generate an invalid opcode. The opcode for this
> instruction is reserved for this purpose.
>
> Other than raising the invalid opcode exception, this instruction is the
> same as the NOP instruction.
> Operation
>
> #UD (* Generates invalid opcode exception *);
> Flags Affected
>
> None.
> Exceptions (All Operating Modes)
>
> #UD - Instruction is guaranteed to raise an invalid opcode exception in
> all operating modes.
>
>
>
> On Thursday, April 7, 2016 at 7:29:18 AM UTC-4, Tamas Papp wrote:
>>
>> Thanks, I always forget that empty blocks return nothing.
>>
>> Best,
>>
>> Tamas
>>
>> On Thu, Apr 07 2016, Mauro wrote:
>>
>> > Use:
>> >
>> > foo(x) = nothing
>> >
>> > Note, you're suggestion also returns `nothing`.
>> >
>> > On Thu, 2016-04-07 at 13:04, Tamas Papp  wrote:
>> >> Hi,
>> >>
>> >> What's the most compact form of writing a function in assignment form
>> >> with an empty body? Eg is
>> >>
>> >> foo(x) = begin end
>> >>
>> >> the shortest?
>> >>
>> >> (context: I am using a local function for iterating over a collection
>> in
>> >> a function. for a particular set of argument types, it does nothing,
>> >> hence the need. I am aware that I could be using Match.jl)
>> >>
>> >> Best,
>> >>
>> >> Tamas
>>
>>


[julia-users] state of Winston

2016-04-07 Thread harven
Hi, I recently upgraded to the last stable version of julia (4.5). 

I noticed that Winston is not advertised on julialang anymore, and the 
development seems to have stalled on github.
Is it still maintained? If not, what should I use instead? I mainly use it 
for 2d graphs and animations.

Thanks for your support.


Re: [julia-users] assignment form function with empty body

2016-04-07 Thread Jeffrey Sarnoff
ok

On Thursday, April 7, 2016 at 1:48:50 PM UTC-4, Yichao Yu wrote:
>
>
>
> On Thu, Apr 7, 2016 at 1:14 PM, Jeffrey Sarnoff  > wrote:
>
>> thanks for the coverage Tamas; I did not check v0.4. from
>>
>>  Julia Version 0.5.0-dev+3313 Commit 5e01b1a (2016-03-29 15:14 UTC) 
>> System: 
>> Windows (x86_64-w64-mingw32)  CPU: Intel(R) Core(TM) i7-4960X CPU @ 
>> 3.60GHz
>>
>> Empty blocks, the ultimate in code compression. With v0.5.0-dev, used as 
>> he wrote, they do not behave as `pass`; they show up (llvm --> Intel) as 
>> opcode ud2 (Undefined/Invalid):
>>
>
> There may be bugs but it is likely fixed on master. If not, please report 
> a bug.
>  
>>
>>
>>   f_nothing(x) = nothing   ;   
>> f_emptyblock(x) = begin end;
>> from code_llvm:   f_nothing(Int32) { return void  };   
>> f_emptyblock(Int32){ unreachable}  ;
>> from code_native: f_nothing(Int32) { push move pop return };   
>> f_emptyblock(Int32){ push move ud2  }  ;
>>
>>
>>
>> UD2--Undefined Instruction
>> OpcodeInstructionDescription
>>
>> 0F 0B
>>
>> UD2
>>
>> Raise invalid opcode exception
>> Description
>>
>> Generates an invalid opcode. This instruction is provided for software 
>> testing to explicitly generate an invalid opcode. The opcode for this 
>> instruction is reserved for this purpose.
>>
>> Other than raising the invalid opcode exception, this instruction is the 
>> same as the NOP instruction.
>> Operation
>>
>> #UD (* Generates invalid opcode exception *);
>> Flags Affected
>>
>> None.
>> Exceptions (All Operating Modes)
>>
>> #UD - Instruction is guaranteed to raise an invalid opcode exception in 
>> all operating modes.
>>
>>
>>
>> On Thursday, April 7, 2016 at 7:29:18 AM UTC-4, Tamas Papp wrote:
>>>
>>> Thanks, I always forget that empty blocks return nothing. 
>>>
>>> Best, 
>>>
>>> Tamas 
>>>
>>> On Thu, Apr 07 2016, Mauro wrote: 
>>>
>>> > Use: 
>>> > 
>>> > foo(x) = nothing 
>>> > 
>>> > Note, you're suggestion also returns `nothing`. 
>>> > 
>>> > On Thu, 2016-04-07 at 13:04, Tamas Papp  wrote: 
>>> >> Hi, 
>>> >> 
>>> >> What's the most compact form of writing a function in assignment form 
>>> >> with an empty body? Eg is 
>>> >> 
>>> >> foo(x) = begin end 
>>> >> 
>>> >> the shortest? 
>>> >> 
>>> >> (context: I am using a local function for iterating over a collection 
>>> in 
>>> >> a function. for a particular set of argument types, it does nothing, 
>>> >> hence the need. I am aware that I could be using Match.jl) 
>>> >> 
>>> >> Best, 
>>> >> 
>>> >> Tamas 
>>>
>>>
>

[julia-users] Re: emacs ess julia trouble

2016-04-07 Thread harven


Le vendredi 1 août 2014 20:32:01 UTC+2, Sarvagnan a écrit :
>
> I'd like to pose a question on the ess config itself. I haven't been able 
> to find a satisfactory explanation anywhere. What directory do you need to 
> provide in the seta inferior-julia-program-name field? When starting julia 
> with M-x julia, this question comes up "ESS (*julia*) starting data 
> directory?". What argument does this require? I've tried a variety of 
> arguments including the julia install directory 
> (/usr/local/Cellar/julia/HEAD/bin/julia), my home directory, location of 
> julia history, and location of julia packages. All of these produce an 
> error that says cannot read .juliahistory. Do you have any idea how to fix 
> this?
> Thanks!
>

I am a bit late, but since google points to that thread, you can put in 
your emacs init file

*(setq ess-ask-for-ess-directory nil)*

if you don't want to be asked for a starting data directory. You will start 
from the directory given by the variable *ess-directory *or from the 
current directory if this variable is not set. 
 


Re: [julia-users] state of Winston

2016-04-07 Thread Mauro
https://github.com/tbreloff/Plots.jl wraps many of the plotting packages
and thus allows to use all of them with a single syntax.  Maybe you
should give that a spin?

On Thu, 2016-04-07 at 20:42, harven  wrote:
> Hi, I recently upgraded to the last stable version of julia (4.5).
>
> I noticed that Winston is not advertised on julialang anymore, and the
> development seems to have stalled on github.
> Is it still maintained? If not, what should I use instead? I mainly use it
> for 2d graphs and animations.
>
> Thanks for your support.


[julia-users] Cross-correlation: rfft() VS fft() VS xcorr() performances

2016-04-07 Thread CrocoDuck O'Ducks
Hey there cool people!

Seems like this topic will be pretty similar to this one 
.

So, I am trying to write my version of alignsignals 
.
 
In few words, I calculate the cross-correlation, find the peak, calculate 
its shift from the origin of time, use it to align the signals. I got three 
version of a function to achieve this, using xcorr, fft and rfft 
respectively. When using two signals one minute long, sampled at 48 kHz, 
they benchmark  as follows:

xcorr() version:

 Benchmark Results 
 Time per evaluation: 832.16 ms [663.40 ms, 1.00 s]
Proportion of time in GC: 15.94% [14.32%, 17.57%]
Memory allocated: 460.01 mb
   Number of allocations: 239 allocations
   Number of samples: 10
   Number of evaluations: 10
 Time spent benchmarking: 9.73 s

rfft() version:

 Benchmark Results 
 Time per evaluation: 1.01 s [654.63 ms, 1.36 s]
Proportion of time in GC: 12.11% [8.30%, 15.91%]
Memory allocated: 306.21 mb
   Number of allocations: 344 allocations
   Number of samples: 6
   Number of evaluations: 6
 Time spent benchmarking: 7.58 s

fft() version:

 Benchmark Results 
 Time per evaluation: 715.45 ms [536.86 ms, 894.04 ms]
Proportion of time in GC: 20.37% [16.49%, 24.24%]
Memory allocated: 569.87 mb
   Number of allocations: 276 allocations
   Number of samples: 13
   Number of evaluations: 13
 Time spent benchmarking: 10.56 s

It seems that the fft() version is the fastest while the rfft() version is 
the one that allocates less memory. According to my understanding, rfft() 
should also be faster with respect fft(). Unfortunately, the FFTW plan in 
the post I linked above does not seem to work. Are you able to suggest how 
to plan rfft() to make it faster? I will have to align many data 
collections sampled at 96 kHz minium, usually at least 30 s long. I plan to 
do it in a loopy structure, so it would be of great advantage to have 
quickest execution and lowest memory usage.

Here the code defining the functions:

function alignsignals{T <: Real}(x::Array{T, 1}, u::Array{T, 1})

# Delay as lag of cross correlation peak from origin of time.
lₓ = length(x)
lᵤ = length(u)
lₛ = lₓ + lᵤ - 1

sₓᵤ::Array{T, 1} = xcorr(x, u)

if mod(lₛ, 2) == 0
ct_idx = fld(lₛ, 2)
else
ct_idx = fld(lₛ, 2) + 1
end

_::Array{T, 1}, pk_idx::Array{Int, 1} = findmax(sₓᵤ, 1)

δ::Int = ct_idx - pk_idx[1]

# Align:
y = zeros(T, lᵤ)

if δ > 0
y[1:(lᵤ - δ)] = u[(δ + 1):lᵤ]
else
y[(-δ + 1):lᵤ] = u[1:(lᵤ - -δ)]
end

return y, δ

end

function rfftalignsignals{T <: Real}(x::Array{T, 1}, u::Array{T, 1}; ncores
::Int = 1)

lₓ = length(x)
lᵤ = length(u)

FFTW.set_num_threads(ncores)

x_nfft = nextprod(primes(10), lₓ)
u_nfft = nextprod(primes(10), lᵤ)
nfft = max(x_nfft, u_nfft)

X = rfft([x; zeros(nfft - lₓ)])
U = rfft([u; zeros(nfft - lᵤ)])

Sₓᵤ = conj(X) .* U

sₓᵤ = flipdim(fftshift(irfft(Sₓᵤ, 2 * length(Sₓᵤ) - 1)), 1)

lₛ = length(sₓᵤ)

if mod(lₛ, 2) == 0
ct_idx = fld(lₛ, 2)
else
ct_idx = fld(lₛ, 2) + 1
end

_::Array{T, 1}, pk_idx::Array{Int, 1} = findmax(sₓᵤ, 1)

δ::Int = ct_idx - pk_idx[1]

# Align:
y = zeros(T, lᵤ)

if δ > 0
y[1:(lᵤ - δ)] = u[(δ + 1):lᵤ]
else
y[(-δ + 1):lᵤ] = u[1:(lᵤ - -δ)]
end

return y, δ

end

function fftalignsignals{T <: Real}(x::Array{T, 1}, u::Array{T, 1}; ncores::
Int = 1)

lₓ = length(x)
lᵤ = length(u)

FFTW.set_num_threads(ncores)

x_nfft = nextprod(primes(10), lₓ)
u_nfft = nextprod(primes(10), lᵤ)
nfft = max(x_nfft, u_nfft)

X = fft([x; zeros(x_nfft - lₓ)])
U = fft([u; zeros(u_nfft - lᵤ)])

Sₓᵤ = conj(X) .* U

sₓᵤ = abs(flipdim(fftshift(ifft(Sₓᵤ)), 1))

lₛ = length(sₓᵤ)

if mod(lₛ, 2) == 0
ct_idx = fld(lₛ, 2)
else
ct_idx = fld(lₛ, 2) + 1
end

_::Array{T, 1}, pk_idx::Array{Int, 1} = findmax(sₓᵤ, 1)

δ::Int = ct_idx - pk_idx[1]

# Align:
y = zeros(T, lᵤ)

if δ > 0
y[1:(lᵤ - δ)] = u[(δ + 1):lᵤ]
else
y[(-δ + 1):lᵤ] = u[1:(lᵤ - -δ)]
end

return y, δ

end





Re: [julia-users] Re: Macro expansion for ccall with tuple argument

2016-04-07 Thread Laurent Bartholdi
Sorry, I still don't get it entirely. The code now looks like this (in 
simplified form) with a callable object Obj defined in the module:

macro CALL_VARARG(obj,args...)
quote
f = handler_function($(esc(obj)))
ccall(f,Obj,$(Expr(:tuple,[Obj for arg in 1:nargs]...)),$([esc(arg) 
for arg in args]...))
end
end

(obj::Obj)(args...) = @CALL_nARGS(obj,map(Obj,args)...)

and given x a function object taking one argument and xx a function object 
taking 2 arguments, and y an object,

julia> GAP.@CALL_nARGS(x,y) # all fine


julia> x(y) # same answer


julia> GAP.@CALL_nARGS(xx,y,y) # all fine


julia> xx(y,y) # oops!
ERROR: MethodError: no method matching cconvert(::Type{GAP.Obj}, ::GAP.Obj, 
::GAP.Obj)

So the splicing $(args...) you wrote is necessary for pass the correct 
arguments to ccall, but the cconvert method gets applied to "args..." and 
not individually to all elements of args.

Strangely enough, cconvert is not documented in Julia (?cconvert returns 
nothing) even though it's on the online docs; and no method seems available 
(methods(cconvert) returns nothing).

Thanks in advance! Laurent


[julia-users] How to initialize a Matrix{T}?

2016-04-07 Thread Lucas de Almeida Carotta
How I make this code works?

function read_matrix( data::DataType=Any, spacing=" " )
local line::Vector{ data } = Array( data, 1 )
local matrix::Matix{ data } = Array( Array{ data, 1 }, 1 )

while !eof( STDIN )
line = [ parse( data, i ) for i in split( chomp( readline( STDIN ) 
), spacing ) ]
push!( matrix, line )
end

return matrix
end


Re: [julia-users] Re: Macro expansion for ccall with tuple argument

2016-04-07 Thread Yichao Yu
On Apr 7, 2016 4:44 PM, "Laurent Bartholdi" 
wrote:
>
> Sorry, I still don't get it entirely. The code now looks like this (in
simplified form) with a callable object Obj defined in the module:
>
> macro CALL_VARARG(obj,args...)
> quote
> f = handler_function($(esc(obj)))
> ccall(f,Obj,$(Expr(:tuple,[Obj for arg in
1:nargs]...)),$([esc(arg) for arg in args]...))
> end
> end
>
> (obj::Obj)(args...) = @CALL_nARGS(obj,map(Obj,args)...)
>
> and given x a function object taking one argument and xx a function
object taking 2 arguments, and y an object,
>
> julia> GAP.@CALL_nARGS(x,y) # all fine
> 
>
> julia> x(y) # same answer
> 
>
> julia> GAP.@CALL_nARGS(xx,y,y) # all fine
> 
>
> julia> xx(y,y) # oops!
> ERROR: MethodError: no method matching cconvert(::Type{GAP.Obj},
::GAP.Obj, ::GAP.Obj)
>
> So the splicing $(args...) you wrote is necessary for pass the correct
arguments to ccall, but the cconvert method gets applied to "args..." and
not individually to all elements of args.
>
> Strangely enough, cconvert is not documented in Julia (?cconvert returns
nothing) even though it's on the online docs; and no method seems available
(methods(cconvert) returns nothing).

Splatting and vararg are not allowed in ccall.

>
> Thanks in advance! Laurent


[julia-users] Error installing hydrogen for Atom

2016-04-07 Thread Achu
Was trying to install hydrogen for Atom when I got this error. Tried it 
with every available version of ZMQ and no luck. Anyone know why?

Installing hydrogen to C:\Users\achug\.atom\packages failed 

> zmq@2.14.0 install 
C:\Users\achug\AppData\Local\Temp\apm-install-dir-11637-16296-1xp74zg\node_modules\Hydrogen\node_modules\jmp\node_modules\zmq
> node-gyp rebuild


C:\Users\achug\AppData\Local\Temp\apm-install-dir-11637-16296-1xp74zg\node_modules\Hydrogen\node_modules\jmp\node_modules\zmq>if
 
not defined npm_config_node_gyp (node 
"C:\Users\achug\AppData\Local\atom\app-1.6.2\resources\app\apm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js"
 
rebuild )  else (node  rebuild )

gypnpm ERR! Windows_NT 6.2.9200
npm ERR! argv 
"C:\\Users\\achug\\AppData\\Local\\atom\\app-1.6.2\\resources\\app\\apm\\bin\\node.exe"
 
"C:\\Users\\achug\\AppData\\Local\\atom\\app-1.6.2\\resources\\app\\apm\\node_modules\\npm\\bin\\npm-cli.js"
 
"--globalconfig" "C:\\Users\\achug\\.atom\\.apm\\.apmrc" "--userconfig" 
"C:\\Users\\achug\\.atom\\.apmrc" "install" 
"C:\\Users\\achug\\AppData\\Local\\Temp\\d-11637-16296-10fuf5t\\package.tgz" 
"--target=0.34.5" "--arch=ia32"
npm ERR! node v0.10.40
npm ERR! npm  v2.13.3
npm ERR! code ELIFECYCLE

npm ERR! zmq@2.14.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zmq@2.14.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls zmq
npm ERR! There is likely additional logging output above.


[julia-users] diagm for an (n x 1) Array{T, 2}

2016-04-07 Thread SrAceves
Wouldn't it make sense to extend diagm to accept (n x 1) Array{T, 2}?


[julia-users] Re: Error installing hydrogen for Atom

2016-04-07 Thread Jeffrey Sarnoff
I have experienced this too.  Hydrogen has never been a load-and-go 
proposition for Julia on Windows.  Before this, there were other hang-ups 
and some have had their roots in something an earlier release of Atom on 
Win was doing or not doing.  I have downloaded a version of Juno/LT that 
works on Win7.  It is less of an advanced editor today, but it coordinates 
easily with Julia for type/eval/edit/eval/save.

On Thursday, April 7, 2016 at 9:58:20 PM UTC-4, Achu wrote:
>
> Was trying to install hydrogen for Atom when I got this error. Tried it 
> with every available version of ZMQ and no luck. Anyone know why?
>
> Installing hydrogen to C:\Users\achug\.atom\packages failed 
>
> > zmq@2.14.0 install 
> C:\Users\achug\AppData\Local\Temp\apm-install-dir-11637-16296-1xp74zg\node_modules\Hydrogen\node_modules\jmp\node_modules\zmq
> > node-gyp rebuild
>
>
> C:\Users\achug\AppData\Local\Temp\apm-install-dir-11637-16296-1xp74zg\node_modules\Hydrogen\node_modules\jmp\node_modules\zmq>if
>  
> not defined npm_config_node_gyp (node 
> "C:\Users\achug\AppData\Local\atom\app-1.6.2\resources\app\apm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js"
>  
> rebuild )  else (node  rebuild )
>
> gypnpm ERR! Windows_NT 6.2.9200
> npm ERR! argv 
> "C:\\Users\\achug\\AppData\\Local\\atom\\app-1.6.2\\resources\\app\\apm\\bin\\node.exe"
>  
> "C:\\Users\\achug\\AppData\\Local\\atom\\app-1.6.2\\resources\\app\\apm\\node_modules\\npm\\bin\\npm-cli.js"
>  
> "--globalconfig" "C:\\Users\\achug\\.atom\\.apm\\.apmrc" "--userconfig" 
> "C:\\Users\\achug\\.atom\\.apmrc" "install" 
> "C:\\Users\\achug\\AppData\\Local\\Temp\\d-11637-16296-10fuf5t\\package.tgz" 
> "--target=0.34.5" "--arch=ia32"
> npm ERR! node v0.10.40
> npm ERR! npm  v2.13.3
> npm ERR! code ELIFECYCLE
>
> npm ERR! zmq@2.14.0 install: `node-gyp rebuild`
> npm ERR! Exit status 1
> npm ERR!
> npm ERR! Failed at the zmq@2.14.0 install script 'node-gyp rebuild'.
> npm ERR! This is most likely a problem with the zmq package,
> npm ERR! not with npm itself.
> npm ERR! Tell the author that this fails on your system:
> npm ERR! node-gyp rebuild
> npm ERR! You can get their info via:
> npm ERR! npm owner ls zmq
> npm ERR! There is likely additional logging output above.
>


[julia-users] How to initialize a Matrix{T}?

2016-04-07 Thread Tomas Lycken
Matrices in Julia, unlike some other languages, aren't vectors of vectors - 
they are first class citizens of the multidimensional array system in Julia. 
Thus, 

A = Array(Float64,1,1)

creates a 1x1 matrix that holds Float64s. In most cases, it's even better to 
use 

A = zeros(Float64, 1, 1)

to ensure that you don't have any garbage data (Array allocates, but doesn't 
wipe the memory). Whether that is possible in your case depends on the type 
parameter data. 

// T 



[julia-users] Fast multiprecision integers?

2016-04-07 Thread Laurent Bartholdi
Dear all,
How hard would it be to code arbitrary-precision integers in Julia with at 
worst 2x performance loss over native Ints?

This is what I have in mind: have a bitstype structure, say 64 bits, which 
is either the address of a BigInt (if even), or an Int64 (if odd). Addition 
would be something like:

function +(a::FastInt,b::FastInt)
if a&b&1
(result,obit) = @llvm.sadd.with.overflow.i64(a,b&~1)
obit ? reinterpret(FastInt,BigInt(a>>1)+(b>>1)) : result
elseif a&1
reinterpret(FastInt,(a>>1) + reinterpret(BigInt,b))
elseif b&1
reinterpret(FastInt,reinterpret(BigInt,a) + b>>1)
else
reinterpret(FastInt,reinterpret(BigInt,a) + reinterpret(BigInt,b))
end
end

(code not meant to be run, just a skeleton)

This would be very useful in the development of computer algebra systems, 
in which BigInts are too slow and eat up too much memory, but one is ready 
to pay a small price for guard against arithmetic overflows.

If this is too complicated, then perhaps at least a type of integers that 
would raise an error in case of over/underflows? Those could be caught in 
throw/catch enclosures, so the user could restart the operation with 
BigInts.

TIA, Laurent


Re: [julia-users] What is the correct way to use the type alias Vector and Matrix in multiple dispatch?

2016-04-07 Thread Po Choi
Thanks.

One point I don't understand is the type alias `Matrix{T}` with parametric 
type `T`.

julia> foo{T}(A::Vector{Matrix{T}}) = 1

foo (generic function with 1 method)


julia> methods(foo)

# 1 method for generic function "foo":

foo{T}(A::Array{Array{T,2},1}) at none:1


julia> bar(A::Vector{Matrix}) = 1

bar (generic function with 1 method)


julia> methods(bar)

# 1 method for generic function "bar":

bar(A::Array{Array{T,2},1}) at none:1


julia> baz(A::Vector{Matrix{T}}) = 1

ERROR: UndefVarError: T not defined


I can define `foo{T}(A::Array{Array{T,2},1})`.
I can define `bar(A::Array{Array{T,2},1})`  by using type alias `Matrix` 
without `{T}`
But, I cannot define `baz` as above without `{T}`.
Is it fair?


On Wednesday, April 6, 2016 at 6:24:34 PM UTC-7, Andy Ferris wrote:
>
> T is meant to be a parametric type, defined in this case in the definition 
> of Matrix (as a type alias) and also Array (as a type parameter with the 
> same name). In typeof(AAA) it's pulling T out of that definition of the 
> typealias. You could have written AAA = Matrix{Float64}[randn(3,3) for k in 
> 1:4] to define T.
>
> Further, types in Julia are not covariant which means even if A <: B, we 
> do NOT have Type{A} <: Type{B}. In your case that reads Matrix{Float64} <: 
> Matrix, but not Vector{Matrix{Float64}} <: Vector{Matrix}.
>
> To be generic, your function definitions could take a type parameter, like:
>
> hello{T}(A::Vector{Matrix{T}}) = 2
>
> Here we have introduced a new "parameteric type" variable "T". It could 
> have been named anything. It works since there is some T (==Float64) where 
> it will find a match. 
>
> Or, to be specific about the input type, just define:
>
> hello(A::Vector{Matrix{Float64}}) = 2
>
> You don't have to be afraid of using Matrix and Vector, but you do have to 
> think about how that might interact with the non-covariant type system. In 
> cases like these AFAIK the only way to make a generic function is to 
> introduce type parameters (using either Array{T,2} or Matrix{T} should be 
> fully equivalent).
>
> Does that help?
> Andy
>
>
> On Thursday, April 7, 2016 at 9:58:50 AM UTC+10, Po Choi wrote:
>>
>>
>> Does it make sense to declare a variable with the type `Matrix`?
>>
>> julia> methods(hello)
>> # 2 methods for generic function "hello":
>> hello(A::Array{T,2}) at none:1
>> hello(A::Array{Array{T,2},1}) at none:1
>>
>> julia> AA = [randn(3,3) for k in 1:4];
>>
>> julia> AAA = Matrix[randn(3,3) for k in 1:4];
>>
>> julia> hello(AA)
>> ERROR: MethodError: `hello` has no method matching 
>> hello(::Array{Array{Float64,2},1})
>>
>> julia> hello(AAA)
>> 2
>>
>>
>> julia> typeof(AA)
>> Array{Array{Float64,2},1}
>>
>> julia> typeof(AAA)
>> Array{Array{T,2},1}
>>
>> julia> Array{T,2}
>> ERROR: UndefVarError: T not defined
>>
>>
>> I am a little bit confused about the `T`. Why can `T` appear inside `AAA` 
>> without being declared?
>>
>>
>> On Wednesday, April 6, 2016 at 1:44:38 PM UTC-7, Yichao Yu wrote:
>>>
>>> On Wed, Apr 6, 2016 at 4:23 PM, Po Choi  wrote: 
>>> > 
>>> > hello(A::Matrix) = 1 
>>> > hello(A::Vector{Matrix}) = 2 
>>>
>>>
>>> http://julia.readthedocs.org/en/latest/manual/types/#parametric-composite-types
>>>  
>>>
>>> Vector{Matrix{Float64}} is not a subtype of Vector{Matrix} 
>>>
>>> > A = randn(3,3); 
>>> > AA = [randn(3,3) for k in 1:4]; 
>>> > hello(A) 
>>> > hello(AA) 
>>> > 
>>> > The output has method error. 
>>> > julia> hello(A) 
>>> > 1 
>>> > 
>>> > julia> hello(AA) 
>>> > ERROR: MethodError: `hello` has no method matching 
>>> > hello(::Array{Array{Float64,2},1}) 
>>> > 
>>> > 
>>> > If I write down the types explicitly, 
>>> > hi(A::Array{Float64,2}) = 1 
>>> > hi(A::Array{Array{Float64,2},1}) = 2 
>>> > A = randn(3,3); 
>>> > AA = [randn(3,3) for k in 1:4]; 
>>> > hi(A) 
>>> > hi(AA) 
>>> > The output is what I expect. 
>>> > julia> hi(A) 
>>> > 1 
>>> > 
>>> > julia> hi(AA) 
>>> > 2 
>>> > 
>>> > Am I using Vector and Matrix in a wrong way? 
>>>
>>

[julia-users] Re: MXNet setting workspace, Convolutional layers, kernels etc

2016-04-07 Thread Valentin Churavy
What happens if you set the batch_size to 1? Also take a look 
at https://github.com/dmlc/mxnet/tree/master/example/memcost

Also workspace is per convolution and you should keep it small.  

On Thursday, 7 April 2016 19:13:36 UTC+9, kleinsplash wrote:
>
> Hi,
>
> I have a memory error using Quadro K5000M which has 4GB global memory. I 
> was wondering if there is some guide as to how to set my workspace and 
> Convolutional layers.
>
> My current settings: 
>
> training_data =  128x128x1x800
> batch_size = 128x128x1x8
> workspace = 2048 (I think this can go up to 4096 because of the 
> .deviceQuery)
>
> This is my net (still to be designed so just basic ):
>
> # first conv
> conv1 = @mx.chain mx.Convolution(data=data, kernel=(5,5), num_filter=20, 
> workspace=workspace)  =>
>   mx.Activation(act_type=:relu) =>
>   mx.Pooling(pool_type=:max, kernel=(2,2), stride=(2,2))
> # second conv
> conv2 = @mx.chain mx.Convolution(data=conv1, kernel=(5,5), num_filter=50, 
> workspace=workspace) =>
>   mx.Activation(act_type=:relu) =>
>   mx.Pooling(pool_type=:max, kernel=(2,2), stride=(2,2))
>   # first fully-connected
> fc1   = @mx.chain mx.Flatten(data=conv2) =>
>   mx.FullyConnected(num_hidden=500) =>
>   mx.Activation(act_type=:relu)
> # second fully-connected
> fc2   = mx.FullyConnected(data=fc1, num_hidden=10) 
> # third fully-connected
> fc3   = mx.FullyConnected(data=fc2, num_hidden=2) 
> # softmax loss
> net = mx.SoftmaxOutput(data=fc3, name=:softmax)
>
> So far if I reduce my image to 28x28 it all works - but I need to up the 
> resolution to pick out features. Anyone have any ideas on thumb sucking 
> initial values for at least getting past memory issues to the design of the 
> net? 
>
>
> Thx
>
>