Giter Club home page Giter Club logo

fixedsizearrays.jl's Introduction

FixedSizeArrays

Join the chat at https://gitter.im/SimonDanisch/FixedSizeArrays.jl

Build Status Coverage Status codecov.io Build status

This package doesn't support 0.3

Packages that use FixedSizeArrays:

GeometryTypes.jl

Usage and advantages:

FixedSizeArrays is giving any composite type array like behavior by inheriting from FixedSizeArrays. So you can do something like this:

immutable RGB{T} <: FixedVectorNoTuple{3, T}
    r::T
    g::T
    b::T
    function RGB(a::NTuple{3, T}) #needs to be like this to keep constructor code sane
        new{T}(a[1], a[2], a[3])
    end
end
immutable Vec{N, T} <: FixedVector{N, T} # defined in FixedSizeArrays already
    _::NTuple{N, T}
end
Vec{3, Float32}(77) # constructor with 1 argument already defined
rand(Vec{3, Float64})+sin(Vec(0.,2.,2.)) # a lot of array functions are already defined
#There is also a matrix type
eye(Mat{3,3,Float32}) * rand(Vec{3, Float32}) # will also "just work"
a = Vec(1,2,3)[1:2] # returns (1,2)

Note that all of the above types are stack allocated and the speed of operations should be fairly fast! If you find operations to be slow, please file a bug report!

FixedSizeArrays can be used in a lot of different ways. You can define color types the same way, and arbitrary other point types like normals, vertices etc. As they all inherit from FixedSizeArray, it's very easy to handle them in the same way.

For some more advantages, you can take a look at MeshIO.

Because it's so easy to define different types like Point3, RGB, HSV or Normal3, one can create customized code for these types via multiple dispatch. This is great for visualizing data, as you can offer default visualizations based on the type. Without FixedSizeArrays, this would end up in a lot of types which would all need to define the same functions over and over again.

Roadmap

TODO's

  • Core Array
    • basic array interface
    • Inherit from DenseArray (a lot of warnings is caused by this)
    • use tuples as a basis
  • Indexing:
    • multidimensional access
    • colon access for matrices
    • multidimensional colon access
    • setindex!
    • setindex!/getindex for arrays of FSA (e.g. easy acces to single fields)
    • access slices e.g. Matrix{RGBA} -> Matrix{Red} (sort of)
  • Constructor
    • generic constructor for arbitrary Nvectors
    • fast constructor for arbitrary types
    • parsing constructor e.g Vec{3, Float32}(["23.", "23.", "0.23"])
    • different constructors for ease of use (zero, eye, from other FSAs, etc...) (could be more)
    • clean up constructor code (very messy since its hard to write constructors for abstract types)
  • Functions
    • all kinds of unary/binary operators
    • matrix multiplication
    • matrix functions (inv, transpose, etc...) (could be more)

Acknowledgements

ImmutableArrays by twadleigh was the package that got me going and gave the initial inspirations. There has been quite a few discussions on JuliaLang/julia#7568 shaping the implementation. Also, aaalexandrov supplied some code and inspirations. Big thanks to all the other contributors !

fixedsizearrays.jl's People

Contributors

c42f avatar cassiersg avatar cdsousa avatar dpsanders avatar gitter-badger avatar mschauer avatar rdeits avatar schlady avatar scottpjones avatar simondanisch avatar sjkelly avatar timholy avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.