[julia-users] fast columnwise norm of matrix/speed up mapslices?

2015-08-12 Thread jw3126
I have a matrix and I want to compute the norm of each column. I tried using TimeIt N = 10^6 mat = randn(3, N) @timeit mapslices(norm, mat, 1) 1 loops, best of 3: 915.13 ms per loop Dog slow, 100times slower then numpy: import numpy as np N = 10**6 mat = np.random.randn(3, N) %timeit

[julia-users] Re: fast columnwise norm of matrix/speed up mapslices?

2015-08-28 Thread jw3126
+ mat3[i]^2) end A end f (generic function with 2 methods) julia f(mat); julia @time f(mat); 0.008991 seconds (15 allocations: 7.630 MB) On Wednesday, August 12, 2015 at 11:09:06 AM UTC-4, jw3126 wrote: I have a matrix and I want to compute the norm of each

[julia-users] Re: Excessive memory allocations in for loop

2016-06-09 Thread jw3126
There is also the FixedSizeArrays package, which has much better performance and is much more memory friendly (the fixed size arrays are stack allocated) when dealing with small arrays . On Thursday, June 9, 2016 at 1:37:43 AM UTC+2, stst

[julia-users] How to produce the ≉ symbol?

2016-06-03 Thread jw3126
How to produce the ` ≉` character in julia? I tried detexify and it told me `\not\isapprox` but that does not work. More generally if I see some cool UTF-8 character how do I find out its Latex name?

[julia-users] Re: How to produce the ≉ symbol?

2016-06-03 Thread jw3126
Okay, thanks. I tried `\approx + tab + go 1 back + \not + tab` It gives me the same thing as `\not + tab + \approx + tab` on ubuntu with both atom and jupyter. It gives me something that does look roughly but not exactly like ≉. I think it is two symbols on top of each other, a slash thingy

[julia-users] Re: How to produce the ≉ symbol?

2016-06-03 Thread jw3126
Thanks, guys it works! On Friday, June 3, 2016 at 12:16:00 PM UTC+2, Avik Sengupta wrote: > > The canonical list of completions is in the latex_symbols.jl file within > the julia source > > https://github.com/JuliaLang/julia/blob/master/base/latex_symbols.jl#L546 > > On Friday, 3 June 2016

[julia-users] Parse Array of Bytes

2016-06-22 Thread jw3126
I have an array containing 4n bytes (::Array{UInt8,1}) and I want to parse it into an array of n Float32. What is a sane way of doing this?

[julia-users] Re: Parse Array of Bytes

2016-06-22 Thread jw3126
Thats exactly what I was looking for, thanks! On Wednesday, June 22, 2016 at 3:11:17 PM UTC+2, David van Leeuwen wrote: > > Probably just > > reinterpret(Float32, block) > > ---david > > On Wednesday, June 22, 2016 at 2:56:46 PM UTC+2, jw3126 wrote: >> >>

[julia-users] Drop element from tuple

2016-06-24 Thread jw3126
I have a Tuple and I want to drop its ith element (e.g. construct a new tuple with the same elements, except the ith is missing). For example (1,2,3,4) , 1 --> (2,3,4) (1,2,3,4) , 3 --> (1,2,4) (1,2,3,4) , 4 --> (1,2,3) How to do this?

[julia-users] Re: Drop element from tuple

2016-06-24 Thread jw3126
Okay thanks, it works! However it has extremely poor performance. I would love to do this stack allocated. ``` using BenchmarkTools function subtuple(t::Tuple,i::Integer) idx = 1:length(t) idx = setdiff(idx,i) t[idx] end @benchmark subtuple($(1,2,3,4), $1) ```

[julia-users] Re: Drop element from tuple

2016-06-24 Thread jw3126
ance: 5.00% memory tolerance: 1.00% memory estimate: 0.00 bytes allocs estimate: 0 minimum time: 6.00 ns (0.00% GC) median time: 6.00 ns (0.00% GC) mean time:6.11 ns (0.00% GC) maximum time: 70.00 ns (0.00% GC) On Friday, June 24, 2016 at 4:50:59 PM UTC+2,

[julia-users] Re: Plots with Plots

2016-06-24 Thread jw3126
Looks pretty awesome! On Friday, June 24, 2016 at 5:37:15 PM UTC+2, Tom Breloff wrote: > > I just uploaded the IJulia notebook which was my JuliaCon workshop: > https://github.com/tbreloff/ExamplePlots.jl/blob/master/notebooks/plotswithplots.ipynb > . > > You'll need to be on master or dev to

[julia-users] Re: Drop element from tuple

