From c38b6cd33c0b01f1c08391397a1412570c9ae244 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sat, 3 Feb 2024 21:03:42 +0000 Subject: [PATCH] build based on 07989c4 --- dev/.documenter-siteinfo.json | 2 +- dev/Example_dsl/index.html | 2 +- dev/LArrays/index.html | 16 ++++++++-------- dev/NamedTuples_relation/index.html | 2 +- dev/Note_labelled_slices/index.html | 2 +- dev/SLArrays/index.html | 16 ++++++++-------- dev/assets/Manifest.toml | 28 ++++++++++++++++------------ dev/index.html | 14 +++++++------- dev/search_index.js | 2 +- 9 files changed, 44 insertions(+), 40 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index dd26542..81854b4 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-22T07:20:54","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-02-03T21:03:38","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/Example_dsl/index.html b/dev/Example_dsl/index.html index 163058d..76d384c 100644 --- a/dev/Example_dsl/index.html +++ b/dev/Example_dsl/index.html @@ -27,4 +27,4 @@ p = LorenzParameterVector(10.0, 28.0, 8 / 3) tspan = (0.0, 10.0) prob = ODEProblem(f, u0, tspan, p) -sol = solve(prob, Tsit5()) +sol = solve(prob, Tsit5()) diff --git a/dev/LArrays/index.html b/dev/LArrays/index.html index 77f8e9a..069bd45 100644 --- a/dev/LArrays/index.html +++ b/dev/LArrays/index.html @@ -16,22 +16,22 @@ julia> z.a 2-element view(::Array{Int64,2}, 2, :) with eltype Int64: 3 - 4

The labels of LArray and SLArray can be accessed by function symbols, which returns a tuple of symbols.

source
LabelledArrays.@LVectorMacro
@LVector Type Names

The @LVector macro creates an LArray of dimension 1 with eltype and undefined values. The vector's length is equal to the number of names given.

As with an LArray, the user can initialize the vector and set its values later.

A = @LVector Float64 (:a, :b, :c, :d)
-A .= rand(4)

On the other hand, users can also initialize the vector and set its values at the same time:

b = @LVector [1, 2, 3] (:a, :b, :c)
source

LArray and LVector constructors

The original constructors for LArrays and LVectors are as follows:

LabelledArrays.LArrayType
LArray(::Tuple, ::NamedTuple)
+ 4

The labels of LArray and SLArray can be accessed by function symbols, which returns a tuple of symbols.

source
LabelledArrays.@LVectorMacro
@LVector Type Names

The @LVector macro creates an LArray of dimension 1 with eltype and undefined values. The vector's length is equal to the number of names given.

As with an LArray, the user can initialize the vector and set its values later.

A = @LVector Float64 (:a, :b, :c, :d)
+A .= rand(4)

To initialize the vector and set its values at the same time, use @LArray instead:

b = @LArray [1, 2, 3] (:a, :b, :c)
source

LArray and LVector constructors

The original constructors for LArrays and LVectors are as follows:

LabelledArrays.LArrayType
LArray(::Tuple, ::NamedTuple)
 LArray(::Tuple, kwargs)

The standard constructors for LArray.

For example:

LArray((2, 2), (a = 1, b = 2, c = 3, d = 4))  # need to specify size
-LArray((2, 2); a = 1, b = 2, c = 3, d = 4)
source
LVector(v1::Union{SLArray,LArray}; kwargs...)

Creates a copy of v1 with corresponding items in kwargs replaced.

For example:

ABCD = @SLArray (2,2) (:a,:b,:c,:d);
+LArray((2, 2); a = 1, b = 2, c = 3, d = 4)
source
LVector(v1::Union{SLArray,LArray}; kwargs...)

Creates a copy of v1 with corresponding items in kwargs replaced.

For example:

ABCD = @SLArray (2,2) (:a,:b,:c,:d);
 B = ABCD(1,2,3,4);
-B2 = LArray(B; c=30 )
source
LabelledArrays.LVectorFunction
LVector(::NamedTuple)
+B2 = LArray(B; c=30 )
source
LabelledArrays.LVectorFunction
LVector(::NamedTuple)
 LVector(kwargs)

The standard constructor for LVector.

For example:

LVector((a = 1, b = 2))
-LVector(a = 1, b = 2)
source
LVector(v1::Union{SLArray,LArray}; kwargs...)

Creates a 1D copy of v1 with corresponding items in kwargs replaced.

For example:

z = LVector(a=1, b=2, c=3);
-z2 = LVector(z; c=30)
source

Manipulating LArrays and LVectors

User may want a list of the labels or keys in an LArray or LVector. The symbols(::LArray) function returns a tuple of array labels.

LabelledArrays.symbolsFunction
symbols(::SLArray)

Returns the labels of the SLArray.

For example:

julia> z = SLVector(a = 1, b = 2, c = 3)
+LVector(a = 1, b = 2)
source
LVector(v1::Union{SLArray,LArray}; kwargs...)

Creates a 1D copy of v1 with corresponding items in kwargs replaced.

For example:

z = LVector(a=1, b=2, c=3);
+z2 = LVector(z; c=30)
source

Manipulating LArrays and LVectors

User may want a list of the labels or keys in an LArray or LVector. The symbols(::LArray) function returns a tuple of array labels.

LabelledArrays.symbolsFunction
symbols(::SLArray)

Returns the labels of the SLArray.

For example:

julia> z = SLVector(a = 1, b = 2, c = 3)
 3-element SLArray{Tuple{3}, Int64, 1, 3, (:a, :b, :c)} with indices SOneTo(3):
  :a => 1
  :b => 2
  :c => 3
 
 julia> symbols(z)
-(:a, :b, :c)
source
symbols(::LArray)

Returns the labels of the LArray.

For example:

julia> z = @LVector Float64 (:a, :b, :c, :d);
+(:a, :b, :c)
source
symbols(::LArray)

Returns the labels of the LArray.

For example:

julia> z = @LVector Float64 (:a, :b, :c, :d);
 
 julia> symbols(z)
-(:a, :b, :c, :d)
source
+(:a, :b, :c, :d)source diff --git a/dev/NamedTuples_relation/index.html b/dev/NamedTuples_relation/index.html index 263a129..e7a47dd 100644 --- a/dev/NamedTuples_relation/index.html +++ b/dev/NamedTuples_relation/index.html @@ -17,4 +17,4 @@ julia> SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4)) 2×2 SLArray{Tuple{2,2},2,(:a, :b, :c, :d),Int64}: 1 3 - 2 4

Converting to a named tuple from a labelled array x is available using convert(NamedTuple, x). Furthermore, pairs(x) creates an iterator that is functionally the same as pairs(convert(NamedTuple, x)), yielding :label => x.label for each label of the array.

There are some crucial differences between a labelled array and a named tuple. Labelled arrays can have any dimensions, while named tuples are always 1D. A named tuple can have different types on each element, while an SLArray can only have one element type and furthermore it has the actions of a static vector. As a result SLArray has less element type information, which improves compilation speed while giving more vector functionality than a NamedTuple. LArray also only has a single element type and, unlike a named tuple, is mutable.

+ 2 4

Converting to a named tuple from a labelled array x is available using convert(NamedTuple, x). Furthermore, pairs(x) creates an iterator that is functionally the same as pairs(convert(NamedTuple, x)), yielding :label => x.label for each label of the array.

