Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @inbands, analogous to @inbounds #16

Closed
dlfivefifty opened this issue Nov 29, 2016 · 2 comments
Closed

Add @inbands, analogous to @inbounds #16

dlfivefifty opened this issue Nov 29, 2016 · 2 comments

Comments

@dlfivefifty
Copy link
Member

Create an @inbands to replicate the behaviour of @inbounds for the case where a user knows that the operation is inside the bands. This way the performance of @inbands A[k,j] should be equivalent to

@inbounds A.data[A.u + k - j + 1, j]
@dlfivefifty
Copy link
Member Author

It looks like @inbounds is hard coded into inference.jl, so it's not possible to replicate it's behaviour.

I think it's OK to use @inbounds to mean inside the band. @inbounds implicitly implies that the user knows something about the data storage, so if the user uses @inbounds incorrectly, it's their own fault.

@dlfivefifty
Copy link
Member Author

On second thought, this is a bad idea, as Base assumes @inbounds works for all indexes:

function copy!{T,N}(dest::AbstractArray{T,N}, src::AbstractArray{T,N})
    @boundscheck checkbounds(dest, indices(src)...)
    for I in eachindex(linearindexing(src,dest), src)
        @inbounds dest[I] = src[I]
    end
    dest
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant