Re: [julia-users] Re: How to quickly count the moving average with one vector and save in the other vec? Whitout while

2016-03-06 Thread Bryan Rivera
Stefan, your calc looks forward on the data. Typically we want to look back: mean(data[max(1, i-period):i]) On Tuesday, February 10, 2015 at 8:59:08 AM UTC-5, Stefan Karpinski wrote: > > There's always going to be a loop since that's what the computer is doing. > Either you wrote it or

Re: [julia-users] Need Ref on UInt32 but not Float64

2016-02-01 Thread Bryan Rivera
to be varying and on the order of 29105550 and 1000 respectively. On Monday, February 1, 2016 at 1:48:00 PM UTC-5, Yichao Yu wrote: > > > On Feb 1, 2016 1:38 PM, "Bryan Rivera" <future...@gmail.com > > wrote: > > > > Hi Eric, > > > > I get 'garba

[julia-users] Re: Need Ref on UInt32 but not Float64

2016-02-01 Thread Bryan Rivera
I figured it out. Is it ok to use Ref this way? cfunction(callbackfun, Void, (Ptr{UInt8}, UInt32, Ref{SomeConcreteType}))

[julia-users] Re: Need Ref on UInt32 but not Float64

2016-02-01 Thread Bryan Rivera
I figured this out. Is using Ref in such a way be acceptable? cfunction(callbackfun, Void, (Ptr{UInt8}, UInt32, Ref{SomeConcreteType}))

[julia-users] Re: Juno IDE

2016-02-01 Thread Bryan Rivera
I've seen some enthusiasm about Juno, but I think we might be reinventing the wheel here. Atom's approach using web technologies really appeals to me. It doesn't have all the features of IntelliJ, but it has the potential to.

Re: [julia-users] Need Ref on UInt32 but not Float64

2016-02-01 Thread Bryan Rivera
Hi Eric, I get 'garbage' results if I don't use Ref. The number returned may change slightly, but it is way too large. I don't know if it's a memory address or what.

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-31 Thread Bryan Rivera
"the type parameter can simply be replaced with the abstract type itself. " I believe I was having trouble with this. Could be part of the bug.

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-31 Thread Bryan Rivera
t; > > > Thanks! > > > > Chris > > > > > > On Sunday, January 31, 2016 at 4:27:00 AM UTC-5, Bryan Rivera wrote: > >> > >> I just realized #13412 has been merged. > >> > >> What should this look like now that `Base.

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-31 Thread Bryan Rivera
Working on 0.5.0-dev+2422: julia> type SomeCallBack z::Int end julia> (_::SomeCallBack)(c) = _.z + c julia> s = SomeCallBack(24) SomeCallBack(24) julia> s(10) 34 julia> @code_llvm s(10) define i64 @julia_SomeCallBack_23730(%jl_value_t*, i64) #0 { top: %2 =

[julia-users] Need Ref on UInt32 but not Float64

2016-01-31 Thread Bryan Rivera
For some reason I need to specify Ref{UInt32} instead of just UInt32. Float64 does not seem to require the same. Can anyone explain this behavior? function callbackfun(a::UInt32, b::Float64, c::UInt32) ... end cfunction(callbackfun, Void, (Ref{UInt32},Float64,Ref{UInt32})) typedef

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-31 Thread Bryan Rivera
performance guarantees apply. Does that answer your question? > > On Thursday, January 21, 2016 at 9:02:50 PM UTC-5, Bryan Rivera wrote: >> >> I think what I wrote above might be too complicated, as it is an attempt >> to solve this problem. >> >>

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-31 Thread Bryan Rivera
> same performance guarantees apply. Does that answer your question? > > On Thursday, January 21, 2016 at 9:02:50 PM UTC-5, Bryan Rivera wrote: >> >> I think what I wrote above might be too complicated, as it is an attempt >> to solve this problem. >> >>

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-31 Thread Bryan Rivera
I just realized #13412 <https://github.com/JuliaLang/julia/pull/13412> has been merged. What should this look like now that `Base.call(...)` is deprecated? Thinking something like: (_::SomeCallBack)(c) = _.z + c On Sunday, January 31, 2016 at 3:47:03 AM UTC-5, Bryan Rivera wrote: >

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
Are circular type trees supposed to work? We can't even join types: *abstract A* *abstract B* *type D <: Union{A, B} # Fail* *end*

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
*typealias D Union{A,B}* *julia> **D <: Union{A,B}* *true* *;) thanks*

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
Whoops. Can I get editing permission for my own posts?

Re: [julia-users] Circular parametric types

2016-01-27 Thread Bryan Rivera
*typealias D Union{A,B}* *julia> **D <: Union{A,B}* *true* *Is this what you meant?* *So if the example code is a bug, does this mean Julia should have a recursive type tree?*

[julia-users] Seg Fault Using a Pointer Load

2016-01-26 Thread Bryan Rivera
Why are these ops causing a segfault? unsafe_pointer_to_objref( Ptr{UInt32}(1000) ) unsafe_load( Ptr{UInt32}(1000) ) The only reason I am using a pointer is because of a C function call. When I try to write a test using only Julia, it fails. The load is what I narrowed it down to.

Re: [julia-users] Seg Fault Using a Pointer Load

2016-01-26 Thread Bryan Rivera
julia> @code_llvm unsafe_load( Ptr{UInt32}(1000) ) define i32 @julia_unsafe_load_21205(i32*) { top: %1 = load i32* %0, align 1 ret i32 %1 } Does this mean `Ptr{UInt32}(1000)` does not alloc any memory? What effect does the 1000 have?

Re: [julia-users] Seg Fault Using a Pointer Load

2016-01-26 Thread Bryan Rivera
Ok, it makes sense now.

[julia-users] Why can't function passing be unrolled?

2016-01-24 Thread Bryan Rivera
Why can't this: function functionWithPaths(state::State, a::Int, b::Int, onPathA) if( a > b) onPathA(a, b) state.value = a else state.value = a + b end end function test() array = zeros(Int, 100) onPathA(a, b) = array[a] = b functionWithPaths(State(0), 10, 20,

Re: [julia-users] Why can't function passing be unrolled?

2016-01-24 Thread Bryan Rivera
Yea, the callback also has its issues. Will those new lambdas be in 0.5? I thought they were already available in 0.5dev.

Re: [julia-users] Why can't function passing be unrolled?

2016-01-24 Thread Bryan Rivera
I can hardly wait. Is it just me, or is this something long overdue for Julia? (don't get me wrong, I know time is precious)

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
Good to know, this is quite a core issue. I see performant lambda's as a must. Next would be to have C++ like options for how local vars are handled. We should be able to negate some options with intelligent compilation. Those Python vs. Julia benchmarks are about to get a whole lot faster

[julia-users] Re: Macros, functions and module

2016-01-22 Thread Bryan Rivera
I don't know what your exact use case is, but you should't be using macros like that. Does @inline g() suit your purposes? If not, I recommend making your example a bit more pertinent to what you want accomplished. On Friday, January 22, 2016 at 3:43:10 PM UTC-5, ami...@gmail.com wrote: > >

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
gt; the > > > spacial overhead of storing multiple functions. > > > > > > Can we be greedy? :) > > > > > > On Thursday, January 21, 2016 at 9:56:51 PM UTC-5, Cedric St-Jean > wrote: > > >> Something like this? > > >>

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
It doesn't look like I can edit my posts anymore. Is that normal? I have to cleanup the copied OP.

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
I tried to mitigate that by not timing the code where @anon is called. Is that still the case given the two snippets?

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
I tried to mitigate that by not timing the code where @anon is called. Is that still the case given the two snippets? On Friday, January 22, 2016 at 2:15:20 PM UTC-5, Tim Holy wrote: > > On Friday, January 22, 2016 10:21:31 AM Bryan Rivera wrote: > > For 1000 elements: > >

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
Yea those were averages of 5 runs each, minus the first for JIT. On Friday, January 22, 2016 at 1:24:00 PM UTC-5, Stefan Karpinski wrote: > > Make sure you time it twice – the faster version may generate more code. > > On Fri, Jan 22, 2016 at 1:21 PM, Bryan Rivera <future...@gmail

[julia-users] Help with some code where we would normally use inheritance

2016-01-22 Thread Bryan Rivera
Hopefully you can help me out with this. I left out function implementations that we should't need to see. This part of the code I think seems ok: abstract Intervalizer{Time <: Integer, Value <: Union{AbstractFloat, Integer }} type StreamingIntervalizer{Time, Value} <: Intervalizer{Time,

[julia-users] Re: Help with some code where we would normally use inheritance

2016-01-22 Thread Bryan Rivera
I think I almost got it - just need to figure out how to inject onCompletedInterval with the proper vars in macro. macro gen_intervalize(onCompletedInterval) return quote if(isNextInterval(i.intervalState, time)) onCompletedInterval(getCurrentIntervalTime(i.intervalState), i.

[julia-users] Re: Interrupting script gives constant error

2016-01-22 Thread Bryan Rivera
You are on the potentially unstable dev branch 0.5. Try 0.4 instead. You should probably file this as an issue on Julia's github. On Friday, January 22, 2016 at 7:32:55 AM UTC-5, Lutfullah Tomak wrote: > > I have a julia script that runs IJulia > as > > #!/bin/sh > julia -e "using IJulia;

Re: [julia-users] Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
Thanks for the responses guys. @Mauro Hopefully I'm approved soon :) @Viral Makes sense, looks like it works. @Kevin This is the only email I've used to post here. It might be another Bryan.

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-22 Thread Bryan Rivera
. My feeling is that .call > overloading is not to be abused in Julia, so I would favor using a regular > function call with a descriptive name instead of call overloading, but the > same performance guarantees apply. Does that answer your question? > > On Thursday, Januar

[julia-users] Optimizing Function Injection in Julia

2016-01-21 Thread Bryan Rivera
The goal is to remove all overhead associated with using Nullable, since we know at compile time what path (in the if branch) will result in None vs Some. Since we know this, we can simply inject `function2` into `function1`. However, we have an issue that `function2 ` requires the variable

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-21 Thread Bryan Rivera
I think what I wrote above might be too complicated, as it is an attempt to solve this problem. In essence this is what I want: function function1(a, b, onGreaterThanCallback) if(a > b) c = a + b res = onGreaterThanCallback(c, z) return res + 1 else # do anything #

[julia-users] Re: Optimizing Function Injection in Julia

2016-01-21 Thread Bryan Rivera
Guys, it's killing me having to wait hours until my posts are approved. (Ability to edit would be nice as well.. Although it looks like I can edit all of my posts save for the original.) What must be done to overcome this limit?

Re: [julia-users] Using Dot Syntax in Julia

2016-01-18 Thread Bryan Rivera
ple dispatch. However you can >> do something like: >> >> type Wallet >> dotTest::Function >> end >> >> Which might have ambiguous performance impact. >> On Jan 17, 2016 12:45 PM, "Bryan Rivera" <futurehori...@gmail.com&g

[julia-users] Re: Curious behavior

2016-01-17 Thread Bryan Rivera
Looks to me like the compiler is smart enough to see there is no use for blah, and therefore removes it from final output.

[julia-users] Using Dot Syntax in Julia

2016-01-17 Thread Bryan Rivera
I have seen some code out in the wild that allows us to use dot syntax like so: function dotTest!(wallet::Wallet, valueToAdd::Int): ... end wallet = Wallet(100) wallet.dotTest!(5) # Does not work dotTest!(wallet, 5) # Works However I cannot get it to work, the method is not found

[julia-users] Re: tip for using Julia on OS X

2016-01-13 Thread Bryan Rivera
This works on El Capitan: sudo nano /etc/paths Add this line to end of file: /Applications/Julia-0.4.2.app/Contents/Resources/julia/bin Ctrl-O then enter to save.