[julia-users] Re: Why construction of Dict via generator is not type-stable?

2016-11-14 Thread Lutfullah Tomak
You could find `ta=t.(a)` first and then construct a 
`Dict{eltype(a),eltype(ta)}` but it is just a workaround and wastes some memory.

[julia-users] Why construction of Dict via generator is not type-stable?

2016-11-13 Thread Lutfullah Tomak
What about storing eltypes in  variables and directly calling 
'Dict{eltypa,eltypet_a}(...)'? I think there is some issue about this github 
too.

Re: [julia-users] Adding ZMQ fails on debian-strech ARM

2016-11-05 Thread Lutfullah Tomak
Thanks Yichao. I also found that there is an open 
issue https://github.com/JuliaLang/julia/issues/18816.

On Saturday, November 5, 2016 at 3:04:25 PM UTC+3, Yichao Yu wrote:
>
> On Sat, Nov 5, 2016 at 3:55 AM, Lutfullah Tomak <tomak...@gmail.com 
> > wrote: 
> > 1)System libzmq fails because binary tarball(julia-0.5) from 
> julialang.org includes old libstdc++ shared library hence 
> Pkg.build("ZMQ") fails. 2) I tried to build julia-0.5 with the system's gcc 
> (6.2) but build fails while compiling julia that says "target does not 
> support ifunc". Are there ways to work around these two? 
>
> Both fixed on master. You can delete the libstdc++ from the 0.5 binary. 
>


[julia-users] Adding ZMQ fails on debian-strech ARM

2016-11-05 Thread Lutfullah Tomak
1)System libzmq fails because binary tarball(julia-0.5) from julialang.org 
includes old libstdc++ shared library hence Pkg.build("ZMQ") fails. 2) I tried 
to build julia-0.5 with the system's gcc (6.2) but build fails while compiling 
julia that says "target does not support ifunc". Are there ways to work around 
these two?

[julia-users] Re: julia-i18n: Translators and reviewer needed!

2016-10-09 Thread Lutfullah Tomak
Inspite of initial spur, it took a while for me finish hompage for Turkish 
page 
because of the new term starting at my university. I'm not an expert in 
translation
it would be good if some other Turkish speaking user can check and give 
feedback
for my crude translation.

On Thursday, September 22, 2016 at 9:32:13 AM UTC+3, Ismael Venegas 
Castelló wrote:
>
> Looking how to contribute to Julia? Check out the web translation project 
> on Transifex. 
> Help us bring Julia internationalization to your native language one 
> string at a time!
>
>
>- https://www.transifex.com/julialang-i18n/julialang-web
>- https://gitter.im/JuliaLangEs/julia-i18n
>- https://github.com/JuliaLang/julialang.github.com/pull/252
>
>

[julia-users] Problem with julia-0.5 on Gentoo

2016-09-29 Thread Lutfullah Tomak
https://github.com/JuliaLang/julia/pull/18658

[julia-users] How to call macro stored in variable

2016-09-25 Thread Lutfullah Tomak
It you should return just esc(ex). It seems :($(esc(ex))) makes it an 
expression wrapping an expression.

[julia-users] Int Matrix multiplication versus Float Matrix multiplication

2016-09-21 Thread Lutfullah Tomak
Float matrix multiplication uses heavily optimized openblas but integer matrix 
multiplication is a generic one from julia and there is not much you can do to 
improve it a lot because not all cpus have simd multiplication and addition for 
integers.

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

2016-09-16 Thread Lutfullah Tomak
It is related to the `importall` part of code. It can be that the files are not 
in the same directory but I'm not sure. Also, [] creates an Array with element 
type of Any. Giving it a type annotation may help peeformance ei TypeofArray[].

[julia-users] Slow Performance Compared to MATLAB

2016-09-10 Thread Lutfullah Tomak
Ome minor thing minimum([a,b]) -> min(a,b).
Relevant parts of documentation for performance issues
http://docs.julialang.org/en/release-0.5/manual/faq/
http://docs.julialang.org/en/release-0.5/manual/performance-tips/
http://docs.julialang.org/en/release-0.5/manual/noteworthy-differences/

[julia-users] Slow Performance Compared to MATLAB

2016-09-10 Thread Lutfullah Tomak
Lots of lots of can be done for improvements over there. First of most indexing 
with [:,i] allocates a lot of temporaries in this code. At least, you could do 
size(vertex,i) instead of length(vertex[:,i]). Some of variables initialized 
like a=[], it is dangerous since it makes element type of it Any. If you know 
the element type of a, do it like a=TypeOfa[]. These are my observings.

[julia-users] Re: @profile does not allow variable assignment on v0.5

2016-09-09 Thread Lutfullah Tomak
I think it is on the way @profile defined makes it not processed in outer 
scope

