Re: [julia-users] how use find ?

2014-07-14 Thread Tim Holy
Your function isn't really using a pre-allocated output , because you're creating I. To really use the preallocated output (indexes), you'll need to set values in that array. resize! might be useful here, or you could use push!. Regarding the warnings, I have no idea, but it looks like you've

Re: [julia-users] how use find ?

2014-07-13 Thread Tim Holy
If this really matters to you, check out the implementations of find in base/array.jl. It's so short, you can trivially implement whatever behavior you want. For example, you could pass in an empty output array and have it push! the indexes into it. --Tim On Saturday, July 12, 2014 12:43:29

Re: [julia-users] how use find ?

2014-07-13 Thread J Luis
Thanks. That's what I intend to do but I confess that I find the default to Int64 a bit annoying (for example when writing wrappers to C functions whre the Int(s) arguments are almost never Int64) Domingo, 13 de Julho de 2014 10:50:12 UTC+1, Tim Holy escreveu: If this really matters to you,

Re: [julia-users] how use find ?

2014-07-13 Thread Tim Holy
On Sunday, July 13, 2014 11:38:46 AM J Luis wrote: Thanks. That's what I intend to do but I confess that I find the default to Int64 a bit annoying (for example when writing wrappers to C functions whre the Int(s) arguments are almost never Int64) I can understand that. On the other hand,

Re: [julia-users] how use find ?

2014-07-13 Thread Tim Holy
But actually your point is a good one, and is one more argument for https://github.com/JuliaLang/julia/issues/1115 Over time more and more functions have been modified to have this type of interface, so certainly there is room for a find!(indexes, testf::Function, x) function. `find` could

Re: [julia-users] how use find ?

2014-07-13 Thread J Luis
Hmm, tried my luck ... but If I add this to bitarray.jl find(B::BitArray) = find(Int[], B::BitArray) function find(indexes, B::BitArray) l = length(B) nnzB = countnz(B) #I = Array(Int, nnzB) I = similar(indexes, nnzB) it works but I also get these strange warnings when

[julia-users] how use find ?

2014-07-12 Thread paul analyst
I need all indexes where a[:] 5 julia a=rand(10)*10 10-element Array{Float64,1}: 4.84005 8.29994 8.8531 3.42319 2.60318 7.25313 0.816263 4.44463 6.71836 4.65337 julia a.5 10-element BitArray{1}: false true true false false true false false true false julia find(a.5,a)

Re: [julia-users] how use find ?

2014-07-12 Thread Cameron McBride
julia find( a . 5 ) cheers, Cameron On Sat, Jul 12, 2014 at 11:40 AM, paul analyst paul.anal...@mail.com wrote: I need all indexes where a[:] 5 julia a=rand(10)*10 10-element Array{Float64,1}: 4.84005 8.29994 8.8531 3.42319 2.60318 7.25313 0.816263 4.44463 6.71836

Re: [julia-users] how use find ?

2014-07-12 Thread programistawpf
Big thx. In documentation is : find(f, A) Return a vector of the linear indexes of A where f returns true. (function, OBJECT) What You think, s it error in documention ? Paul W dniu sobota, 12 lipca 2014 17:52:05 UTC+2 użytkownik Cameron McBride napisał: julia find( a . 5 ) cheers,

Re: [julia-users] how use find ?

2014-07-12 Thread Leah Hanson
The problem is that `a . 5` is a BitArray, not a function. ~~~ julia a = rand(10) * 10 10-element Array{Float64,1}: 5.5408 5.52724 2.87541 1.59491 0.278013 1.56604 8.29388 8.27159 0.737642 7.40957 julia find(x-x5,a) 5-element Array{Int64,1}: 1 2 7 8 10 ~~~ When you call

Re: [julia-users] how use find ?

2014-07-12 Thread J Luis
julia find(x-x5,a) 5-element Array{Int64,1}: 1 2 7 8 10 which very very sadly are Int64. When dealing with large matrices this may lead to a large memory waste. These almost mandatory 64 bits issue is one the things that annoyed me more in Matlab for many times it was the

Re: [julia-users] how use find ?

2014-07-12 Thread John Myles White
I’m really confused. Do you want the indices to be 32-bit integers instead of 64-bit integers? Isn’t that equivalent to asking for your code to be broken anytime your vector has more than typemax(Int32) elements? — John On Jul 12, 2014, at 12:43 PM, J Luis jmfl...@gmail.com wrote: julia

Re: [julia-users] how use find ?

2014-07-12 Thread J Luis
I’m really confused. Do you want the indices to be 32-bit integers instead of 64-bit integers? Yes. Isn’t that equivalent to asking for your code to be broken anytime your vector has more than typemax(Int32) elements? That is also true but a much more rare case, typemax(Int32) is

Re: [julia-users] how use find ?

2014-07-12 Thread John Myles White
On Jul 12, 2014, at 1:04 PM, J Luis jmfl...@gmail.com wrote: That is also true but a much more rare case, typemax(Int32) is still a quite high number for an array size and before an Int64 is needed changes are non negligible that a memory requested failed because a big contigous chunk of

Re: [julia-users] how use find ?

2014-07-12 Thread J Luis
Sábado, 12 de Julho de 2014 21:16:04 UTC+1, John Myles White escreveu: On Jul 12, 2014, at 1:04 PM, J Luis jmf...@gmail.com javascript: wrote: That is also true but a much more rare case, typemax(Int32) is still a quite high number for an array size and before an Int64 is needed

Re: [julia-users] how use find ?

2014-07-12 Thread Stefan Karpinski
On 32-bit systems, Int is Int32. 64-bit systems tend to have enough memory, not to mention the fact that pointers, indices, etc. are natively 64-bit on those systems. On Sat, Jul 12, 2014 at 1:21 PM, J Luis jmfl...@gmail.com wrote: Sábado, 12 de Julho de 2014 21:16:04 UTC+1, John Myles White

Re: [julia-users] how use find ?

2014-07-12 Thread J Luis
yes, but those are scalars not (potentially big) arrays. Sábado, 12 de Julho de 2014 21:33:17 UTC+1, Stefan Karpinski escreveu: On 32-bit systems, Int is Int32. 64-bit systems tend to have enough memory, not to mention the fact that pointers, indices, etc. are natively 64-bit on those

Re: [julia-users] how use find ?

2014-07-12 Thread Stefan Karpinski
You can easily make an Array{Int32}. I'm not sure if that's your point or not. On Sat, Jul 12, 2014 at 1:51 PM, J Luis jmfl...@gmail.com wrote: yes, but those are scalars not (potentially big) arrays. Sábado, 12 de Julho de 2014 21:33:17 UTC+1, Stefan Karpinski escreveu: On 32-bit systems,