[julia-users] Re: memory allocation in nested loops

2016-10-04 Thread 'Greg Plowman' via julia-users
Not sure what the best way is, especially on Julia 0.5 where maybe some sort of view. But you could always use an Array of Arrays if you don't really need a true multi-dimensional array elsewhere: d = randn(3,n) d2 = [ d[:,i]::Vector{Float64} for i=1:n ] r = randn(3,m) r2 = [

[julia-users] Re: memory allocation in nested loops

2016-10-04 Thread 'Greg Plowman' via julia-users
You haven't passed in r as argument to function. Try nested_loop!(Y,X,d,r,n,m,f) On Tuesday, October 4, 2016 at 8:05:41 PM UTC+11, Niccolo' Antonello wrote: > Hi all, > > I'm trying to make this code to go faster: > > n,m = 100,25 > f = 100 > d = randn(3,n) > r = randn(3,m) > > Y =

[julia-users] Re: What is the deal with macros that do not return expressions?

2016-10-01 Thread 'Greg Plowman' via julia-users
In your two examples, note the difference *when* the macro argument is multiplied by 2. @ex_timestwo happens at runtime @n_timestwo happens at macro expansion time a = 6 @ex_timestwo(a) will return 12 as expected, whereas: a = 6 @n_timestwo(a) will still result in error because at macro

Re: [julia-users] fieldtype() for parameterised types

2016-09-19 Thread 'Greg Plowman' via julia-users
Ah, TypeVars, parameter and bound fields. Thanks Tim. This looks like what I'm after. Will investigate.

[julia-users] fieldtype() for parameterised types

2016-09-19 Thread 'Greg Plowman' via julia-users
For a parameterised composite type, I want to distinguish between fields defined with parameters and generic fields. An example is probably best: type Foo{T,N} a::Array b::Array{T,N} end fieldtype(Foo,:a) returns Array{T,N} fieldtype(Foo,:b) returns Array{T,N} And if I use

[julia-users] Re: Error when assigning values to an object

2016-09-16 Thread 'Greg Plowman' via julia-users
Export PhyNode from MyClass module.

[julia-users] Re: code design question – best ideomatic way to define nested types?

2016-09-15 Thread 'Greg Plowman' via julia-users
Another variation on Chris's @commonfields and Tom's @base & @extend <&@extend>: This is somewhere between example 2 and 3, Avoids copy and paste of example 2 Avoids delegating to Foo of example 3 abstract AbstractFoo type Foo <: AbstractFoo bar baz end type Foobar <: AbstractFoo

Re: [julia-users] code design question – best ideomatic way to define nested types?

2016-09-15 Thread 'Greg Plowman' via julia-users
Bart, Which one is the FooData solution? Is this Example 1,2 or 3? Or another solution.

Re: [julia-users] slow for loops because of comparisons

2016-09-08 Thread 'Greg Plowman' via julia-users
The difference is probably simd. the branch will code will not use simd. Either of these should eliminate branch and allow simd. ak += ss1>ss2 ak += ifelse(ss1>ss2, 1, 0) Check with @code_llvm, look for section vector.body at 5:45:30 AM UTC+10, Dupont wrote: > What is strange to me is that

[julia-users] printf format for round-trip Floats

2016-09-02 Thread 'Greg Plowman' via julia-users
Yes, of course I can! Thanks David. That is embarrassingly simple.

[julia-users] printf format for round-trip Floats

2016-09-01 Thread 'Greg Plowman' via julia-users
I'm trying to print Float64 with all significant digits, so that re-inputting these numbers from output strings will result in exactly the same number (is this called a round-trip?) I understand that Julia uses a grisu algorithm to do this automatically for values displayed at REPL and with

Re: [julia-users] Re: Adding items into a tuple

2016-08-30 Thread 'Greg Plowman' via julia-users
> > > I could use an array, but one product can correspond to different number > of bases. > > That's why I decided to use tuples. > > You could use an Array of (different length) Arrays, similar to Array of Tuples. Another strategy might be to construct a vector of (Product, Base) pairs,

[julia-users] Re: Why aren't multiple const definitions allowed on a line?

2016-08-22 Thread 'Greg Plowman' via julia-users
global const u = 7, v = 11, w = 13 seems to work.

Re: [julia-users] Fast random access to Dict

