https://github.com/evizero/cachedarrays.jl
https://github.com/evizero/cachedarrays.jl
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/evizero/cachedarrays.jl
- Owner: Evizero
- License: other
- Created: 2018-03-20T14:01:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-23T12:18:09.000Z (over 7 years ago)
- Last Synced: 2025-02-23T06:13:33.027Z (5 months ago)
- Language: Julia
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CachedArrays
[](https://travis-ci.org/Evizero/CachedArrays.jl)
[](http://codecov.io/github/Evizero/CachedArrays.jl?branch=master)CachedArrays.jl provides a couple of array decorator types that
buffer intermediate result when `getindex` is invoked. This is
mainly useful in the combination with other lazy array decorators
such as
[MappedArrays.jl](https://github.com/JuliaArrays/MappedArrays.jl).## Usage
```julia
julia> using CachedArrays, MappedArraysjulia> function foo(x)
println("# expensive computation on ", x)
x^2
endjulia> A = mappedarray(foo, [1 2; 3 4]);
julia> B = cachedarray(A);
julia> size(B)
(2, 2)julia> B[1,2]
# expensive computation on 2
4julia> B[1,2]
4julia> B[2,2]
# expensive computation on 4
16julia> collect(B)
# expensive computation on 1
# expensive computation on 3
2×2 Array{Int64,2}:
1 4
9 16
```