[julia-users] Re: appending `Take`s, `Zip`s & friends to a vector

2016-05-15 Thread Steven G. Johnson
See https://github.com/JuliaLang/julia/issues/7798


[julia-users] Re: appending `Take`s, `Zip`s & friends to a vector

2016-05-15 Thread Steven G. Johnson


On Sunday, May 15, 2016 at 8:42:24 AM UTC-4, Davide Lasagna wrote:
>
> append!(some_int_array, repeated(1, 10))
>

Yes, there should probably be a method that allows an arbitrary iterator 
for the second argument; currently only instances of AbstractVector are 
allowed.   A PR would be welcome.


Re: [julia-users] Re: Slow reading of file

2016-05-15 Thread Milan Bouchet-Valat
Le dimanche 15 mai 2016 à 08:08 -0700, Ford Ox a écrit :
> Thanks Yu and Quinn.
> 
> Now lets go one step further. Lets say I don't want to use any
> default parse function. I will make my own.
> 
> type Buffer{T} x::T end
> 
> function store!(b::Buffer{String}, c::Char) b.x = "$(b.x)$x" end
> function store!(b::Buffer{Int}, c::Char, d::Int) b.x += (c -
> '0')*10^d end #d is number of digits
> 
> 
> Usage
> get_rid_of_leading_spaces()
> while !isspace((x = read_next_char()) store(buffer, x) end
> 
> But I can see potential problems:
> "$(b.x)$x" is probably not much effective, maybe I should use arrays
> of chars with fixed size, but how do I convert it to string?
> string(char_array...) doesn't work with '\0' and I don't want to
> create new array by calling char_array[1:size].
> is b.x += (c - '0')*10^d really the fastest implementation possible?
See IOBuffer and takebuf_string.


Regards

> As a side note, is there anything like show_method_body(function)? I
> often want to see how is function base.xy implemented, but I have to
> manually search all the files which is quite exhausting.
> 
>   


[julia-users] Difficulty building latest master

2016-05-15 Thread David Gold
Something relating to OpenBLAS is going wrong when I try to build the 
latest master:

22736 Symbol names changed

ld: warning: could not create compact unwind for _sgbtrf_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _shseqr_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _spbtrf_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _dhseqr_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _dpbtrf_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _chseqr_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _cpbtrf_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _zpbtrf_64_: stack subq 
instruction is too different from dwarf stack size

ld: warning: could not create compact unwind for _dlatm6_64_: stack subq 
instruction is too different from dwarf stack size

Undefined symbols for architecture x86_64:

  "_blas_cpu_number", referenced from:

  _goto_set_num_threads64_ in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

  _gotoblas_pthread in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

  "_blas_get_cpu_number", referenced from:

  _gotoblas_pthread in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

  "_blas_num_threads", referenced from:

  _blas_thread_init in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

  _exec_blas_async in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

  _goto_set_num_threads64_ in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

  _blas_thread_shutdown_ in 
libopenblas64_p-r0.2.18.a.osx.renamed(blas_server.o)

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

make[3]: *** [libopenblas64_p-r0.2.18.dylib] Error 1

make[2]: *** [shared] Error 2

 Clean the OpenBLAS build with 'make -C deps clean-openblas'. Rebuild 
with 'make OPENBLAS_USE_THREAD=0' if OpenBLAS had trouble linking 
libpthread.so, and with 'make OPENBLAS_TARGET_ARCH=NEHALEM' if there were 
errors building SandyBridge support. Both these options can also be used 
simultaneously. 

make[1]: *** 
[build/openblas-12ab1804b6ebcd38b26960d65d254314d8bc33d6/libopenblas64_.dylib] 
Error 1

make: *** [julia-deps] Error 2


I've tried the suggestions, but I keep encountering errors involving 
symbols not being found. I've updated OSX recently and I ran xcode-select 
--install after doing so. Does anybody have thoughts?


Thanks in advance,

David


Re: [julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread chobbes158
Thanks for the explanation!! That's exactly what I need at the moment, 
though I clearly know that unpredictable return type could be dangerous. 
Many thanks.

On Sunday, May 15, 2016 at 9:07:12 PM UTC+1, Kristoffer Carlsson wrote:
>
> It is possible but seems like something undesirable because you then don't 
> know if an Array{T,1} or Array{T,2} will be returned by the function. This 
> is something Julia people like to call "type instability" when the type of 
> your returned variables depend not only on the type of the arguments to the 
> function. 
>
> If you really want this, then this is an example:
>
> function maybevec(A::AbstractMatrix)
> if size(A, 2) == 1 || size(A, 1) == 1
> return vec(A)
> else
> return A
> end 
> end
>
>
> julia> maybevec(rand(5,5))
> 5×5 Array{Float64,2}:
>  0.542099  0.901245  0.267711  0.260192  0.395683
>  0.361152  0.373492  0.231736  0.259319  0.933759
>  0.307834  0.460153  0.157018  0.712722  0.194619
>  0.869251  0.947844  0.53740.715395  0.67132 
>  0.928848  0.642071  0.948639  0.693701  0.562648
>
>
> julia> maybevec(rand(5,1))
> 5-element Array{Float64,1}:
>  0.579539
>  0.012443
>  0.307975
>  0.742628
>  0.997113
>
>
>
> On Sunday, May 15, 2016 at 9:17:27 PM UTC+2, chobb...@gmail.com wrote:
>>
>> Thanks for the pointer for reshape. 
>>
>> Sorry that I failed to make my question clear enough. In fact, I wonder 
>> if there is a function which can _automatically_ recast a single-column 
>> Array{T,2} to an Array{T,1} and do nothing if this Array{T,2} has multiple 
>> rows.
>>
>>
>>
>>
>>
>> On Sunday, May 15, 2016 at 6:41:51 PM UTC+1, Tim Holy wrote:
>>>
>>> See reshape and vec. 
>>>
>>> Best, 
>>> --Tim 
>>>
>>> On Sunday, May 15, 2016 09:00:33 AM chobb...@gmail.com wrote: 
>>> > Here is rookie question, which I have tried to find a similar question 
>>> and 
>>> > answer in the history of this group, but failed. Please bear me. 
>>> > 
>>> > Since Julia distinguishes between Array{Float64,1} and 
>>> Array{Float64,2}, 
>>> > even there is only one column in an Array{Float64,2}. Therefore, the 
>>> type 
>>> > of rand(5) and rand(5,1) are not same. 
>>> > 
>>> > julia> x = rand(5) 
>>> > 5-element Array{Float64,1}: 
>>> >  0.183247 
>>> >  0.480208 
>>> >  0.623144 
>>> >  0.342792 
>>> >  0.0400695 
>>> > 
>>> > julia> y = rand(5, 1) 
>>> > 5x1 Array{Float64,2}: 
>>> >  0.553224 
>>> >  0.0061835 
>>> >  0.762059 
>>> >  0.643796 
>>> >  0.655135 
>>> > 
>>> > 
>>> > Is there any way that I can upgrade x about to become an 
>>> Array{Float64,2}? 
>>> > And is there a way to downgrade y to become an Array{Float64,1}, when 
>>> it 
>>> > has only one column? 
>>> > 
>>> > In case that there is a similar discussion before, a link to the 
>>> previous 
>>> > thread is good enough and appreciated! 
>>> > 
>>> > Thanks! 
>>>
>>>

Re: [julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread Kristoffer Carlsson
It is possible but seems like something undesirable because you then don't 
know if an Array{T,1} or Array{T,2} will be returned by the function. This 
is something Julia people like to call "type instability" when the type of 
your returned variables depend not only on the type of the arguments to the 
function. 

If you really want this, then this is an example:

function maybevec(A::AbstractMatrix)
if size(A, 2) == 1 || size(A, 1) == 1
return vec(A)
else
return A
end 
end


julia> maybevec(rand(5,5))
5×5 Array{Float64,2}:
 0.542099  0.901245  0.267711  0.260192  0.395683
 0.361152  0.373492  0.231736  0.259319  0.933759
 0.307834  0.460153  0.157018  0.712722  0.194619
 0.869251  0.947844  0.53740.715395  0.67132 
 0.928848  0.642071  0.948639  0.693701  0.562648


julia> maybevec(rand(5,1))
5-element Array{Float64,1}:
 0.579539
 0.012443
 0.307975
 0.742628
 0.997113



On Sunday, May 15, 2016 at 9:17:27 PM UTC+2, chobb...@gmail.com wrote:
>
> Thanks for the pointer for reshape. 
>
> Sorry that I failed to make my question clear enough. In fact, I wonder if 
> there is a function which can _automatically_ recast a single-column 
> Array{T,2} to an Array{T,1} and do nothing if this Array{T,2} has multiple 
> rows.
>
>
>
>
>
> On Sunday, May 15, 2016 at 6:41:51 PM UTC+1, Tim Holy wrote:
>>
>> See reshape and vec. 
>>
>> Best, 
>> --Tim 
>>
>> On Sunday, May 15, 2016 09:00:33 AM chobb...@gmail.com wrote: 
>> > Here is rookie question, which I have tried to find a similar question 
>> and 
>> > answer in the history of this group, but failed. Please bear me. 
>> > 
>> > Since Julia distinguishes between Array{Float64,1} and 
>> Array{Float64,2}, 
>> > even there is only one column in an Array{Float64,2}. Therefore, the 
>> type 
>> > of rand(5) and rand(5,1) are not same. 
>> > 
>> > julia> x = rand(5) 
>> > 5-element Array{Float64,1}: 
>> >  0.183247 
>> >  0.480208 
>> >  0.623144 
>> >  0.342792 
>> >  0.0400695 
>> > 
>> > julia> y = rand(5, 1) 
>> > 5x1 Array{Float64,2}: 
>> >  0.553224 
>> >  0.0061835 
>> >  0.762059 
>> >  0.643796 
>> >  0.655135 
>> > 
>> > 
>> > Is there any way that I can upgrade x about to become an 
>> Array{Float64,2}? 
>> > And is there a way to downgrade y to become an Array{Float64,1}, when 
>> it 
>> > has only one column? 
>> > 
>> > In case that there is a similar discussion before, a link to the 
>> previous 
>> > thread is good enough and appreciated! 
>> > 
>> > Thanks! 
>>
>>

Re: [julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread chobbes158
Thanks for the pointer for reshape. 

Sorry that I failed to make my question clear enough. In fact, I wonder if 
there is a function which can _automatically_ recast a single-column 
Array{T,2} to an Array{T,1} and do nothing if this Array{T,2} has multiple 
rows.





On Sunday, May 15, 2016 at 6:41:51 PM UTC+1, Tim Holy wrote:
>
> See reshape and vec. 
>
> Best, 
> --Tim 
>
> On Sunday, May 15, 2016 09:00:33 AM chobb...@gmail.com  
> wrote: 
> > Here is rookie question, which I have tried to find a similar question 
> and 
> > answer in the history of this group, but failed. Please bear me. 
> > 
> > Since Julia distinguishes between Array{Float64,1} and Array{Float64,2}, 
> > even there is only one column in an Array{Float64,2}. Therefore, the 
> type 
> > of rand(5) and rand(5,1) are not same. 
> > 
> > julia> x = rand(5) 
> > 5-element Array{Float64,1}: 
> >  0.183247 
> >  0.480208 
> >  0.623144 
> >  0.342792 
> >  0.0400695 
> > 
> > julia> y = rand(5, 1) 
> > 5x1 Array{Float64,2}: 
> >  0.553224 
> >  0.0061835 
> >  0.762059 
> >  0.643796 
> >  0.655135 
> > 
> > 
> > Is there any way that I can upgrade x about to become an 
> Array{Float64,2}? 
> > And is there a way to downgrade y to become an Array{Float64,1}, when it 
> > has only one column? 
> > 
> > In case that there is a similar discussion before, a link to the 
> previous 
> > thread is good enough and appreciated! 
> > 
> > Thanks! 
>
>

Re: [julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread Tim Holy
See reshape and vec.

Best,
--Tim

On Sunday, May 15, 2016 09:00:33 AM chobbes...@gmail.com wrote:
> Here is rookie question, which I have tried to find a similar question and
> answer in the history of this group, but failed. Please bear me.
> 
> Since Julia distinguishes between Array{Float64,1} and Array{Float64,2},
> even there is only one column in an Array{Float64,2}. Therefore, the type
> of rand(5) and rand(5,1) are not same.
> 
> julia> x = rand(5)
> 5-element Array{Float64,1}:
>  0.183247
>  0.480208
>  0.623144
>  0.342792
>  0.0400695
> 
> julia> y = rand(5, 1)
> 5x1 Array{Float64,2}:
>  0.553224
>  0.0061835
>  0.762059
>  0.643796
>  0.655135
> 
> 
> Is there any way that I can upgrade x about to become an Array{Float64,2}?
> And is there a way to downgrade y to become an Array{Float64,1}, when it
> has only one column?
> 
> In case that there is a similar discussion before, a link to the previous
> thread is good enough and appreciated!
> 
> Thanks!



[julia-users] Matrix multiplication performance with BitMatrix, Matrix{Bool}, Matrix{Int8}

2016-05-15 Thread Josh Day
Hi all.  Suppose I have a large matrix with entries {0, 1} and I'd like to 
keep storage small by using a BitMatrix.  Are there any tricks to squeeze 
better performance out of BitMatrix multiplication?  I'm also curious about 
the performance difference between Matrix{Bool} and Matrix{Int8}.  Thoughts 
or suggestions are appreciated.  Thanks.

n, p = 1000, 100_000
x1 = rand(n, p) .> .5
x2 = Matrix{Bool}(x1)
x3 = Matrix{Float64}(x1)
x4 = Matrix{Int8}(x1)
b = randn(p)

@time x1 * b
@time x2 * b
@time x3 * b
@time x4 * b
  0.559938 seconds (7 allocations: 8.078 KB)
  0.437336 seconds (7 allocations: 8.078 KB)
  0.062144 seconds (7 allocations: 8.078 KB)
  0.109573 seconds (7 allocations: 8.078 KB)


[julia-users] Re: Slow reading of file

2016-05-15 Thread Ford Ox
Thanks, that's awesome. Based on that I have written function, that will 
print out the method body right into the console (great when you operate in 
REPL).

function functionbody(f::Function, types::Tuple)
filename, line = functionloc(f, types)
open(filename, "r") do f
for _ in 1:line-2 readline(f) end
body = readline(f)
while parse(body).head == :incomplete
body = "$(body)$(readline(f))"
end
print(body)
end
end



Dne neděle 15. května 2016 17:44:52 UTC+2 Kristoffer Carlsson napsal(a):
>
>
>
> On Sunday, May 15, 2016 at 5:08:18 PM UTC+2, Ford Ox wrote:
>>
>> As a side note, is there anything like show_method_body(function)? I 
>> often want to see how is function base.xy implemented, but I have to 
>> manually search all the files which is quite exhausting.
>>
>>   
>>
>
> There is @edit / edit
>


[julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread chobbes158
Here is rookie question, which I have tried to find a similar question and 
answer in the history of this group, but failed. Please bear me.

Since Julia distinguishes between Array{Float64,1} and Array{Float64,2}, 
even there is only one column in an Array{Float64,2}. Therefore, the type 
of rand(5) and rand(5,1) are not same.

julia> x = rand(5)
5-element Array{Float64,1}:
 0.183247
 0.480208
 0.623144
 0.342792
 0.0400695

julia> y = rand(5, 1)
5x1 Array{Float64,2}:
 0.553224
 0.0061835
 0.762059
 0.643796
 0.655135


Is there any way that I can upgrade x about to become an Array{Float64,2}? 
And is there a way to downgrade y to become an Array{Float64,1}, when it 
has only one column?

In case that there is a similar discussion before, a link to the previous 
thread is good enough and appreciated!

Thanks!


[julia-users] Re: Slow reading of file

2016-05-15 Thread Kristoffer Carlsson


On Sunday, May 15, 2016 at 5:08:18 PM UTC+2, Ford Ox wrote:
>
> As a side note, is there anything like show_method_body(function)? I often 
> want to see how is function base.xy implemented, but I have to manually 
> search all the files which is quite exhausting.
>
>   
>

There is @edit / edit


[julia-users] How to vectorize a function which has a tuple as return value to a function which returns a tuple of matrices instead of a matrix with tuple elements?

2016-05-15 Thread Hakuna M.
e.g. for a function like this:
tupleFun(a::Float64) = (a+1, a-1);
if I use
@vectorize_1arg Float64 tupleFun
I get for:
typeof( tupleFun(rand(3,3)) )
Array{Tuple{Float64,Float64},2}
How can I get a function which returns:
Tuple{Array{Float64,2},Array{Float64,2}}
(without an explicit for loop over all elements)


[julia-users] Re: Slow reading of file

2016-05-15 Thread Ford Ox
Thanks Yu and Quinn.

Now lets go one step further. Lets say I don't want to use any default 
parse function. I will make my own.

type Buffer{T} x::T end

function store!(b::Buffer{String}, c::Char) b.x = "$(b.x)$x" end
function store!(b::Buffer{Int}, c::Char, d::Int) b.x += (c - '0')*10^d end #d 
is number of digits


Usage
get_rid_of_leading_spaces()
while !isspace((x = read_next_char()) store(buffer, x) end

But I can see potential problems:

   1. *"$(b.x)$x"* is probably not much effective, maybe I should use 
   arrays of chars with fixed size, but how do I convert it to string? 
   string(char_array...) doesn't work with '\0' and I don't want to create new 
   array by calling char_array[1:size].
   2. is *b.x += (c - '0')*10^d *really the fastest implementation possible?


As a side note, is there anything like show_method_body(function)? I often 
want to see how is function base.xy implemented, but I have to manually 
search all the files which is quite exhausting.

  


[julia-users] Re: Slow reading of file

2016-05-15 Thread Ford Ox
Thanks Yu and Quinn.

One more question.

I want to further improve the reading speed, so I want to generate the new 
string / int already when I am reading. - I am reading char after char

type IntBuffer end # can store one integer
type StrBuffer end

function next!(b::IntBuffer, 


Re: [julia-users] A Question About Structure Of Pointers

2016-05-15 Thread Yichao Yu
On Sun, May 15, 2016 at 2:29 AM, Stefan Schnell  wrote:
>
>
> Hello community,
>
> I am fresh at Julia language and I am fascinated about the possibilities.
> At the moment I examine the possibilities to communicate with C libraries.
> And here I have a question.
>
> I have a structure of pointers as parameter for a C function
> struct connparam{
>   charU * name
>   charU * value
> }
>
> In Julia I try this:
> type connparam
>   name::Ptr{UInt16}
>   value::Ptr{UInt16}
> end
>
> uname = "UserName"
> uvalue = "Stefan"
> cp = connparams(utf16(uname), utf16(uvalue))
>
> ccall((:Test, "CTest.dll"), stdcall, Void, (Ptr{Void},), cp)
>
> But this is not the correct way to transfer type data to a C function,
> because I get the error:
> MethodError: `convert` has no method matching convert(::Type{Ptr{UInt16}},
> ::UTF16String)
>
> What is the correct way to fill the structure with pointers and to transfer
> it to the C function?

Passing structs with pointers to managed memory typically requires
manual management of the object lifetime using `cconvert` and
`unsafe_convert`. This is done automatically for `ccall` arguments
since the lifetime of the argument is very clear to the compiler.

For how `cconvert` and `unsafe_convert` works, see the manual[1]
For an example see my recent PyCall.jl PR[2].

For your case, I would write it as

```
type connparam
name::Ptr{UInt16}
value::Ptr{UInt16}
name_root # GC Root for name (never read from)
value_root # GC Root for value (never read from)
function connparam(name, value)
# As long as `name_root` and `value_root` are live, the
# `unsafe_convert` result should be valid
name_root = Base.cconvert(Ptr{UInt16}, name)
value_root = Base.cconvert(Ptr{UInt16}, value)
new(Base.unsafe_convert(Ptr{UInt16}, name_root),
Base.unsafe_convert(Ptr{UInt16}, value_root),
name_root, value_root)
end
end

uname = "UserName"
uvalue = "Stefan"
cp = connparams(utf16(uname), utf16(uvalue))

# The Ref{connparam} here should pass a reference of `cp` to the
# C function.
ccall((:Test, "CTest.dll"), stdcall, Void, (Ref{connparam},), cp)
```

The interface is not particularly optimized for using outside `ccall`
so suggestions of how to make this easier to use are welcome. The
explicit rooting and `unsafe_convert` part is basically equivalent to
what you need to do in all other managed languages when the language
runtime/compiler can't reason about the lifetime of the C pointer, the
`cconvert` is needed since data copy might be necessary as part of the
conversion (imagining you have a linked list and want to pass it as an
array to C, the allocation of the array would be done in `cconvert`).

[1] 
http://julia.readthedocs.io/en/latest/manual/calling-c-and-fortran-code/#auto-conversion
[2] https://github.com/stevengj/PyCall.jl/pull/267#issuecomment-217683606

>
> Thanks for tips and hints.
>
> Cheers
> Stefan


Re: [julia-users] Re: Immutables redeclaration

2016-05-15 Thread Stefan Karpinski
This depends entirely on context. If this code appears in a gobal scope (or
in the REPL) then each return value will be separately heap allocated. If
the code occurs in the middle of a function and the variables are all local
and Julia's compiler can infer the type of x, then x will be stored in
registers or on the stack. The easiest way to tell is by looking at the
output of @code_typewarn for type instabilities and @code_llvm/native for
lots of reading/writing of memory.

On Sun, May 15, 2016 at 5:35 AM, Kristoffer Carlsson 
wrote:

> Since these are just normal integers they will (assuming you are putting
> them in a function) be allocated on the stack so no gc will need to run.
>
> If x instead allocated something then the previous x would still be in
> memory until the gc desides to clean them up. I'm not sure about the exact
> question but frequent unnecessary allocations can significantly affect
> performance, yes.
>
>
> On Sunday, May 15, 2016 at 9:55:39 AM UTC+2, Ford Ox wrote:
>>
>> Just from pure curiosity.
>>
>> x = 10
>> x = 100
>> x = x << 2
>> x = foo() # returns int64
>>
>> Will x after any of these instruction use new memory storage (thus there
>> will be two x variables present, until gc deletes the one with no pointer)?
>> If yes, does it affect performance significantly?
>>
>>


Re: [julia-users] LQ decomposition.

2016-05-15 Thread Stefan Karpinski
This appears to be a homework question. Just as on StackOverflow, it's not
ok to ask people to do homework problems for you on julia-users.

On Sun, May 15, 2016 at 7:07 AM, Rafiul Nakib 
wrote:

> Can anyone please help me on this?
>


[julia-users] LQ decomposition.

2016-05-15 Thread Rafiul Nakib
Can anyone please help me on this? 


[julia-users] A Question About Structure Of Pointers

2016-05-15 Thread Stefan Schnell


Hello community,

I am fresh at Julia language and I am fascinated about the possibilities.
At the moment I examine the possibilities to communicate with C libraries. 
And here I have a question.

I have a structure of pointers as parameter for a C function
struct connparam{
  charU * name
  charU * value
}

In Julia I try this:
type connparam
  name::Ptr{UInt16}
  value::Ptr{UInt16}
end

uname = "UserName"
uvalue = "Stefan"
cp = connparams(utf16(uname), utf16(uvalue))

ccall((:Test, "CTest.dll"), stdcall, Void, (Ptr{Void},), cp)

But this is not the correct way to transfer type data to a C function, 
because I get the error:
MethodError: `convert` has no method matching convert(::Type{Ptr{UInt16}}, 
::UTF16String)

What is the correct way to fill the structure with pointers and to transfer 
it to the C function?

Thanks for tips and hints.

Cheers
Stefan


[julia-users] Re: Attention users of HTTPClient

2016-05-15 Thread NagaMurali reddy

Hi Jonathan ,

   Is there any way to implement multipart file upload in web 
applications using julia?

On Wednesday, 2 September 2015 19:26:38 UTC+5:30, Jonathan Malmaud wrote:
>
> We are considering deprecating HTTPClient (a wrapper around libcurl) in 
> favor of Requests.jl (a mostly pure-Julia implementation of the HTTP 
> client-side protocol).  Requests has recently gained support for features 
> that currently only HTTPClient had (redirects, cookies, full utf8 support, 
> multipart encoding, etc.) which makes this move viable.
>
> Please chime in on https://github.com/JuliaWeb/HTTPClient.jl/issues/21 
> with your thoughts, especially if you hae a use for HTTPClient that 
> Requests still doesn't support.
>


[julia-users] appending `Take`s, `Zip`s & friends to a vector

2016-05-15 Thread Davide Lasagna
Hi, 

shouldn't this be allowed?

append!(some_int_array, repeated(1, 10))

ERROR: MethodError: `append!` has no method matching 
append!(::Array{Int64,1}, ::Base.Take{Base.Repeated{Int64}})

Closest candidates are:

  append!{T}(::Array{T,1}, ::AbstractArray{T,1})


The same with zip, drop, filter, and enumerate. 


One could `collect` the second argument into a vector, but that would 
allocate memory. 

Thanks, 

Davide



[julia-users] Re: Immutables redeclaration

2016-05-15 Thread Kristoffer Carlsson
Since these are just normal integers they will (assuming you are putting 
them in a function) be allocated on the stack so no gc will need to run. 

If x instead allocated something then the previous x would still be in 
memory until the gc desides to clean them up. I'm not sure about the exact 
question but frequent unnecessary allocations can significantly affect 
performance, yes.

On Sunday, May 15, 2016 at 9:55:39 AM UTC+2, Ford Ox wrote:
>
> Just from pure curiosity.
>
> x = 10
> x = 100
> x = x << 2
> x = foo() # returns int64
>
> Will x after any of these instruction use new memory storage (thus there 
> will be two x variables present, until gc deletes the one with no pointer)?
> If yes, does it affect performance significantly?
>
>

Re: [julia-users] Julia text editor on iPad?

2016-05-15 Thread Sheehan Olver
It works on the smart keyboard for me.  Otherwise, you have to press the “play” 
button in the toolbar.


> On 15 May 2016, at 5:11 PM, Andrew Gibb  wrote:
> 
> Is there a way to do shift-enter to execute a cell using the iPad software 
> keyboard? Does shift enter just work on the hardware keyboard?



[julia-users] Re: Julia Utopia: Share your tips and tricks to efficient coding in Julia

2016-05-15 Thread Chris Rackauckas
I work on numerical/scientific code, so my experience may be different than 
more traditional programming uses. 

Atom is great. I tried the original JunoLT, and it put me off from Julia 
for awhile, but I feel at home in Atom. Nice tip: there's a package for 
hidpi if you have a 4K screen. It will automatically resize your text to 
match the difference. I have a 4K widescreen monitor turned vertical and 
can swap my code over there to show code paradise, but then if I swap it to 
another screen (to have a big pdf open) it changes instantly. 

Honestly, the debugging could be better. The errors are really good so you 
usually know what line it is and what kind of problem it is, but I would 
like a debugger (and haven't tried to build Gallium yet). But println 
debugging works well.

Plots.jl is great. I was using a mixture of PyPlot and Gadfly, but am 
moving my package over to Plots.jl because it lets you use like every 
package. That's actually the key to Julia. Julia with its named functions 
and multiple dispatch has the ability to wrap things really well. Thus 
there are very powerful packages which wrap things. Plots wraps a bunch of 
backends so you can use the same plot command with a bunch of different 
backends. JuMP lets you define a nonlinear problem and try out a bunch of 
different solvers. Etc. Things that would normally be multiple different 
scripts just to test things out, is now the difference of 1 line. 

Must have packages? DifferentialEquations.jl. I kid... but not really. I 
made something like this in MATLAB a few years ago, but it was really slow 
due to what MATLAB does with anonymous functions, and many other reasons. I 
built this in Julia quite quickly and it works well. The flexibility of 
Julia gives the same situation like I described in the last paragraph where 
it's really simple to define new problems/algorithms and so developing new 
numerical methods is much easier.

But the true good packages are the amazing performance-based macros. 
ParallelAccelerator.jl is killer: you just add @acc in front of a loop and 
get a really fast basically fully-optimized C++ program. Devectorize.jl can 
devectorize vector-functions to make readable but fast code. JuMP and all 
of the optimization packages it can use is amazing if you do that kind of 
work as well. CudaRT.jl is really easy to use and gives a quick interface 
to CUDA code. 

Two pieces of advice. The first is to get on Gitter. People are really 
helpful on Gitter, don't be afraid to ask. It's been really helpful for me. 
The second, is the machinefile. I don't know if you use HPCs, but if you 
use an HPC using multiple nodes for a computation in Julia is as simple as 
this: add the MPI stuff to your job script, and pass the machinefile to 
Julia. That's it. Now your @paralllel loop runs on 192 cores. I wrote how 
to do this in more detail on my blog. 
 
Coming 
from doing C+MPI coding to do this stuff, I will never go back. Now code 
that takes MATLAB amount of time to develop can do almost what the C+MPI 
code could do (which takes sooo much longer to make).

On Thursday, May 12, 2016 at 10:01:04 AM UTC-7, David Parks wrote:
>
> I'm a few weeks into Julia and excited and motivated to learn and be as 
> efficient as possible. I'm sure I'm not alone. I know my way around now, 
> but am I as efficient as I can be? 
>
> What haven't I tried? What haven't I seen? What haven't I asked?
>
> For those of you who have been around longer, could you share your advice 
> on efficient day-to-day development style?
>
> For example:
>
>- What IDE do you use? Are you using Atom? A combination of Atom and 
>the REPL? Something else?
>- How do you debug complex code efficiently? How do you debug other 
>peoples code efficiently?
>- Do you have a favorite way of visualizing your work?
>- Are there must have tools? packages? utilities?
>- Any simple day-to-day efficiency/advice you could share with others 
>who didn't yet know to ask.
>
>
>

[julia-users] Re: Changing a package name

2016-05-15 Thread Tony Kelman
Renaming an existing package can cause problems if anyone else has started 
using or depending on it. You can deprecate the existing name of the 
package by adding an upper Julia version number bound on all existing tags 
of the package in METADATA, so it will no longer be installable once newer 
versions of Julia are released. Then register the new name as a new 
package, using a separate repository for development.


On Sunday, May 15, 2016 at 12:59:17 AM UTC-7, Rob wrote:
>
> Does anyone have any tips on changing a packages name? I am looking to 
> expand EEG.jl to encompass other electrophysiological techniques, and think 
> the name Electrophysiology.jl would be more accurate.
>
> Is the general consensus to keep the old repo around and provide a warning?
> Or, change the name of the repo in github? I imagine this will cause 
> issues with METADATA.jl?
>
> Any tips to ease the transition would be appreciated.
>


Re: [julia-users] How to change REPL mode on startup?

2016-05-15 Thread Rafael Fourquet
John, I tried your branch which works as expected, thank you. I found
that there has been a PR at
https://github.com/JuliaLang/julia/pull/13545 related to REPL hooks,
not sure how much this overlaps with your solution. In any case, I
hope to see this functionality merged.


[julia-users] Changing a package name

2016-05-15 Thread Rob
Does anyone have any tips on changing a packages name? I am looking to 
expand EEG.jl to encompass other electrophysiological techniques, and think 
the name Electrophysiology.jl would be more accurate.

Is the general consensus to keep the old repo around and provide a warning?
Or, change the name of the repo in github? I imagine this will cause issues 
with METADATA.jl?

Any tips to ease the transition would be appreciated.


[julia-users] Immutables redeclaration

2016-05-15 Thread Ford Ox
Just from pure curiosity.

x = 10
x = 100
x = x << 2
x = foo() # returns int64

Will x after any of these instruction use new memory storage (thus there 
will be two x variables present, until gc deletes the one with no pointer)?
If yes, does it affect performance significantly?



Re: [julia-users] Julia text editor on iPad?

2016-05-15 Thread Andrew Gibb
Is there a way to do shift-enter to execute a cell using the iPad software 
keyboard? Does shift enter just work on the hardware keyboard?