julia> macroexpand(:(@profile y = f(5)))
quote  # profile.jl, line 11:
try  # profile.jl, line 12:
#10#status = (Base.Profile.start_timer)() # profile.jl, line 13:
if #10#status < 0 # profile.jl, line 14:
(Base.Profile.error)((Base.Profile.error_codes)[#10#status])
end # profile.jl, line 16:
y = f(5)
finally  # profile.jl, line 18:
(Base.Profile.stop_timer)()
end
end

try finally end block makes y a local variable if not defined beforehand.

julia> try
   y=125
   finally
   nothing
   end
125


julia> y
ERROR: UndefVarError: y not defined


julia> y =5
5


julia> try
   y=125
   finally
   nothing
   end
125


If you think it is a regression file a bug report for profile.


On Friday, September 9, 2016 at 1:04:21 PM UTC+3, Florian Oswald wrote:
>
> hi all, 
>
> on v0.5-rc3, I see this
>
> *julia> **f(x)=x^3*
>
> *f (generic function with 1 method)*
>
>
> *julia> **@profile y = f(5)*
>
> *125*
>
>
> *julia> **y*
>
> *ERROR: UndefVarError: y not defined*
>
>
>
> which used to work in previous versions. Is that intended behaviour?
>
>
>

[julia-users] Re: Inference and Core.Box - why is this happening?

2016-09-09 Thread Lutfullah Tomak
Using a captured variable in a closure makes it somehow a Core.box.
Generator defines an anonymous with maxV so it is hitting something like 
this https://github.com/JuliaLang/julia/issues/15276
Smaller repro
function c!{T}(::T,P)
  if length(P)>2
maxV = one(T)
d = x->maxV
  end
  P
end



On Friday, September 9, 2016 at 1:02:29 PM UTC+3, Patrick Kofod Mogensen 
wrote:
>
> So, I am kind of confused here. In my code, a maxV = maximum(V) is labeled 
> as Core.Box in @code_warntype, but if I remove a line after the line where 
> maxV is calculated, it is correctly labelled as eltype(V). Can anyone 
> explain what happens/what I am doing wrong here? This is not the whole 
> function, I've tried to remove all irrelevant code.
> V = [0.,]
> P = Vector{Float64}[[0.0,], [0.0,]]
> U = Vector{Float64}[[1.,], [1.,]]
> F = Matrix{Float64}[eye(1), eye(1)]
> b = 0.9
>
> function c!{T}(P, U, b::T, F, V)
> if length(P) > 2
> maxV = maximum(V)
> d = sum(exp(U[ia]+b*F[ia]*V-maxV) for ia = 1:length(P))::T
> end
> P
> end
>
> # This shows maxV as Core.Box
> @code_warntypec!(P, U, β, F, V)
>
>
> function c!{T}(P, U, b::T, F, V)
> if length(P) > 2
> maxV = maximum(V)
> end
> P
> end
>
> # This does not show maxV as Core.Box, but as eltype(V) as I expected
> @code_warntypec!(P, U, β, F, V)
>
> Thanks
>


[julia-users] Re: Running Julia in Ubuntu

2016-09-08 Thread Lutfullah Tomak
I didn't say it is required in general in Android. Mostly, we need a way to 
compile fortran based dependencies.
Google uses llvm compiler toolchain(called android ndk) for native apps but it 
doesn't have fortran compiler yet.
If those dependencies are left out, julia can be built plainly without FFTW, 
Blas, and lapack. Other than that only a terminal interface would be required.

[julia-users] Re: Running Julia in Ubuntu

2016-09-08 Thread Lutfullah Tomak
There are some non-root google play apps(debian noroot 
<https://github.com/pelya/debian-noroot> by pelya and GNURoot Debian 
<https://github.com/corbinlc/GNURootDebian> by corbin) that basically 
provide
chroot into another linux system by using proot library. `Chroot`ing is not 
using a VM but using a boxed system under a regular android(or any unix) 
system.
AFAIK,it runs programs natively but some filesystem and socket 
operations(or some privileged operations)
go through proot(or used chroot library) library to simulate a root system.

On Thursday, September 8, 2016 at 4:26:09 PM UTC+3, Páll Haraldsson wrote:
>
> On Tuesday, September 6, 2016 at 8:21:48 PM UTC, Lutfullah Tomak wrote:
>>
>> I use julia 0.4.6 package from Debian Stretch in arm cpu(with chroot 
>> environment in my android phone). It works well and IJulia works too.
>>
>
> You mean you use Julia straight on Android, not on Debian or Ubuntu (in a 
> VM under Android)? Interesting.. I had heard of the latter in a VM.
>
> I think I know what chroot is, not quite a VM, lightweight, and you get 
> the file system hierarchy you expect. Was that the point?
>
> [Android isn't strictly supported, only the Linux [kernel], but this 
> indicates to me that nothing more in userspace is needed and only file 
> system changes/chroot is needed (if that..).]
>
>
>
>> On Tuesday, September 6, 2016 at 11:12:24 PM UTC+3, Angshuman Goswami 
>> wrote:
>>>
>>> Anyone has a working version of Julia running on ARM processors?
>>>
>>> On Thursday, September 1, 2016 at 10:15:05 PM UTC-4, Josh Langsfeld 
>>> wrote:
>>>>
>>>> This link is only to an archive of the source code; you would still 
>>>> have to build julia after downloading this.
>>>>
>>>> Ideally what you want is an ARM binary that's version 0.4 instead of a 
>>>> nightly build but I don't see anywhere obvious where that can be 
>>>> downloaded.
>>>>
>>>> RobotOS will start working on 0.5 and up eventually, but you may still 
>>>> need to wait a few weeks.
>>>>
>>>> On Thursday, September 1, 2016 at 7:52:09 PM UTC-4, Angshuman Goswami 
>>>> wrote:
>>>>>
>>>>> But there is no folder /bin/julia in the one I downloaded from 
>>>>> https://github.com/JuliaLang/julia/releases/tag/v0.4.6
>>>>>
>>>>> What should be the simlink when I try to build with this ??
>>>>>
>>>>> On Thursday, September 1, 2016 at 6:52:41 PM UTC-4, Kaj Wiik wrote:
>>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> You symlink a wrong file, first 
>>>>>> sudo rm /usr/local/bin/julia.h
>>>>>>
>>>>>> The correct symlink line is
>>>>>> sudo ln -s /opt/julia-0.4.6/bin/julia  /usr/local/bin
>>>>>>
>>>>>> On Friday, September 2, 2016 at 1:11:07 AM UTC+3, Angshuman Goswami 
>>>>>> wrote:
>>>>>>>
>>>>>>> I have downloaded the Julia 0.4.6 from the repository: 
>>>>>>> https://github.com/JuliaLang/julia/releases/tag/v0.4.6
>>>>>>> I extracted the folder and copied to opt folder
>>>>>>> sudo ln -s /opt/julia-0.4.6/src/julia.h  /usr/local/bin
>>>>>>>
>>>>>>> I made the folder executable using sudo chmod +x *
>>>>>>>
>>>>>>> But I am getting the error:
>>>>>>> bash: julia: command not found
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thursday, September 1, 2016 at 5:38:10 PM UTC-4, Angshuman 
>>>>>>> Goswami wrote:
>>>>>>>>
>>>>>>>> I want to use Julia 0.4.6. Can you guide me through the process as 
>>>>>>>> if I am a novice
>>>>>>>> On Thursday, September 1, 2016 at 2:24:43 AM UTC-4, Lutfullah Tomak 
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> You've already built julia I guess. You need to install python 
>>>>>>>>> using ubuntu's package system. In command prompt
>>>>>>>>> sudo apt-get install `pkg-name`
>>>>>>>>> will install the package you want to install by asking you your 
>>>>>>>>> password.
>>>>>>>>> For python
>>>>>&

[julia-users] Re: How I did get a spurious method for *{T}(Irrational{T},Irrational{T})?

2016-09-07 Thread Lutfullah Tomak
A reduced case that also makes multiplication of the same Irrational an 
error.

   _
   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/   |  x86_64-linux-gnu


julia> module Erratic


   const DummyUnion =  Union{Irrational,AbstractFloat}
   abstract DummyReal <: Real
   immutable DummyType <: DummyReal
   var::DummyUnion
   end


   mulSym(x::DummyUnion, y::DummyUnion) = x*y
   mulSym(x::DummyUnion, y::DummyType)  = DummyType(mulSym(x, y.var
))


   import Base.*
   *(x::DummyUnion, y::DummyReal) = mulSym(x, y)


   end
Erratic


julia> pi*pi
ERROR: * not defined for Irrational{:π}
 in error(::String, ::String, ::Vararg{Any,N}) at ./error.jl:22
 in no_op_err(::String, ::Type{T}) at ./promotion.jl:254
 in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256
 in eval(::Module, ::Any) at ./boot.jl:234


julia> pi*Erratic.DummyType(pi)
ERROR: * not defined for Irrational{:π}
 in error(::String, ::String, ::Vararg{Any,N}) at ./error.jl:22
 in no_op_err(::String, ::Type{T}) at ./promotion.jl:254
 in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256
 in mulSym(::Irrational{:π}, ::Irrational{:π}) at ./REPL[1]:9
 in mulSym(::Irrational{:π}, ::Erratic.DummyType) at ./REPL[1]:10
 in *(::Irrational{:π}, ::Erratic.DummyType) at ./REPL[1]:13
 in eval(::Module, ::Any) at ./boot.jl:234


julia> pi*Erratic.DummyType(2.)
Erratic.DummyType(6.283185307179586)

DummyReal does not cover Irrationals but it somehow triggers default 
*{T<:Number}(x::T, y::T) = no_op_err("*", T)
What kind of number does not have multiplication defined with itself?


[julia-users] Re: Running Julia in Ubuntu

2016-09-06 Thread Lutfullah Tomak
I use julia 0.4.6 package from Debian Stretch in arm cpu(with chroot 
environment in my android phone). It works well and IJulia works too.

On Tuesday, September 6, 2016 at 11:12:24 PM UTC+3, Angshuman Goswami wrote:
>
> Anyone has a working version of Julia running on ARM processors?
>
> On Thursday, September 1, 2016 at 10:15:05 PM UTC-4, Josh Langsfeld wrote:
>>
>> This link is only to an archive of the source code; you would still have 
>> to build julia after downloading this.
>>
>> Ideally what you want is an ARM binary that's version 0.4 instead of a 
>> nightly build but I don't see anywhere obvious where that can be downloaded.
>>
>> RobotOS will start working on 0.5 and up eventually, but you may still 
>> need to wait a few weeks.
>>
>> On Thursday, September 1, 2016 at 7:52:09 PM UTC-4, Angshuman Goswami 
>> wrote:
>>>
>>> But there is no folder /bin/julia in the one I downloaded from 
>>> https://github.com/JuliaLang/julia/releases/tag/v0.4.6
>>>
>>> What should be the simlink when I try to build with this ??
>>>
>>> On Thursday, September 1, 2016 at 6:52:41 PM UTC-4, Kaj Wiik wrote:
>>>>
>>>> Hi!
>>>>
>>>> You symlink a wrong file, first 
>>>> sudo rm /usr/local/bin/julia.h
>>>>
>>>> The correct symlink line is
>>>> sudo ln -s /opt/julia-0.4.6/bin/julia  /usr/local/bin
>>>>
>>>> On Friday, September 2, 2016 at 1:11:07 AM UTC+3, Angshuman Goswami 
>>>> wrote:
>>>>>
>>>>> I have downloaded the Julia 0.4.6 from the repository: 
>>>>> https://github.com/JuliaLang/julia/releases/tag/v0.4.6
>>>>> I extracted the folder and copied to opt folder
>>>>> sudo ln -s /opt/julia-0.4.6/src/julia.h  /usr/local/bin
>>>>>
>>>>> I made the folder executable using sudo chmod +x *
>>>>>
>>>>> But I am getting the error:
>>>>> bash: julia: command not found
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thursday, September 1, 2016 at 5:38:10 PM UTC-4, Angshuman Goswami 
>>>>> wrote:
>>>>>>
>>>>>> I want to use Julia 0.4.6. Can you guide me through the process as if 
>>>>>> I am a novice
>>>>>> On Thursday, September 1, 2016 at 2:24:43 AM UTC-4, Lutfullah Tomak 
>>>>>> wrote:
>>>>>>>
>>>>>>> You've already built julia I guess. You need to install python using 
>>>>>>> ubuntu's package system. In command prompt
>>>>>>> sudo apt-get install `pkg-name`
>>>>>>> will install the package you want to install by asking you your 
>>>>>>> password.
>>>>>>> For python
>>>>>>> sudo apt-get install python
>>>>>>> will install python. Close prompt and open julia and try again 
>>>>>>> building PyCall.jl by Pkg.build().
>>>>>>>
>>>>>>> On Wednesday, August 31, 2016 at 11:48:32 PM UTC+3, Angshuman 
>>>>>>> Goswami wrote:
>>>>>>>>
>>>>>>>> I don't get how to do that. 
>>>>>>>>
>>>>>>>> Can you please tell me the steps. Its all too confusing and I am 
>>>>>>>> very new to Ubuntu or Julia. Mostly used to work on Matlab. I have no 
>>>>>>>> idea 
>>>>>>>> how to install dependancies
>>>>>>>>
>>>>>>>> On Wednesday, August 31, 2016 at 3:26:40 AM UTC-4, Kaj Wiik wrote:
>>>>>>>>>
>>>>>>>>> Ah, sorry, I assumed you are using x86_64. Find the arm binary 
>>>>>>>>> tarball and follow the instructions otherwise. See
>>>>>>>>> https://github.com/JuliaLang/julia/blob/master/README.arm.md
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Wednesday, August 31, 2016 at 9:54:38 AM UTC+3, Lutfullah Tomak 
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> You are on an arm cpu so Conda cannot install python for you. 
>>>>>>>>>> Also, you tried downloading x86 cpu linux binaries, instead try arm 
>>>>>>>>>> nightlies.
>>>>>>>>>> To get away with PyCall is

[julia-users] How I did get a spurious method for *{T}(Irrational{T},Irrational{T})?

2016-09-06 Thread Lutfullah Tomak
1)In fresh repl or in a repl without multiplying irrationals previously, 
this gist 
 
somehow adds a method for  *(Irrational,Irrational)
and gives error on the next use of multiplications of the same irrational 
like pi*pi but not pi*eulergamma.

   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/   |  x86_64-linux-gnu


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> methods(*,(Irrational{:π},Irrational{:π}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> module Erratic


   const BaseIrrationals = Union{Irrational{:e},Irrational{:catalan
},Irrational{:γ},
 Irrational{:π},Irrational{:φ}}
   abstract DummyReal <: Real
   immutable SymReal <: DummyReal
   var::BaseIrrationals
   end


   mulSym(x::BaseIrrationals, y::BaseIrrationals) = x*y
   mulSym(x::SymReal, y::SymReal)  = SymReal(mulSym(x.var, y.var))
   mulSym(x::BaseIrrationals, y::SymReal)  = SymReal(mulSym(x, y.var
))
   mulSym(x::SymReal, y::BaseIrrationals)= SymReal(mulSym(x.var, y))


   import Base.*
   *(x::BaseIrrationals, y::DummyReal) = mulSym(x, y)


   end
Erratic


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> methods(*,(Irrational{:π},Irrational{:π}))
# 1 method for generic function "*":
*{T<:Number}(x::T, y::T) at promotion.jl:256


julia> pi*pi
ERROR: * not defined for Irrational{:π}
 in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256


julia> pi*e
8.539734222673566


2)However, if multiplications of irrationals is used previously it doesn't 
give error except @code_** shows erroneous new method.

   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/   |  x86_64-linux-gnu


julia> pi*pi
9.869604401089358


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> module Erratic


   const BaseIrrationals = Union{Irrational{:e},Irrational{:catalan
},Irrational{:γ},
 Irrational{:π},Irrational{:φ}}
   abstract DummyReal <: Real
   immutable SymReal <: DummyReal
   var::BaseIrrationals
   end


   mulSym(x::BaseIrrationals, y::BaseIrrationals) = x*y
   mulSym(x::SymReal, y::SymReal)  = SymReal(mulSym(x.var, y.var))
   mulSym(x::BaseIrrationals, y::SymReal)  = SymReal(mulSym(x, y.var
))
   mulSym(x::SymReal, y::BaseIrrationals)= SymReal(mulSym(x.var, y))


   import Base.*
   *(x::BaseIrrationals, y::DummyReal) = mulSym(x, y)


   end
Erratic


julia> pi*pi
9.869604401089358


julia> methods(*,(Irrational{:π},Irrational{:π}))
# 1 method for generic function "*":
*{T<:Number}(x::T, y::T) at promotion.jl:256


julia> methods(*,(Irrational{:π},Irrational{:e}))
# 1 method for generic function "*":
*(x::Irrational, y::Irrational) at irrationals.jl:88


julia> pi*e
8.539734222673566


julia> @code_lowered pi*pi
LambdaInfo template for *{T<:Number}(x::T, y::T) at promotion.jl:256
:(begin 
nothing
return (Base.no_op_err)("*",$(Expr(:static_parameter, 1)))
end)


It happens both on 0.4(.5) and 0.5-rc3.
Is this a bug or otherwise what happens here?


[julia-users] Re: Running Julia in Ubuntu

2016-09-01 Thread Lutfullah Tomak
You've already built julia I guess. You need to install python using 
ubuntu's package system. In command prompt
sudo apt-get install `pkg-name`
will install the package you want to install by asking you your password.
For python
sudo apt-get install python
will install python. Close prompt and open julia and try again building 
PyCall.jl by Pkg.build().

On Wednesday, August 31, 2016 at 11:48:32 PM UTC+3, Angshuman Goswami wrote:
>
> I don't get how to do that. 
>
> Can you please tell me the steps. Its all too confusing and I am very new 
> to Ubuntu or Julia. Mostly used to work on Matlab. I have no idea how to 
> install dependancies
>
> On Wednesday, August 31, 2016 at 3:26:40 AM UTC-4, Kaj Wiik wrote:
>>
>> Ah, sorry, I assumed you are using x86_64. Find the arm binary tarball 
>> and follow the instructions otherwise. See
>> https://github.com/JuliaLang/julia/blob/master/README.arm.md
>>
>>
>> On Wednesday, August 31, 2016 at 9:54:38 AM UTC+3, Lutfullah Tomak wrote:
>>>
>>> You are on an arm cpu so Conda cannot install python for you. Also, you 
>>> tried downloading x86 cpu linux binaries, instead try arm nightlies.
>>> To get away with PyCall issues you have to manually install all 
>>> depencies. 
>>>
>>> On Wednesday, August 31, 2016 at 7:53:24 AM UTC+3, Angshuman Goswami 
>>> wrote:
>>>>
>>>> When i performed build again errors cropped up.
>>>>
>>>> Pkg.build("PyCall")
>>>> WARNING: unable to determine host cpu name.
>>>> INFO: Building PyCall
>>>> INFO: No system-wide Python was found; got the following error:
>>>> could not spawn `/usr/local/lib/python2.7 -c "import 
>>>> distutils.sysconfig; 
>>>> print(distutils.sysconfig.get_config_var('VERSION'))"`: permission denied 
>>>> (EACCES)
>>>> using the Python distribution in the Conda package
>>>> INFO: Downloading miniconda installer ...
>>>>   % Total% Received % Xferd  Average Speed   TimeTime Time  
>>>> Current
>>>>  Dload  Upload   Total   SpentLeft  
>>>> Speed
>>>> 100 24.7M  100 24.7M0 0  2401k  0  0:00:10  0:00:10 
>>>> --:--:-- 2743k
>>>> INFO: Installing miniconda ...
>>>> PREFIX=/home/odroid/.julia/v0.4/Conda/deps/usr
>>>> installing: _cache-0.0-py27_x0 ...
>>>> installing: python-2.7.11-0 ...
>>>> installing: conda-env-2.4.5-py27_0 ...
>>>> installing: openssl-1.0.2g-0 ...
>>>> installing: pycosat-0.6.1-py27_0 ...
>>>> installing: pyyaml-3.11-py27_1 ...
>>>> installing: readline-6.2-2 ...
>>>> installing: requests-2.9.1-py27_0 ...
>>>> installing: sqlite-3.9.2-0 ...
>>>> installing: tk-8.5.18-0 ...
>>>> installing: yaml-0.1.6-0 ...
>>>> installing: zlib-1.2.8-0 ...
>>>> installing: conda-4.0.5-py27_0 ...
>>>> installing: pycrypto-2.6.1-py27_0 ...
>>>> installing: pip-8.1.1-py27_1 ...
>>>> installing: wheel-0.29.0-py27_0 ...
>>>> installing: setuptools-20.3-py27_0 ...
>>>> /home/odroid/.julia/v0.4/Conda/deps/usr/installer.sh: line 288: 
>>>> /home/odroid/.julia/v0.4/Conda/deps/usr/pkgs/python-2.7.11-0/bin/python: 
>>>> cannot execute binary file: Exec format error
>>>> ERROR:
>>>> cannot execute native linux-32 binary, output from 'uname -a' is:
>>>> Linux odroid 3.10.69 #1 SMP PREEMPT Thu Feb 12 15:22:14 BRST 2015 
>>>> armv7l armv7l armv7l GNU/Linux
>>>> ===[ ERROR: PyCall 
>>>> ]
>>>>
>>>> LoadError: failed process: 
>>>> Process(`/home/odroid/.julia/v0.4/Conda/deps/usr/installer.sh -b -f -p 
>>>> /home/odroid/.julia/v0.4/Conda/deps/usr`, ProcessExited(1)) [1]
>>>> while loading /home/odroid/.julia/v0.4/PyCall/deps/build.jl, in 
>>>> expression starting on line 17
>>>>
>>>>
>>>> 
>>>>
>>>> [ BUILD ERRORS 
>>>> ]
>>>>
>>>> WARNING: PyCall had build errors.
>>>>
>>>>  - packages with build errors remain installed in 
>>>> /home/odroid/.julia/v0.4
>>>>  - build the package(s) and all dependencies with `Pkg.build("PyCall")`
>>>&g

[julia-users] Re: Running Julia in Ubuntu

2016-08-31 Thread Lutfullah Tomak
You are on an arm cpu so Conda cannot install python for you. Also, you 
tried downloading x86 cpu linux binaries, instead try arm nightlies.
To get away with PyCall issues you have to manually install all depencies. 

On Wednesday, August 31, 2016 at 7:53:24 AM UTC+3, Angshuman Goswami wrote:
>
> When i performed build again errors cropped up.
>
> Pkg.build("PyCall")
> WARNING: unable to determine host cpu name.
> INFO: Building PyCall
> INFO: No system-wide Python was found; got the following error:
> could not spawn `/usr/local/lib/python2.7 -c "import distutils.sysconfig; 
> print(distutils.sysconfig.get_config_var('VERSION'))"`: permission denied 
> (EACCES)
> using the Python distribution in the Conda package
> INFO: Downloading miniconda installer ...
>   % Total% Received % Xferd  Average Speed   TimeTime Time  
> Current
>  Dload  Upload   Total   SpentLeft  
> Speed
> 100 24.7M  100 24.7M0 0  2401k  0  0:00:10  0:00:10 --:--:-- 
> 2743k
> INFO: Installing miniconda ...
> PREFIX=/home/odroid/.julia/v0.4/Conda/deps/usr
> installing: _cache-0.0-py27_x0 ...
> installing: python-2.7.11-0 ...
> installing: conda-env-2.4.5-py27_0 ...
> installing: openssl-1.0.2g-0 ...
> installing: pycosat-0.6.1-py27_0 ...
> installing: pyyaml-3.11-py27_1 ...
> installing: readline-6.2-2 ...
> installing: requests-2.9.1-py27_0 ...
> installing: sqlite-3.9.2-0 ...
> installing: tk-8.5.18-0 ...
> installing: yaml-0.1.6-0 ...
> installing: zlib-1.2.8-0 ...
> installing: conda-4.0.5-py27_0 ...
> installing: pycrypto-2.6.1-py27_0 ...
> installing: pip-8.1.1-py27_1 ...
> installing: wheel-0.29.0-py27_0 ...
> installing: setuptools-20.3-py27_0 ...
> /home/odroid/.julia/v0.4/Conda/deps/usr/installer.sh: line 288: 
> /home/odroid/.julia/v0.4/Conda/deps/usr/pkgs/python-2.7.11-0/bin/python: 
> cannot execute binary file: Exec format error
> ERROR:
> cannot execute native linux-32 binary, output from 'uname -a' is:
> Linux odroid 3.10.69 #1 SMP PREEMPT Thu Feb 12 15:22:14 BRST 2015 armv7l 
> armv7l armv7l GNU/Linux
> ===[ ERROR: PyCall 
> ]
>
> LoadError: failed process: 
> Process(`/home/odroid/.julia/v0.4/Conda/deps/usr/installer.sh -b -f -p 
> /home/odroid/.julia/v0.4/Conda/deps/usr`, ProcessExited(1)) [1]
> while loading /home/odroid/.julia/v0.4/PyCall/deps/build.jl, in expression 
> starting on line 17
>
>
> 
>
> [ BUILD ERRORS 
> ]
>
> WARNING: PyCall had build errors.
>
>  - packages with build errors remain installed in /home/odroid/.julia/v0.4
>  - build the package(s) and all dependencies with `Pkg.build("PyCall")`
>  - build a single package by running its `deps/build.jl` script
>
>
> 
>
>
> On Wednesday, August 31, 2016 at 12:08:33 AM UTC-4, Angshuman Goswami 
> wrote:
>>
>> julia> Pkg.status()
>> 7 required packages:
>>  - AmplNLWriter  0.2.2
>>  - CoinOptServices   0.1.2
>>  - IJulia1.2.0
>>  - Ipopt 0.2.4
>>  - JuMP  0.14.0
>>  - PyCall1.7.1
>>  - RobotOS   0.4.1
>> 19 additional packages:
>>  - BinDeps   0.4.3
>>  - Calculus  0.1.15
>>  - Cbc   0.2.3
>>  - Clp   0.2.2
>>  - Compat0.8.8
>>  - Conda 0.2.3
>>  - DataStructures0.4.5
>>  - ForwardDiff   0.2.4
>>  - JSON  0.7.0
>>  - Lazy  0.11.0
>>  - LightXML  0.3.0
>>  - MacroTools0.3.2
>>  - MathProgBase  0.5.4
>>  - NaNMath   0.2.1
>>  - Nettle0.2.4
>>  - ReverseDiffSparse 0.5.8
>>  - SHA   0.2.1
>>  - URIParser 0.1.6
>>  - ZMQ   0.3.4
>>
>>
>> On Tuesday, August 30, 2016 at 10:58:39 PM UTC-4, Angshuman Goswami wrote:
>>>
>>> I am running julia on a 32 bit system and I made sure the version i 
>>> downloaded is 32 bit
>>>
>>> On Tuesday, August 30, 2016 at 10:34:25 PM UTC-4, Angshuman Goswami 
>>> wrote:

 I did that and now I am getting this error when I type julia to run in 
 the command line 
 bash: /usr/local/bin/julia: cannot execute binary file: Exec format 
 error


 On Tuesday, August 30, 2016 at 4:55:54 AM UTC-4, Kaj Wiik wrote:
>
> I have been using the third route very successfully:
>
> Download the binary from e.g.
>
> https://julialang.s3.amazonaws.com/bin/linux/x64/0.4/julia-0.4.6-linux-x86_64.tar.gz
> or
>
> 

Re: [julia-users] How to make a Matrix of Matrix's?

2016-06-24 Thread Lutfullah Tomak
While experimenting this, I don't know if it is intentional but [[M] [M];] 
makes it sparse matrix of matrices. :)

On Friday, June 24, 2016 at 5:39:51 AM UTC+3, Dan wrote:
>
> [[M] [M]] works.
> And is the same as Matrix{Float64}[[M] [M]]
>
> But concur it is unintuitive.
>
> On Thursday, June 23, 2016 at 10:28:39 PM UTC-4, Sheehan Olver wrote:
>>
>>
>> [M,M]  will do a Vector of Matrices in 0.5.   But [M M] still 
>> does concatenation.  So the question is how to do Matrices of Matrices 
>> without concatinating. 
>>
>>
>>
>>
>> > On 24 Jun 2016, at 12:05 PM, Lutfullah Tomak <tomak...@gmail.com> 
>> wrote: 
>> > 
>> > By default [M M] (without delimeter like , or ;) means concatenation so 
>> it throws error. But I think in julia 0.5 [M, M] should do Matrix of 
>> Matricies. 
>>
>>

[julia-users] How to make a Matrix of Matrix's?

2016-06-23 Thread Lutfullah Tomak
By default [M M] (without delimeter like , or ;) means concatenation so it 
throws error. But I think in julia 0.5 [M, M] should do Matrix of Matricies.

[julia-users] Re: Calling Fortran code?

2016-06-06 Thread Lutfullah Tomak
You are missing & in ccall for variables that put as Int64 but expected to 
be passed as Ptr{Int64}.

ccall( (:gcvspl_, "./libgcvspl.so"), Void, (Ptr{Float64},Ptr{Float64},Ptr{
Int64},Ptr{Float64},Ptr{Float64},Ptr{Int64},Ptr{Int64},Ptr{Int64},Ptr{Int64
},Ptr{Float64},Ptr{Float64},Ptr{Int64},Ptr{Float64},Ptr{Int64}),x,y,,wx,
wy,VAL,c,,WK,)

I would make IER one element array since it needs to be retrieved as output.

IER=Int64[0]

then it is

ccall( (:gcvspl_, "./libgcvspl.so"), Void, (Ptr{Float64},Ptr{Float64},Ptr{
Int64},Ptr{Float64},Ptr{Float64},Ptr{Int64},Ptr{Int64},Ptr{Int64},Ptr{Int64
},Ptr{Float64},Ptr{Float64},Ptr{Int64},Ptr{Float64},Ptr{Int64}),x,y,,wx,
wy,VAL,c,,WK,IER)

On Monday, June 6, 2016 at 6:22:47 AM UTC+3, Charles Ll wrote:
>
> Dear all,
>
> I am trying to call some Fortran code in Julia, but I have a hard time 
> doing so... I have read the docs, looked at the wrapping of ARPACK and 
> other libraries... But I did not find any way to make it work.
>
> I am trying to wrap a spline function library (gcvspl.f, 
> https://github.com/charlesll/Spectra.jl/tree/master/Dependencies), which 
> I want to use in my project, Spectra.jl.
>
> I already have a wrapper in Python, but this was easier to wrap with using 
> f2py. In Julia, I understand that I have to do it properly. The function I 
> am trying to call is:
> GCVSPL ( X, Y, NY, WX, WY, M, N, K, MD, VAL, C, NC, WK, IER) (LINE 42 of 
> GCVSPL.f)
>
>
> X(N)( I )   Independent variables, Float64
> Y(NY,K)   ( I )   Input data to be smoothed (or interpolated), Float64
> NY   ( I )   First dimension of array Y(NY,K), with NY.ge.N, 
> Integer
> WX(N) ( I )   Weight factor array, Float64
> WY(K) ( I )   Weight factor array, Float64
> M ( I )   M = 1,2,3,4 correspond to linear, cubic, quintic
> , and heptic splines, respectively. Integer
> N ( I )   Number of observations per dataset, Integer
> K( I )   Number of datasets, with K.ge.1., Integer
> MD ( I )   Optimization mode switch, Integer
> VAL( I )   Mode value, as described above under MD., Array of 
> Float64
> C(NC,K)( O )   Spline coefficients, Array of Float64
> NC ( I )  First dimension of array C(NC,K), NC.ge.N., Integer
> WK(IWK) (I/W/O) Work vector, IWK.ge.6*(N*M+1)+N, Array of Float64
> IER( O )   Error parameter, Integer
>
> with I and O designating Inputs and Outputs, respectively. From this and 
> my previous Python wrap, I generated a fake dataset and tried to use this 
> function with ccall:
>
> x = collect(0.0:1.0:100)
> y = 2.0.*x.^2 - 100.0 + x +0.0003.*x.^5
> ese = y./1
>
>
> NN::Int64 = length(y)
> wx = 1./(ese.^2) # relative variance of observations
> wy = zeros([1])+1 # systematic errors... not used so put them to 1, works 
> under the Python wrap
> VAL = ese.^2
>
>
> M::Int64 = 2
> N::Int64 = length(x)
> K::Int64 = 1 # number of y columns
> MD::Int64 = 2 #spline mode
> NC::Int64 = length(y)
>
> # initialising stuffs for outputs... isit the right way?
> c = ones(NN,NC)
> WK = [1.,1.,1.,1.,1.,1.]
> IER::Int64 = 0
>
>
> ccall( (:gcvspl_, "./libgcvspl.so"), Void, (Ptr{Float64},Ptr{Float64},Ptr{
> Int64},Ptr{Float64},Ptr{Float64},Ptr{Int64},Ptr{Int64},Ptr{Int64},Ptr{
> Int64},Ptr{Float64},Ptr{Float64},Ptr{Int64},Ptr{Float64},Ptr{Int64}),x,y,
> NN,wx,wy,M,N,K,MD,VAL,c,NN,WK,IER)
>
> This code does not work, returning me some convert problems... Notably, I 
> get this one:
>
> LoadError: MethodError: `convert` has no method matching 
> convert(::Type{Ptr{Float64}}, ::Array{Int64,1})
>
>
> That I don't understand... In the "examples" (code already wrapped...) 
> available online, that was the way people wrapped stuffs... 
>
> Do anyone has some clue about doing this wrapping? The gcvspl.f code is 
> available in 
> https://github.com/charlesll/Spectra.jl/tree/master/Dependencies .
>
> Thanks in advance!
>
> Best,
> Charles.
>
>
>

Re: [julia-users] Is Julia slow with large arrays?

2016-06-03 Thread Lutfullah Tomak
I think it is on julia 0.5 but it does not help. Though it produces some 
simd instructions for moving memory 
it still uses scalar float instructions for this loop for @simd version 
(similar for just @inbounds and julia -O on 0.4)

movsd (%r15,%r11,8), %xmm0# xmm0 = mem[0],zero
movsd (%rbx,%r11,8), %xmm2# xmm2 = mem[0],zero
subsd (%rax), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
subsd 8(%rax), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2


On Friday, June 3, 2016 at 6:15:50 PM UTC+3, Stefan Karpinski wrote:
>
> Julia also has an `-O3` option – you could try that.
>
> On Fri, Jun 3, 2016 at 10:54 AM, Angel de Vicente <angel.vice...@gmail.com 
> > wrote:
>
>> Lutfullah Tomak <tomak...@gmail.com > writes:
>> > It may be because ifort uses proper simd instructions. Eriks's 
>> suggestion for @simd
>> > does not use simd instructions in my laptop.
>>
>> I don't see any improvement in Julia by using @simd either.
>>
>> On the other hand, vectorization with the Intel compiler definitely
>> helps, but even with vectorization off, somehow it manages to go faster
>>
>> [angelv@duna TESTS]$ ifort -no-vec -O3 -o test_ifort test.F90
>> [angelv@duna TESTS]$ ./test_ifort
>>   0.065636 seconds
>>9363171.53179644
>> [angelv@duna TESTS]$
>>
>> --
>> Ángel de Vicente
>> http://www.iac.es/galeria/angelv/
>>
>
>

Re: [julia-users] Is Julia slow with large arrays?

2016-06-03 Thread Lutfullah Tomak
It may be because ifort uses proper simd instructions. Eriks's suggestion 
for @simd 
does not use simd instructions in my laptop.


[julia-users] Re: Is Julia slow with large arrays?

2016-06-01 Thread Lutfullah Tomak
Thanks for the tip. It makes sense. I did not pay attention that the given 
function does not returns but I always assumed that timings of for-loop should 
not change before even if the function does not return bar. Also, on julia 0.4, 
it is strange that after first run my last timing triples(maybe due to GC 
interupting more.). It stays about the same on julia 0.5 though.

[julia-users] Re: Is Julia slow with large arrays?

2016-06-01 Thread Lutfullah Tomak
Ok, I revise what I said about @ simd, according to documentation, it only 
works for 
one dimensional ranges and it does not allow this type for-loop and throws 
error.

Here is timings for me

julia> function foo()
  array1 = rand(70, 1000)
  array2 = rand(70, 1000)
  array3 = rand(2, 70, 20, 20)
  bar = 0
  @time for l = 1:1000, k = 1:20, j = 1:20, i = 1:70
bar = bar +
(array1[i, l] - array3[1, i, j, k])^2 +
(array2[i, l] - array3[2, i, j, k])^2
  end
   end
foo (generic function with 1 method)


julia> foo()
  1.215454 seconds (84.00 M allocations: 1.252 GB, 4.16% gc time)


julia> foo()
  1.308979 seconds (84.00 M allocations: 1.252 GB, 3.92% gc time)


julia> function foo()
  array1 = rand(70, 1000)
  array2 = rand(70, 1000)
  array3 = rand(2, 70, 20, 20)
  bar = 0.0
  @time for l = 1:1000, k = 1:20, j = 1:20, i = 1:70
bar = bar +
(array1[i, l] - array3[1, i, j, k])^2 +
(array2[i, l] - array3[2, i, j, k])^2
  end
   end
foo (generic function with 1 method)


julia> foo()
  0.114811 seconds


julia> foo()
  0.150542 seconds


julia> function foo()  array1 = rand(70, 1000)
  array2 = rand(70, 1000)
  array3 = rand(2, 70, 20, 20)
  bar = 0.0
  @time @inbounds for l = 1:1000, k = 1:20, j = 1:20, i = 1:70
bar = bar +
(array1[i, l] - array3[1, i, j, k])^2 +
(array2[i, l] - array3[2, i, j, k])^2
  end

   end

foo (generic function with 1 method)


julia> foo()
  0.004927 seconds





[julia-users] Re: Is Julia slow with large arrays?

2016-06-01 Thread Lutfullah Tomak
Since it is in function, it is not timing copile time but only for-loop. If 
it were in @time foo() it would time compilation.


On Wednesday, June 1, 2016 at 2:30:16 PM UTC+3, Andreas Lobinger wrote:
>
> It's valid and interesting to measure full roundtrip including compile 
> time like you do, however in examples like this, the julia overhead on 
> compiling dominates your measurement.
> You could put your code into a package and pre-compile. 
>
> In any case your not measuring the time to run the code only.
>
> On Wednesday, June 1, 2016 at 1:15:54 PM UTC+2, Mosè Giordano wrote:
>>
>> Hi all,
>>
>> I'm working on a Fortran77 code, but I'd much prefer to translate it to 
>> Julia.  However, I've the impression that when working with large arrays 
>> (of the order of tens of thousands elements) Julia is way slower than the 
>> equivalent Fortran code.  See the following examples:
>>
>> Julia:
>>
>> function foo()
>> array1 = rand(70, 1000)
>> array2 = rand(70, 1000)
>> array3 = rand(2, 70, 20, 20)
>> bar = 0
>> @time for l = 1:1000, k = 1:20, j = 1:20, i = 1:70
>> bar = bar +
>> (array1[i, l] - array3[1, i, j, k])^2 +
>> (array2[i, l] - array3[2, i, j, k])^2
>> end
>> end
>> foo()
>>
>> Fortran77 (it uses some GNU extensions, so gfortran is required):
>>
>>   program main
>>   implicit none
>>   double precision array1(70, 1000), array2(70, 1000),
>>  &array3(2, 70, 20, 20), bar, start, finish
>>   integer i, j, k, l
>>   call srand(time())
>> c Initialize "array1" and "array2"
>>   do j = 1, 1000
>> do i = 1, 70
>>   array1(i, j) = rand()
>>   array2(i, j) = rand()
>> enddo
>>   enddo
>> c Initialize "array3"
>>   do l = 1, 2
>> do k = 1, 70
>>   do j = 1, 20
>> do i = 1, 20
>>   array3(i, j, k, l) = rand()
>> enddo
>>   enddo
>> enddo
>>   enddo
>> c Do the calculations
>>   bar = 0
>>   call cpu_time(start)
>>   do l = 1, 1000
>> do k = 1, 20
>>   do j = 1, 20
>> do i = 1, 70
>>   bar = bar +
>>  &(array1(i, l) - array3(1, i, j, k))**2 +
>>  &(array2(i, l) - array3(2, i, j, k))**2
>> enddo
>>   enddo
>> enddo
>>   enddo
>>   call cpu_time(finish)
>>   print "(f10.6, a)", finish - start, " seconds"
>>   end program main
>>
>> This is the result of running the two programs on my computer:
>>
>> % julia --version
>> julia version 0.4.5
>> % gfortran --version
>> GNU Fortran (Debian 5.3.1-20) 5.3.1 20160519
>> Copyright (C) 2015 Free Software Foundation, Inc.
>>
>> GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
>> You may redistribute copies of GNU Fortran
>> under the terms of the GNU General Public License.
>> For more information about these matters, see the file named COPYING
>>
>> % julia -f test.jl
>>   1.099910 seconds (84.00 M allocations: 1.252 GB, 7.14% gc time)
>> % gfortran test.f&&./a.out
>>   0.132000 seconds
>>
>> While Julia code is 3 times shorter than the Fortran77 code (and this one 
>> of the many reasons why I like Julia very much), it's also more than 8 
>> times slower and my build of Julia 0.5 (updated to aa1ce87) performs even 
>> worse, it takes about 1.4 seconds.  If I remove access to the arrays (just 
>> put "bar = bar" as loop body) then Julia is infinitely faster than Fortran 
>> in the sense that Julia takes 0.00 seconds, Fortran 0.056000.
>>
>> Is this difference to be expected or are there tricks to fasten the Julia 
>> code?  I should have gotten the order of nested loops right.  @inbounds 
>> doesn't help that much.  Parallelization is probably not an option because 
>> the code above is a small part of a larger loop that does data movement 
>> (can DistributedArrays help?).
>>
>> Bye,
>> Mosè
>>
>

[julia-users] Re: Is Julia slow with large arrays?

2016-06-01 Thread Lutfullah Tomak
First thing I caught in your code

http://docs.julialang.org/en/release-0.4/manual/performance-tips/#avoid-changing-the-type-of-a-variable

make bar non-type-changing
function foo()
array1 = rand(70, 1000)
array2 = rand(70, 1000)
array3 = rand(2, 70, 20, 20)
bar = 0.0
@time for l = 1:1000, k = 1:20, j = 1:20, i = 1:70
bar = bar +
(array1[i, l] - array3[1, i, j, k])^2 +
(array2[i, l] - array3[2, i, j, k])^2
end
end

Second, Julia checks array bounds so @inbounds macro before for-loop should 
help
improve performance. In some situation @simd may emit vector instructions 
thus faster
code.


[julia-users] Re: julia equivalent of python [] (Part II)

2016-06-01 Thread Lutfullah Tomak
julia> b_prime = ["8",9,10,c]

This works with Any.

julia> Any["3", 4, 14, c]
4-element Array{Any,1}:
   "3"
  4   
 14   
   Any[10,"c"]



[julia-users] Re: julia equivalent of python [] (Part II)

2016-06-01 Thread Lutfullah Tomak
Sorry for the noise it doesn't work obviously.


[julia-users] Re: julia equivalent of python [] (Part II)

2016-06-01 Thread Lutfullah Tomak
Do what the warning says. Replace ',' with ';', meaning ["8"; 9; 10; c] or [
"8"; 9;10; [12; "c"]]

On Wednesday, June 1, 2016 at 12:21:59 PM UTC+3, Andreas Lobinger wrote:
>
> Hello colleagues,
>
> i actually was a little bit puzzled by this:
>
>_
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "?help" for help.
>   | | | | | | |/ _` |  |
>   | | |_| | | | (_| |  |  Version 0.4.5 (2016-03-18 00:58 UTC)
>  _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
> |__/   |  x86_64-linux-gnu
>
> julia> a = [8,"9",10]
> 3-element Array{Any,1}:
>   8
>"9"
>  10
>
> julia> b = ["8",9,10,[12,"c"]]
> WARNING: [a,b,...] concatenation is deprecated; use [a;b;...] instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at ./abstractarray.jl:29
>  in vect at abstractarray.jl:38
> while loading no file, in expression starting on line 0
> 5-element Array{Any,1}:
>"8"
>   9
>  10
>  12
>"c"
>
> julia> c = [12,"c"]
> 2-element Array{Any,1}:
>  12
>"c"
>
> julia> b_prime = ["8",9,10,c]
> WARNING: [a,b,...] concatenation is deprecated; use [a;b;...] instead
>  in depwarn at deprecated.jl:73
>  in oldstyle_vcat_warning at ./abstractarray.jl:29
>  in vect at abstractarray.jl:38
> while loading no file, in expression starting on line 0
> 5-element Array{Any,1}:
>"8"
>   9
>  10
>  12
>"c"
>
>
> How do i put a list into a list? (bonus points for literals!)
>
>
>

[julia-users] Re: Opening a julia's IDE from a linux server

2016-05-25 Thread Lutfullah Tomak
You need to look at jupyter/ipython settings, specifically you need to 
allow your host ip for connection.
Related places are
https://ipython.org/ipython-doc/3/notebook/public_server.html
http://jupyter-notebook.readthedocs.io/en/latest/public_server.html


On Wednesday, May 25, 2016 at 10:54:53 AM UTC+3, hilili...@gmail.com wrote:
>
>
>
> Hello,
>
> I need to use julia through a linux server. I can use julia but I can not 
> properly use an IDE. I could instal IJulia but I can not open it by doing 
> using IJulia notebook().
> I can neither open notebook by doing ipython notebook (my access is 
> refused).
> Do you have any idea how could I open an IDE from the server in my 
> personal pc?
>
> Thank you very much!
> H.
>


[julia-users] Re: How is broadcast supposed to work?

2016-05-20 Thread Lutfullah Tomak
It is because promote_op(::Any, T) = (@_pure_meta; T)

julia> @which Base.promote_op(sin,Int64)
promote_op(::Any, T) at promotion.jl:226

julia> Base.promote_op(sin,Int64)
Int64

It seems promote_op assumes that all functions that does not specialize on 
it return element type of array.
On Friday, May 20, 2016 at 3:41:49 PM UTC+3, Scott T wrote:
>
> Noticed this when playing around with the new f.(x) syntax, which I 
> assumed would work like map.
>
> julia> map(sin, 3)
> 0.1411200080598672
>
> julia> map(sin, [3])
> 1-element Array{Float64,1}:
>  0.14112
>
> Map works like I'm used to: number goes to number, array goes to array.
>
> julia> sin.(3)  # same as broadcast(sin, 3)
> ERROR: InexactError()
>  in fill!(::Array{Int64,0}, ::Float64) at ./array.jl:155
>  in (::Base.Broadcast.#_F_#5)(::Array{Int64,0}, ::Int64) at 
> ./broadcast.jl:95
>  in broadcast!(::Function, ::Array{Int64,0}, ::Int64) at ./broadcast.jl:213
>  in broadcast(::Function, ::Int64) at ./broadcast.jl:220
>  in broadcast(::Function, ::Int64) at ./deprecated.jl:1130
>  in eval(::Module, ::Any) at ./boot.jl:225
>  in macro expansion at ./REPL.jl:92 [inlined]
>  in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
>
> julia> sin.([3])  # same as broadcast(sin, [3])
> ERROR: InexactError()
>  in macro expansion at ./broadcast.jl:95 [inlined]
>  in macro expansion at ./cartesian.jl:64 [inlined]
>  in (::Base.Broadcast.#_F_#6)(::Array{Int64,1}, ::Array{Int64,1}) at 
> ./broadcast.jl:90
>  in broadcast!(::Function, ::Array{Int64,1}, ::Array{Int64,1}) at 
> ./broadcast.jl:213
>  in broadcast(::Function, ::Array{Int64,1}) at ./broadcast.jl:220
>  in eval(::Module, ::Any) at ./boot.jl:225
>  in macro expansion at ./REPL.jl:92 [inlined]
>  in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
>
> Broadcast doesn't like integers in sin for some reason
>
> julia> sin.(3.)  # same as broadcast(sin, 3.)
> 0-dimensional Array{Float64,0}:
> 0.14112
>
> julia> sin.([3.])  # same as broadcast(sin, [3.])
> 1-element Array{Float64,1}:
>  0.14112
>
> And it produces a 0D array when called on a Number. So broadcast works 
> differently from map. 
>
> Is the error when called on an Int a bug, given that sin(3) is obviously 
> fine? And should calling it on a Number yield a Number or a 0D array? 
>


[julia-users] Re: Getting into macros nightmare!

2016-05-11 Thread Lutfullah Tomak
What you want to have is

julia> x = 33
33

julia> macro inc(a)
   esc(:($a = $a + 1))
   end

julia> @show macroexpand(:(@inc x))
macroexpand($(Expr(:quote, :(@inc x = :(x = x + 1)
:(x = x + 1)

julia> @show @inc x
@inc(x) = 34
34


1. You need esc I think otherwise
julia> macro inc(a)
   :($a = $a + 1)
   end

julia> @show macroexpand(:(@inc x))
macroexpand($(Expr(:quote, :(@inc x = :(#6#x = #6#x + 1)
:(#6#x = #6#x + 1)

It is just garbage ending with `x`

2. You should feed an expression to macroexpand to get the resulting 
expression from the macro


On Wednesday, May 11, 2016 at 1:21:09 PM UTC+3, Ford Ox wrote:
>
>
> *My struggle with macros*
> Lets code macro for increment, that should be fairly easy right?
> x = 33
> macro inc(x)
> :(x = x + 1)
> end
>
> @show @inc x
>
>> LoadError: UndefVarError: x not defined
>
>  
> Hmm, it's not so easy as I thought, I must be missing some very basic 
> knowledge, lets see whats happening inside. In docs they say* macroexpand* 
> should be used for debugging.
> x = 33
> macro inc(x) x end
> @show macroexpand(@inc x)
>
> macro inc(x) :x end
> @show macroexpand(@inc x)
>
> macro inc(x) :($x) end
> @show macroexpand(@inc x)
>
>> macroexpand(@inc(x)) = 33
>> macroexpand(@inc(x)) = 33
>> macroexpand(@inc(x)) = 33
>>
>
> Little confused : That didn't tell me anything... What type is *x *anyway?
> x = 33
> macro inc(x) 
> show(x)
> x
> end
> @inc(x)
>
>> :x
>>
>  
> So it is a symbol. In that case, why "*macro inc(x) :x end*" evaluates as 
> *"33" 
> *instead of "*:x*"??
> ...
> After hour of playing with macros I finally realize how to make use of 
> *macroexpand()*.
> x = 33
> v = 3
> w = :v
>
> ex = :(:(w = w + 1))
>
> macro inc(x)
> :(:(x = x + 1))
> end
>
> @inc v
> @show macroexpand(eval(ex))
>
>> macroexpand(eval(ex)) = :(w = w + 1)
>>
>
> And I also realize that I need to use interpolation...
> x = 33
> v = 3
> w = :v
>
> ex = :(:($w = $w + 1))
>
> macro inc(x)
> :(:($x = $x + 1))
> end
>
> @show macroexpand(eval(ex))
>
>> macroexpand(eval(ex)) = :(v = v + 1)
>>
>  
> Oh, that looks very nice. That's exactly what I wanted. My macro should 
> work exactly in the same way, since x ~ w and eval() is called 
> automatically when the line is executed...
> @show @inc v
>
>> @inc(v) = :(33 = 33 + 1)
>>
>  
> WOW, WTF?
>
>
>
>
>
>

[julia-users] Re: for loop with multiple variables

2016-05-10 Thread Lutfullah Tomak
for (i,j)=zip(0:5,6:10)
println(i+j)
end
On Tuesday, May 10, 2016 at 2:02:41 PM UTC+3, Vishnu Raj wrote:
>
> What  if the equivalent of the C code below
> for( i=0, j=6; i<=5, j <=10; i++, j++ ) print( "%d", i+j );
> in julia?
>


[julia-users] undefined reference error

2016-05-10 Thread Lutfullah Tomak
You need to initialize array entries if you don't have eltype as bitstype. 
Here, undefined reference means you had not initialize the entry. And, full 
type assignment works because it initializes the entry.

Re: [julia-users] promotion and conversion

2016-05-04 Thread Lutfullah Tomak
I think I wasn't clear. I was telling after your new method definition like

julia>convert(::Type{A1}, a::A2) = A1(a)  #without trailing semicolon
convert (generic function with 1 method)

Because you had trailing semicolon prompt did not show the result.

I agree that documentation should mention that in order to expand a 
module's function
one needs to import that function first. Otherwise it is just a new 
function for the current module.

Best,

On Wednesday, May 4, 2016 at 11:35:26 AM UTC+3, Arda Aytekin wrote:
>
> Hey Stefan,
>
> Actually, I did not import these functions, nor did I try extending 
> Base.{convert,promote_rule} versions.
>
> Following purely the documentation, one cannot understand easily whether 
> they should extend them, or not.
> Sorry for being dumb --- extending Base. versions solved my issue. But as 
> `g` says, this is not trivial
> at first try.
>
> And, as for your comment, Lutfullah Tomak, I can say I cannot notice that 
> there is only one method due to
> one reason. If you type `?promote_rule` in repl to see how it works, repl 
> gives you the correct function without
> any `Base.` preceding the function's name. Then, if you run 
> `methods(promote_rule)` prior to extending this
> function, you see again a list of `promote_rule`s which are already 
> defined in Julia. Finally, you assume (at
> least I assumed) that it is the very `promote_rule` function you need to 
> extend, not `Base.promote_rule`.
>
> The same applies to `convert`. 
>
> On Tuesday, May 3, 2016 at 7:31:56 PM UTC+2, Stefan Karpinski wrote:
>>
>> Did you import the convert and promote_rule functions?
>>
>> On Tue, May 3, 2016 at 12:21 PM, Arda Aytekin <ardaa...@gmail.com> wrote:
>>
>>> Hey,
>>>
>>> I am sorry if this question is either irrelevant or stupid, but I am 
>>> having problems figuring out the type promotion and conversions.
>>> Could you please explain to me why the below code excerpt is not giving 
>>> me what I want it to return:
>>>
>>> abstract A;
>>>
>>> immutable A1 <: A
>>> num::Float64
>>> end;
>>>
>>> immutable A2 <: A
>>> num::Int64
>>> end;
>>>
>>> # conversion
>>> A1(a::A2) = A1(a.num);
>>> convert(::Type{A1}, a::A2) = A1(a);
>>>
>>> # promotion
>>> promote_rule(::Type{A1}, ::Type{A2}) = A1;
>>>
>>> a1 = A1(1.);
>>> a2 = A2(2);
>>>
>>> promote(a1,a2)
>>> julia> (A1(1.0),A2(2))
>>>
>>> Why can I not get `(A1(1.0),A1(2.0))` for example, although the 
>>> `convert(::Type{A1}, a::A2)` method and the `A1(a::A2)` constructor
>>> are working properly. Or, am I missing something?
>>>
>>> I tried to follow the promotion and conversion section of documentation 
>>> <http://julia.readthedocs.org/>; however, I have not been successful so 
>>> far.
>>>
>>> Thanks!
>>>
>>
>>

Re: [julia-users] promotion and conversion

2016-05-03 Thread Lutfullah Tomak
Hi Arda,
As Stefan sad, you need import those Base functions or use Base.convert and 
Base.promote_rule to add a new method to them. You may notice in repl that if 
you do not import them after typing those methods you have only 1 methods for 
each of those functions.

Re: [julia-users] Pyplot and type definitions

2016-04-27 Thread Lutfullah Tomak
I cannot make sense of these warnings but you need to either import + from 
Base or explicitly use Base.(:+)
when overloading.
 
On Tuesday, April 26, 2016 at 11:35:02 PM UTC+3, samuel@gmail.com wrote:
>
> In my jupyter notebook, sequentially, I define types:
>
> workspace() # needed for redefining type
> type State
> position::Int
> spin::Array{Any,2}
> State() = new(0,[1 0]')
> State(position,spin) = new(position,spin)
> end
>
> and functions on types
>
> function +(s1::State, s2::State)
> #Linear combination
> if s1.position == s2.position
> s=State(s1.position,s2.spin+s1.spin)
> return s
> else
> return [s1,s2]
> end
> end
>
> then when I call
>
> using PyPlot
>
> the warnings are (I get no plots, only PyObject 
> )
>
> WARNING: Method definition remotecall(Function, Main.Base.LocalProcess, 
> Any...) in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:822 
> overwritten in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:822.
> WARNING: Method definition remotecall(Function, Main.Base.Worker, Any...) 
> in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:823 
> overwritten in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:823.
> WARNING: Method definition remotecall(Function, Integer, Any...) in module 
> Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:824 overwritten in 
> module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:824.
> WARNING: Method definition cor(AbstractArray{T<:Any, 2}, 
> AbstractArray{T<:Any, 2}, Integer) in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:888 overwritten in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:888.
> WARNING: Method definition cor(AbstractArray{T<:Any, 2}, Integer) in 
> module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:887 overwritten 
> in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:887.
> WARNING: Method definition readavailable(Main.Base.IOStream) in module 
> Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:905 overwritten in 
> module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:905.
> WARNING: Method definition 
> readavailable(Main.Base.AbstractIOBuffer{Array{UInt8, 1}}) in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:906 overwritten in module 
> Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:906.
> WARNING: Method definition remote_do(Function, Main.Base.LocalProcess, 
> Any...) in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:822 
> overwritten in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:822.
> WARNING: Method definition remote_do(Function, Main.Base.Worker, Any...) 
> in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:823 
> overwritten in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:823.
> WARNING: Method definition remote_do(Function, Integer, Any...) in module 
> Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:824 overwritten in 
> module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:824.
> WARNING: Method definition readlines(AbstractString) in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:904 overwritten in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:904.
> WARNING: Method definition remotecall_wait(Function, 
> Main.Base.LocalProcess, Any...) in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:822 overwritten in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:822.
> WARNING: Method definition remotecall_wait(Function, Main.Base.Worker, 
> Any...) in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:823 
> overwritten in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:823.
> WARNING: Method definition remotecall_wait(Function, Integer, Any...) in 
> module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:824 overwritten 
> in module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:824.
> WARNING: Method definition cov(AbstractArray{T<:Any, 1}, 
> AbstractArray{T<:Any, 1}, Bool) in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:883 overwritten in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:883.
> WARNING: Method definition cov(AbstractArray{T<:Any, 2}, 
> AbstractArray{T<:Any, 2}, Integer) in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:884 overwritten in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:884.
> WARNING: Method definition cov(AbstractArray{T<:Any, 2}, 
> AbstractArray{T<:Any, 2}, Integer, Bool) in module Compat at 
> /Users//.julia/v0.4/Compat/src/Compat.jl:885 overwritten in module Compat 
> at /Users//.julia/v0.4/Compat/src/Compat.jl:885.
> WARNING: Method definition cov(AbstractArray{T<:Any, 1}, Bool) in module 
> Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:880 overwritten in 
> module Compat at /Users//.julia/v0.4/Compat/src/Compat.jl:880.
> WARNING: Method definition cov(AbstractArray{T<:Any, 2}, Integer) in 
> module 

[julia-users] Re: julia ?

2016-04-26 Thread Lutfullah Tomak
Instruction from the error

  ENV["PYTHON"]=""
  Pkg.build("PyCall")

worked for me. Since sinecoef is defined I could not work out whole example but 
the rest worked 

with copy paste after above steps. If that does not work try removing and 
adding matplotlib with Conda.rm and Conda.add .

On Tuesday, April 26, 2016 at 11:14:10 AM UTC+3, Henri Girard wrote:
>
> Here is the code (sorry I forgot to join it ) : 
>
> using PyPlot
> n = 1:2:99 # odd integers from 1 to 99
> loglog(n, abs(sinecoef(f, n)), "bo")
> xlabel(L"n")
> ylabel(L"Fourier sine coefficient $|b_n|$")
> title(L"Sine series convergence for $f(x) = 0.5 - |x - 0.5|$")
> loglog(n, 1 ./ n.^2, "b--")
> legend([L"|b_n|", L"1/n^2"])
>
> Le mardi 26 avril 2016 08:23:57 UTC+2, Henri Girard a écrit :
>>
>> Hi,
>> It's really a pain to make julia (ijulia) works on native ubuntu 16.04. I 
>> tried conda env but after adding modules in julia I got a lot of errors 
>> specially with pycall pyplots ans scipy.
>> Can you advice me to have a good stable working julia (ijulia) on ubuntu, 
>> even if I must use conda doesn't matter. I am on this since few days and 
>> it's getting worse !
>> I even format my disk to make a fresh install... But I think it's worse 
>> ...
>> Best regards,
>> Henri
>>
>

[julia-users] Re: julia ?

2016-04-26 Thread Lutfullah Tomak
I use  julia 0.4.5 from Ubuntu 16.04 repository without any problem. As an 
IDE I prefer Atom and it works very well
and IJulia works too. I have not tried any other python related package for 
that matter but if you post specific errors
it'd be better.
On Tuesday, April 26, 2016 at 9:23:57 AM UTC+3, Henri Girard wrote:
>
> Hi,
> It's really a pain to make julia (ijulia) works on native ubuntu 16.04. I 
> tried conda env but after adding modules in julia I got a lot of errors 
> specially with pycall pyplots ans scipy.
> Can you advice me to have a good stable working julia (ijulia) on ubuntu, 
> even if I must use conda doesn't matter. I am on this since few days and 
> it's getting worse !
> I even format my disk to make a fresh install... But I think it's worse ...
> Best regards,
> Henri
>


[julia-users] Re: logic operations

2016-04-16 Thread Lutfullah Tomak
I think setdiff does what you want.
Ref http://docs.julialang.org/en/release-0.4/stdlib/collections/#Base.setdiff

On Saturday, April 16, 2016 at 7:05:39 PM UTC+3, digxx wrote:
>
> Say I have 2 arrays
> A=[1,2,3,4,5,6]
> B=[1,6,7]
> and the resulting array
> C=[2,3,4,5] = A NOT B results from a logical operation
> Is there already something implemented like this?
>


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

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

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


Re: [julia-users] The Arrays are hard to pre-allocate for me, are they possible to be pre-allocated?

2016-03-30 Thread Lutfullah Tomak
Surely not the main issue here but doing `length( ϕ[:, 1] )` wastes memory 
for nothing. Instead use `size(ϕ, 1)` ?
Also `for j1 in [1:n1-1; n2+1:ns]` this can be split to 2 for loops to 
avoid allocations and memory loads. 
j1 is off by 1 in indexing so just decrease ranges by 1 as `0:n1-2` and 
n2:ns-1` and use j1 instead of `j1-1` (The same for previous loop).

On Wednesday, March 30, 2016 at 8:58:55 AM UTC+3, 博陈 wrote:
>
> I rewrote my code and manually loop from 1:n, the pre-allocation problem 
> is solved. I also added some parenthesis as you suggested, that helps, but 
> not very much. 
>
> 在 2016年3月30日星期三 UTC+8上午1:56:47,Yichao Yu写道:
>>
>>
>>
>> On Tue, Mar 29, 2016 at 1:50 PM, 博陈  wrote:
>>
>>> Additionally, the allocation problem is not solved. I guess this 
>>> http://julia-programming-language.2336112.n4.nabble.com/How-to-avoid-temporary-arrays-being-created-in-a-function-td14492.html
>>>  might 
>>> be helpful, but I just don't know how to change my code.
>>>
>>>
>> The only places you create temporary arrays according to your profile is 
>> the `sum(A[1:n])` and you just need to loop from 1:n manually instead of 
>> creating an subarray
>>  
>>
>>>
>>>
>>> 在 2016年3月30日星期三 UTC+8上午1:15:07,Yichao Yu写道:
>>>


 On Tue, Mar 29, 2016 at 12:43 PM, 博陈  wrote:

> I tried the built-in profiler, and find that the problem lies in lines 
> I end  with **, the result is shown below:
> that proved my guess, how can I pre-allocate these arrays? If I don't 
> want to divide this code into several parts that calculate these arrays 
> separately. 
>

 I don't understand what you mean by `divide this code into several 
 parts that calculate these arrays separately`
  

> | lines | backtrace |
>
> |   169 |  9011 |  ***
>
> |   173 |  1552 |
>
> |   175 |  2604 |
>
> |   179 |  2906 |
>
> |   181 |  1541 |
>
> |   192 |  4458 |
>
> |   211 | 13332 |
>
> |   214 |  8431 |
>
> |   218 | 15871 |***
>
> |   221 |  2538 |
>
>
> 在 2016年3月29日星期二 UTC+8下午9:27:27,Stefan Karpinski写道:
>>
>> Have you tried:
>>
>> (a) calling @code_typewarn on your function
>> (b) using the built-in profiler?
>>
>>
>> On Tue, Mar 29, 2016 at 9:23 AM, 博陈  wrote:
>>
>>> First of all, have a look at the result.
>>>
>>>
>>> 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> My code calculates the evolution of 1-d 2-electron system in the 
>>> electric field, some variables are calculated during the evolution.
>>> According to the result of @time evolution, my code must have a 
>>> pre-allocation problem. Before you see the long code, i suggest that 
>>> the 
>>> hotspot might be around the Arrays prop_e, \phio, pp. I have learnt 
>>> that I 
>>> can use m = Array(Float64, 1) outside a "for" loop and empty!(m) and 
>>> push!(m, new_m) inside the loop to pre-allocate the variable m, but in 
>>> my 
>>> situations, I don't know how to pre-allocate these arrays.
>>>
>>> Below is the script (precisely, the main function) itself.
>>>
>>> function evolution(ϕ::Array{Complex{Float64}, 2},
>>>ele::Array{Float64, 1}, dx::Float64, dt::Float64,
>>>flags::Tuple{Int64, Int64, Int64, Int64})
>>> ϕg = copy(ϕ)
>>> FFTW.set_num_threads(8)
>>> ns = length( ϕ[:, 1] )
>>> x = get_x(ns, dx)
>>> p = get_p(ns, dx)
>>> if flags[4] == 1
>>> pp = similar(p)
>>> A = -cumsum(ele) * dt
>>> A² = A.*A
>>> # splitting
>>> r_sp = 150.0
>>> δ_sp = 5.0
>>> splitter = Array(Float64, ns, ns)
>>> end
>>> nt = length( ele )
>>>
>>> # # Pre-allocate result and temporary arrays
>>> #if flags[1] == 1
>>> σ = zeros(Complex128, nt)
>>> #end
>>> #if flags[2] == 1
>>> a = zeros(Float64, nt)
>>> #end
>>> #if flags[3] == 1
>>> r_ionization = 20.0
>>> n1 = round(Int, ns/2 - r_ionization/dx)
>>> n2 = round(Int, ns/2 + r_ionization/dx)
>>> ip = zeros(Float64, nt)
>>> #end
>>>
>>> # FFT plan
>>> p_fft! = plan_fft!( similar(ϕ), flags=FFTW.MEASURE )
>>>
>>> prop_x = similar( ϕ )
>>> prop_p = similar( prop_x )
>>> prop_e = similar( prop_x )
>>> # this two versions just cost the same time
>>> xplusy = Array(Float64, ns, ns)
>>> #xplusy = 

[julia-users] Re: I am Getting problem with julia and light table to work them together

2016-03-19 Thread Lutfullah Tomak
I thought you already have julia connected to lighttable. If not you need some 
plugins for lighttable most notably Jewel. I insist that you use Atom is 
because it is maintained regularly and tested more. Last time I used lighttable 
interface, it did not work and in every update of lighttable it breaks more.

[julia-users] Re: I am Getting problem with julia and light table to work them together

2016-03-19 Thread Lutfullah Tomak
Hi again,
Julia programmes not yet can be compiled in the sense that c and fortran 
can be compiled. You define your methods/functions and later you use them 
in real context. As your julia file executed from top to down, the main 
julia executable parses it to internal codes and as you call a function 
within the file julia converts it to machine code and  runs it similar to 
python but JITed.

I don't know what you mean by synchronize but you can run a part of code 
where cursor is in your file by just shift+enter.

I think you may better start with generic distribution at 
julilang.org/download to get feel how julia compilation works. Also, if you 
don't have a reason to use discontinued or deprecated lighttable IDE 
interface you'd better start with Atom IDE interface and instructions for 
it is here https://github.com/JunoLab/atom-julia-client/tree/master/manual 

Best,

On Thursday, March 17, 2016 at 2:13:39 PM UTC+2, tann...@gmail.com wrote:
>
> Hello Tomak,
>
> Please dont mind if I am asking stupid question because I am just beginner 
> on julia.I think I am not conveying you people right.Now I try again. I 
> wrote the program on Light table and now I want to compile this program on 
> julia.I dont know how I can synchronize both Julia and Light table.
>
> Best Regards 
>
> On Thursday, March 17, 2016 at 10:33:17 AM UTC+1, Lutfullah Tomak wrote:
>>
>> Hi.
>> I think you need Shift+Enter or equivalent on OSX? If you want to print 
>> something you can open console tab to see. Also there is 'Evaluate All' in 
>> one of the top down menus. 
>> But it'd better use new Atom interface because if you update lighttable 
>> you can break working setting.
>> Best,
>> On Thursday, March 17, 2016 at 11:24:20 AM UTC+2, tann...@gmail.com 
>> wrote:
>>>
>>> Hello Sebastian,
>>>
>>> Thank you for you reply. But when I open the light table it gives the 
>>> notification "Connect with julia".But just the problem is that I dont know 
>>> how to synchronize them both.Means if I write a program on light table then 
>>> how i can run on julia.
>>>
>>> Best Regards
>>>
>>> On Wednesday, March 16, 2016 at 12:51:47 PM UTC+1, randm...@gmail.com 
>>> wrote:
>>>>
>>>> Hi Tanveer,
>>>>
>>>> the Julia plugin for LightTable isn't maintened anymore. Recent work 
>>>> has focussed on getting Julia nicely integrated into Atom -- you can find 
>>>> the install instructions for that here 
>>>> <https://github.com/JunoLab/atom-julia-client/tree/master/manual>. 
>>>> There's also a nice piece on the Juno workflow and how it differs from the 
>>>> usual REPL workflow here 
>>>> <https://github.com/JunoLab/atom-julia-client/blob/master/manual/workflow.md>
>>>> .
>>>>
>>>> Best,
>>>> Sebastian
>>>>
>>>> Am Dienstag, 15. März 2016 15:07:27 UTC+1 schrieb tann...@gmail.com:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I installed julia and light table is also connect with julia.But I 
>>>>> dont know how to run code of light table on julia.Or we can say that how 
>>>>> to 
>>>>> make them on work together.
>>>>> Thank you for your time 
>>>>>
>>>>> BR,
>>>>> Tanveer
>>>>>
>>>>

[julia-users] Re: I am Getting problem with julia and light table to work them together

2016-03-19 Thread Lutfullah Tomak
Hi.
I think you need Shift+Enter or equivalent on OSX? If you want to print 
something you can open console tab to see. Also there is 'Evaluate All' in 
one of the top down menus. 
But it'd better use new Atom interface because if you update lighttable you 
can break working setting.
Best,
On Thursday, March 17, 2016 at 11:24:20 AM UTC+2, tann...@gmail.com wrote:
>
> Hello Sebastian,
>
> Thank you for you reply. But when I open the light table it gives the 
> notification "Connect with julia".But just the problem is that I dont know 
> how to synchronize them both.Means if I write a program on light table then 
> how i can run on julia.
>
> Best Regards
>
> On Wednesday, March 16, 2016 at 12:51:47 PM UTC+1, randm...@gmail.com 
> wrote:
>>
>> Hi Tanveer,
>>
>> the Julia plugin for LightTable isn't maintened anymore. Recent work has 
>> focussed on getting Julia nicely integrated into Atom -- you can find the 
>> install instructions for that here 
>> . 
>> There's also a nice piece on the Juno workflow and how it differs from the 
>> usual REPL workflow here 
>> 
>> .
>>
>> Best,
>> Sebastian
>>
>> Am Dienstag, 15. März 2016 15:07:27 UTC+1 schrieb tann...@gmail.com:
>>>
>>> Hello,
>>>
>>> I installed julia and light table is also connect with julia.But I dont 
>>> know how to run code of light table on julia.Or we can say that how to make 
>>> them on work together.
>>> Thank you for your time 
>>>
>>> BR,
>>> Tanveer
>>>
>>

Re: [julia-users] Julia on Android (and/or the web) - a scientific calculator on steroids.. good for tablets

2016-03-19 Thread Lutfullah Tomak
Hi again,
I tried to pull out what I have so far to write down a suggestion but I've 
lost them because I updated the ndk version and all related files deleted.
I tried again what I remember but I cannot build libgfortran this time 
cannot go on there.
Yet, I think adding an entry for this will attract interested students. 
Also, I think it can be broader in the sense that how julia can be ported 
other architectures
and/or systems.
Sorry for this.

On Thursday, March 10, 2016 at 2:38:04 PM UTC+2, Viral Shah wrote:
>
> If there is someone who applies with the right background in build 
> systems, Android and tooling, I am happy to find mentors - both on the 
> Julia and Android side to make this port successful. 
>
> The important thing is to get something up on the ideas page. 
>
> Another platform for an embedded port that has come up in my discussions 
> with people is openwrt. 
>
> -viral 
>
>
>
> > On 10-Mar-2016, at 5:52 PM, Ismael Venegas Castelló <ismael...@gmail.com 
> > wrote: 
> > 
> > Of course I understand that, it's not my intention to make assumptions 
> or tell people otherwise. I just wanted to show to the community that the 
> interest for Julia on Android is anything but fading away. I've never 
> participated in an event such as GSOC, but since this semester I return to 
> School I'm interested in considering this and the possibilities that may 
> arise. :D I'm going to educate myself about all that a GSOC project 
> entails, thanks for your help. 
> > 
> > El jueves, 10 de marzo de 2016, 5:22:53 (UTC-6), Lutfullah Tomak 
> escribió: 
> > Hi Ismael, 
> > As I said I cannot do on my own since I've just started a new job. If 
> there is an interested student I can help him/her though 
> > I am not software engineer. I've just curious about julia on android as 
> you are. So, it's a little overestimate you do on gitter 
> > sorry about that. I can write a suggestion about it in julia-opt or a 
> related place and intersted party can carry on there. 
> > 
> > On Thursday, March 10, 2016 at 6:38:37 AM UTC+2, Ismael Venegas Castelló 
> wrote: 
> > Here is a keep recap of what I've been able to achieve so far: 
> > 
> > * https://gitter.im/termux/termux?at=56e0f41a6fde057c26856001 
> > 
> > 
> > 
> > 
> > 
> > El miércoles, 9 de marzo de 2016, 10:35:53 (UTC-6), Lutfullah Tomak 
> escribió: 
> > Sure I can write a proposal or suggestion and  if there is an interested 
> student I can help the work. I use my phone a substitute for pc so much and 
> right now I use a linux chroot app for julia but it is slow compared to 
> native apps like termux provides. The thing is I've recently started to a 
> new job so it may not be straight away. 
> > 
> > On Wednesday, March 9, 2016 at 8:32:02 AM UTC+2, Viral Shah wrote: 
> > How about making this a GSOC project? Could you perhaps submit a PR to 
> the GSOC project page on julialang.org with these ideas, since you seem 
> to have made the most amount of progress here? 
> > 
> > -viral 
> > 
> > 
> > 
> > > On 09-Mar-2016, at 11:47 AM, Lutfullah Tomak <tomak...@gmail.com> 
> wrote: 
> > > 
> > > I think the most crictical one that toolchain misses is (lib)gfortran 
> support. I managed to build gfortran for cross compile but I think I am 
> missing pure hard float libgfortran to compile libopenblas with. For 
> android, libopenblas expect hard float libraries. In google provided 
> toolchain, hard float libraries in .../armv7-a/hard but I don't have 
> .../armv7-a/hard directory in my personal build of toolchain. Nevertheless, 
> I can build openblas with lapack support but netlib provided tests does not 
> work well. Blas passes tests. 
> > > Also, for some dependecies including llvm, there is an app called 
> termux. They have source package build system available at 
> https://github.com/termux/termux-packages . It can be helpful to look at. 
> They listed julia in their package suggestion page for some time 
> https://termux.com/package-suggestions.html . 
> > 
>
>

[julia-users] Re: Custom ranges

2016-03-14 Thread Lutfullah Tomak
filter(x->mod(x,7)!=0,0:100)

On Monday, March 14, 2016 at 8:57:20 PM UTC+2, Lutfullah Tomak wrote:
>
> Hi,
> I think you can do what you want with filter but it returns whole 
> collection
> filter(x>mod(x,7)!=0,0:100)
>
> On Monday, March 14, 2016 at 8:49:06 PM UTC+2, Jesse Jaanila wrote:
>>
>> Hi
>>
>> How could I build range (UnitRange) that doesn't include elements given 
>> some condition? Like
>> if i'd like to build a range that doesn't contain elements that are 
>> divisible by 7 ( x mod 7 == 0).
>> Is this possible for ranges or do I have to use some other type (it 
>> should be iterable)?
>>
>

[julia-users] Re: Custom ranges

2016-03-14 Thread Lutfullah Tomak
Hi,
I think you can do what you want with filter but it returns whole collection
filter(x>mod(x,7)!=0,0:100)

On Monday, March 14, 2016 at 8:49:06 PM UTC+2, Jesse Jaanila wrote:
>
> Hi
>
> How could I build range (UnitRange) that doesn't include elements given 
> some condition? Like
> if i'd like to build a range that doesn't contain elements that are 
> divisible by 7 ( x mod 7 == 0).
> Is this possible for ranges or do I have to use some other type (it should 
> be iterable)?
>


[julia-users] spawn detach process windows

2016-03-13 Thread Lutfullah Tomak
Hi,
IJulia.notebook has a keyword argument detached. Without that, I don't think 
you can detach server properly.
Try it with
IJulia.notebook(detached=true)

Re: [julia-users] Julia on Android (and/or the web) - a scientific calculator on steroids.. good for tablets

2016-03-10 Thread Lutfullah Tomak
Hi Ismael,
As I said I cannot do on my own since I've just started a new job. If there 
is an interested student I can help him/her though
I am not software engineer. I've just curious about julia on android as you 
are. So, it's a little overestimate you do on gitter
sorry about that. I can write a suggestion about it in julia-opt or a 
related place and intersted party can carry on there.

On Thursday, March 10, 2016 at 6:38:37 AM UTC+2, Ismael Venegas Castelló 
wrote:
>
> Here is a keep recap of what I've been able to achieve so far:
>
> * https://gitter.im/termux/termux?at=56e0f41a6fde057c26856001
>
>
> <https://lh3.googleusercontent.com/-7oxuTda5nZk/VuD6Rx2cskI/A9E/WDmYW4Lp8j0/s1600/julia-arm.jpg>
>
>
> El miércoles, 9 de marzo de 2016, 10:35:53 (UTC-6), Lutfullah Tomak 
> escribió:
>>
>> Sure I can write a proposal or suggestion and  if there is an interested 
>> student I can help the work. I use my phone a substitute for pc so much and 
>> right now I use a linux chroot app for julia but it is slow compared to 
>> native apps like termux provides. The thing is I've recently started to a 
>> new job so it may not be straight away. 
>>
>> On Wednesday, March 9, 2016 at 8:32:02 AM UTC+2, Viral Shah wrote:
>>>
>>> How about making this a GSOC project? Could you perhaps submit a PR to 
>>> the GSOC project page on julialang.org with these ideas, since you seem 
>>> to have made the most amount of progress here? 
>>>
>>> -viral 
>>>
>>>
>>>
>>> > On 09-Mar-2016, at 11:47 AM, Lutfullah Tomak <tomak...@gmail.com> 
>>> wrote: 
>>> > 
>>> > I think the most crictical one that toolchain misses is (lib)gfortran 
>>> support. I managed to build gfortran for cross compile but I think I am 
>>> missing pure hard float libgfortran to compile libopenblas with. For 
>>> android, libopenblas expect hard float libraries. In google provided 
>>> toolchain, hard float libraries in .../armv7-a/hard but I don't have 
>>> .../armv7-a/hard directory in my personal build of toolchain. Nevertheless, 
>>> I can build openblas with lapack support but netlib provided tests does not 
>>> work well. Blas passes tests. 
>>> > Also, for some dependecies including llvm, there is an app called 
>>> termux. They have source package build system available at 
>>> https://github.com/termux/termux-packages . It can be helpful to look 
>>> at. They listed julia in their package suggestion page for some time 
>>> https://termux.com/package-suggestions.html . 
>>>
>>>

[julia-users] Re: Julia on Android (and/or the web) - a scientific calculator on steroids.. good for tablets

2016-03-08 Thread Lutfullah Tomak
I think the most crictical one that toolchain misses is (lib)gfortran support. 
I managed to build gfortran for cross compile but I think I am missing pure 
hard float libgfortran to compile libopenblas with. For android, libopenblas 
expect hard float libraries. In google provided toolchain, hard float libraries 
in .../armv7-a/hard but I don't have .../armv7-a/hard directory in my personal 
build of toolchain. Nevertheless, I can build openblas with lapack support but 
netlib provided tests does not work well. Blas passes tests.
Also, for some dependecies including llvm, there is an app called termux. They 
have source package build system available at 
https://github.com/termux/termux-packages . It can be helpful to look at. They 
listed julia in their package suggestion page for some time 
https://termux.com/package-suggestions.html .

[julia-users] Current status of in-place ops

2016-03-03 Thread Lutfullah Tomak
Hi Marcin,

Here is an effort under Julia to conclude a final aproach based on actual user 
code.

https://groups.google.com/forum/m/#!topic/julia-users/_LduslpljpE

If you like you can contribute too.

[julia-users] Abstract typed array construction JIT performance

2016-03-03 Thread Lutfullah Tomak
Hi Colin,
I think if getindex inlined in vect it is not compiled seperately for your 
second run. Check code generated with @code_* for youreself.

[julia-users] Re: Difference between push! and append! ?

2016-03-02 Thread Lutfullah Tomak
Hi Ryan,
I believe you need to look at sizehint if you need to use push! or append! a 
lot 

Here a thread for it  
https://groups.google.com/forum/m/#!topic/julia-users/214uuJcCF6o
and julia doc
and reference 
http://docs.julialang.org/en/release-0.4/stdlib/collections/#Base.sizehint!

Best,

[julia-users] Standalone executables with Julia?

2016-02-29 Thread Lutfullah Tomak
I don't know any direct way to achive this at the moment. Also, depending upon 
what parts of julia you use, there would also be many dependencies that such 
binary to work. You can do 2 things for binaries

1. Embed your code to C code and link with -ljulia. 
2. Look at this post it has some hints at how to make a complete binary 
http://www.juliabloggers.com/static-and-ahead-of-time-aot-compiled-julia/

However, these will need everything julia depends to work normally.

Having said that, julia codes are usually distributed as packages. 
http://pkg.julialang.org

[julia-users] Re: Globally enable / disable @time execution

2016-02-29 Thread Lutfullah Tomak
Hi Adrian, I think macros always evaluated in parse time. AFAICT, While a macro 
parsed, unescaped names prepended with current namespace and macro local names 
are regenerated with GenSym to avoid collusions with names in current scope. I 
think esc() is for escaping this kind of modifications to parsed code. I find 
macroexpand very useful to look at what a macro returns and track what should 
be changed accordingly.

Re: [julia-users] Implicit call problem

2016-02-27 Thread Lutfullah Tomak
You can use promote_rule and its promote_op(If it is basic ops I think 
-AddGun-MulFun-etc-) variant but it would be awkward.

Re: [julia-users] Weird Hygiene Issue

2016-02-17 Thread Lutfullah Tomak
Hi
Will this achieve what you want?

module Z
g()=println("Z.g")
function h()
(current_module()).g()
end
end
module X
using Z
g()=println("X.g")
function f()
Z.h()
(current_module()).g()
end
end
module Y
using X
g()=println("Y.g")
X.f()
end

using Y

It prints Y.g twice. Or do you want h() to use X's g()?

[julia-users] Accessing factors in Bunch Kaufman factorization

2016-02-16 Thread Lutfullah Tomak
Hi,
In Julia, it is usually done for other factorization by indexing with symbols as
Afactored = factoring_func(A)
P=Afactored[:P]
However, searching by

methods(getindex,(Base.LinAlg.BunchKaufman, Symbol))

this factorization isn't available for that indexing.
Also, searching how this factorization type is defined by Julia

?Base.LinAlg.BunchKaufman

No documentation found.
Summary:
immutable Base.LinAlg.BunchKaufman{T,S<:AbstractArray{T,2}} <: Factorization{T}
Fields:
LD:: S<:AbstractArray{T,2}
ipiv  :: Array{Int32,1}
uplo  :: Char
symmetric :: Bool
rook  :: Bool

If you know what these fields refer you can define your getindex method for 
this factorization. You can get help looking up how other factorization defines 
getindex methods. Also, you can open an issue for this at github repo if not 
already done.
Note: I observed this on v0.5 but I guess it is the same for v0.4.
Best,

Re: [julia-users] Weird Hygiene Issue

2016-02-15 Thread Lutfullah Tomak
>From this issue
https://github.com/JuliaLang/julia/issues/15085
and trying macroexpand in module X itself I come to believe that it is not 
hyiene issue but side effect of -at-eval. Here is macroexpand instead of 
-at-eval -at-f _ex_func in module X
quote 
 # In[13], line 7:
function _ex_func() # In[13], line 8:
println("st")
end # In[13], line 11:
function _1ex_func() # In[13], line 12:
_ex_func() # In[13], line 13:
println("sty")
end # In[13], line 15:
export _ex_func # In[13], line 16:
export _1ex_func
end

Re: [julia-users] Weird Hygiene Issue

2016-02-15 Thread Lutfullah Tomak
Shouldn't it be if you escaped

julia> module X 
   macro p(y) 
 esc(quote 
   println($y) 
 end) 
   end 
   macro q(y) 
 quote 
   println(:($($y))) 
 end 
   end 
   end 
X 
 
julia> using X 
 
julia> test = "Hello, world" 
"Hello, world" 
 
julia> @X.p(test) 
"Hello, world" 
 
julia> @X.q(test) 
Hello, world 


[julia-users] Re: Error with Julia + Juno IDE bundle installation on Windows 10

2016-02-15 Thread Lutfullah Tomak
Hi Mike,

You did not answer my question. Assuming julia version from Juno is 0.3 then 
you need required packages. For that, julia needs to set up a fresh package 
directory. Pkg.init() sets up this directory. After that, Pkg.add("Jewel") 
should install required packages. If julia version is 0.4 then Juno should 
already have required packages. 
Best,

[julia-users] Re: Error with Julia + Juno IDE bundle installation on Windows 10

2016-02-14 Thread Lutfullah Tomak
Did you download from junolab.org? The latest verison(1.1.0) is at 

 https://junolab.s3.amazonaws.com/release/1.1.0/juno-windows-x64.zip

from julialang.org/downloads . It is bundled with all the required packages and 
julia 0.4.3 . Your downloaded Juno version seems old and it was not bundled 
with required packages for older versions. I suggest using new version if you 
do not need julia 0.3 .

If you willing you can also try Juno with Atom editor instead of Lightable 
derived one. New developmemt of Juno progresses around Atom editor. The link to 
the complete bundle is

https://github.com/JunoLab/atom/releases/download/0.3.0/JunoSetup.exe

from https://github.com/JunoLab/atom-julia-client/blob/master/README.md

[julia-users] Re: Weird Hygiene Issue

2016-02-14 Thread Lutfullah Tomak
It seems impossible then. What if _1ex_func has a fuction argument then you can 
pass _ex_func to _1ex_func or module as an argument and you call _ex_func from 
provided module?

[julia-users] Re: Weird Hygiene Issue

2016-02-14 Thread Lutfullah Tomak
Ok. If it helps there is

current_module()

that may help get arbitrary module you are calling _1ex_func from. if ex_func 
is in that module you can know which module ex_func is defined.

[julia-users] Weird Hygiene Issue

2016-02-14 Thread Lutfullah Tomak
Instead of 
@eval @f ex_func

this
eval(Main, @f ex_func)

might do that. I cannot test what you do with julia 0.5 because functions are 
now very diferent internally.
@eval @f ex_func
will be X.eval(@f ex_func) thus there will be X namespace but not outside of 
the module as shown from macroexpand.

[julia-users] Error with Julia + Juno IDE bundle installation on Windows 10

2016-02-13 Thread Lutfullah Tomak
Hi, welcome Julia.
You don't need to install julia separately. Juno has one in it with all the 
required packages. Somehow, your installation  of Juno is missing Requires 
package. 
First, in Juno press Ctrl+Space, enter `Julia: open a new terminal repl` and 
click to what shows up to open julia in console mode. 
Second, in julia repl, try `Pkg.update()` .
Third, when it finishes with success close everything and reopen Juno. 
Fourth, if it still fails, then open up the julia repl again and do 
`Pkg.add("Requires")` .  
Last, when it finishes,close everything and reopen Juno, see if it starts 
correctly.
If it still shows error please ask again.
Note:Omit quotation(`) while writing.

Re: [julia-users] Re: Googling the functions I need in Julia is hard

2016-02-12 Thread Lutfullah Tomak
Sorry deleted that post because that wasn't I used.

Re: [julia-users] Re: Googling the functions I need in Julia is hard

2016-02-12 Thread Lutfullah Tomak
For reference, I had used just 'deviation'.

http://docs.julialang.org/en/release-0.4/search/?q=deviation_keywords=yes=default#

Another instance of 'standard deviation' shows up in the search but this one 
when 'standard deviation' is searched. 

Re: [julia-users] Re: Googling the functions I need in Julia is hard

2016-02-12 Thread Lutfullah Tomak
For reference, it shows up in my search.

http://docs.julialang.org/en/release-0.4/search/?q=standard+deviation_keywords=yes=default

About google side, I think that MATLAB and R are used for years and thus 
results are indexed better for them.

[julia-users] Googling the functions I need in Julia is hard

2016-02-11 Thread Lutfullah Tomak
There is this one

http://docs.julialang.org/en/release-0.4/stdlib/math/#Base.std

Instead of google, I use this manual for search. 

[julia-users] ccall with an opaque struct

2016-02-11 Thread Lutfullah Tomak
Try
p = Ptr{Int}[]
julia> ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
Ref{Ptr{Int}}),"/dev/cu.usbmodem1413",p)