2016-08-21 Thread 'Greg Plowman' via julia-users
t you > could tune (read: play with). There is also a function `Base.rehash!` that > you can call to increase the size of the hash table, which might increase > performance by avoiding hash collisions, if you have sufficient memory. > > -erik > > > On Wed, Aug 17, 2016 at 7

[julia-users] Re: Composition of setindex!

2016-08-21 Thread 'Greg Plowman' via julia-users
But also note that a[1:3] = 1.0 will modify a (rather than a copy) On Sunday, August 21, 2016 at 6:34:28 PM UTC+10, Kristoffer Carlsson wrote: > > Range indexing produces copies yes. Either just write the loops or use > "view" or "sub" to refer to the original memory.

[julia-users] Fast random access to Dict

2016-08-17 Thread 'Greg Plowman' via julia-users
I need fast random access to a Dict{Int64,Float64}. My application has a first phase in which the Dict is populated, and a second phase where it accessed randomly (with no further additions or deletions). There are about 50,000 to 100,000 entries, with keys in the range 10^9 to 10^14. Firstly

[julia-users] Re: How to Manipulate each character in of a string using a for loop in Julia ?

2016-08-17 Thread 'Greg Plowman' via julia-users
I think Jacob meant: for char in a write(io, char + 1) end

[julia-users] Re: Still confused about how to use pmap with sharedarrays in Julia

2016-08-11 Thread 'Greg Plowman' via julia-users
pmap inside a function also seems to work: @everywhere f(A,i) = (println("A[$i] = $(A[i])+1"); A[i] += 1) wrapped_pmap(A) = pmap(i -> f(A,i), 1:length(A)) S = SharedArray(Int,10) S[:] = 1:length(S) output1 = pmap(i -> f(S,i), 1:length(S)) #error output2 = wrapped_pmap(S) #seems to work I'm

[julia-users] Re: Still confused about how to use pmap with sharedarrays in Julia

2016-08-11 Thread 'Greg Plowman' via julia-users
> > > The fact that meaning of "," changes depending on what is in placed in > [a,b,c] seems have been the source of the issue. > > (As an aside, this inconsistency seems to me to be somewhat of a > less-than-desireable feature in Julia.) > I think this is changing in v0.5. See

[julia-users] Re: Still confused about how to use pmap with sharedarrays in Julia

2016-08-10 Thread 'Greg Plowman' via julia-users
I have also found the combination of shared arrays, anonymous functions and parallel constructs confusing. StackOverflow question helped me Shared array usage in Julia In essence, "although the underlying data is shared

[julia-users] Re: Unexpected Performance Behaviour

2016-08-01 Thread 'Greg Plowman' via julia-users
I get timing/allocations the other way around. (test1, hard-coded version is fast without allocation) @code_warntype for test2 shows type-instability for s (because return type cannot be inferred for f1) On Tuesday, August 2, 2016 at 2:33:24 PM UTC+10, Christoph Ortner wrote: > Below are two

[julia-users] Re: I can't believe this spped-up !

2016-07-21 Thread 'Greg Plowman' via julia-users
and also compare (note the @sync) @time @sync @parallel for i in 1:10 sleep(1) end Also note that using reduction with @parallel will also wait: z = @parallel (*) for i = 1:n A end On Friday, July 22, 2016 at 3:11:15 AM UTC+10, Kristoffer Carlsson wrote: > > > julia> @time for i in

[julia-users] Re: Clarification about @parallel (op) for loop

2016-07-20 Thread 'Greg Plowman' via julia-users
> > > does every worker compute func(i) and return it to the calling process, > which then reduces it on the fly? > No. > Or does every worker apply the reduction operator for its chunk and then > return it to the calling process? > Yes. The documentation >

[julia-users] Re: Array of vectors in type definition

2016-07-18 Thread 'Greg Plowman' via julia-users
Although Vector{Array{Float64}} works, be aware that it is specifying a vector of the abstract type Array{Float64} (any dimension allowed). In general this is not recommended. It is better to specify a concrete type where possible. In your case, this probably means Vector{Vector{Float64}}. On

[julia-users] Re: Calculating pi using parallel computing

2016-07-18 Thread 'Greg Plowman' via julia-users
Maybe something like this: See http://docs.julialang.org/en/release-0.4/manual/parallel-computing/ (particularly section Parallel Map and Loops) @everywhere f(x) = 4/(1+(x*x)) function calc_pi(n) a,b = 0,1 dx = (b-a)/n sumfx = @parallel (+) for x in a:dx:b f(x) end

Re: [julia-users] Trying to understand parametric types as function arguments

2016-07-15 Thread 'Greg Plowman' via julia-users
Yes, thanks for that Tim. I can see that now. That's a nice workaround.

Re: [julia-users] Trying to understand parametric types as function arguments

2016-07-15 Thread 'Greg Plowman' via julia-users
Yes, thanks for that Tim. I can see that now. That's a nice workaround.

Re: [julia-users] Trying to understand parametric types as function arguments

2016-07-14 Thread 'Greg Plowman' via julia-users
> > What about the following? > myfunc(vec::Vector{Dict{ASCIIString}}) = 1 a = [ Dict("a"=>1), Dict("b"=>1.0) ] b = [ Dict(1=>:hello), Dict(2=>:world) ] julia> myfunc(a) 1 julia> myfunc(b) ERROR: MethodError: `myfunc` has no method matching myfunc(::Array{Dict{Int64,Symbol},1})

[julia-users] Parallel computing: SharedArrays not updating on cluster

2016-06-21 Thread 'Greg Plowman' via julia-users
Yes. AFAIK, Shared arrays are shared across multiple processes on the same machine. Distributed arrays can be distributed across different machines.

[julia-users] Re: Standard wrapper for global variable optimization hack?

2016-06-13 Thread 'Greg Plowman' via julia-users
I have a feeling this is a stupid question, but here it is anyway: Why do you need a wrapper? Why not just declare the object const directly? const x = 0.0 function inc_global() x += 1 end

Re: [julia-users] Why does adding type assertion to field slow down this example?

2016-06-09 Thread 'Greg Plowman' via julia-users
I know this is not replying to your original question but it might be relevant or not. There was a suggestion for speeding up dispatch of abstract types in another julia-users discussion: dispatch slowdown when iterating over array with abstract values

[julia-users] Re: pmap on functions with variable #'s of arguments

2016-06-02 Thread 'Greg Plowman' via julia-users
Of course I meant: Fprime(a) = F(a,b0,c0)

[julia-users] Re: pmap on functions with variable #'s of arguments

2016-06-02 Thread 'Greg Plowman' via julia-users
> > > function Fprime(a; b0 = b, c0 = c) >F(a, b0, c0) # treating b and c above as fixed > end > Where did you define b and c? Did you define on all workers? > > (i) this does not solve my problem when the a_i's are different sizes and > can't be put into one array > Not sure what you

[julia-users] Re: Importing Functions on Different Workers

2016-06-01 Thread 'Greg Plowman' via julia-users
I find that putting everything required on workers into a module is the way to go. Then just use using Module (after adding workers) This works for me (v0.4.5): ProjectModule.jl: module ProjectModule using DataFrames include("function1.jl") export function1 end function1.jl:

[julia-users] Re: moving data to workers for distributed workloads

2016-05-19 Thread 'Greg Plowman' via julia-users
> > > It looks like that SO answer is moving data into the global scope of each > worker. It is probably worth experimenting with but I'd be worried about > performance implications of non-const global variables. It's probably the > case that this is still a win for my use case though. Thanks

Re: [julia-users] Re: calling sort on a range with rev=true

