On Mon, Sep 12, 2016 at 8:03 AM, Patrick Kofod Mogensen < patrick.mogen...@gmail.com> wrote:
> This surprised me as well, where did you find this syntax? > Call overload. > > > On Monday, September 12, 2016 at 1:59:33 PM UTC+2, DNF wrote: >> >> I haven't looked very closely at your code, but a brief look reveals that >> you are defining your functions in a very unusual way. Two examples: >> >> function (f::FIRFilter)(x) >> return filt(f, x) >> end >> >> function(p::pnseq)(n,T=Int64) >> out = Array{T}(n) >> for i in eachindex(out) >> if p.count < p.width >> p.cache = rand(Int64) >> p.count = 64 >> end >> out[i] = p.cache & p.mask >> p.cache >>= p.width >> p.count -= p.width >> end >> return out >> end >> >> I have never seen this way of defining them before, and I am pretty >> surprised that it's not a syntax error. Long-form function signatures >> should be of the form >> function myfunc{T<:SomeType}(myarg1::T, myarg2) >> where the type parameter section (in curly bracket) is optional. >> >> As I said, I'm surprised it's not a syntax error, but maybe it gets >> parsed as an anonymous function (just guessing here). If so, and if you are >> using version 0.4, you can get slow performance. >> >> You can read here about the right way to define functions: >> http://docs.julialang.org/en/stable/manual/functions/ >> >> On Monday, September 12, 2016 at 1:32:48 PM UTC+2, Neal Becker wrote: >>> >>> As a first (nontrivial) try at julia, I put together some simple DSP >>> code, >>> which represents a >>> pn generator (random fixed-width integer generator) >>> constellation mapping >>> interpolating FIR filter (from DSP.jl) >>> decimating FIR filter (from DSP.jl) >>> mean-square error measure >>> >>> Source code is here: >>> https://github.com/nbecker/julia-test >>> >>> Profile result is here: >>> https://gist.github.com/anonymous/af2459fc831ddbeb6e3be25e5c8d5197 >>> >>> If I understand how to read this profile (not sure I do) it looks like >>> 1/2 >>> the time is spent in PnSeq.jl, which seems surprising. >>> >>> PnSeq.jl calls rand() to get a Int64, caching the result and then >>> providing >>> N bits at a time to fill an Array. It's supposed to be a fast way to >>> get an >>> Array of small-width random integers. >>> >>> Most of the number crunching should be in the FIR filter functions, >>> which I >>> would have expected to use the most time. >>> >>> Anyone care to make suggestions on this code, how to make it faster, or >>> more >>> idiomatic Julia? I'm not proficient with Julia or with Matlab (I've >>> been >>> using python/numpy/c++ for all my work for years). >>> >>> >>>