or

im;mutable Port
x:

[julia-users] Re: ccall with an opaque struct

2016-02-11 Thread Lutfullah Tomak
p = Ptr{Int}[0]
ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
Ref{Ptr{Int}}),"/dev/cu.usbmodem1413",p)

or

immutable Port
portpointer::Ptr{Void}
end
p=Port(0)
ccall((:sp_get_port_by_name, "libserialport"),Cint,(AbstractString, 
Ref{Port}),"/dev/cu.usbmodem1413",p)

Re: [julia-users] Re: ccall with an opaque struct

2016-02-11 Thread Lutfullah Tomak
Hi Yuchiao. Thanks for advice.


Re: [julia-users] Re: ccall with an opaque struct

2016-02-11 Thread Lutfullah Tomak
Sorry I couldn't test my examples. I'm glad someone more knowledgeable corrects 
the code.

I think the second one I'm suggesting needs to be

p=Ref{Port}() #looking Yuchiao comment.

I learn myself too, maybe I should look at docs again. Ref confuses me.

[julia-users] Multiple dispatch and AbstractString

2016-02-10 Thread Lutfullah Tomak
I think you need

g{T<:MyString}(x::Vector{T})

Have a look in 
http://docs.julialang.org/en/release-0.4/manual/types/#man-parametric-types for 
parametric types.

