You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main export of this package is the ````CArray```` type. "Components" of ````CArray````s
9
+
The main export of this package is the ````ComponentArray```` type. "Components" of ````ComponentArray````s
10
10
are really just array blocks that can be accessed through a named index. The magic here is
11
-
that this named indexing can create a new ```CArray``` whose data is a view into the original,
11
+
that this named indexing can create a new ```ComponentArray``` whose data is a view into the original,
12
12
allowing for standalone models to be composed together by simple function composition. In
13
-
essence, ```CArray```s allow you to do the things you would usually need a modeling
13
+
essence, ```ComponentArray```s allow you to do the things you would usually need a modeling
14
14
language for, but without actually needing a modeling language. The main targets are for use
15
15
in [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl) and
16
16
[Optim.jl](https://github.com/JuliaNLSolvers/Optim.jl), but anything that requires
17
17
flat vectors is fair game.
18
18
19
19
## General use
20
-
The easiest way to construct 1-dimensional ```CArray```s is as if they were ```NamedTuple```s. In fact, a good way to think about them is as arbitrarily nested, mutable ```NamedTuple```s that can be passed through a solver.
20
+
The easiest way to construct 1-dimensional ```ComponentArray```s is as if they were ```NamedTuple```s. In fact, a good way to think about them is as arbitrarily nested, mutable ```NamedTuple```s that can be passed through a solver.
21
21
```julia
22
22
julia> c = (a=2, b=[1, 2]);
23
23
24
-
julia> x =CArray(a=1, b=[2, 1, 4], c=c)
25
-
CArray{Float64}(a =1.0, b = [2.0, 1.0, 4.0], c = (a =2.0, b = [1.0, 2.0]))
24
+
julia> x =ComponentArray(a=5, b=[(a=20., b=0), (a=33., b=0), (a=44., b=3)], c=c)
25
+
ComponentArray{Float64}(a =5.0, b = [(a =20.0, b =0.0), (a =33.0, b =0.0), (a =44.0, b =3.0)], c = (a =2.0, b = [1.0, 2.0]))
26
26
27
27
julia> x.c.a =400; x
28
-
CArray{Float64}(a =1.0, b = [2.0, 1.0, 4.0], c = (a =400.0, b = [1.0, 2.0]))
28
+
ComponentArray{Float64}(a =5.0, b = [(a =20.0, b =0.0), (a =33.0, b =0.0), (a =44.0, b =3.0)], c = (a =400.0, b = [1.0, 2.0]))
Higher dimensional ```CArray```s can be created too, but it's a little messy at the moment. The nice thing for modeling is that dimension expansion through broadcasted operations can create higher-dimensional ```CArray```s automatically, so Jacobian cache arrays that are created internally with ```false .* x .* x'``` will be ```CArray```s with proper axes. Check out the [ODE with Jacobian](https://github.com/jonniedie/ComponentArrays.jl/blob/master/examples/ODE_jac_example.jl) example in the examples folder to see how this looks in practice.
50
+
Higher dimensional ```ComponentArray```s can be created too, but it's a little messy at the moment. The nice thing for modeling is that dimension expansion through broadcasted operations can create higher-dimensional ```ComponentArray```s automatically, so Jacobian cache arrays that are created internally with ```false .* x .* x'``` will be ```ComponentArray```s with proper axes. Check out the [ODE with Jacobian](https://github.com/jonniedie/ComponentArrays.jl/blob/master/examples/ODE_jac_example.jl) example in the examples folder to see how this looks in practice.
48
51
```julia
49
52
julia> x2 = x .* x'
50
-
7×7CArray{Tuple{Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))},Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))}},Float64,2,Array{Float64,2}}:
53
+
7×7ComponentArray{Tuple{Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))},Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))}},Float64,2,Array{Float64,2}}:
51
54
1.02.01.04.02.01.02.0
52
55
2.04.02.08.04.02.04.0
53
56
1.02.01.04.02.01.02.0
@@ -57,7 +60,7 @@ julia> x2 = x .* x'
57
60
2.04.02.08.04.02.04.0
58
61
59
62
julia> x2[:c,:c]
60
-
3×3CArray{Tuple{Axis{(a =1, b =2:3)},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
63
+
3×3ComponentArray{Tuple{Axis{(a =1, b =2:3)},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
61
64
4.02.04.0
62
65
2.01.02.0
63
66
4.02.04.0
@@ -66,10 +69,10 @@ julia> x2[:a,:a]
66
69
1.0
67
70
68
71
julia> x2[:a,:c]
69
-
CArray{Float64}(a =2.0, b = [1.0, 2.0])
72
+
ComponentArray{Float64}(a =2.0, b = [1.0, 2.0])
70
73
71
74
julia> x2[:b,:c]
72
-
3×3CArray{Tuple{Axis{NamedTuple()},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
75
+
3×3ComponentArray{Tuple{Axis{NamedTuple()},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
73
76
4.02.04.0
74
77
2.01.02.0
75
78
8.04.08.0
@@ -102,7 +105,7 @@ function lorenz!(D, u, p, t; f=0.0)
Copy file name to clipboardExpand all lines: docs/src/examples/ODE_jac.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# ODE with Jacobian
2
2
3
-
This example shows how to use ComponentArrays for composing Jacobian update functions as well as ODE functions. Note using plain symbols to index into ```CArrays``` is still pretty slow. Until symbolic indexing is faster, the convenience function ```fastindices``` can be used to speed up simulation. The general syntax looks like
3
+
This example shows how to use ComponentArrays for composing Jacobian update functions as well as ODE functions. Note using plain symbols to index into ```ComponentArrays``` is still pretty slow. Until symbolic indexing is faster, the convenience function ```fastindices``` can be used to speed up simulation. The general syntax looks like
4
4
5
5
```julia
6
6
_x, _y, _z =fastindices(:x, :y, :z)
@@ -46,7 +46,7 @@ function lorenz_jac!(D, u, p, t)
Copy file name to clipboardExpand all lines: docs/src/quickstart.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
# Quick Start
2
2
3
3
## General use
4
-
The easiest way to construct 1-dimensional ```CArray```s is as if they were ```NamedTuple```s. In fact, a good way to think about them is as arbitrarily nested, mutable ```NamedTuple```s that can be passed through a solver.
4
+
The easiest way to construct 1-dimensional ```ComponentArray```s is as if they were ```NamedTuple```s. In fact, a good way to think about them is as arbitrarily nested, mutable ```NamedTuple```s that can be passed through a solver.
5
5
```julia
6
6
julia> c = (a=2, b=[1, 2]);
7
7
8
-
julia> x =CArray(a=1, b=[2, 1, 4], c=c)
9
-
CArray{Float64}(a =1.0, b = [2.0, 1.0, 4.0], c = (a =2.0, b = [1.0, 2.0]))
8
+
julia> x =ComponentArray(a=1, b=[2, 1, 4], c=c)
9
+
ComponentArray{Float64}(a =1.0, b = [2.0, 1.0, 4.0], c = (a =2.0, b = [1.0, 2.0]))
10
10
11
11
julia> x.c.a =400; x
12
-
CArray{Float64}(a =1.0, b = [2.0, 1.0, 4.0], c = (a =400.0, b = [1.0, 2.0]))
12
+
ComponentArray{Float64}(a =1.0, b = [2.0, 1.0, 4.0], c = (a =400.0, b = [1.0, 2.0]))
Higher dimensional ```CArray```s can be created too, but it's a little messy at the moment. The nice thing for modeling is that dimension expansion through broadcasted operations can create higher-dimensional ```CArray```s automatically, so Jacobian cache arrays that are created internally with ```false .* x .* x'``` will be ```CArray```s with proper axes. Check out the [ODE with Jacobian](https://github.com/jonniedie/ComponentArrays.jl/blob/master/examples/ODE_jac_example.jl) example in the examples folder to see how this looks in practice.
31
+
Higher dimensional ```ComponentArray```s can be created too, but it's a little messy at the moment. The nice thing for modeling is that dimension expansion through broadcasted operations can create higher-dimensional ```ComponentArray```s automatically, so Jacobian cache arrays that are created internally with ```false .* x .* x'``` will be ```ComponentArray```s with proper axes. Check out the [ODE with Jacobian](https://github.com/jonniedie/ComponentArrays.jl/blob/master/examples/ODE_jac_example.jl) example in the examples folder to see how this looks in practice.
32
32
```julia
33
33
julia> x2 = x .* x'
34
-
7×7CArray{Tuple{Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))},Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))}},Float64,2,Array{Float64,2}}:
34
+
7×7ComponentArray{Tuple{Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))},Axis{(a =1, b =2:4, c = (5:7, (a =1, b =2:3)))}},Float64,2,Array{Float64,2}}:
35
35
1.02.01.04.02.01.02.0
36
36
2.04.02.08.04.02.04.0
37
37
1.02.01.04.02.01.02.0
@@ -41,7 +41,7 @@ julia> x2 = x .* x'
41
41
2.04.02.08.04.02.04.0
42
42
43
43
julia> x2[:c,:c]
44
-
3×3CArray{Tuple{Axis{(a =1, b =2:3)},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
44
+
3×3ComponentArray{Tuple{Axis{(a =1, b =2:3)},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
45
45
4.02.04.0
46
46
2.01.02.0
47
47
4.02.04.0
@@ -50,10 +50,10 @@ julia> x2[:a,:a]
50
50
1.0
51
51
52
52
julia> x2[:a,:c]
53
-
CArray{Float64}(a =2.0, b = [1.0, 2.0])
53
+
ComponentArray{Float64}(a =2.0, b = [1.0, 2.0])
54
54
55
55
julia> x2[:b,:c]
56
-
3×3CArray{Tuple{Axis{NamedTuple()},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
56
+
3×3ComponentArray{Tuple{Axis{NamedTuple()},Axis{(a =1, b =2:3)}},Float64,2,SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}}:
0 commit comments