2016-06-26 Thread jw3126
e fact that a tuple is immutable so you need to > construct a new one from scratch. > > On Saturday, June 25, 2016 at 9:45:06 AM UTC-4, jw3126 wrote: >> >> @Sisyphuss: The problem with vectors is that they are always heap >> allocated. If you do stuff involving lots of small si

[julia-users] Re: Drop element from tuple

2016-06-25 Thread jw3126
tuple? On Saturday, June 25, 2016 at 12:45:55 PM UTC+2, Sisyphuss wrote: > > Why not use `vector`? > > On Friday, June 24, 2016 at 4:16:49 PM UTC+2, jw3126 wrote: >> >> I have a Tuple and I want to drop its ith element (e.g. construct a new >> tuple with the same elements, exc

[julia-users] Investigating instances of parametric types

2016-02-15 Thread jw3126
I have an instance of a parametric type, is there a canonical way to get the parameter values? For example I could have some Array{T, d} and want to know whether T is Float64 and what its dimension is. The only way of doing this I am aware of is writing code like: dimension{T,

[julia-users] Re: Investigating instances of parametric types

2016-02-15 Thread jw3126
016 at 2:14:35 PM UTC+1, jw3126 wrote: >> >> I have an instance of a parametric type, is there a canonical way to get >> the parameter values? >> For example I could have some Array{T, d} and want to know whether T is >> Float64 and what its dimension is. >>

Re: [julia-users] Re: Investigating instances of parametric types

2016-02-15 Thread jw3126
go > about this kind of manipulation. > > Best, > --Tim > > On Monday, February 15, 2016 05:28:19 AM Bart Janssens wrote: > > There is the parameters field of the types, but I'm not sure if that's > > considered private. You can do > > Array{Float6

Re: [julia-users] Type parameters and Numbers

2016-03-09 Thread jw3126
Nice this is much cleaner! On Wednesday, March 9, 2016 at 10:49:03 AM UTC+1, Milan Bouchet-Valat wrote: > > Le mercredi 09 mars 2016 à 01:41 -0800, jw3126 a écrit : > > I want to construct an immutable parametrized by a number dim, which > > has a field of type Tuple{Int64,

[julia-users] Possible to chain iterators efficiently?

2016-03-31 Thread jw3126
Is it possible to chain iterators in julia efficiently? By chaining I mean the following. I have a tuple of iterators and I would like to have a function "chain" such that for itr in iters, i in itr ... end is equivalent to for i in chain(iters) ... end I found such a function in the

[julia-users] Re: raytracing in julia

2016-04-06 Thread jw3126
Thanks for the help offer! It is good to have something boost.julia style. At the moment it looks like I will not have enough time to wrap FireRays though. On Friday, March 25, 2016 at 2:54:01 PM UTC+1, jw3126 wrote: > > I need to do things like building a simple geometry which co

[julia-users] Dropping or replacing NaNs from array

2016-04-07 Thread jw3126
I have an array, which has some NaNs and I want to do things like replace them by 42 or delete them. What is the canonical way to do this?

[julia-users] Re: Dropping or replacing NaNs from array

2016-04-07 Thread jw3126
eplace with 42, maybe: >> >> map!((i) -> isnan(i)? 42 : i, a) >> >> to delete: >> >> deleteat!(a, find(isnan, a)) >> >> >> >> >> On Thursday, April 7, 2016 at 2:33:56 PM UTC+2, jw3126 wrote: >>> >>> I have an array, which has some NaNs and I want to do things like >>> replace them by 42 or delete them. What is the canonical way to do this? >>> >>

[julia-users] raytracing in julia

2016-03-25 Thread jw3126
I need to do things like building a simple geometry which consists of a few polygons, cylinders, spheres and calculate if/where rays hit these objects. Is there some julia library which does this already? Or some easy to wrap C/Fortran library? Any suggestions? I would prefer a solution, which

Re: [julia-users] DataFrame from string

2016-03-23 Thread jw3126
> > On Mon, Mar 21, 2016 at 9:28 AM, jw3126 <jw3...@gmail.com > > wrote: > >> I have a string which is secretly a csv like >> """ >> 1, 7.6 >> 2, 45.6 >> 3, 12.1 >> ... >> """ >> >> I want to

[julia-users] Type parameters and Numbers

2016-03-09 Thread jw3126
I want to construct an immutable parametrized by a number dim, which has a field of type Tuple{Int64, Int64, ... } where Int64 is repeated dim times. I tried immutable SomeType{dim} x :: Tuple{repeat([Int64], outer = [dim])...} end However this gives the following error: LoadError:

[julia-users] Re: raytracing in julia

2016-03-30 Thread jw3126
t; > Am Freitag, 25. März 2016 14:54:01 UTC+1 schrieb jw3126: >> >> I need to do things like building a simple geometry which consists of a >> few polygons, cylinders, spheres and calculate if/where rays hit these >> objects. >> >> Is there some julia librar

[julia-users] How to test if a type is concrete?

2016-04-01 Thread jw3126
How to check if a Type is concrete? e.g. isconcrete(Array{Float64, 1}) true isconcrete(Int) false Also is there an established way to check if the return value of a function is type stable for given input? (e.g. check if @code_warntype shows return type in ALL CAPS.)

[julia-users] Re: raytracing in julia

2016-03-29 Thread jw3126
> you started. > > Best, > Simon > > > Am Freitag, 25. März 2016 14:54:01 UTC+1 schrieb jw3126: >> >> I need to do things like building a simple geometry which consists of a >> few polygons, cylinders, spheres and calculate if/where rays hit these >

Re: [julia-users] How to test if a type is concrete?

2016-04-01 Thread jw3126
Thanks! On Friday, April 1, 2016 at 2:45:58 PM UTC+2, Yichao Yu wrote: > > On Fri, Apr 1, 2016 at 8:32 AM, jw3126 <jw3...@gmail.com > > wrote: > > How to check if a Type is concrete? e.g. > > > > isconcrete(Array{Float64, 1}) > > true > &g

Re: [julia-users] Possible to chain iterators efficiently?

2016-03-31 Thread jw3126
ay, March 31, 2016 01:44:17 AM jw3126 wrote: > > Is it possible to chain iterators in julia efficiently? By chaining I > mean > > the following. I have a tuple of iterators and I would like to have a > > function "chain" such that > > > > for i

[julia-users] Re: Compute Hashes

2016-05-13 Thread jw3126
Thanks! On Wednesday, May 11, 2016 at 2:13:51 PM UTC+2, Kristoffer Carlsson wrote: > > For SHA hashes there is this package: > https://github.com/staticfloat/SHA.jl

[julia-users] Compute Hashes

2016-05-11 Thread jw3126
I have a string and I want to compute its sha-1 and maybe also other hashes. What is a good way to do this in julia? (There is a function `hash` in Base, though I am not sure what hash it computes or whether it will be changed over time.)

[julia-users] Re: Tuple type to tuple of types

2016-07-26 Thread jw3126
Thanks! On Sunday, July 24, 2016 at 1:52:47 PM UTC+2, jw3126 wrote: > > I need a function, which accepts an arbitrary tuple type and returns the > types of the components of the tuple. For example > ``` > f(Tuple{Int64, Float64})--> (Int64, Float64) >

[julia-users] Tuple type to tuple of types

2016-07-24 Thread jw3126
I need a function, which accepts an arbitrary tuple type and returns the types of the components of the tuple. For example ``` f(Tuple{Int64, Float64})--> (Int64, Float64) f(Tuple{Int64, MyType, Float32}) --> (Int64, MyType, Float32) f(NTuple{3})

[julia-users] Numer of ones in bitstype

2016-08-11 Thread jw3126
I have a bitstype and want to know the number of ones in its bit representation as well as the first bit. How to accomplish these in a performant way?

Re: [julia-users] Re: Numer of ones in bitstype

2016-08-14 Thread jw3126
>> I hope that LLVM generates the same machine code for this as for Steven's >> bit masks above. Using bit masks is more general since it allows you to >> test every bit, not just the "first" (sign) bit. >> >> -erik >> >> >> On Sat, Aug 13, 20

Re: [julia-users] Numer of ones in bitstype

2016-08-12 Thread jw3126
h: count_ones count_zeros >> >> count_ones(x::Integer) -> Integer >> >> Number of ones in the binary representation of x. >> >> julia> count_ones(7) >> 3 >> >> >> On Thu, Aug 11, 2016 at 1:48 PM, jw3126 <jw3...@gmail.com >

Re: [julia-users] Numer of ones in bitstype

2016-08-13 Thread jw3126
ore efficient way in julia? On Friday, August 12, 2016 at 2:10:37 PM UTC+2, jw3126 wrote: > > Thank you both! > > On Thursday, August 11, 2016 at 9:17:13 PM UTC+2, Erik Schnetter wrote: >> >> See also "leading_zeros". >> >> -erik >> >> On Thu,

Re: [julia-users] Numer of ones in bitstype

2016-08-13 Thread jw3126
day, August 12, 2016 at 2:10:37 PM UTC+2, jw3126 wrote: > > Thank you both! > > On Thursday, August 11, 2016 at 9:17:13 PM UTC+2, Erik Schnetter wrote: >> >> See also "leading_zeros". >> >> -erik >> >> On Thu, Aug 11, 2016 at 1:52 PM, T

[julia-users] Re: Numer of ones in bitstype

2016-08-13 Thread jw3126
gt; justified in the word (if you consider the msb as being the rightmost bit). > If you want the most significant 1 bit set, then leading_zeros(x) (which > other people have already mentioned). > > On Thursday, August 11, 2016 at 7:48:08 PM UTC+2, jw3126 wrote: >> >> I have

[julia-users] Re: Writable arrays

2016-07-12 Thread jw3126
I think FixedSizeArrays are immutable. On Tuesday, July 12, 2016 at 2:09:30 PM UTC+2, Jeffrey Sarnoff wrote: > > If your arrays keep their shape and dimensionality, the FixedSizeArrays > package is > worthwhile. > > On Wednesday, June 15,

Re: [julia-users] Re: Drop element from tuple

2016-06-27 Thread jw3126
Thanks again Tim! On Sunday, June 26, 2016 at 1:41:36 PM UTC+2, Tim Holy wrote: > > On Saturday, June 25, 2016 6:45:05 AM CDT jw3126 wrote: > > @Tim: Thanks for the insights! On my machine slowness starts to kick in > at > > size 9 already. > > Depends on which vers

[julia-users] What does x,y = t get desugared into?

2016-06-29 Thread jw3126
If I have some julia code like ``` x,y = t ``` what does this get desugared into? From playing with @code... macros it seems that it is not exactly the same as x = t[1]; y = t[2]? More generally if I have some julia expression, how can I find out what it gets desugared into?

[julia-users] Fixing some parameters of parametrized type?

2016-07-01 Thread jw3126
I have some Types, which depend on a few parameters: type Foo{f,o} ... end type Bar{b,a,r} ... end and I have a function between them bar{f,o}(_::Foo{f,o}) = ... for which julia has problems inferring the output type. So I want to annotate it. Unfortunately I only know some parameters of the

Re: [julia-users] What does x,y = t get desugared into?

2016-06-29 Thread jw3126
Thanks! On Wednesday, June 29, 2016 at 12:52:44 PM UTC+2, Yichao Yu wrote: > > On Wed, Jun 29, 2016 at 5:27 AM, jw3126 <jw3...@gmail.com > > wrote: > > If I have some julia code like > > ``` > > x,y = t > > ``` > > It uses the iterator

[julia-users] Re: Fixing some parameters of parametrized type?

2016-07-04 Thread jw3126
Thanks for the help! On Saturday, July 2, 2016 at 9:25:54 AM UTC+2, Fengyang Wang wrote: > > I don't know about performance or correctness, but it *is* possible to do > something like this: > > x :: SomeType{X, TypeVar(:T), Z} > > but I think the typealias is a better solution. >

[julia-users] wrapping a julia package

2016-08-26 Thread jw3126
I want to use a julia package (SFML.jl), which defines its own types for lots of basic things like 2d vectors, rectangles colors etc. It would be cool however if one could use its functionality with "standard types", like colors from Colors.jl, StaticArrays.jl vectors, GeometryTypes.jl

[julia-users] control inline at callsite?

2016-09-26 Thread jw3126
Is it possible to control inline behaviour of a function purely from the callsite? I have a function f and I call it at several places. At some places I want it to get it inlined and at others not. I do not want to touch the code of f at all (like adding @inline macro to it etc.). f(...) =

[julia-users] Re: small array/vector ops with broadcast and generators?

2016-09-26 Thread jw3126
If your code consists mainly of small arrays, you may want to have a look at the FixedSizeArrays or StaticArrays package. These provide fast and convenient stack allocated arrays. On Sunday,

[julia-users] Trait for exactness of numbers

2016-10-24 Thread jw3126
A couple of times I was in a situation, where I had two algorithms solving the same problem, one which was faster and one which was more numerically stable. Now for some types of numbers (FloatingPoint, Complex{Float64}...) numerical stability is important while for others it does not matter

[julia-users] Reductions sometimes not typestable?

2016-10-15 Thread jw3126
myop(::Int16, ::Int16) = Int32(1) myop(::Int16, ::Int32) = Int64(1) myop(::Int16, ::Int64) = Int128(1) myop(::Int16, ::Int128) = Int128(1) foldr(myop, Int16[1]) |> typeof |> println foldr(myop, Int16[1,1]) |> typeof |> println foldr(myop, Int16[1,1,1]) |> typeof |> println foldr(myop,

Re: [julia-users] Reductions sometimes not typestable?

2016-10-15 Thread jw3126
On Sunday, October 16, 2016 at 12:12:14 AM UTC+2, Yichao Yu wrote: > > > > 2016-10-15 18:06 GMT-04:00 jw3126 <jw3...@gmail.com >: > >> myop(::Int16, ::Int16) = Int32(1) >> myop(::Int16, ::Int32) = Int64(1) >> myop(::Int16, ::Int64) = Int128(1) >> my