[julia-users] Computing a related concrete type

2016-02-10 Thread Lutfullah Tomak
Do yo mean something like

onedimless{T,N}(A::Array{T,N}) = Array{T,N-1}
?

[julia-users] Re: Computing a related concrete type

2016-02-10 Thread Lutfullah Tomak
For AbstractArray, a caveat is the actual type may have more parameters and 
cannot be sure about parameters' order.

[julia-users] Latest master: make command fails

2016-02-08 Thread Lutfullah Tomak
Hi All
After 'git pull' or new 'git clone', 'make full-source-dist' or 'make -C 
deps getall'
fails with

make[1]: *** No rule to make target 
'/path/to/julia/deps/srccache/libunwind-1.1-julia.tar.gz', needed by 
'get-unwind'.  Stop.
make[1]: *** Waiting for unfinished jobs

Do I have to get 'libunwind-1.1-julia.tar.gz' from somewhere manually?



Re: [julia-users] Latest master: make command fails

2016-02-08 Thread Lutfullah Tomak
Thanks Yichao, it works now.

[julia-users] julia build fails on arm

2016-02-08 Thread Lutfullah Tomak
I tried to build julia master on arm but build fails while linking libjulia.so
Fail message reads as

LINK usr/bin/julia
/path/to/julia/usr/lib/libjulia.so: undefined reference to `__register_frame'
/path/to/julia/usr/lib/libjulia.so: undefined reference to `__deregister_frame'
collect2: error: ld returned 1 exit status
Makefile:78: recipe for target '/path/to/julia/usr/bin/julia' failed
make[1]: *** [/path/to/julia/usr/bin/julia] Error 1
Makefile:93: recipe for target 'julia-ui-release' failed
make: *** [julia-ui-release] Error 2

