Re: [julia-users] Function for checking monotonicity of higher-dimensional arrays

2015-08-12 Thread Nils Gudat
Thanks for all the suggestions! Since I'm still on 0.3.11, and only have to check a couple of fairly small arrays, I simply went with function checkmonotonicity(v::Array{Float64}) counter = Array(Int64, ndims(v)) for i = 1:ndims(v) counter[i] = sum(mapslices(issorted, v, i)) end

Re: [julia-users] Function for checking monotonicity of higher-dimensional arrays

2015-08-11 Thread Tim Holy
I actually think you don't need generated functions for this kind of stuff anymore. Our iterators have gotten to be sufficiently awesome for many tasks, especially with the LLVM optimizations that mean that things that _look_ like additions don't actually need to be performed :-) That said, I d

Re: [julia-users] Function for checking monotonicity of higher-dimensional arrays

2015-08-11 Thread Stefan Karpinski
The way to do this efficiently and generally is to use generated functions . You can generate specialized versions of this functionality for each dimensionality of array and shape of slice. On Tue, Aug 11, 2015 at 2:2

Re: [julia-users] Function for checking monotonicity of higher-dimensional arrays

2015-08-11 Thread Tim Holy
If you don't care about performance, the generalization of your method is `mapslices`. If you do care about performance and you're running Julia 0.4, check out the Cartesian iterators: http://docs.julialang.org/en/latest/manual/arrays/#iteration Something like: for I in CartesianRange(Istar

[julia-users] Function for checking monotonicity of higher-dimensional arrays

2015-08-11 Thread Nils Gudat
This is a re-post of sorts of a question I already asked a year ago in the user group. At the time, Stefan Karpinski proposed that base.issorted might be expanded to accomodate checking in multiple dimensions, but looking at the docs it seems this hasn't happened. This post now has two purposes: