|
4 | 4 | [](https://codecov.io/gh/JuliaApproximation/InfiniteArrays.jl)
|
5 | 5 |
|
6 | 6 |
|
7 |
| -A Julia package for representing infinite-dimensional arrays |
| 7 | +A Julia package for representing infinite-dimensional arrays, designed to work |
| 8 | +with other array types. Infinite arrays are by necessity lazy, and so this |
| 9 | +package is closely linked to [LazyArrays.jl](https://github.com/JuliaArrays/LazyArrays.jl). |
8 | 10 |
|
| 11 | +The package currently supports construction, but future versions will include |
| 12 | +support for linear algebra operations like matrix multiplication, LU decompositions, |
| 13 | +and QR decompositions. |
| 14 | + |
| 15 | + |
| 16 | +Here are some examples of current functionality: |
9 | 17 |
|
10 |
| -This is a WIP package. When finished, the following behaviour should work: |
11 | 18 | ```julia
|
12 |
| -B = Ones(1,∞) # creates 1 x ∞ InfMatrix of all ones |
13 |
| -T = diagm(Fill(0.5,∞)) + diagm(Fill(-0.5,∞),2) # a Toeplitz operator |
14 |
| -e₁ = [1; Zeros(∞)] # a PaddedInfVector |
15 |
| -(e₁*e₁')/2 # a PaddedInfMatrix: it knows to manipulate on the data |
16 |
| -C = T + (e₁*e₁')/2 # a PlusInfMatrix, it adds the rank-1 perturbation lazily |
17 |
| -D = diagm(1:∞,1) # Chebyshev derivative, represented as a Diagonal{<:InfUnitRange} |
18 |
| -A = [B; D+C] # A ConcatenatedInfMatrix |
19 |
| -u = A \ [2; Zeros(∞)] # Finds Chebyshev coefficients of solution to u'+u = 0, u(1) = 2, using adaptive QR |
20 |
| -``` |
| 19 | +julia> using InfiniteArrays, LinearAlgebra |
| 20 | + |
| 21 | +julia> x = Ones(∞) # infinite vector of all ones |
| 22 | +Ones{Float64,1,Tuple{InfiniteArrays.Infinity}} with indices OneToInf(): |
| 23 | + 1.0 |
| 24 | + 1.0 |
| 25 | + 1.0 |
| 26 | + 1.0 |
| 27 | + 1.0 |
| 28 | + 1.0 |
| 29 | + 1.0 |
| 30 | + 1.0 |
| 31 | + 1.0 |
| 32 | + 1.0 |
| 33 | + 1.0 |
| 34 | + 1.0 |
| 35 | + 1.0 |
| 36 | + 1.0 |
| 37 | + 1.0 |
| 38 | + 1.0 |
| 39 | + 1.0 |
| 40 | + 1.0 |
| 41 | + 1.0 |
| 42 | + 1.0 |
| 43 | + 1.0 |
| 44 | + 1.0 |
| 45 | + 1.0 |
| 46 | + 1.0 |
| 47 | + 1.0 |
| 48 | + 1.0 |
| 49 | + ⋮ |
| 50 | + |
| 51 | +julia> cumsum(x) # infinite sum |
| 52 | +1.0:1.0:+∞ |
| 53 | + |
| 54 | +julia> exp.(-(1:∞)) .+ 2 # broadcasting supported |
| 55 | +BroadcastArray{Float64,1,Base.Broadcast.Broadcasted{LazyArrays.LazyArrayStyle{1},Tuple{InfiniteArrays.OneToInf{Int64}},typeof(+),Tuple{BroadcastArray{Float64,1,Base.Broadcast.Broadcasted{LazyArrays.LazyArrayStyle{1},Tuple{InfiniteArrays.OneToInf{Int64}},typeof(exp),Tuple{InfiniteArrays.InfStepRange{Int64,Int64}}}},Int64}}} with indices OneToInf(): |
| 56 | + 2.3678794411714423 |
| 57 | + 2.135335283236613 |
| 58 | + 2.049787068367864 |
| 59 | + 2.018315638888734 |
| 60 | + 2.0067379469990856 |
| 61 | + 2.0024787521766663 |
| 62 | + 2.0009118819655547 |
| 63 | + 2.0003354626279024 |
| 64 | + 2.0001234098040865 |
| 65 | + 2.0000453999297623 |
| 66 | + 2.0000167017007904 |
| 67 | + 2.000006144212353 |
| 68 | + 2.000002260329407 |
| 69 | + 2.000000831528719 |
| 70 | + 2.0000003059023204 |
| 71 | + 2.0000001125351745 |
| 72 | + 2.0000000413993773 |
| 73 | + 2.00000001522998 |
| 74 | + 2.0000000056027964 |
| 75 | + 2.0000000020611535 |
| 76 | + 2.000000000758256 |
| 77 | + 2.0000000002789466 |
| 78 | + 2.000000000102619 |
| 79 | + 2.000000000037751 |
| 80 | + 2.000000000013888 |
| 81 | + 2.0000000000051092 |
| 82 | + ⋮ |
| 83 | + |
| 84 | +julia> Diagonal(1:∞) # combines well with Base arrays |
| 85 | +Diagonal{Int64,InfiniteArrays.InfUnitRange{Int64}} with indices OneToInf()×OneToInf(): |
| 86 | + 1 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ … |
| 87 | + ⋅ 2 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 88 | + ⋅ ⋅ 3 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 89 | + ⋅ ⋅ ⋅ 4 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 90 | + ⋅ ⋅ ⋅ ⋅ 5 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 91 | + ⋅ ⋅ ⋅ ⋅ ⋅ 6 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ … |
| 92 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 7 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 93 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 8 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 94 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 9 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 95 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 10 ⋅ ⋅ ⋅ ⋅ ⋅ |
| 96 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 11 ⋅ ⋅ ⋅ ⋅ … |
| 97 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 12 ⋅ ⋅ ⋅ |
| 98 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 13 ⋅ ⋅ |
| 99 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 14 ⋅ |
| 100 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 15 |
| 101 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ … |
| 102 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 103 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 104 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 105 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 106 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ … |
| 107 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 108 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 109 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 110 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ |
| 111 | + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ … |
| 112 | + ⋮ ⋮ ⋮ ⋱ |
| 113 | + |
| 114 | + julia> C = cache(Ones(∞)); C[1] = 3; C # Use cache to make mutable |
| 115 | +LazyArrays.CachedArray{Float64,1,Array{Float64,1},Ones{Float64,1,Tuple{InfiniteArrays.Infinity}}} with indices OneToInf(): |
| 116 | + 3.0 |
| 117 | + 1.0 |
| 118 | + 1.0 |
| 119 | + 1.0 |
| 120 | + 1.0 |
| 121 | + 1.0 |
| 122 | + 1.0 |
| 123 | + 1.0 |
| 124 | + 1.0 |
| 125 | + 1.0 |
| 126 | + 1.0 |
| 127 | + 1.0 |
| 128 | + 1.0 |
| 129 | + 1.0 |
| 130 | + 1.0 |
| 131 | + 1.0 |
| 132 | + 1.0 |
| 133 | + 1.0 |
| 134 | + 1.0 |
| 135 | + 1.0 |
| 136 | + 1.0 |
| 137 | + 1.0 |
| 138 | + 1.0 |
| 139 | + 1.0 |
| 140 | + 1.0 |
| 141 | + 1.0 |
| 142 | + ⋮ |
| 143 | + ``` |
0 commit comments