Any suggestion?

[julia-users] julia build fails on arm

2016-02-08 Thread Lutfullah Tomak
I think there is a pull request now for this at

https://github.com/JuliaLang/julia/pull/14996

Sorry for the noise.

[julia-users] Re: Outer constructors for type aliases overwriting each other

2016-02-06 Thread Lutfullah Tomak
I cannot understand you well, I think then. Whenever you 'typealias' a type the 
new name will always be replaced with the actual type name before it is further 
compiled.
Your examples always converted to
TypeA(...) -> SomeType(...)
TypeB(...) -> SomeType(...)
Since both have the same argument types and number arguments the last one will 
be the one used later.
The most closest thing you can do is having 2 methods named TypeA and TypeB
that constructs two different instances of SomeType.

type SomeType
  name::ASCIIString
  value::Int
end
#No 'typealiase's
TypeA(x)=SomeType("A",x)
TypeB(x)=SomeType("B",x)

But TypeA and TypeB will not be 'type's.

I may have not understood you well but definetely, you cannot achieve what you 
want with 'typealias'.

[julia-users] Outer constructors for type aliases overwriting each other

2016-02-06 Thread Lutfullah Tomak
'typealias' is not for defining new type but calling a type different names. 
Therefore, TypeA and TypeB names refer to and is replaced by the same type 
namely SomeType.

