Giter Club home page Giter Club logo

circulararrays.jl's Introduction

CircularArrays.jl - Multi-dimensional arrays with fixed size and circular indexing

Build Status codecov

CircularArrays.jl is a small package adding the CircularArray type which can be backed by any AbstractArray. A CircularArray{T,N,A} is an AbstractArray{T,N} backed by a data array of type A. It has a fixed size and features circular indexing (periodic boundary conditions) across all dimensions: Indexing and assigning beyond its bounds in both directions is possible, as the end of the array is considered adjacent to its start. CircularArrays have the same axes as the underlying backing array, and iterators only iterate over these indices.

The CircularVector{T} type is added as an alias for CircularArray{T, 1}.

The following constructors are provided.

# Initialize a CircularArray backed by any AbstractArray.
CircularArray(arr::AbstractArray{T, N}) where {T, N}
# Initialize a CircularArray with default values and the specified dimensions.
CircularArray(initialValue::T, dims...) where T
# Alternative functions for one-dimensional circular arrays.
CircularVector(arr::AbstractArray{T, 1}) where T
CircularVector(initialValue::T, size::Int) where T
# Alternative functions for two-dimensional circular arrays.
CircularMatrix(mat::AbstractArray{T, 2}) where T
CircularMatrix(initialValue::T, size::NTuple{2, Integer}) where T

Examples

julia> using CircularArrays
julia> a = CircularArray([1,2,3]);
julia> a[0:4]
5-element CircularVector(::Vector{Int64}):
 3
 1
 2
 3
 1
julia> using OffsetArrays
julia> i = OffsetArray(1:5,-2:2);
julia> a[i]
5-element CircularVector(OffsetArray(::Vector{Int64}, -2:2)) with indices -2:2:
 1
 2
 3
 1
 2

License

CircularArrays.jl is licensed under the MIT license. By using or interacting with this software in any way, you agree to the license of this software.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.