There are some crucial differences between a labelled array and a named tuple. Labelled arrays can have any dimensions, while named tuples are always 1D. A named tuple can have different types on each element, while an SLArray can only have one element type and furthermore it has the actions of a static vector. As a result SLArray has less element type information, which improves compilation speed while giving more vector functionality than a NamedTuple. LArray also only has a single element type and, unlike a named tuple, is mutable.

diff --git a/dev/Note_labelled_slices/index.html b/dev/Note_labelled_slices/index.html index de9928d..e7b1fd0 100644 --- a/dev/Note_labelled_slices/index.html +++ b/dev/Note_labelled_slices/index.html @@ -1,2 +1,2 @@ -Note: Labelled slices · LabelledArrays.jl
+Note: Labelled slices · LabelledArrays.jl
diff --git a/dev/SLArrays/index.html b/dev/SLArrays/index.html index d7fb89f..ea03635 100644 --- a/dev/SLArrays/index.html +++ b/dev/SLArrays/index.html @@ -28,12 +28,12 @@ julia> z.a 2-element view(::StaticArrays.SArray{Tuple{2,2},Int64,2,4}, 2, :) with eltype Int64: 2 - 4source
LabelledArrays.@SLVectorMacro
@SLVector Names
+ 4
source
LabelledArrays.@SLVectorMacro
@SLVector Names
 @SLVector Eltype Names

The macro creates a labelled static vector with element type ElType, and names from Names. If no eltype is given, then the eltype is determined from the values in the constructor. The array size is found from the input data.

For example:

ABC = @SLVector (:a, :b, :c)
 x = ABC(1.0, 2.5, 3.0)
 x.a == 1.0
 x.b == 2.5
-x.c == x[3]
source

SLArray and SLVector constructors

Alternatively, users can construct a static labelled array using the SLVector and SLArrays constructors by writing out the entries as keyword arguments:

LabelledArrays.SLArrayType
SLArray{::Tuple}(::NamedTuple)
+x.c == x[3]
source

SLArray and SLVector constructors

Alternatively, users can construct a static labelled array using the SLVector and SLArrays constructors by writing out the entries as keyword arguments:

LabelledArrays.SLArrayType
SLArray{::Tuple}(::NamedTuple)
 SLArray{::Tuple}(kwargs)

These are the standard constructors for SLArray. For general N-dimensional labelled arrays, users need to specify the size (Tuple{dim1,dim2,...}) in the type parameter to the SLArray constructor:

julia> SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))
 2×2 SLArray{Tuple{2, 2}, Int64, 2, 4, (:a, :b, :c, :d)} with indices SOneTo(2)×SOneTo(2):
  :a => 1  :c => 3
@@ -49,9 +49,9 @@
 julia> B2 = SLArray(B; c = 30)
 2×2 SLArray{Tuple{2,2},Int64,2,4,(:a, :b, :c, :d)}:
  1  30
- 2   4

Additional examples:

SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))
source
SLVector(v1::SLArray; kwargs...)

Creates a copy of v1 with corresponding items in kwargs replaced.

For example:

ABCD = @SLArray (2,2) (:a,:b,:c,:d);
+ 2   4

Additional examples:

SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))
source
SLVector(v1::SLArray; kwargs...)

Creates a copy of v1 with corresponding items in kwargs replaced.

For example:

ABCD = @SLArray (2,2) (:a,:b,:c,:d);
 B = ABCD(1,2,3,4);
-B2 = SLArray(B; c=30 )
source
LabelledArrays.SLVectorFunction
SLVector(::NamedTuple)
+B2 = SLArray(B; c=30 )
source
LabelledArrays.SLVectorFunction
SLVector(::NamedTuple)
 SLVector(kwargs)

The standard constructors for SLArray.

julia> SLVector(a = 1, b = 2, c = 3)
 3-element SLArray{Tuple{3},1,(:a, :b, :c),Int64}:
  1
@@ -63,15 +63,15 @@
   1.1
  20.2
  30.3

Additional examples:

SLVector((a = 1, b = 2))
-SLVector(a = 1, b = 2)
source
SLVector(v1::SLArray; kwargs...)

Creates a 1D copy of v1 with corresponding items in kwargs replaced.

For example:

z = SLVector(a=1, b=2, c=3);
-z2 = SLVector(z; c=30)
source

Manipulating SLArrays and SLVectors

Users may want a list of the labels or keys in an SLArray or SLVector. The symbols(::SLArray) function returns a tuple of array labels.

LabelledArrays.symbolsMethod
symbols(::SLArray)

Returns the labels of the SLArray.

For example:

julia> z = SLVector(a = 1, b = 2, c = 3)
+SLVector(a = 1, b = 2)
source
SLVector(v1::SLArray; kwargs...)

Creates a 1D copy of v1 with corresponding items in kwargs replaced.

For example:

z = SLVector(a=1, b=2, c=3);
+z2 = SLVector(z; c=30)
source

Manipulating SLArrays and SLVectors

Users may want a list of the labels or keys in an SLArray or SLVector. The symbols(::SLArray) function returns a tuple of array labels.

LabelledArrays.symbolsMethod
symbols(::SLArray)

Returns the labels of the SLArray.

For example:

julia> z = SLVector(a = 1, b = 2, c = 3)
 3-element SLArray{Tuple{3}, Int64, 1, 3, (:a, :b, :c)} with indices SOneTo(3):
  :a => 1
  :b => 2
  :c => 3
 
 julia> symbols(z)
-(:a, :b, :c)
source
symbols(::LArray)

Returns the labels of the LArray.

For example:

julia> z = @LVector Float64 (:a, :b, :c, :d);
+(:a, :b, :c)
source
symbols(::LArray)

Returns the labels of the LArray.

For example:

julia> z = @LVector Float64 (:a, :b, :c, :d);
 
 julia> symbols(z)
-(:a, :b, :c, :d)
source
+(:a, :b, :c, :d)source diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index 5a1ba9d..ce695a3 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -58,9 +58,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra"] -git-tree-sha1 = "c1deebd76f7a443d527fc0430d5758b8b2112ed8" +git-tree-sha1 = "1287e3872d646eed95198457873249bd9f0caed2" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.19.1" +version = "1.20.1" weakdeps = ["SparseArrays"] [deps.ChainRulesCore.extensions] @@ -88,9 +88,9 @@ uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" version = "1.0.5+1" [[deps.DataAPI]] -git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c" +git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" -version = "1.15.0" +version = "1.16.0" [[deps.DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -316,9 +316,9 @@ version = "0.8.1+2" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "cc6e1927ac521b659af340e0ca45828a3ffc748f" +git-tree-sha1 = "60e3045590bd104a16fefb12836c00c0ef8c7f8c" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.0.12+0" +version = "3.0.13+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -391,21 +391,25 @@ version = "1.3.4" [[deps.RecursiveArrayTools]] deps = ["Adapt", "ArrayInterface", "DocStringExtensions", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "SparseArrays", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"] -git-tree-sha1 = "dd7fc1923fde0cc6cdff451352d17924b0704ca1" +git-tree-sha1 = "2bd309f5171a628efdf5309361cd8a779b9e63a9" uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" -version = "3.5.4" +version = "3.8.0" [deps.RecursiveArrayTools.extensions] RecursiveArrayToolsFastBroadcastExt = "FastBroadcast" + RecursiveArrayToolsForwardDiffExt = "ForwardDiff" RecursiveArrayToolsMeasurementsExt = "Measurements" RecursiveArrayToolsMonteCarloMeasurementsExt = "MonteCarloMeasurements" + RecursiveArrayToolsReverseDiffExt = ["ReverseDiff", "Zygote"] RecursiveArrayToolsTrackerExt = "Tracker" RecursiveArrayToolsZygoteExt = "Zygote" [deps.RecursiveArrayTools.weakdeps] FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" @@ -448,9 +452,9 @@ weakdeps = ["ChainRulesCore"] [[deps.StaticArrays]] deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] -git-tree-sha1 = "f68dd04d131d9a8a8eb836173ee8f105c360b0c5" +git-tree-sha1 = "7b0e9c14c624e435076d19aea1e5cbdec2b9ca37" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.9.1" +version = "1.9.2" weakdeps = ["ChainRulesCore", "Statistics"] [deps.StaticArrays.extensions] @@ -477,9 +481,9 @@ uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" version = "7.2.1+1" [[deps.SymbolicIndexingInterface]] -git-tree-sha1 = "74502f408d99fc217a9d7cd901d9ffe45af892b1" +git-tree-sha1 = "b3103f4f50a3843e66297a2456921377c78f5e31" uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5" -version = "0.3.3" +version = "0.3.5" [[deps.TOML]] deps = ["Dates"] diff --git a/dev/index.html b/dev/index.html index c9f4fe8..6b6c270 100644 --- a/dev/index.html +++ b/dev/index.html @@ -17,10 +17,10 @@ [1520ce14] AbstractTrees v0.4.4 [79e6a3ab] Adapt v4.0.1 [4fba245c] ArrayInterface v7.7.0 - [d360d2e6] ChainRulesCore v1.19.1 + [d360d2e6] ChainRulesCore v1.20.1 [bbf7d656] CommonSubexpressions v0.3.0 [34da2185] Compat v4.12.0 - [9a962f9c] DataAPI v1.15.0 + [9a962f9c] DataAPI v1.16.0 [e2d170a0] DataValueInterfaces v1.0.0 [163ba53b] DiffResults v1.1.0 [b552c78f] DiffRules v1.15.1 @@ -46,19 +46,19 @@ [aea7be01] PrecompileTools v1.2.0 [21216c6a] Preferences v1.4.1 [3cdcf5f2] RecipesBase v1.3.4 - [731186ca] RecursiveArrayTools v3.5.4 + [731186ca] RecursiveArrayTools v3.8.0 [2792f1a3] RegistryInstances v0.1.0 [ae029012] Requires v1.3.0 [276daf66] SpecialFunctions v2.3.1 - [90137ffa] StaticArrays v1.9.1 + [90137ffa] StaticArrays v1.9.2 [1e83bf80] StaticArraysCore v1.4.2 - [2efcf032] SymbolicIndexingInterface v0.3.3 + [2efcf032] SymbolicIndexingInterface v0.3.5 [3783bdb8] TableTraits v1.0.1 [bd369af6] Tables v1.11.1 [2e619515] Expat_jll v2.5.0+0 [f8c6e375] Git_jll v2.43.0+0 [94ce4f54] Libiconv_jll v1.17.0+0 - [458c3c95] OpenSSL_jll v3.0.12+0 + [458c3c95] OpenSSL_jll v3.0.13+0 [efe28fd5] OpenSpecFun_jll v0.5.5+0 [0dad84c5] ArgTools v1.1.1 [56f22d72] Artifacts @@ -103,4 +103,4 @@ [83775a58] Zlib_jll v1.2.13+1 [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 - [3f19e933] p7zip_jll v17.4.0+2

You can also download the manifest file and the project file.

+ [3f19e933] p7zip_jll v17.4.0+2

You can also download the manifest file and the project file.

diff --git a/dev/search_index.js b/dev/search_index.js index dd64ea2..0c212eb 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"Example_dsl/#Example:-Nice-DiffEq-Syntax-Without-A-DSL","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"","category":"section"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"Users of the SciML ecosystem are often solving large models with complicated states and hundreds or thousands of parameters. These models are implemented using arrays, and those arrays have traditionally been indexed by integers, such as p[1] or p[1:5]. Numerical indexing is wonderful for small models, but can quickly cause problems as models become bigger. It is easy to forget which index corresponds to which reaction rate or which diffusion coefficient. This confusion can lead to difficult to debug problems in a user's code. LabelledArrays can make an important difference here. It is much easier to build a model using parameter references such as p.rate_nacl or p.probability_birth, instead of p[26] or p[1026]. Labelled arrays make both the development and debugging of models much faster.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"LabelledArrays.jl are a way to get DSL-like syntax without a macro. In this case, we can solve differential equations with labelled components by making use of labelled arrays, and always refer to the components by name instead of index.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"One key caveat is that users do not need to sacrifice performance when using labelled arrays. Labelled arrays are as performant as traditional numerically indexed arrays.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"Let's solve the Lorenz equation using an LVectors. LVectors are mutable. Hence, we can use the non-allocating form of the OrdinaryDiffEq API.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"using LabelledArrays, OrdinaryDiffEq\n\nfunction lorenz_f!(du, u, p, t)\n du.x = p.σ * (u.y - u.x)\n du.y = u.x * (p.ρ - u.z) - u.y\n du.z = u.x * u.y - p.β * u.z\nend\n\nu0 = @LArray [1.0, 0.0, 0.0] (:x, :y, :z)\np = @LArray [10.0, 28.0, 8 / 3] (:σ, :ρ, :β)\ntspan = (0.0, 10.0)\nprob = ODEProblem(lorenz_f!, u0, tspan, p)\nsol = solve(prob, Tsit5())\n# Now the solution can be indexed as .x/y/z as well!\nsol[10].x","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"In the example above, we used an LArray to define the initial state u0 as well as the parameter vector p. The remainder of the ODE solution steps are no different that the original DifferentialEquations tutorials.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"Alternatively, we can use an immutable SLVector to implement the same equation. In this case, we need to use the allocating form of the OrdinaryDiffEq API when defining our model equation.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"LorenzVector = @SLVector (:x, :y, :z)\nLorenzParameterVector = @SLVector (:σ, :ρ, :β)\n\nfunction f(u, p, t)\n x = p.σ * (u.y - u.x)\n y = u.x * (p.ρ - u.z) - u.y\n z = u.x * u.y - p.β * u.z\n LorenzVector(x, y, z)\nend\n\nu0 = LorenzVector(1.0, 0.0, 0.0)\np = LorenzParameterVector(10.0, 28.0, 8 / 3)\ntspan = (0.0, 10.0)\nprob = ODEProblem(f, u0, tspan, p)\nsol = solve(prob, Tsit5())","category":"page"},{"location":"Note_labelled_slices/#Note:-Labelled-slices","page":"Note: Labelled slices","title":"Note: Labelled slices","text":"","category":"section"},{"location":"Note_labelled_slices/","page":"Note: Labelled slices","title":"Note: Labelled slices","text":"This functionality has been removed from LabelledArrays.jl, but can be replicated with the same compile-time performance and indexing syntax using DimensionalData.jl.","category":"page"},{"location":"LArrays/#LArrays","page":"LArrays","title":"LArrays","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"LArrays are fully mutable arrays with labels. There is no performance loss by using labelled indexing instead of purely numerical indexing. Using the macro with values and labels generates the labelled array with the given values:","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"Users interested in using labelled elements in their arrays should also consider ComponentArrays from the ComponentArrays.jl library. ComponentArrays are well integrated into the SciML ecosystem.","category":"page"},{"location":"LArrays/#@LArray-and-@LVector-macros","page":"LArrays","title":"@LArray and @LVector macros","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"Macro constructors are convenient for building most LArray objects. An @LArray may be of arbitrary dimension, while an @LVector is a one dimensional array.","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"@LArray\n@LVector","category":"page"},{"location":"LArrays/#LabelledArrays.@LArray","page":"LArrays","title":"LabelledArrays.@LArray","text":"@LArray Eltype Size Names\n@LArray Values Names\n\nThe @LArray macro creates an LArray with names determined from the Names vector and values determined from the Values vector. Otherwise, the eltype and size are used to make an LArray with undefined values.\n\nA = @LArray [1, 2, 3] (:a, :b, :c)\nA.a == 1\n\nUsers can also generate a labelled array with undefined values by instead giving the dimensions. This approach is useful if the user intends to pre-allocate an array for some later input.\n\nA = @LArray Float64 (2, 2) (:a, :b, :c, :d)\nW = rand(2, 2)\nA .= W\nA.d == W[2, 2]\n\nUsers may also use an alternative constructor to set the Names and Values and ranges at the same time.\n\njulia> z = @LArray [1.0, 2.0, 3.0] (a = 1:2, b = 2:3);\n\njulia> z.b\n2-element view(::Array{Float64,1}, 2:3) with eltype Float64:\n 2.0\n 3.0\n\njulia> z = @LArray [1 2; 3 4] (a = (2, :), b = 2:3);\n\njulia> z.a\n2-element view(::Array{Int64,2}, 2, :) with eltype Int64:\n 3\n 4\n\nThe labels of LArray and SLArray can be accessed by function symbols, which returns a tuple of symbols.\n\n\n\n\n\n","category":"macro"},{"location":"LArrays/#LabelledArrays.@LVector","page":"LArrays","title":"LabelledArrays.@LVector","text":"@LVector Type Names\n\nThe @LVector macro creates an LArray of dimension 1 with eltype and undefined values. The vector's length is equal to the number of names given.\n\nAs with an LArray, the user can initialize the vector and set its values later.\n\nA = @LVector Float64 (:a, :b, :c, :d)\nA .= rand(4)\n\nOn the other hand, users can also initialize the vector and set its values at the same time:\n\nb = @LVector [1, 2, 3] (:a, :b, :c)\n\n\n\n\n\n","category":"macro"},{"location":"LArrays/#LArray-and-LVector-constructors","page":"LArrays","title":"LArray and LVector constructors","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"The original constructors for LArrays and LVectors are as follows:","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"LArray\nLVector","category":"page"},{"location":"LArrays/#LabelledArrays.LArray","page":"LArrays","title":"LabelledArrays.LArray","text":"LArray(::Tuple, ::NamedTuple)\nLArray(::Tuple, kwargs)\n\nThe standard constructors for LArray.\n\nFor example:\n\nLArray((2, 2), (a = 1, b = 2, c = 3, d = 4)) # need to specify size\nLArray((2, 2); a = 1, b = 2, c = 3, d = 4)\n\n\n\n\n\nLVector(v1::Union{SLArray,LArray}; kwargs...)\n\nCreates a copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nABCD = @SLArray (2,2) (:a,:b,:c,:d);\nB = ABCD(1,2,3,4);\nB2 = LArray(B; c=30 )\n\n\n\n\n\n","category":"type"},{"location":"LArrays/#LabelledArrays.LVector","page":"LArrays","title":"LabelledArrays.LVector","text":"LVector(::NamedTuple)\nLVector(kwargs)\n\nThe standard constructor for LVector.\n\nFor example:\n\nLVector((a = 1, b = 2))\nLVector(a = 1, b = 2)\n\n\n\n\n\nLVector(v1::Union{SLArray,LArray}; kwargs...)\n\nCreates a 1D copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nz = LVector(a=1, b=2, c=3);\nz2 = LVector(z; c=30)\n\n\n\n\n\n","category":"function"},{"location":"LArrays/#Manipulating-LArrays-and-LVectors","page":"LArrays","title":"Manipulating LArrays and LVectors","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"User may want a list of the labels or keys in an LArray or LVector. The symbols(::LArray) function returns a tuple of array labels.","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"symbols","category":"page"},{"location":"LArrays/#LabelledArrays.symbols","page":"LArrays","title":"LabelledArrays.symbols","text":"symbols(::SLArray)\n\nReturns the labels of the SLArray.\n\nFor example:\n\njulia> z = SLVector(a = 1, b = 2, c = 3)\n3-element SLArray{Tuple{3}, Int64, 1, 3, (:a, :b, :c)} with indices SOneTo(3):\n :a => 1\n :b => 2\n :c => 3\n\njulia> symbols(z)\n(:a, :b, :c)\n\n\n\n\n\nsymbols(::LArray)\n\nReturns the labels of the LArray.\n\nFor example:\n\njulia> z = @LVector Float64 (:a, :b, :c, :d);\n\njulia> symbols(z)\n(:a, :b, :c, :d)\n\n\n\n\n\n","category":"function"},{"location":"SLArrays/#SLArrays","page":"SLArrays","title":"SLArrays","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"The SLArray and SLVector macros create static LabelledArrays. First, the user would create the array type, then use that constructor to generate instances of the labelled array.","category":"page"},{"location":"SLArrays/#@SLArray-and-@SLVector-macros","page":"SLArrays","title":"@SLArray and @SLVector macros","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"Macro constructors are convenient for building most SLArray objects. An @SLArray may be of arbitrary dimension, while an @SLVector is a one dimensional array.","category":"page"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"@SLArray\n@SLVector","category":"page"},{"location":"SLArrays/#LabelledArrays.@SLArray","page":"SLArrays","title":"LabelledArrays.@SLArray","text":"@SLArray Size Names\n@SLArray Eltype Size Names\n\nThe macro creates a labelled static vector with element type ElType, names from Names, and size from Size. If no eltype is given, then the eltype is determined from the arguments in the constructor.\n\nFor example:\n\nABCD = @SLArray (2, 2) (:a, :b, :c, :d)\nx = ABCD(1.0, 2.5, 3.0, 5.0)\nx.a == 1.0\nx.b == 2.5\nx.c == x[3]\nx.d == x[2, 2]\nEFG = @SLArray (2, 2) (e = 1:3, f = 4, g = 2:4)\ny = EFG(1.0, 2.5, 3.0, 5.0)\nEFG = @SLArray (2, 2) (e = (2, :), f = 4, g = 2:4)\n\nUsers can also specify the indices directly.\n\njulia> EFG = @SLArray (2, 2) (e = 1:3, f = 4, g = 2:4);\n\njulia> y = EFG(1.0, 2.5, 3.0, 5.0)\n2×2 SLArray{Tuple{2,2},Float64,2,4,(e = 1:3, f = 4, g = 2:4)}:\n 1.0 3.0\n 2.5 5.0\n\njulia> y.g\n3-element view(reshape(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}, 4), 2:4) with eltype Float64:\n 2.5\n 3.0\n 5.0\n\njulia> Arr = @SLArray (2, 2) (a = (2, :), b = 3);\n\njulia> z = Arr(1, 2, 3, 4);\n\njulia> z.a\n2-element view(::StaticArrays.SArray{Tuple{2,2},Int64,2,4}, 2, :) with eltype Int64:\n 2\n 4\n\n\n\n\n\n","category":"macro"},{"location":"SLArrays/#LabelledArrays.@SLVector","page":"SLArrays","title":"LabelledArrays.@SLVector","text":"@SLVector Names\n@SLVector Eltype Names\n\nThe macro creates a labelled static vector with element type ElType, and names from Names. If no eltype is given, then the eltype is determined from the values in the constructor. The array size is found from the input data.\n\nFor example:\n\nABC = @SLVector (:a, :b, :c)\nx = ABC(1.0, 2.5, 3.0)\nx.a == 1.0\nx.b == 2.5\nx.c == x[3]\n\n\n\n\n\n","category":"macro"},{"location":"SLArrays/#SLArray-and-SLVector-constructors","page":"SLArrays","title":"SLArray and SLVector constructors","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"Alternatively, users can construct a static labelled array using the SLVector and SLArrays constructors by writing out the entries as keyword arguments:","category":"page"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"SLArray\nSLVector","category":"page"},{"location":"SLArrays/#LabelledArrays.SLArray","page":"SLArrays","title":"LabelledArrays.SLArray","text":"SLArray{::Tuple}(::NamedTuple)\nSLArray{::Tuple}(kwargs)\n\nThese are the standard constructors for SLArray. For general N-dimensional labelled arrays, users need to specify the size (Tuple{dim1,dim2,...}) in the type parameter to the SLArray constructor:\n\njulia> SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))\n2×2 SLArray{Tuple{2, 2}, Int64, 2, 4, (:a, :b, :c, :d)} with indices SOneTo(2)×SOneTo(2):\n :a => 1 :c => 3\n :b => 2 :d => 4\n\njulia> SLArray{Tuple{2, 2}}(a = 1, b = 2, c = 3, d = 4)\n 2×2 SLArray{Tuple{2,2},2,(:a, :b, :c, :d),Int64}:\n 1 3\n 2 4\n\nConstructing copies with some changed elements is supported by a keyword constructor whose first argument is the source and whose additional keyword arguments indicate the changes.\n\njulia> ABCD = @SLArray (2, 2) (:a, :b, :c, :d);\n\njulia> B = ABCD(1, 2, 3, 4);\n\njulia> B2 = SLArray(B; c = 30)\n2×2 SLArray{Tuple{2,2},Int64,2,4,(:a, :b, :c, :d)}:\n 1 30\n 2 4\n\nAdditional examples:\n\nSLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))\n\n\n\n\n\nSLVector(v1::SLArray; kwargs...)\n\nCreates a copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nABCD = @SLArray (2,2) (:a,:b,:c,:d);\nB = ABCD(1,2,3,4);\nB2 = SLArray(B; c=30 )\n\n\n\n\n\n","category":"type"},{"location":"SLArrays/#LabelledArrays.SLVector","page":"SLArrays","title":"LabelledArrays.SLVector","text":"SLVector(::NamedTuple)\nSLVector(kwargs)\n\nThe standard constructors for SLArray.\n\njulia> SLVector(a = 1, b = 2, c = 3)\n3-element SLArray{Tuple{3},1,(:a, :b, :c),Int64}:\n 1\n 2\n 3\n\nConstructing copies with some items changed is supported by a keyword constructor whose first argument is the source and whose additional keyword arguments indicate the changes.\n\njulia> v1 = SLVector(a = 1.1, b = 2.2, c = 3.3);\n\njulia> v2 = SLVector(v1; b = 20.20, c = 30.30)\n3-element SLArray{Tuple{3},Float64,1,3,(:a, :b, :c)}:\n 1.1\n 20.2\n 30.3\n\nAdditional examples:\n\nSLVector((a = 1, b = 2))\nSLVector(a = 1, b = 2)\n\n\n\n\n\nSLVector(v1::SLArray; kwargs...)\n\nCreates a 1D copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nz = SLVector(a=1, b=2, c=3);\nz2 = SLVector(z; c=30)\n\n\n\n\n\n","category":"function"},{"location":"SLArrays/#Manipulating-SLArrays-and-SLVectors","page":"SLArrays","title":"Manipulating SLArrays and SLVectors","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"Users may want a list of the labels or keys in an SLArray or SLVector. The symbols(::SLArray) function returns a tuple of array labels.","category":"page"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"symbols(::SLArray)","category":"page"},{"location":"SLArrays/#LabelledArrays.symbols-Tuple{SLArray}","page":"SLArrays","title":"LabelledArrays.symbols","text":"symbols(::SLArray)\n\nReturns the labels of the SLArray.\n\nFor example:\n\njulia> z = SLVector(a = 1, b = 2, c = 3)\n3-element SLArray{Tuple{3}, Int64, 1, 3, (:a, :b, :c)} with indices SOneTo(3):\n :a => 1\n :b => 2\n :c => 3\n\njulia> symbols(z)\n(:a, :b, :c)\n\n\n\n\n\nsymbols(::LArray)\n\nReturns the labels of the LArray.\n\nFor example:\n\njulia> z = @LVector Float64 (:a, :b, :c, :d);\n\njulia> symbols(z)\n(:a, :b, :c, :d)\n\n\n\n\n\n","category":"method"},{"location":"NamedTuples_relation/#Relation-to-NamedTuples","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"","category":"section"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"Julia's Base has NamedTuples in v0.7+. They are constructed as:","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"p = (σ = 10.0, ρ = 28.0, β = 8 / 3)","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"and they support p[1] and p.σ as well. The LVector, SLVector, LArray and SLArray constructors also support named tuples as their arguments:","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"julia> LVector((a = 1, b = 2))\n2-element LArray{Int64,1,(:a, :b)}:\n 1\n 2\n\njulia> SLVector((a = 1, b = 2))\n2-element SLArray{Tuple{2},1,(:a, :b),Int64}:\n 1\n 2\n\njulia> LArray((2, 2), (a = 1, b = 2, c = 3, d = 4))\n2×2 LArray{Int64,2,(:a, :b, :c, :d)}:\n 1 3\n 2 4\n\njulia> SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))\n2×2 SLArray{Tuple{2,2},2,(:a, :b, :c, :d),Int64}:\n 1 3\n 2 4","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"Converting to a named tuple from a labelled array x is available using convert(NamedTuple, x). Furthermore, pairs(x) creates an iterator that is functionally the same as pairs(convert(NamedTuple, x)), yielding :label => x.label for each label of the array.","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"There are some crucial differences between a labelled array and a named tuple. Labelled arrays can have any dimensions, while named tuples are always 1D. A named tuple can have different types on each element, while an SLArray can only have one element type and furthermore it has the actions of a static vector. As a result SLArray has less element type information, which improves compilation speed while giving more vector functionality than a NamedTuple. LArray also only has a single element type and, unlike a named tuple, is mutable.","category":"page"},{"location":"#LabelledArrays.jl:-Arrays-with-Label-Goodness","page":"Home","title":"LabelledArrays.jl: Arrays with Label Goodness","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"LabelledArrays.jl is a package which provides arrays with labels, i.e. they are arrays which map, broadcast, and all of that good stuff, but their components are labelled. For instance, users can name the second component of an array to :second and retrieve it with A.second.","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"To install LabelledArrays.jl, use the Julia package manager:","category":"page"},{"location":"","page":"Home","title":"Home","text":"using Pkg\nPkg.add(\"LabelledArrays\")","category":"page"},{"location":"#Contributing","page":"Home","title":"Contributing","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Please refer to the SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages for guidance on PRs, issues, and other matters relating to contributing to SciML.\nSee the SciML Style Guide for common coding practices and other style decisions.\nThere are a few community forums:\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Slack\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Zulip\nOn the Julia Discourse forums\nSee also SciML Community page","category":"page"},{"location":"#Reproducibility","page":"Home","title":"Reproducibility","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"
The documentation of this SciML package was built using these direct dependencies,","category":"page"},{"location":"","page":"Home","title":"Home","text":"using Pkg # hide\nPkg.status() # hide","category":"page"},{"location":"","page":"Home","title":"Home","text":"
","category":"page"},{"location":"","page":"Home","title":"Home","text":"
and using this machine and Julia version.","category":"page"},{"location":"","page":"Home","title":"Home","text":"using InteractiveUtils # hide\nversioninfo() # hide","category":"page"},{"location":"","page":"Home","title":"Home","text":"
","category":"page"},{"location":"","page":"Home","title":"Home","text":"
A more complete overview of all dependencies and their versions is also provided.","category":"page"},{"location":"","page":"Home","title":"Home","text":"using Pkg # hide\nPkg.status(; mode = PKGMODE_MANIFEST) # hide","category":"page"},{"location":"","page":"Home","title":"Home","text":"
","category":"page"},{"location":"","page":"Home","title":"Home","text":"using TOML\nusing Markdown\nversion = TOML.parse(read(\"../../Project.toml\", String))[\"version\"]\nname = TOML.parse(read(\"../../Project.toml\", String))[\"name\"]\nlink_manifest = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Manifest.toml\"\nlink_project = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Project.toml\"\nMarkdown.parse(\"\"\"You can also download the\n[manifest]($link_manifest)\nfile and the\n[project]($link_project)\nfile.\n\"\"\")","category":"page"}] +[{"location":"Example_dsl/#Example:-Nice-DiffEq-Syntax-Without-A-DSL","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"","category":"section"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"Users of the SciML ecosystem are often solving large models with complicated states and hundreds or thousands of parameters. These models are implemented using arrays, and those arrays have traditionally been indexed by integers, such as p[1] or p[1:5]. Numerical indexing is wonderful for small models, but can quickly cause problems as models become bigger. It is easy to forget which index corresponds to which reaction rate or which diffusion coefficient. This confusion can lead to difficult to debug problems in a user's code. LabelledArrays can make an important difference here. It is much easier to build a model using parameter references such as p.rate_nacl or p.probability_birth, instead of p[26] or p[1026]. Labelled arrays make both the development and debugging of models much faster.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"LabelledArrays.jl are a way to get DSL-like syntax without a macro. In this case, we can solve differential equations with labelled components by making use of labelled arrays, and always refer to the components by name instead of index.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"One key caveat is that users do not need to sacrifice performance when using labelled arrays. Labelled arrays are as performant as traditional numerically indexed arrays.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"Let's solve the Lorenz equation using an LVectors. LVectors are mutable. Hence, we can use the non-allocating form of the OrdinaryDiffEq API.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"using LabelledArrays, OrdinaryDiffEq\n\nfunction lorenz_f!(du, u, p, t)\n du.x = p.σ * (u.y - u.x)\n du.y = u.x * (p.ρ - u.z) - u.y\n du.z = u.x * u.y - p.β * u.z\nend\n\nu0 = @LArray [1.0, 0.0, 0.0] (:x, :y, :z)\np = @LArray [10.0, 28.0, 8 / 3] (:σ, :ρ, :β)\ntspan = (0.0, 10.0)\nprob = ODEProblem(lorenz_f!, u0, tspan, p)\nsol = solve(prob, Tsit5())\n# Now the solution can be indexed as .x/y/z as well!\nsol[10].x","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"In the example above, we used an LArray to define the initial state u0 as well as the parameter vector p. The remainder of the ODE solution steps are no different that the original DifferentialEquations tutorials.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"Alternatively, we can use an immutable SLVector to implement the same equation. In this case, we need to use the allocating form of the OrdinaryDiffEq API when defining our model equation.","category":"page"},{"location":"Example_dsl/","page":"Example: Nice DiffEq Syntax Without A DSL","title":"Example: Nice DiffEq Syntax Without A DSL","text":"LorenzVector = @SLVector (:x, :y, :z)\nLorenzParameterVector = @SLVector (:σ, :ρ, :β)\n\nfunction f(u, p, t)\n x = p.σ * (u.y - u.x)\n y = u.x * (p.ρ - u.z) - u.y\n z = u.x * u.y - p.β * u.z\n LorenzVector(x, y, z)\nend\n\nu0 = LorenzVector(1.0, 0.0, 0.0)\np = LorenzParameterVector(10.0, 28.0, 8 / 3)\ntspan = (0.0, 10.0)\nprob = ODEProblem(f, u0, tspan, p)\nsol = solve(prob, Tsit5())","category":"page"},{"location":"Note_labelled_slices/#Note:-Labelled-slices","page":"Note: Labelled slices","title":"Note: Labelled slices","text":"","category":"section"},{"location":"Note_labelled_slices/","page":"Note: Labelled slices","title":"Note: Labelled slices","text":"This functionality has been removed from LabelledArrays.jl, but can be replicated with the same compile-time performance and indexing syntax using DimensionalData.jl.","category":"page"},{"location":"LArrays/#LArrays","page":"LArrays","title":"LArrays","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"LArrays are fully mutable arrays with labels. There is no performance loss by using labelled indexing instead of purely numerical indexing. Using the macro with values and labels generates the labelled array with the given values:","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"Users interested in using labelled elements in their arrays should also consider ComponentArrays from the ComponentArrays.jl library. ComponentArrays are well integrated into the SciML ecosystem.","category":"page"},{"location":"LArrays/#@LArray-and-@LVector-macros","page":"LArrays","title":"@LArray and @LVector macros","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"Macro constructors are convenient for building most LArray objects. An @LArray may be of arbitrary dimension, while an @LVector is a one dimensional array.","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"@LArray\n@LVector","category":"page"},{"location":"LArrays/#LabelledArrays.@LArray","page":"LArrays","title":"LabelledArrays.@LArray","text":"@LArray Eltype Size Names\n@LArray Values Names\n\nThe @LArray macro creates an LArray with names determined from the Names vector and values determined from the Values vector. Otherwise, the eltype and size are used to make an LArray with undefined values.\n\nA = @LArray [1, 2, 3] (:a, :b, :c)\nA.a == 1\n\nUsers can also generate a labelled array with undefined values by instead giving the dimensions. This approach is useful if the user intends to pre-allocate an array for some later input.\n\nA = @LArray Float64 (2, 2) (:a, :b, :c, :d)\nW = rand(2, 2)\nA .= W\nA.d == W[2, 2]\n\nUsers may also use an alternative constructor to set the Names and Values and ranges at the same time.\n\njulia> z = @LArray [1.0, 2.0, 3.0] (a = 1:2, b = 2:3);\n\njulia> z.b\n2-element view(::Array{Float64,1}, 2:3) with eltype Float64:\n 2.0\n 3.0\n\njulia> z = @LArray [1 2; 3 4] (a = (2, :), b = 2:3);\n\njulia> z.a\n2-element view(::Array{Int64,2}, 2, :) with eltype Int64:\n 3\n 4\n\nThe labels of LArray and SLArray can be accessed by function symbols, which returns a tuple of symbols.\n\n\n\n\n\n","category":"macro"},{"location":"LArrays/#LabelledArrays.@LVector","page":"LArrays","title":"LabelledArrays.@LVector","text":"@LVector Type Names\n\nThe @LVector macro creates an LArray of dimension 1 with eltype and undefined values. The vector's length is equal to the number of names given.\n\nAs with an LArray, the user can initialize the vector and set its values later.\n\nA = @LVector Float64 (:a, :b, :c, :d)\nA .= rand(4)\n\nTo initialize the vector and set its values at the same time, use @LArray instead:\n\nb = @LArray [1, 2, 3] (:a, :b, :c)\n\n\n\n\n\n","category":"macro"},{"location":"LArrays/#LArray-and-LVector-constructors","page":"LArrays","title":"LArray and LVector constructors","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"The original constructors for LArrays and LVectors are as follows:","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"LArray\nLVector","category":"page"},{"location":"LArrays/#LabelledArrays.LArray","page":"LArrays","title":"LabelledArrays.LArray","text":"LArray(::Tuple, ::NamedTuple)\nLArray(::Tuple, kwargs)\n\nThe standard constructors for LArray.\n\nFor example:\n\nLArray((2, 2), (a = 1, b = 2, c = 3, d = 4)) # need to specify size\nLArray((2, 2); a = 1, b = 2, c = 3, d = 4)\n\n\n\n\n\nLVector(v1::Union{SLArray,LArray}; kwargs...)\n\nCreates a copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nABCD = @SLArray (2,2) (:a,:b,:c,:d);\nB = ABCD(1,2,3,4);\nB2 = LArray(B; c=30 )\n\n\n\n\n\n","category":"type"},{"location":"LArrays/#LabelledArrays.LVector","page":"LArrays","title":"LabelledArrays.LVector","text":"LVector(::NamedTuple)\nLVector(kwargs)\n\nThe standard constructor for LVector.\n\nFor example:\n\nLVector((a = 1, b = 2))\nLVector(a = 1, b = 2)\n\n\n\n\n\nLVector(v1::Union{SLArray,LArray}; kwargs...)\n\nCreates a 1D copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nz = LVector(a=1, b=2, c=3);\nz2 = LVector(z; c=30)\n\n\n\n\n\n","category":"function"},{"location":"LArrays/#Manipulating-LArrays-and-LVectors","page":"LArrays","title":"Manipulating LArrays and LVectors","text":"","category":"section"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"User may want a list of the labels or keys in an LArray or LVector. The symbols(::LArray) function returns a tuple of array labels.","category":"page"},{"location":"LArrays/","page":"LArrays","title":"LArrays","text":"symbols","category":"page"},{"location":"LArrays/#LabelledArrays.symbols","page":"LArrays","title":"LabelledArrays.symbols","text":"symbols(::SLArray)\n\nReturns the labels of the SLArray.\n\nFor example:\n\njulia> z = SLVector(a = 1, b = 2, c = 3)\n3-element SLArray{Tuple{3}, Int64, 1, 3, (:a, :b, :c)} with indices SOneTo(3):\n :a => 1\n :b => 2\n :c => 3\n\njulia> symbols(z)\n(:a, :b, :c)\n\n\n\n\n\nsymbols(::LArray)\n\nReturns the labels of the LArray.\n\nFor example:\n\njulia> z = @LVector Float64 (:a, :b, :c, :d);\n\njulia> symbols(z)\n(:a, :b, :c, :d)\n\n\n\n\n\n","category":"function"},{"location":"SLArrays/#SLArrays","page":"SLArrays","title":"SLArrays","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"The SLArray and SLVector macros create static LabelledArrays. First, the user would create the array type, then use that constructor to generate instances of the labelled array.","category":"page"},{"location":"SLArrays/#@SLArray-and-@SLVector-macros","page":"SLArrays","title":"@SLArray and @SLVector macros","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"Macro constructors are convenient for building most SLArray objects. An @SLArray may be of arbitrary dimension, while an @SLVector is a one dimensional array.","category":"page"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"@SLArray\n@SLVector","category":"page"},{"location":"SLArrays/#LabelledArrays.@SLArray","page":"SLArrays","title":"LabelledArrays.@SLArray","text":"@SLArray Size Names\n@SLArray Eltype Size Names\n\nThe macro creates a labelled static vector with element type ElType, names from Names, and size from Size. If no eltype is given, then the eltype is determined from the arguments in the constructor.\n\nFor example:\n\nABCD = @SLArray (2, 2) (:a, :b, :c, :d)\nx = ABCD(1.0, 2.5, 3.0, 5.0)\nx.a == 1.0\nx.b == 2.5\nx.c == x[3]\nx.d == x[2, 2]\nEFG = @SLArray (2, 2) (e = 1:3, f = 4, g = 2:4)\ny = EFG(1.0, 2.5, 3.0, 5.0)\nEFG = @SLArray (2, 2) (e = (2, :), f = 4, g = 2:4)\n\nUsers can also specify the indices directly.\n\njulia> EFG = @SLArray (2, 2) (e = 1:3, f = 4, g = 2:4);\n\njulia> y = EFG(1.0, 2.5, 3.0, 5.0)\n2×2 SLArray{Tuple{2,2},Float64,2,4,(e = 1:3, f = 4, g = 2:4)}:\n 1.0 3.0\n 2.5 5.0\n\njulia> y.g\n3-element view(reshape(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}, 4), 2:4) with eltype Float64:\n 2.5\n 3.0\n 5.0\n\njulia> Arr = @SLArray (2, 2) (a = (2, :), b = 3);\n\njulia> z = Arr(1, 2, 3, 4);\n\njulia> z.a\n2-element view(::StaticArrays.SArray{Tuple{2,2},Int64,2,4}, 2, :) with eltype Int64:\n 2\n 4\n\n\n\n\n\n","category":"macro"},{"location":"SLArrays/#LabelledArrays.@SLVector","page":"SLArrays","title":"LabelledArrays.@SLVector","text":"@SLVector Names\n@SLVector Eltype Names\n\nThe macro creates a labelled static vector with element type ElType, and names from Names. If no eltype is given, then the eltype is determined from the values in the constructor. The array size is found from the input data.\n\nFor example:\n\nABC = @SLVector (:a, :b, :c)\nx = ABC(1.0, 2.5, 3.0)\nx.a == 1.0\nx.b == 2.5\nx.c == x[3]\n\n\n\n\n\n","category":"macro"},{"location":"SLArrays/#SLArray-and-SLVector-constructors","page":"SLArrays","title":"SLArray and SLVector constructors","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"Alternatively, users can construct a static labelled array using the SLVector and SLArrays constructors by writing out the entries as keyword arguments:","category":"page"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"SLArray\nSLVector","category":"page"},{"location":"SLArrays/#LabelledArrays.SLArray","page":"SLArrays","title":"LabelledArrays.SLArray","text":"SLArray{::Tuple}(::NamedTuple)\nSLArray{::Tuple}(kwargs)\n\nThese are the standard constructors for SLArray. For general N-dimensional labelled arrays, users need to specify the size (Tuple{dim1,dim2,...}) in the type parameter to the SLArray constructor:\n\njulia> SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))\n2×2 SLArray{Tuple{2, 2}, Int64, 2, 4, (:a, :b, :c, :d)} with indices SOneTo(2)×SOneTo(2):\n :a => 1 :c => 3\n :b => 2 :d => 4\n\njulia> SLArray{Tuple{2, 2}}(a = 1, b = 2, c = 3, d = 4)\n 2×2 SLArray{Tuple{2,2},2,(:a, :b, :c, :d),Int64}:\n 1 3\n 2 4\n\nConstructing copies with some changed elements is supported by a keyword constructor whose first argument is the source and whose additional keyword arguments indicate the changes.\n\njulia> ABCD = @SLArray (2, 2) (:a, :b, :c, :d);\n\njulia> B = ABCD(1, 2, 3, 4);\n\njulia> B2 = SLArray(B; c = 30)\n2×2 SLArray{Tuple{2,2},Int64,2,4,(:a, :b, :c, :d)}:\n 1 30\n 2 4\n\nAdditional examples:\n\nSLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))\n\n\n\n\n\nSLVector(v1::SLArray; kwargs...)\n\nCreates a copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nABCD = @SLArray (2,2) (:a,:b,:c,:d);\nB = ABCD(1,2,3,4);\nB2 = SLArray(B; c=30 )\n\n\n\n\n\n","category":"type"},{"location":"SLArrays/#LabelledArrays.SLVector","page":"SLArrays","title":"LabelledArrays.SLVector","text":"SLVector(::NamedTuple)\nSLVector(kwargs)\n\nThe standard constructors for SLArray.\n\njulia> SLVector(a = 1, b = 2, c = 3)\n3-element SLArray{Tuple{3},1,(:a, :b, :c),Int64}:\n 1\n 2\n 3\n\nConstructing copies with some items changed is supported by a keyword constructor whose first argument is the source and whose additional keyword arguments indicate the changes.\n\njulia> v1 = SLVector(a = 1.1, b = 2.2, c = 3.3);\n\njulia> v2 = SLVector(v1; b = 20.20, c = 30.30)\n3-element SLArray{Tuple{3},Float64,1,3,(:a, :b, :c)}:\n 1.1\n 20.2\n 30.3\n\nAdditional examples:\n\nSLVector((a = 1, b = 2))\nSLVector(a = 1, b = 2)\n\n\n\n\n\nSLVector(v1::SLArray; kwargs...)\n\nCreates a 1D copy of v1 with corresponding items in kwargs replaced.\n\nFor example:\n\nz = SLVector(a=1, b=2, c=3);\nz2 = SLVector(z; c=30)\n\n\n\n\n\n","category":"function"},{"location":"SLArrays/#Manipulating-SLArrays-and-SLVectors","page":"SLArrays","title":"Manipulating SLArrays and SLVectors","text":"","category":"section"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"Users may want a list of the labels or keys in an SLArray or SLVector. The symbols(::SLArray) function returns a tuple of array labels.","category":"page"},{"location":"SLArrays/","page":"SLArrays","title":"SLArrays","text":"symbols(::SLArray)","category":"page"},{"location":"SLArrays/#LabelledArrays.symbols-Tuple{SLArray}","page":"SLArrays","title":"LabelledArrays.symbols","text":"symbols(::SLArray)\n\nReturns the labels of the SLArray.\n\nFor example:\n\njulia> z = SLVector(a = 1, b = 2, c = 3)\n3-element SLArray{Tuple{3}, Int64, 1, 3, (:a, :b, :c)} with indices SOneTo(3):\n :a => 1\n :b => 2\n :c => 3\n\njulia> symbols(z)\n(:a, :b, :c)\n\n\n\n\n\nsymbols(::LArray)\n\nReturns the labels of the LArray.\n\nFor example:\n\njulia> z = @LVector Float64 (:a, :b, :c, :d);\n\njulia> symbols(z)\n(:a, :b, :c, :d)\n\n\n\n\n\n","category":"method"},{"location":"NamedTuples_relation/#Relation-to-NamedTuples","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"","category":"section"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"Julia's Base has NamedTuples in v0.7+. They are constructed as:","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"p = (σ = 10.0, ρ = 28.0, β = 8 / 3)","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"and they support p[1] and p.σ as well. The LVector, SLVector, LArray and SLArray constructors also support named tuples as their arguments:","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"julia> LVector((a = 1, b = 2))\n2-element LArray{Int64,1,(:a, :b)}:\n 1\n 2\n\njulia> SLVector((a = 1, b = 2))\n2-element SLArray{Tuple{2},1,(:a, :b),Int64}:\n 1\n 2\n\njulia> LArray((2, 2), (a = 1, b = 2, c = 3, d = 4))\n2×2 LArray{Int64,2,(:a, :b, :c, :d)}:\n 1 3\n 2 4\n\njulia> SLArray{Tuple{2, 2}}((a = 1, b = 2, c = 3, d = 4))\n2×2 SLArray{Tuple{2,2},2,(:a, :b, :c, :d),Int64}:\n 1 3\n 2 4","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"Converting to a named tuple from a labelled array x is available using convert(NamedTuple, x). Furthermore, pairs(x) creates an iterator that is functionally the same as pairs(convert(NamedTuple, x)), yielding :label => x.label for each label of the array.","category":"page"},{"location":"NamedTuples_relation/","page":"Relation to NamedTuples","title":"Relation to NamedTuples","text":"There are some crucial differences between a labelled array and a named tuple. Labelled arrays can have any dimensions, while named tuples are always 1D. A named tuple can have different types on each element, while an SLArray can only have one element type and furthermore it has the actions of a static vector. As a result SLArray has less element type information, which improves compilation speed while giving more vector functionality than a NamedTuple. LArray also only has a single element type and, unlike a named tuple, is mutable.","category":"page"},{"location":"#LabelledArrays.jl:-Arrays-with-Label-Goodness","page":"Home","title":"LabelledArrays.jl: Arrays with Label Goodness","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"LabelledArrays.jl is a package which provides arrays with labels, i.e. they are arrays which map, broadcast, and all of that good stuff, but their components are labelled. For instance, users can name the second component of an array to :second and retrieve it with A.second.","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"To install LabelledArrays.jl, use the Julia package manager:","category":"page"},{"location":"","page":"Home","title":"Home","text":"using Pkg\nPkg.add(\"LabelledArrays\")","category":"page"},{"location":"#Contributing","page":"Home","title":"Contributing","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Please refer to the SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages for guidance on PRs, issues, and other matters relating to contributing to SciML.\nSee the SciML Style Guide for common coding practices and other style decisions.\nThere are a few community forums:\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Slack\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Zulip\nOn the Julia Discourse forums\nSee also SciML Community page","category":"page"},{"location":"#Reproducibility","page":"Home","title":"Reproducibility","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"
The documentation of this SciML package was built using these direct dependencies,","category":"page"},{"location":"","page":"Home","title":"Home","text":"using Pkg # hide\nPkg.status() # hide","category":"page"},{"location":"","page":"Home","title":"Home","text":"
","category":"page"},{"location":"","page":"Home","title":"Home","text":"
and using this machine and Julia version.","category":"page"},{"location":"","page":"Home","title":"Home","text":"using InteractiveUtils # hide\nversioninfo() # hide","category":"page"},{"location":"","page":"Home","title":"Home","text":"
","category":"page"},{"location":"","page":"Home","title":"Home","text":"
A more complete overview of all dependencies and their versions is also provided.","category":"page"},{"location":"","page":"Home","title":"Home","text":"using Pkg # hide\nPkg.status(; mode = PKGMODE_MANIFEST) # hide","category":"page"},{"location":"","page":"Home","title":"Home","text":"
","category":"page"},{"location":"","page":"Home","title":"Home","text":"using TOML\nusing Markdown\nversion = TOML.parse(read(\"../../Project.toml\", String))[\"version\"]\nname = TOML.parse(read(\"../../Project.toml\", String))[\"name\"]\nlink_manifest = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Manifest.toml\"\nlink_project = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Project.toml\"\nMarkdown.parse(\"\"\"You can also download the\n[manifest]($link_manifest)\nfile and the\n[project]($link_project)\nfile.\n\"\"\")","category":"page"}] }