Having said that, You may do

type SomeType{T}
   value::Int
end

Then, you can use typealias TypeA and TypeB as

typealias TypeA SomeType{:A}
typealias TypeB SomeType{:B}

You can have functions with SomeType{T} in general. When "A" or "B" is needed I 
guess you can use string(T) to get that.

[julia-users] "WARNING: Forcibly interrupting busy workers" when trying parallel computing in script mode on server

2016-02-03 Thread Lutfullah Tomak
Hi.
I'm not an expert of parallel stuff (Also, I cannot try it by myself) but my 
guess is you can fetch result so that main process does not close until it has 
the result.
Namely, add this at the end of main.jl

fetch(r)

[julia-users] Re: Elapsed CPU time in Julia?

2016-02-03 Thread Lutfullah Tomak
Hi
You may look what @time/@elapsed uses for timings

macroexpand(:(@time begin; 2+2; end))
or
macroexpand(:(@elapsed begin; 2+2; end))

>From these, It looks like you can use time_ns() 

[julia-users] Re: Julia vs Matlab: interpolation and looping

2016-02-02 Thread Lutfullah Tomak
Hi 
I attached the code I used and timings I get.
I used MSpline. If Dierckx is used my changes will be
less visible in timings since interpolations
take much more time.
Regards


splinetry.jl
Description: Binary data
  4.728200 seconds (197.23 k allocations: 5.225 GB, 10.38% gc time)

  3.798389 seconds (20.02 k allocations: 5.217 GB, 10.10% gc time)

  5.218026 seconds (67.92 k allocations: 10.434 GB, 12.10% gc time)

  5.207502 seconds (40.02 k allocations: 10.433 GB, 11.49% gc time)

  6.354629 seconds (73.30 k allocations: 15.650 GB, 14.14% gc time)

  6.326086 seconds (60.02 k allocations: 15.650 GB, 14.33% gc time)


[julia-users] Voronoi tess / ccall with Fortran

2016-02-02 Thread Lutfullah Tomak
I think you already know Fortran functions take arguments by reference/pointer. 
If there is not a typo in ccall some of the arguments are not Ptr but IntXX in 
the example. I suggest you use Ref instead of Ptr and just pass any variable 
since it will be converted automatically to a pointer. You can use Ref if you 
are in julia 0.4+. Warning suggest you use unsafe_convert since casting an 
integer a pointer is unsafe(I think).
Reference to ccall and Ref
http://docs.julialang.org/en/release-0.4/manual/calling-c-and-fortran-code/

[julia-users] Re: Julia vs Matlab: interpolation and looping

2016-02-02 Thread Lutfullah Tomak
I tried this examples. It only improves if xprime is not allocated over and 
over. Instead, try fill!(xprime,1.0) for ones(...). Also, colon indexing 
xprime[:] allocates memory. Instead, you can use reinterpret/reshape. In real 
code, xprime should not be re-allocated with ones method.
You can update it with @inbounds macro in for loops. At least, updating xprime 
and not using xprime[:] solves wasted allocations issue (by doing these in my 
trials overall allocated memory was around 1/3 of the original example).

[julia-users] Re: Julia vs Matlab: interpolation and looping

2016-01-30 Thread Lutfullah Tomak
I did not pay attention to stackoverflow post. There all code is wrapped around 
a function for some.
However, I was talking about examples here as in
 
