[julia-users] Re: python a[range(x), y] equivalent in Julia

2015-12-19 Thread 'Greg Plowman' via julia-users
I'm guessing you want y to specify a column from each row.
Not sure how to do this directly. Closest I can think of this:

a = [ -1 2; 3 -4 ] 
y = [ 1, 2 ]
i = sub2ind(size(a), 1:2, y)
a[i]



[julia-users] Re: ANN: Kip.jl an alternative module system

2015-12-19 Thread Jake Rosoman
I forgot to actually link to the project 

On Sunday, December 20, 2015 at 8:25:04 PM UTC+13, Jake Rosoman wrote:
>
> Julia's module system is the one part of it I feel confident enough to say 
> is bad. It can't handle several versions of the same package. Is hard (or 
> impossible?) to depend on packages that aren't in the registry and hard to 
> add (controversial) things to the registry. I also find it ugly and hard to 
> use but now I'm getting into opinions so I'll stop.
>
> Kip solves all these problems and works fine alongside Julia's current 
> module system so you can try it out now. I hope that eventually we can 
> replace Julia's module system if people generally agree that it's worth 
> doing. I've created a poll to measure the communities opinion 
>  and you can change your vote at any time so feel 
> free to say no now but follow the discussion.
>


[julia-users] ANN: Kip.jl an alternative module system

2015-12-19 Thread Jake Rosoman
Julia's module system is the one part of it I feel confident enough to say 
is bad. It can't handle several versions of the same package. Is hard (or 
impossible?) to depend on packages that aren't in the registry and hard to 
add (controversial) things to the registry. I also find it ugly and hard to 
use but now I'm getting into opinions so I'll stop.

Kip solves all these problems and works fine alongside Julia's current 
module system so you can try it out now. I hope that eventually we can 
replace Julia's module system if people generally agree that it's worth 
doing. I've created a poll to measure the communities opinion 
 and you can change your vote at any time so feel 
free to say no now but follow the discussion.


Re: [julia-users] Re: python a[range(x), y] equivalent in Julia

2015-12-19 Thread Stefan Karpinski
In your example y is a row matrix, rather than a vector. If you make it a
vector it works:

julia> a = [-1  2
 3 -4]
2x2 Array{Int64,2}:
 -1   2
  3  -4

julia> y = [1, 2]
2-element Array{Int64,1}:
 1
 2

julia> a[:,y]
2x2 Array{Int64,2}:
 -1   2
  3  -4


This seems like it may not be what you want though. Can you explain what
you'd like it to do?

On Sat, Dec 19, 2015 at 7:44 PM, Lex  wrote:

> I am expecting [-1 -4] in the Julia example.
>
>
> On Saturday, December 19, 2015 at 4:42:07 PM UTC-8, Lex wrote:
>>
>> Hi
>>
>> In Python, I am able to select values like this:
>>
>> >>> a = np.matrix([[-1,2],[3,-4]])
>> >>> y = np.matrix([1,0])
>> >>> a[range(2),y]
>> matrix([[2, 3]])
>> >>>
>>
>> Is there any equivalent in Julia or using a loop is the only way?
>>
>> julia> a
>> 2x2 Array{Int64,2}:
>>  -1   2
>>   3  -4
>>
>> julia> y
>> 1x2 Array{Int64,2}:
>>  1  2
>>
>> julia> a[:, y]
>> ERROR: MethodError: `index_shape_dim` has no method matching
>> index_shape_dim(::Array{Int64,2}, ::Int64, ::Array{Int64,2})
>>
>> You might have used a 2d row vector where a 1d column vector was required.
>> Note the difference between 1d column vector [1,2,3] and 2d row vector [1
>> 2 3].
>> You can convert to a column vector with the vec() function.
>> Closest candidates are:
>>   index_shape_dim(::Any, ::Any, ::Real...)
>>   index_shape_dim(::Any, ::Any, ::Colon)
>>   index_shape_dim(::Any, ::Any, ::Colon, ::Any, ::Any...)
>>   ...
>>  in getindex at abstractarray.jl:488
>>
>> julia> a[:, y[]]
>> 2-element Array{Int64,1}:
>>  -1
>>   3
>>
>> julia> a[:, y[:]]
>> 2x2 Array{Int64,2}:
>>  -1   2
>>   3  -4
>>
>> julia>
>>
>>
>>


[julia-users] Re: Nettle has build errors - no provider can provide libnettle on Win 10

2015-12-19 Thread Tony Kelman
Fix merged to master in https://github.com/staticfloat/Nettle.jl/pull/60, 
will tag as soon as I get the okay from Elliot.


On Saturday, December 19, 2015 at 3:34:56 PM UTC-8, Tony Kelman wrote:
>
> Nevermind. Looks like we need a new package name / alias again: 
> https://build.opensuse.org/package/rdiff/windows:mingw:win64/mingw64-libnettle?linkrev=base&rev=12
>
>
> On Saturday, December 19, 2015 at 3:31:27 PM UTC-8, Tony Kelman wrote:
>>
>> Please post the entire output of what happens when you try 
>> Pkg.build("Nettle").
>>
>>
>> On Saturday, December 19, 2015 at 2:17:35 PM UTC-8, Nils Gudat wrote:
>>>
>>> Getting this error when trying to add IJulia to my 0.4.2 installation. I 
>>> found this old IJulia issue 
>>>  which in turn 
>>> references this BinDeps issue 
>>>  as a possible 
>>> solution, but both of these are >1 year old and from what I understand the 
>>> solution there was to change the name of the libnettle package in Nettles 
>>> build script, which has been done by now.
>>>
>>> The error messages I'm getting are the same as the ones in those issues, 
>>> as is the output from BinDeps.debug (RPM/AptGet/Yum can't provide 
>>> libnettle).
>>>
>>> Any ideas on how to solve this?
>>>
>>

[julia-users] Re: Juno bundles for Julia v0.4

2015-12-19 Thread Sheehan Olver
Hmm, double clicking Juno doesn't work (Says "Application can't be opened") 
but running Juno.app/Contents/MacOS/Electron works fine.  This is on El 
Capitan

On Saturday, December 19, 2015 at 3:24:39 AM UTC+11, Mike Innes wrote:
>
> Hey All,
>
> Juno bundles including Julia v0.4 are now available on the Julia 
> downloads page . If you're still using 
> Juno with Julia v0.3 the upgrade is definitely recommended – among other 
> things, features like precompilation make using packages like Gadfly much 
> easier. Enjoy!
>
> Cheers,
> Mike
>


Re: [julia-users] The sound of clashing symbols

2015-12-19 Thread Jeff Bezanson
You only need to qualify the symbols that conflict. So you need
A.save() and B.save(), but you shouldn't need to qualify any of the
other names in the modules.

On Sat, Dec 19, 2015 at 3:08 PM,   wrote:
> Sorry for this basic question, but I've got myself confused...
>
> Suppose I use 2 modules, A and B. Both modules export a function, let's say 
> it's `save()`. Julia warns me that the symbols clash. I don't want to have to 
> use the module name to qualify every function imported from A and B (after 
> `import` not `using`). I'd like to just have, say `B.save()` and `save()` 
> (which uses the A version), and use the non-clashing symbols without 
> qualifying them.
>
> it seems that I have to modify all the local code whenever modules A or B 
> decide to export a new symbol... You'd have to use `import` and qualify every 
> imported symbol when using it to be guaranteed safe against changes to 
> imported packages...?


[julia-users] Re: python a[range(x), y] equivalent in Julia

2015-12-19 Thread Lex
I am expecting [-1 -4] in the Julia example. 

On Saturday, December 19, 2015 at 4:42:07 PM UTC-8, Lex wrote:
>
> Hi
>
> In Python, I am able to select values like this:
>
> >>> a = np.matrix([[-1,2],[3,-4]])
> >>> y = np.matrix([1,0])
> >>> a[range(2),y]
> matrix([[2, 3]])
> >>>
>
> Is there any equivalent in Julia or using a loop is the only way?
>
> julia> a
> 2x2 Array{Int64,2}:
>  -1   2
>   3  -4
>
> julia> y
> 1x2 Array{Int64,2}:
>  1  2
>
> julia> a[:, y]
> ERROR: MethodError: `index_shape_dim` has no method matching 
> index_shape_dim(::Array{Int64,2}, ::Int64, ::Array{Int64,2})
>
> You might have used a 2d row vector where a 1d column vector was required.
> Note the difference between 1d column vector [1,2,3] and 2d row vector [1 
> 2 3].
> You can convert to a column vector with the vec() function.
> Closest candidates are:
>   index_shape_dim(::Any, ::Any, ::Real...)
>   index_shape_dim(::Any, ::Any, ::Colon)
>   index_shape_dim(::Any, ::Any, ::Colon, ::Any, ::Any...)
>   ...
>  in getindex at abstractarray.jl:488
>
> julia> a[:, y[]]
> 2-element Array{Int64,1}:
>  -1
>   3
>
> julia> a[:, y[:]]
> 2x2 Array{Int64,2}:
>  -1   2
>   3  -4
>
> julia>
>
>
>

