https://github.com/emmt/flatarrays.jl
Flat arrays for Julia (for fast linear indexing)
https://github.com/emmt/flatarrays.jl
Last synced: 5 months ago
JSON representation
Flat arrays for Julia (for fast linear indexing)
- Host: GitHub
- URL: https://github.com/emmt/flatarrays.jl
- Owner: emmt
- License: other
- Created: 2018-12-21T18:29:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-03T21:42:21.000Z (over 5 years ago)
- Last Synced: 2025-06-04T08:57:57.079Z (about 1 year ago)
- Language: Julia
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# FlatArrays
[](LICENSE.md)
[](https://travis-ci.com/emmt/FlatArrays.jl)
[](https://ci.appveyor.com/project/emmt/FlatArrays-jl/branch/master)
[](https://coveralls.io/github/emmt/FlatArrays.jl?branch=master)
[](http://codecov.io/github/emmt/FlatArrays.jl?branch=master)
This [Julia](http://julialang.org/) package provides *flat* arrays. That is
arrays with 1-based indices, whose elements are all continuous and in
column-major order. Such arrays are useful for writting efficient Julia code
using linear indexing. This kind of arrays is also what is expected by most
numerical libraries and FlatArrays may be helpful to link such libraries in
Julia.
FlatArrays are built from any Julia array and can have any dimensions providing
that their total size do not exceed that of the input array. This is like
`reshape` except that building a `FlatArray` from a Julia `Array` is faster
than calling `reshape` (by a factor ~ 7 for a vector, ~ 5 for a matrix). This
may be significant for very small arrays.
Indexing of FlatArray's is as fast as regular Julia arrays.
I found FlatArrays useful to pretend that multidimensional arrays are vectors
or matrices so as to automatically benefit from very fast linear algebra
methods (*e.g.*, BLAS or LAPACK). Again, this seems like `reshape` except that
`reshape` is slower and does not guarantee how the elements are stored.
## Simple Usage
Import the package:
```julia
using FlatArrays
```
and then:
```julia
flatten(A, n) -> V
```
yields a *flat* vector `V` of length `n` whose elements are given by array `A`.
To build a *flat* matrix from the elements of `A`, call:
```julia
flatten(A, m, n) -> M
```
which yields a *flat* matrix `M` of size `m` rows by `n` columns whose elements are
given by array `A`.
## Installation
To install FlatArrays, you must clone its repository:
```sh
using Pkg
Pkg.clone("https://github.com/emmt/FlatArrays.jl.git")
```
The FlatArrays package is pure Julia code and there is nothing to build.