for banana=1:NoIter
xprime=ones(Nalal,Naa)
W_temp = spl(xprime[:])
end

If all code run as it shown in the example here then Nalal, Naa are going to be 
checked for their types and 'ones' will be dispatced accordingly for each 
iteration in the loop.
Having looked at stackoverflow post, there are some differences.
I cannot try the codes right now. I wish I could tell something practical 
perspective using the code actually.

Regards

[julia-users] Re: SharedArray / parallel question

2016-01-30 Thread Lutfullah Tomak
There is this issue on on github 
https://github.com/JuliaLang/julia/issues/14764 . I am no expert about parallel 
computing but may be related.

Regards

[julia-users] Re: Julia vs Matlab: interpolation and looping

2016-01-30 Thread Lutfullah Tomak
If you do not change length of xprime or use it later for another purposes then 
just update existing array instead of re-allocating each time. Also, using 
global variables in the innermost loop is very inefficient in Julia. 
It would be good to revise the code in the light of this tips from docs 
http://docs.julialang.org/en/release-0.4/manual/performance-tips/

[julia-users] Weird problem when I call a C function from a DLL library inside a loop

2016-01-26 Thread Lutfullah Tomak
What is the C code for Study_create?

[julia-users] Julia on beaglebone

2016-01-23 Thread Lutfullah Tomak
If it is compatible with arm7 there is nigtly build on julialang.org/downloads 
for linux. If you want to build from source on machine it will take too long I 
think.

[julia-users] help with using Julia + Cilk

2016-01-22 Thread Lutfullah Tomak
It is unrelated to Julia because you are missing a python library that is 
needed by PyPlot. From error, I think you're missing numpy.

[julia-users] Interrupting script gives constant error

2016-01-22 Thread Lutfullah Tomak
I have a julia script that runs IJulia
as

#!/bin/sh
julia -e "using IJulia; notebook()"

Interrupting this script gives recurring error reading

jl_uv_writecb() ERROR: bad file descripter EBADF

and cannot be stopped. I needed to cancel because IJulia freezes giving warning 
lots of depreciation warning because of recent change in read* and write* 
function. I'm on 0.5-dev+2238 Commit 8e036b4. Debian Sid armc7-a.
How can I stop that errors and how I can I stop depreciation warnings.

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

2016-01-22 Thread Lutfullah Tomak
Thanks for your answer.
I later googled jl_uv_writecb. Basically, it happens because of depreciation 
warning. And, it also in repl too if a depreciated method is interrupted. 
Depreciation warning for readall would make IJulia unusable even if I use 
jupyter.

  1   2   >