[julia-users] python a[range(x), y] equivalent in Julia

2015-12-19 Thread Lex
Hi

In Python, I am able to select values like this:

>>> a = np.matrix([[-1,2],[3,-4]])
>>> y = np.matrix([1,0])
>>> a[range(2),y]
matrix([[2, 3]])
>>>

Is there any equivalent in Julia or using a loop is the only way?

julia> a
2x2 Array{Int64,2}:
 -1   2
  3  -4

julia> y
1x2 Array{Int64,2}:
 1  2

julia> a[:, y]
ERROR: MethodError: `index_shape_dim` has no method matching 
index_shape_dim(::Array{Int64,2}, ::Int64, ::Array{Int64,2})

You might have used a 2d row vector where a 1d column vector was required.
Note the difference between 1d column vector [1,2,3] and 2d row vector [1 2 
3].
You can convert to a column vector with the vec() function.
Closest candidates are:
  index_shape_dim(::Any, ::Any, ::Real...)
  index_shape_dim(::Any, ::Any, ::Colon)
  index_shape_dim(::Any, ::Any, ::Colon, ::Any, ::Any...)
  ...
 in getindex at abstractarray.jl:488

julia> a[:, y[]]
2-element Array{Int64,1}:
 -1
  3

julia> a[:, y[:]]
2x2 Array{Int64,2}:
 -1   2
  3  -4

julia>




[julia-users] using types with params that nest types?

2015-12-19 Thread Jeffrey Sarnoff
I am unclear about how higher order parameterizations, some nested, best 
govern method dispatch.
Here is a simplified exemplar.  What of this is appropriate --how is it 
approached?

#=
  n talleys the number of system Floats used as an extended 
accumulator
 F is the floating point type that carries out the smaller ops 
calculations require
D is the discipline that most immediately benefits from 
this runnable schema 
   a is a discipline-contextualized abstract supertype of 
... that nests as D{ ϕ }
  p is a match assignable param that better 
orchestrates multidispatch
=#

immutable StyledFloat{ n, F, D, a, p }
  accum::Vector{F}(n)
  assign::Account{ D{a} }
end

function Glide{ D{a}, p }( context::D{a},  pattern::p ) 
function Glide{ D, a, p }( context::D{a},  pattern::p )




[julia-users] Different result in pmap vs remotecall

2015-12-19 Thread lmagarshack
Hi all,

I'm using Julia 0.4.2 and I was playing around with pmap and the 
DataStructures package when I found something weird: the same function call 
when done through remotecall or pmap gives different results.

Here's a code example:


@everywhere using DataStructures






 

@everywhere global const thresholds = collect(0:25)

 

push!(thresholds, typemax(eltype(thresholds))) #last element is 
9223372036854775807

 

@everywhere global const sortedThresholds = SortedSet(thresholds)




 

global const warmup = round(Int64, rand(100) .* 26)




 

@everywhere function findAndReturn2(x::Int64)

return deref((sortedThresholds, searchsortedfirst(sortedThresholds, x)))

end




ref = remotecall(findAndReturn2, 1, 26)

fetch(ref) #returns 9223372036854775807




pmap(findAndReturn2, [26]) #returns 
[RemoteException(2,CapturedException(BoundsError(#undef,#undef),Any[(:findAndReturn2,:none,2,symbol(""),-1,1),(:anonymous,symbol("multi.jl"),907,symbol(""),-1,1),(:run_work_thunk,symbol("multi.jl"),645,symbol(""),-1,1),(:anonymous,symbol("multi.jl"),907,symbol("task.jl"),63,1)]))]



I would expect both calls to return the same thing (albeit wrapped in an 
Array in the case of pmap and not in the case of remotecall)


Cheers,

Louis



[julia-users] PyData Amsterdam CFP, we'd love to have somebody talk about Julia!

2015-12-19 Thread vincent warmerdam
Hi, I'm one of the organising members of PyData Amsterdam. The Call For 
Papers just opened up and we'd love to have somebody from the Julia 
community drop by and talk about the current status of the project. 

Please consider the call for papers for this event; 

http://pydata.org/amsterdam2016/cfp/


[julia-users] Re: Nettle has build errors - no provider can provide libnettle on Win 10

2015-12-19 Thread Tony Kelman
Nevermind. Looks like we need a new package name / alias 
again: 
https://build.opensuse.org/package/rdiff/windows:mingw:win64/mingw64-libnettle?linkrev=base&rev=12


On Saturday, December 19, 2015 at 3:31:27 PM UTC-8, Tony Kelman wrote:
>
> Please post the entire output of what happens when you try 
> Pkg.build("Nettle").
>
>
> On Saturday, December 19, 2015 at 2:17:35 PM UTC-8, Nils Gudat wrote:
>>
>> Getting this error when trying to add IJulia to my 0.4.2 installation. I 
>> found this old IJulia issue 
>>  which in turn 
>> references this BinDeps issue 
>>  as a possible 
>> solution, but both of these are >1 year old and from what I understand the 
>> solution there was to change the name of the libnettle package in Nettles 
>> build script, which has been done by now.
>>
>> The error messages I'm getting are the same as the ones in those issues, 
>> as is the output from BinDeps.debug (RPM/AptGet/Yum can't provide 
>> libnettle).
>>
>> Any ideas on how to solve this?
>>
>

[julia-users] Re: Nettle has build errors - no provider can provide libnettle on Win 10

2015-12-19 Thread Tony Kelman
Please post the entire output of what happens when you try 
Pkg.build("Nettle").


On Saturday, December 19, 2015 at 2:17:35 PM UTC-8, Nils Gudat wrote:
>
> Getting this error when trying to add IJulia to my 0.4.2 installation. I 
> found this old IJulia issue 
>  which in turn 
> references this BinDeps issue 
>  as a possible 
> solution, but both of these are >1 year old and from what I understand the 
> solution there was to change the name of the libnettle package in Nettles 
> build script, which has been done by now.
>
> The error messages I'm getting are the same as the ones in those issues, 
> as is the output from BinDeps.debug (RPM/AptGet/Yum can't provide 
> libnettle).
>
> Any ideas on how to solve this?
>


[julia-users] Nettle has build errors - no provider can provide libnettle on Win 10

2015-12-19 Thread Nils Gudat
Getting this error when trying to add IJulia to my 0.4.2 installation. I 
found this old IJulia issue 
 which in turn references 
this 
BinDeps issue  as a 
possible solution, but both of these are >1 year old and from what I 
understand the solution there was to change the name of the libnettle 
package in Nettles build script, which has been done by now.

The error messages I'm getting are the same as the ones in those issues, as 
is the output from BinDeps.debug (RPM/AptGet/Yum can't provide libnettle).

Any ideas on how to solve this?


[julia-users] The sound of clashing symbols

2015-12-19 Thread cormullion
Sorry for this basic question, but I've got myself confused...

Suppose I use 2 modules, A and B. Both modules export a function, let's say 
it's `save()`. Julia warns me that the symbols clash. I don't want to have to 
use the module name to qualify every function imported from A and B (after 
`import` not `using`). I'd like to just have, say `B.save()` and `save()` 
(which uses the A version), and use the non-clashing symbols without qualifying 
them. 

it seems that I have to modify all the local code whenever modules A or B 
decide to export a new symbol... You'd have to use `import` and qualify every 
imported symbol when using it to be guaranteed safe against changes to imported 
packages...?

[julia-users] Re: Why can't julia make the most of the system resource?

2015-12-19 Thread elextr

>
> As can be seen, all the 8 cores of my pc is being used by the julia 
> program, however, only 35% of the system resource is covered. My julia code 
> mainly does the fft operates in a loop. I use fftw.set_num_threads(8) 
> outside the loop.  In my opinion, the top command should exhibit nearly 
> 100% use of the system resource, but that's not true. 
>

I'm not quite sure where you get 35% from, as I read your `top` the top 
three users are Julia using 6.89 cpus, QQ.exe 0.45 cpu and X 0.11 cpu. 
 Julia is getting the vast majority of the cpu resources, nearly 7 out of 8 
cores.


Re: [julia-users] Why variables passed to this macro are referencing to the module?

2015-12-19 Thread Jeff Bezanson
Yes, believe it or not we are still interested in that change. As Tom
pointed out, Jameson has rebased it and we might get to it in the 0.5
timeframe. We can continue the discussion in PR #10940.

On Sat, Dec 19, 2015 at 10:04 AM, Tom Short  wrote:
> David Moon, see https://github.com/JuliaLang/julia/pull/10940. It's still an
> open WIP.
>
>
> On Sat, Dec 19, 2015 at 9:51 AM, David Moon  wrote:
>>
>> On Saturday, December 19, 2015 at 6:17:18 AM UTC-5, Tim Holy wrote:
>>>
>>> Presumably you need an esc around the exp. See the metaprogramming
>>> chapter.
>>
>>
>> So the Julia maintainers never pulled my pull request from almost 2 years
>> ago that fixed that?
>
>


[julia-users] Re: Juno bundles for Julia v0.4

2015-12-19 Thread Randy Zwitch
Thanks Mike.

Tangent: what's the right way to programmatically detect being in the Juno 
environment? In the Vega plotting package, I have inline plotting working 
in Jupyter Notebook, but in Juno I get an error because load all my 
JavaScript using requirejs in Jupyter (but requirejs is not available in 
Juno).

Juno console:


   - 
   
   Invalid behavior: :lt.objs.langs.julia/commands
   
   - 
   
   TypeError: require.config is not a function
   at eval (eval at eval_scripts 
(/Applications/Juno.app/Contents/Resources/app/plugins/Julia-LT/julia_compiled.js),
 :3:15)
   at eval (native)
   at eval_scripts 
(/Applications/Juno.app/Contents/Resources/app/plugins/Julia-LT/julia_compiled.js:105:63)
   at Function.__BEH__commands 
(/Applications/Juno.app/Contents/Resources/app/plugins/Julia-LT/julia_compiled.js:294:46)
   at c 
(file:///Applications/Juno.app/Contents/Resources/app/core/node_modules/lighttable/bootstrap.js:6196:14)
   at a 
(file:///Applications/Juno.app/Contents/Resources/app/core/node_modules/lighttable/bootstrap.js:6236:18)
   at c 
(file:///Applications/Juno.app/Contents/Resources/app/core/node_modules/lighttable/bootstrap.js:20443:76)
   at a 
(file:///Applications/Juno.app/Contents/Resources/app/core/node_modules/lighttable/bootstrap.js:20477:18)
   at a 
(file:///Applications/Juno.app/Contents/Resources/app/core/node_modules/lighttable/bootstrap.js:20488:34)
   at b 
(file:///Applications/Juno.app/Contents/Resources/app/core/node_modules/lighttable/bootstrap.js:20492:14)
   
   

Working Vega code for Jupyter Notebook:

https://github.com/johnmyleswhite/Vega.jl/blob/master/src/render.jl#L18-L68

On Friday, December 18, 2015 at 11:24:39 AM UTC-5, Mike Innes wrote:
>
> Hey All,
>
> Juno bundles including Julia v0.4 are now available on the Julia 
> downloads page . If you're still using 
> Juno with Julia v0.3 the upgrade is definitely recommended – among other 
> things, features like precompilation make using packages like Gadfly much 
> easier. Enjoy!
>
> Cheers,
> Mike
>


Re: [julia-users] Is `ccall` efficient when the library is given by path name?

2015-12-19 Thread Yichao Yu
On Sat, Dec 19, 2015 at 11:29 AM, Erik Schnetter  wrote:
> The current implementation of `MPI.jl` uses `ccall` to call MPI functions,
> and specifies the MPI library via its file system path. How efficient is
> this? I was naively expecting that a `ccall` is as efficient as a regular
> function call, maybe calling a function via a function pointer or similar,
> as it would be in C.
>
> However, if the library is specified only by its path, then it seems that
> Julia must use string comparisons and at least two dictionary lookups (for
> library name and function name) to find the respective function pointer.
>
> Some MPI functions are performance critical, and some don't perform much
> work. Is there a way to make `ccall` more efficient? Should we think about
> caching the result of some MPI calls? Or can one cache the result of the
> `ccall` dynamic library lookups?

The lookup is done at compile time. You can see that in either
code_llvm or code_native

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


[julia-users] Is `ccall` efficient when the library is given by path name?

2015-12-19 Thread Erik Schnetter
The current implementation of `MPI.jl` uses `ccall` to call MPI functions,
and specifies the MPI library via its file system path. How efficient is
this? I was naively expecting that a `ccall` is as efficient as a regular
function call, maybe calling a function via a function pointer or similar,
as it would be in C.

However, if the library is specified only by its path, then it seems that
Julia must use string comparisons and at least two dictionary lookups (for
library name and function name) to find the respective function pointer.

Some MPI functions are performance critical, and some don't perform much
work. Is there a way to make `ccall` more efficient? Should we think about
caching the result of some MPI calls? Or can one cache the result of the
`ccall` dynamic library lookups?

-erik

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


[julia-users] 5th Julia meetup in Japan: JuliaTokyo #5

2015-12-19 Thread theremins
On December 19th we had our 5th Julia meetup in Japan, "JuliaTokyo #5".
http://juliatokyo.connpass.com/event/21715/


---


JuliaTokyo #5 Presentation List in English


# Main Talks

1. Julia Tuning Hands-on - Kenta Sato
2. Introducing DiscreteDP from QuanEcon.jl - Daisuke Oyama
3. Mechajo-san and Julia-tan (unofficial Julia anime character) - @kimrin
4. MXNet.jl+AWS GPU: DeepLearning Super Powers from ~ $0.35hr - Andre 
Pemmelaar
5. Neural POS-Tagging with Julia (hshindo/Merlin.jl) - Hiroyuki Shindo


# Lightning Talks

1. Changes that would be in v0.5 - Kenta Sato
2. Online Linear Classifier with Julia 
(IshitaTakeshi/SoftConfidenceWeighted.jl) - @sonicair
3. How about Hierarchical Temporal Memory? - @iizukak
4. Adaptive Regularization of Weight Vectors (kazoo04/AROW.jl) - @kazoo04
5. It's easy/painful to use CUDA with Julia - @olanleed
6. Text Analysis with Julia - Yoshifumi Seki
7. Voice Conversion with Julia - @ohtaman


---


We also had a survey on what kind of languages and softwares people use on 
a daily basis. 

70 people (multiple choices allowed);

language, #people
Python, 51
Julia, 23
R, 23
C++, 19
Java, 18
Ruby, 15
C, 12
Excel, 10
Perl, 10
Matlab, 7
Scala, 5
Mathematica, 3
Bash, 2
Clojure, 2
D, 2
F#, 2
JavaScript, 2
SAS, 2
Visual Basic, 2
ATS, 1
Elixir, 1
Go, 1
Haskell, 1
LaTex, 1


- sorami


Re: [julia-users] Why variables passed to this macro are referencing to the module?

2015-12-19 Thread Tom Short
David Moon, see https://github.com/JuliaLang/julia/pull/10940. It's still
an open WIP.

On Sat, Dec 19, 2015 at 9:51 AM, David Moon  wrote:

> On Saturday, December 19, 2015 at 6:17:18 AM UTC-5, Tim Holy wrote:
>>
>> Presumably you need an esc around the exp. See the metaprogramming
>> chapter.
>>
>
> So the Julia maintainers never pulled my pull request from almost 2 years
> ago that fixed that?
>


Re: [julia-users] Why can't julia make the most of the system resource?

2015-12-19 Thread Isaiah Norton
Hard to say, but you could try creating an FFT plan.

https://groups.google.com/d/msg/julia-users/ww-57NucHKA/Sc3RZFpFY9UJ
http://docs.julialang.org/en/release-0.4/stdlib/math/#Base.plan_fft

On Sat, Dec 19, 2015 at 8:13 AM, 博陈  wrote:

>
> 
> As can be seen, all the 8 cores of my pc is being used by the julia
> program, however, only 35% of the system resource is covered. My julia code
> mainly does the fft operates in a loop. I use fftw.set_num_threads(8)
> outside the loop.  In my opinion, the top command should exhibit nearly
> 100% use of the system resource, but that's not true.
>


Re: [julia-users] Why variables passed to this macro are referencing to the module?

2015-12-19 Thread David Moon
On Saturday, December 19, 2015 at 6:17:18 AM UTC-5, Tim Holy wrote:
>
> Presumably you need an esc around the exp. See the metaprogramming 
> chapter. 
>

So the Julia maintainers never pulled my pull request from almost 2 years 
ago that fixed that? 


[julia-users] Re: Using callable types or FastAnonymous with Sundials

2015-12-19 Thread Simon Frost
Dear Dan,

Changing the function to (say) g doesn't help. I want cvode to use J as a 
function (as I'm overloading call); this is really just doing what 
FastAnonymous does under the hood. I think it may be because Sundials 
passes the derivatives as an argument to the function, and modifies them in 
place.

Best
Simon

**
using Sundials

function cvode{f}(::Type{f}, y0::Vector{Float64}, t::Vector{Float64}; 
reltol::Float64=1e-4, abstol::Float64=1e-6)
neq = length(y0)
mem = Sundials.CVodeCreate(Sundials.CV_BDF, Sundials.CV_NEWTON)
flag = Sundials.CVodeInit(mem, cfunction(Sundials.cvodefun, Int32, 
(Sundials.realtype, Sundials.N_Vector, Sundials.N_Vector, Ref{Function})), 
t[1], Sundials.nvector(y0))
flag = Sundials.CVodeSetUserData(mem, f)
flag = Sundials.CVodeSStolerances(mem, reltol, abstol)
flag = Sundials.CVDense(mem, neq)
yres = zeros(length(t), length(y0))
yres[1,:] = y0
y = copy(y0)
tout = [0.0]
for k in 2:length(t)
flag = Sundials.CVode(mem, t[k], y, tout, Sundials.CV_NORMAL)
yres[k,:] = y
end
Sundials.CVodeFree([mem])
return yres
end

function g(t, y, ydot)
ydot[1] = 0.1*(-72-y[1])+0.1*1.4*exp((y[1]+48)/1.4)+10
ydot[3] = 0.
ydot[2] = 0.
end

immutable J; end
call(::Type{J},t, y, ydot) = g(t, y, ydot)

t = [0.1:0.0001:1]
res = Sundials.cvode(g, [-60.0, 0.0, 0.0, t); # this works, passing a 
Function type
res = cvode(J, [-60.0, 0.0, 0.0], t);  # this gives ReadOnlyMemoryError


On Saturday, December 19, 2015 at 12:52:23 AM UTC, Dan wrote:
>
> The parameter for the `cvode` function is `f` and so is the function you 
> want to use. These get confused, and it tries to use the "function" `J` 
> instead. Changing the parameter name to something other than `{f}` should 
> work
>
> On Wednesday, December 16, 2015 at 4:26:41 PM UTC+2, Simon Frost wrote:
>>
>> Dear Julia Users,
>>
>> I'm trying to speed up some code that employs passing functions as 
>> arguments. One part of the code solves an ODE; if I use CVODE from 
>> Sundials, and rewrite the function to accept callable types, I get a 
>> ReadOnlyMemoryError - as I don't know the Sundials API, can someone help me 
>> with where I'm going wrong? Code below.
>>
>> Best
>> Simon
>>
>> **
>>
>> using Sundials
>>
>> function cvode{f}(::Type{f}, y0::Vector{Float64}, t::Vector{Float64}; 
>> reltol::Float64=1e-4, abstol::Float64=1e-6)
>> neq = length(y0)
>> mem = Sundials.CVodeCreate(Sundials.CV_BDF, Sundials.CV_NEWTON)
>> flag = Sundials.CVodeInit(mem, cfunction(Sundials.cvodefun, Int32, 
>> (Sundials.realtype, Sundials.N_Vector, Sundials.N_Vector, Ref{Function})), 
>> t[1], Sundials.nvector(y0))
>> flag = Sundials.CVodeSetUserData(mem, f)
>> flag = Sundials.CVodeSStolerances(mem, reltol, abstol)
>> flag = Sundials.CVDense(mem, neq)
>> yres = zeros(length(t), length(y0))
>> yres[1,:] = y0
>> y = copy(y0)
>> tout = [0.0]
>> for k in 2:length(t)
>> flag = Sundials.CVode(mem, t[k], y, tout, Sundials.CV_NORMAL)
>> yres[k,:] = y
>> end
>> Sundials.CVodeFree([mem])
>> return yres
>> end
>>
>> function f(t, y, ydot)
>> ydot[1] = 0.1*(-72-y[1])+0.1*1.4*exp((y[1]+48)/1.4)+10
>> ydot[3] = 0.
>> ydot[2] = 0.
>> end
>>
>> immutable J; end
>> call(::Type{J},t, y, ydot) = f(t, y, ydot)
>>
>> t = [0.1:0.0001:1]
>> res = cvode(J, [-60.0, 0.0, 0.0], t);
>>
>

[julia-users] Why can't julia make the most of the system resource?

2015-12-19 Thread 博陈



As can be seen, all the 8 cores of my pc is being used by the julia 
program, however, only 35% of the system resource is covered. My julia code 
mainly does the fft operates in a loop. I use fftw.set_num_threads(8) 
outside the loop.  In my opinion, the top command should exhibit nearly 
100% use of the system resource, but that's not true. 


Re: [julia-users] Re: Operations on TypeVars

2015-12-19 Thread Kristoffer Carlsson
Ah, cool, that seems indeed to work! Thanks.

Re: [julia-users] Re: Operations on TypeVars

2015-12-19 Thread Mike Innes
I think you can get what you want with

foo{T}(::V{5,T}) = print("hello I'm spechial")

On Sat, 19 Dec 2015 at 10:45 Kristoffer Carlsson 
wrote:

> Found some discussion here:
> https://github.com/JuliaLang/julia/issues/7311#issuecomment-46563315
>
>
> On Saturday, December 19, 2015 at 11:43:39 AM UTC+1, Kristoffer Carlsson
> wrote:
>>
>> Slightly related.
>>
>> Are there any issues regarding explicit specialization of parameterized
>> methods (on value)?
>>
>> immutable V{N, T}
>>a::NTuple{N,T}
>>  end
>>
>> foo{N, T} = print("hello")
>>
>> v = V{5, Float64}((1.0,2.0,3.0,4.0,5.0))
>>
>> foo(v)
>> # hello
>>
>> # Explicit specialization, nope:
>>
>> foo{5, T}(::V{5,T}) = print("hello I'm spechial")
>> # ERROR: syntax: malformed type parameter list
>>
>>
>>
>> On Friday, December 18, 2015 at 10:36:42 PM UTC+1, Kristoffer Carlsson
>> wrote:
>>>
>>> Thanks for the link.
>>
>>


Re: [julia-users] Why variables passed to this macro are referencing to the module?

2015-12-19 Thread Tim Holy
Presumably you need an esc around the exp. See the metaprogramming chapter.

--Tim

On Friday, December 18, 2015 04:02:08 PM Diego Javier Zea wrote:
> I defined the macro @iteratelist
>  jl#L1-L27> in PairwiseListMatrices. I used a similar macro in function
> definitions
>  selistmatrix.jl#L745> inside that package without problems. However, the
> same code doesn't work for function definitions outside that package, like
> in the example below. Why was *l* expanded as *PairwiseListMatrices.l *?
> Thanks!
> 
> 
>  6s86P90/s1600/macro.png>
> 
> *Code: *
> 
> using PairwiseListMatrices
> 
> PLM = PairwiseListMatrix([1, 2, 3], false)
> 
> function test(plm)
>l = []
>@iteratelist plm Base.push!(l, list[k])
>l
> end
> 
> function test_macroexpand(plm)
>l = []
>println( macroexpand( quote @iteratelist plm Base.push!(l, list[k])
> end))
>l
> end
> 
> test(PLM)
> 
> test_macroexpand(PLM)



[julia-users] Re: Operations on TypeVars

2015-12-19 Thread Kristoffer Carlsson
Found some discussion 
here: https://github.com/JuliaLang/julia/issues/7311#issuecomment-46563315

On Saturday, December 19, 2015 at 11:43:39 AM UTC+1, Kristoffer Carlsson 
wrote:
>
> Slightly related.
>
> Are there any issues regarding explicit specialization of parameterized 
> methods (on value)?
>
> immutable V{N, T}
>a::NTuple{N,T}
>  end
>
> foo{N, T} = print("hello")
>
> v = V{5, Float64}((1.0,2.0,3.0,4.0,5.0))
>
> foo(v)
> # hello
>
> # Explicit specialization, nope:
>
> foo{5, T}(::V{5,T}) = print("hello I'm spechial")
> # ERROR: syntax: malformed type parameter list
>
>
>
> On Friday, December 18, 2015 at 10:36:42 PM UTC+1, Kristoffer Carlsson 
> wrote:
>>
>> Thanks for the link.
>
>

[julia-users] Re: Operations on TypeVars

2015-12-19 Thread Kristoffer Carlsson
Slightly related.

Are there any issues regarding explicit specialization of parameterized 
methods (on value)?

immutable V{N, T}
   a::NTuple{N,T}
 end

foo{N, T} = print("hello")

v = V{5, Float64}((1.0,2.0,3.0,4.0,5.0))

foo(v)
# hello

# Explicit specialization, nope:

foo{5, T}(::V{5,T}) = print("hello I'm spechial")
# ERROR: syntax: malformed type parameter list



On Friday, December 18, 2015 at 10:36:42 PM UTC+1, Kristoffer Carlsson 
wrote:
>
> Thanks for the link.