2016-05-07 Thread 'Greg Plowman' via julia-users
? On Friday, May 6, 2016 at 2:36:27 AM UTC+10, Milan Bouchet-Valat wrote: > Le dimanche 01 mai 2016 à 19:11 -0700, 'Greg Plowman' via julia-users a > écrit : > > > > Extending/overwriting sort in range.jl (line 686) > > > > sort(r::Range) = issorted(r) ? r : reverse(r

Re: [julia-users] calling sort on a range with rev=true

2016-05-04 Thread 'Greg Plowman' via julia-users
Thanks Steven for fixing this. (If you pass them keyword arguments, then they pretty much have to return a > full array, rather than try to be clever and return another range, for > type-stability. e.g. sort(-5:5, by=abs) can't be expressed in terms of a > range.) At first I didn't

[julia-users] Re: calling sort on a range with rev=true

2016-05-01 Thread 'Greg Plowman' via julia-users
Extending/overwriting sort in range.jl (line 686) sort(r::Range) = issorted(r) ? r : reverse(r) with the following worked for me. function Base.sort(r::Range; rev::Bool=false) if rev issorted(r) ? reverse(r) : r else issorted(r) ? r : reverse(r) end end

[julia-users] calling sort on a range with rev=true

2016-05-01 Thread 'Greg Plowman' via julia-users
There have been discussions about whether a range can substitute in most cases where a vector is required. julia> sort(1:3) 1:3 julia> sort(1:3, rev=true) ERROR: indexed assignment not defined for UnitRange{Int64} in sort! at sort.jl:222 in sort! at sort.jl:292 in sort! at sort.jl:402 in

[julia-users] Re: performance of two different array allocations

2016-04-21 Thread 'Greg Plowman' via julia-users
It seems concatenating, especially vectors, is quite common. And it would be nice if concatenating with mixed scalar and vector arguments was type-stable. I did some playing around and although I don't fully understand the impact, I [think I] was able to get a type-stable version of vcat with

[julia-users] Re: a'*b and svds for custom operators

2016-04-20 Thread 'Greg Plowman' via julia-users
> > > 3. Any other methods I should implement for my operator? > > http://docs.julialang.org/en/release-0.4/manual/interfaces/#abstract-arrays

[julia-users] Re: a'*b and svds for custom operators

2016-04-20 Thread 'Greg Plowman' via julia-users
On Thursday, April 21, 2016 at 11:17:32 AM UTC+10, Madeleine Udell wrote: > > Hi, > > I'm trying to define my own custom operator type that will allow me to > implement my own * and '* operations for use inside eigenvalue or singular > value routines like eigs and svds. But I'm having trouble

[julia-users] Re: Starting Julia with Julia -p 2 provides 1 worker

2016-04-20 Thread 'Greg Plowman' via julia-users
Sorry, I can't really help you with command line julia -p 2 But what happens when you call addprocs() from REPL? Also, what is the value of CPU_CORES (typed at REPL)?

[julia-users] Re: Starting Julia with Julia -p 2 provides 1 worker

2016-04-19 Thread 'Greg Plowman' via julia-users
julia -p 2 will start Julia with 2 processes. nprocs() will return 2 nworkers() will return 1 (1 less than nprocs()) http://docs.julialang.org/en/release-0.4/stdlib/parallel/?highlight=nworkers#Base.nworkers On Tuesday, April 19, 2016 at 6:58:30 PM UTC+10, Iacopo Poli wrote: > Hi, > > I'm

[julia-users] Re: Starting Julia with Julia -p 2 provides 1 worker

2016-04-19 Thread 'Greg Plowman' via julia-users
julia -p 2 will start Julia with 2 processes. nprocs() will return 2 nworkers() will return 2 (1 less than nprocs()) http://docs.julialang.org/en/release-0.4/stdlib/parallel/?highlight=nworkers#Base.nworkers On Tuesday, April 19, 2016 at 6:58:30 PM UTC+10, Iacopo Poli wrote: > Hi, > > I'm

[julia-users] @async tasks not yielding

2016-04-18 Thread 'Greg Plowman' via julia-users
I 'm somewhat confused about when @async tasks switch. My understanding was tasks would yield on a blocking operation such as IO. On 0.4.1, I started multiple workers on remote hosts asynchronously, and these started as I expected. Presumably the tasks launching the workers yielded when the

[julia-users] Re: Warning on operations mixing BigFloat and Float64

2016-04-18 Thread 'Greg Plowman' via julia-users
Perhaps you could overwrite the convert function to include a warning. (Maybe just temporarily until you discover all the conversions) As an example, this is a quick hack, modified from definition in mpfr.jl @eval begin function Base.convert(::Type{BigFloat}, x::Float64)

[julia-users] Re: Parametric types which add or delete fields.

2016-04-17 Thread 'Greg Plowman' via julia-users
Notwithstanding the explosion of possible types and the excellent advice and insight provided by Tim, you can get the following to compile and run. typealias Color ASCIIString typealias Horsepower Float64 typealias Model ASCIIString typealias Year Int type Car{ C<:Union{Color,Void},

[julia-users] Re: Should `append!(a::Vector{T}, items::NTuple{N, T})` be defined in Base?

2016-04-13 Thread 'Greg Plowman' via julia-users
Considering the existing append! is pretty loose wrt the items being appended, a simple extension to the signature might work: append!{T}(a::Array{T,1}, items::Union{AbstractVector,Tuple}) You could extend this yourself to try it out. On Thursday, April 14, 2016 at 4:07:45 AM UTC+10, Davide

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-13 Thread 'Greg Plowman' via julia-users
> julia> reshape(d,3,2) 3x2 Array{ASCIIString,2}: "x1" "y2" "y1" "x3" "x2" "y3" This is because of Julia's column-major ordering. you see the problem ? instead I would like to have : x1 y1 x2 y2 .. xn yn In this case, you could use: julia> reshape(d,2,3)' 3x2

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

2016-04-08 Thread 'Greg Plowman' via julia-users
Maybe something like: x = Array{Int}(3,4,0) x = vec(x) append!(x, 1:12) x = reshape(x,3,4,1) x = vec(x) append!(x, 13:24) x = reshape(x,3,4,2) Of course you could wrap it into a more convenient function. On Friday, April 8, 2016 at 7:31:30 PM UTC+10, Sisyphuss wrote: > I have a related

[julia-users] Re: pmap scheduling and idle workers near the "end" of a job

2016-04-06 Thread 'Greg Plowman' via julia-users
In that case, try sorting the tasks in descending order of complexity (i.e. start longest running tasks first). On Thursday, April 7, 2016 at 9:23:56 AM UTC+10, Thomas Covert wrote: > Its hard to construct a MWE without the data I am using, but I can give a > bit more detail. > > There are

[julia-users] Re: Help with convoluted types and Vararg

2016-04-06 Thread 'Greg Plowman' via julia-users
Pair is a parametric type, and in Julia these are invariant, meaning element subtyping does not imply pair subtyping. In your case, the pair elements are subtypes: Tuple{Function,Int,Int,Int} <: Tuple{Function,Vararg{Int}} # true Int <: Int # true but the Pair is not:

[julia-users] Re: pmap scheduling and idle workers near the "end" of a job

2016-04-06 Thread 'Greg Plowman' via julia-users
It's difficult to comment without knowing more detail about numbers of workers, their relative speed, number of tasks and their expected completion times. As an extreme example, say you have 4 workers (all of the same speed) and 2x15-minute tasks and 16x1-minute tasks. Depending on how this

[julia-users] Re: enforcing homogeneity of vector elements in function signature

2016-04-06 Thread 'Greg Plowman' via julia-users
Actually, I'm totally wrong. The Union won't work. Sorry for bad post. On Wednesday, April 6, 2016 at 1:52:15 PM UTC+10, Greg Plowman wrote: > > A workaround would be to have two methods, one for the homogeneous >> elements in the first parameter, as you suggest, and a second for a vector >>

[julia-users] Re: enforcing homogeneity of vector elements in function signature

2016-04-05 Thread 'Greg Plowman' via julia-users
> A workaround would be to have two methods, one for the homogeneous > elements in the first parameter, as you suggest, and a second for a vector > with homogeneous elements in both parameters, with both T, N specified in > the signature. But I have to write an extra method... > As pointed

Re: [julia-users] dispatch slowdown when iterating over array with abstract values

2016-04-05 Thread 'Greg Plowman' via julia-users
Thanks for your relies. I'm starting to understand some of this now. In particular, I'm learning there are many aspects to dynamic dispatch. Also worth noting the difference between: if isa(features[i], A) retval += evaluate(features[i]::A) elseif isa(features[i], B) retval +=

Re: [julia-users] Re: dispatch on type of tuple from ...

2016-04-03 Thread 'Greg Plowman' via julia-users
I saw your repost on julia-dev, but replying here. m2 won't work because it expects a series of tuple arguments (which if supplied would slurp up into a tuple of tuples). m3 seems the way to go. I wouldn't necessarily look at it as indirect however. Think of it as one function with 2 methods:

Re: [julia-users] dispatch slowdown when iterating over array with abstract values

2016-04-03 Thread 'Greg Plowman' via julia-users
Thanks for your replies. I'm sorry to trouble you again, but I'm still confused about general concepts. It seems to me that slowness of dynamic dispatch and type instability are orthogonal. I mean is dynamic dispatch inherently slow, or is it slow because it involves type instability?

Re: [julia-users] dispatch slowdown when iterating over array with abstract values

2016-04-02 Thread 'Greg Plowman' via julia-users
Thanks Cedric and Yichao. This makes sense that there might be new subtypes and associated specialised methods. I understand that now. Thanks. On my machine (v0.4.5 Windows), fast() and pretty_fast() seem to run in similar time. So I looked as @code_warntype as Yichao suggested and get the

Re: [julia-users] dispatch slowdown when iterating over array with abstract values

2016-04-02 Thread 'Greg Plowman' via julia-users
Cedric, On my machine fast() and pretty_fast() run in the roughly the same time. Are you sure pre-compiled first? Yichao, > The compiler has no idea what the return type of the third one so this > version is still type unstable and you get dynamic dispatch at every > iteration for the floating

[julia-users] Re: programatically unquote something

2016-04-01 Thread 'Greg Plowman' via julia-users
I'm not an expert, nor do I understand what you're trying to do. Presumably you've read: http://docs.julialang.org/en/release-0.4/manual/metaprogramming/ I'm also somewhat confused by various ways to create expressions, and their relationship to each other: :(code) quote code end

[julia-users] Re: Nullable{Date}

2016-02-08 Thread 'Greg Plowman' via julia-users
If only Nullables can be null, could we formally define this? isnull(x::Nullable) = x.isnull # already defined in nullable.jl isnull(x) = false # extra definition for everything else > isnull( lp15 ) --> true > isnull( lp16 ) --> MethodError: `isnull` has no method

[julia-users] Re: Executing anonymous function on worker fails when wrapped in a module

2016-01-20 Thread 'Greg Plowman' via julia-users
OK, it seems a workaround may be to use something like eval(Base.Main, :(()->CPU_CORES)) in place of the standard anonymous function. Below, Lemon.getCores(pid) doesn't work, Apple.getCores(pid) does work. Is there a better way? This workaround seems awkward and overly complicated. module

[julia-users] Executing anonymous function on worker fails when wrapped in a module

2016-01-18 Thread 'Greg Plowman' via julia-users
I'm trying to execute an anonymous function on a worker from within a module: getCores(pid) = remotecall_fetch(pid, ()->CPU_CORES) module Banana export getCores2 getCores2(pid) = remotecall_fetch(pid, ()->CPU_CORES) end Firstly, is using anonymous function,()->CPU_CORES, as above a

[julia-users] Re: good approach to run julia scripts in parallel in a PC

2016-01-13 Thread 'Greg Plowman' via julia-users
You might be able to use pmap: http://docs.julialang.org/en/release-0.4/manual/parallel-computing/#parallel-map-and-loops http://docs.julialang.org/en/release-0.4/stdlib/parallel/?highlight=pmap#Base.pmap Perhaps something like: @everywhere function test1(p) println("doing stuff with $p")

Re: [julia-users] excessive memory allocation with @printf at compile time

2016-01-08 Thread 'Greg Plowman' via julia-users
This is amazing! It also speeds up my compilation time by more than x10. I have a lot of @printf statements and this has changed my life :) What would be wrong with a macro something like: macro fastprintf(args...) :( f()=@printf $(args...); f() ) end I did a comparision of 50 simple @printf

[julia-users] Re: Why does this code never return?

2016-01-02 Thread 'Greg Plowman' via julia-users
This seemed a little non-obvious to me as well. I guess the take-away is that "loading" a module (via any means, not just reload??) loads the entire *file* containing the module, not just the stuff between module Foo end. Only the stuff between module Foo end is scoped to the module, but the

Re: [julia-users] What is @d?

2015-12-23 Thread 'Greg Plowman' via julia-users
Hi Eric, I too am a long suffering Windows user. I find the Atom editor to be useful here: >From the menu bar, Find->Find in Project I typed "macro d(" 1 result found in 1 file for macro d( v0.4\Lazy\src\macros.jl 241 macro d(xs...) And here's the macro: macro d(xs...) @cond if VERSION

[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]

Re: [julia-users] Re: Using macros to override lots of operators for a user-defined type

2015-12-16 Thread 'Greg Plowman' via julia-users
On Thursday, December 17, 2015 at 12:12:06 AM UTC+11, Jeffrey Sarnoff wrote: > > Useful stuff, Greg. I would like to see the way you implemented handing > copy constructors, unary operators, etc. > Would you mind collecting them in a gist or posting a link to the file[s]? > Jeffrey, Here's a

Re: [julia-users] Re: Using macros to override lots of operators for a user-defined type

2015-12-16 Thread 'Greg Plowman' via julia-users
I have exactly the same requirement. Additionally, I often have more than 2 fields and also change the fields of my custom types. So I use a slightly more general version of the above: function CompositeBinaryOp(T::Symbol, op::Symbol) expressions = [ :($op(x1.$field, x2.$field)) for field

[julia-users] Re: range bug in 0.4.1?

2015-12-06 Thread 'Greg Plowman' via julia-users
What about using integer division with div(), and colon operator to construct range? julia> N = 2^3-1 7 julia> imid = div(N+1,2) 4 julia> imid-2 : imid+2 2:6

[julia-users] Re: pmap - intermingled output from workers on v0.4

2015-11-26 Thread 'Greg Plowman' via julia-users
OK, I've done a little more digging. It seems that in v0.4, remote workers are started differently. This is my understanding: Only one worker for each host is started directly from the master process. Additional workers on each host are started from the first worker on that host. Thus output

[julia-users] Re: pmap - intermingled output from workers on v0.4

2015-11-25 Thread 'Greg Plowman' via julia-users
Thanks for your reply. In my view it is natural, that the order of the "output" (print statements) > is intermingled, as the code runs in parallel. Yes, I agree. But I'd like to make sure we're talking about the same level of intermingledness (is this a new word?) Firstly I don't really

[julia-users] pmap - intermingled output from workers on v0.4

2015-11-23 Thread 'Greg Plowman' via julia-users
Has output from parallel workers changed in Julia v0.4 from v0.3? I guess that running parallel processes might lead to intermingled output. However, I have (more or less) the same parallel simulation code using pmap running on v0.3 and v0.4. On v0.3 the output from workers is always orderly.

[julia-users] Re: pmap - intermingled output from workers on v0.4

2015-11-23 Thread 'Greg Plowman' via julia-users
I should add this problem is only when using *remote* workers. (In my case ssh on Windows). The following code produces intermingled output with multiple workers on multiple machines (Julia v0.4) Output is orderly when using Julia v0.3, or with v0.4 when workers are on local machine only.

[julia-users] Re: General help with concepts: splatting/slurping, inlining, tuple access, function chaining

2015-11-11 Thread 'Greg Plowman' via julia-users
Thank you so much Stefan and Matt. This really helps me a lot! I really appreciate your time. -- Greg

[julia-users] General help with concepts: splatting/slurping, inlining, tuple access, function chaining

2015-11-10 Thread 'Greg Plowman' via julia-users
I have some naïve and probably stupid questions about writing efficient code in Julia. I almost didn't post this because I'm not sure if this is the right place for asking for this type of conceptual help. I do hope it is appropriate. I apologise in advance if it's not. I have been trying to

[julia-users] Re: Windows: Add packages for all users

2015-11-07 Thread 'Greg Plowman' via julia-users
Perhaps set environment variable JULIA_PKGDIR for all users. http://docs.julialang.org/en/release-0.4/stdlib/pkg/#Base.Pkg.dir

Re: [julia-users] Re: Order of multiple for-loops

2015-10-29 Thread 'Greg Plowman' via julia-users
I wouldn't say that storage order was irrelevant, but rather that mathematics order is different to Julia's storage order. If Julia had row-major storage, I suspect order of comprehension loops would/should be the same as normal for-loops. (Presumably order of comprehension loops now are so that

[julia-users] Performance of functions when called indirectly via parameter passing

2015-10-28 Thread 'Greg Plowman' via julia-users
I think I have read that passing around functions in not efficient. Or maybe this is just anonymous functions? In any case I want to run some comparison performance tests on many functions, so have written a general function to perform tests on functions passed in as arguments. See below. Q1.

[julia-users] Re: Is there a tutorial on how to set up my own Julia cluster?

2015-10-28 Thread 'Greg Plowman' via julia-users
On v0.3 try multiple entries (lines) in machine file, one for each worker.

[julia-users] Re: Performance of functions when called indirectly via parameter passing

2015-10-28 Thread 'Greg Plowman' via julia-users
Thanks Kristoffer. But for Q2, I'm not sure I want to exclude gc time. Rather I want gc time to be correctly allocated. I'm not really sure how gc works, but I thought calling gc() before each function call would ensure there are no outstanding gc's that might happen during the call. In other

[julia-users] Re: REPL: show( io::IO, x::Array{my_object,1} ) = ... overwrite

2015-09-30 Thread 'Greg Plowman' via julia-users
I think I have a similar question. I have defined a type (it happens to be a subtype of AbstractArray). Also I have defined Base.show(io::IO, A::MyArray), so that show(A) works as I want. But the REPL doesn't seem to use show. i.e. typing A at the REPL produces default output. How can I get the

[julia-users] Re: Julia equivalent to a static member function in C++/MATLAB

2015-09-25 Thread 'Greg Plowman' via julia-users
> In Julia, you can do the same thing, it is just spelled differently. You > could do x = zeros(MyMatrix, 3, 4) where you have defined Base.zeros(::Type{MyMatrix}, m, n) = . Show trimmed content Of course in Julia you can do anything you want. However, is it recommended to

Re: [julia-users] Juno stopped working - error message

2015-09-23 Thread 'Greg Plowman' via julia-users
Hi, I'm aware that there are problems with Juno at the moment (I've had my share of problems). I'm not really expecting a resolution to the following issue, but rather reporting it in case it is useful or important. The message says to submit a bug report and seems to be coming from Julia

[julia-users] Re: When does colon indexing get evaluated / converted?

2015-09-22 Thread 'Greg Plowman' via julia-users
Matt, Thankyou so much for your great reply. And yes it does make sense now after such a helpful and well-targeted explanation. You explained "colon-lowering" in a "explanation-lowered" way that a non-expert can understand. This is refreshingly thoughtful and helpful. Thanks again. -- Greg On

[julia-users] Re: When does colon indexing get evaluated / converted?

2015-09-21 Thread 'Greg Plowman' via julia-users
Hi All, Thanks all for your replies. OK I can see this will be much easier in v0.4. I will revisit when v0.4 released. I'm still curious about colon and end > Colon lowering changed in 0.4, Matt, could you expand on this? How/when is this done in v0.3 vs v0.4? Does this mean v0.3 code

[julia-users] Re: Juno stopped working - error message

2015-09-20 Thread 'Greg Plowman' via julia-users
Hi, I tried Pkg.pin("JuliaParser", v"0.1.2") but now I get the following error (multiple times). Before this JuliaParser was at version v0.6.3, are you sure we should try reverting to v0.1.2? WARNING: LightTable.jl: `skipws` has no method matching skipws(::TokenStream ) in scopes at

[julia-users] Re: Juno stopped working - error message

2015-09-20 Thread 'Greg Plowman' via julia-users
Hi All, On 2 different PCs where Juno works (almost without error) Pkg.status() reports JuliaParser v0.6.2 On PC that has Juno errors, Pkg.status() reports JuliaParser v0.6.3 Rolling back to JuliaParser v0.1.2 creates different errors. So it seems we need to revert to JuliaParser v0.6.2 I'm not

[julia-users] When does colon indexing get evaluated / converted?

2015-09-20 Thread 'Greg Plowman' via julia-users
Hi, I'm trying to define a custom Array type that can be indexed using arbitrary ranges. e.g. A = MyArray(Int, 3:8) would define a 6-element vector with indexes ranging from 3 to 8, rather than the default 1 to 6. I've made some progress, but am now stuck on how to handle colon indexing.

[julia-users] Re: Juno stopped working - error message

2015-09-20 Thread 'Greg Plowman' via julia-users
OK I see that second latest tag is v0.1.2 (17 June 2014). Seems a strange jump. But now I understand pinning, I can use a strategy of rolling back Juno-related packages until Juno works again. What other packages would Juno depend on? To help me in this endeavour, I have access to another PC

Re: [julia-users] When does colon indexing get evaluated / converted?

2015-09-20 Thread 'Greg Plowman' via julia-users
To further clarify, I thought I could specialise getindex / setindex! on colon type argument. see below, getindex2 is being called, but getindex is not being called. A[:] calls getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at abstractarray.jl:380 presumably after [:] has been converted

Re: [julia-users] When does colon indexing get evaluated / converted?

2015-09-20 Thread 'Greg Plowman' via julia-users
ulia...@googlegroups.com where for other > users I see their names (at least in my email client), so it’s a bit hard > to see who you are in lists of thread participant names. > > -s > > > > > On Sep 20, 2015, at 9:34 PM, 'Greg Plowman' via julia-users < > jul

Re: [julia-users] Adding remote workers on windows

2015-09-08 Thread 'Greg Plowman' via julia-users
> > I meant the remote machine/network may be firewalled to only accept > incoming ssh, http and other known ports. OK sorry. By now you can probably guess I don't really understand networking. Anyway I turned off the remote firewall entirely, and addprocs() successfully added remote