Skip to content

Commit a2141a1

Browse files
Merge pull request #776 from SciML/ChrisRackauckas-patch-1
Add more details to the indexing interface page
2 parents 62cd8ec + 56f31e0 commit a2141a1

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

docs/src/basics/solution.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# [Solution Handling](@id solution)
22

3+
The solution is an `RecursiveArrayTools.AbstractDiffEqArray`.
4+
[See RecursiveArrayTools.jl for more information on the interface](https://docs.sciml.ai/RecursiveArrayTools/stable/).
5+
The following is a more DiffEq-centric explanation of the interface.
6+
37
## Accessing the Values
48

59
The solution type has a lot of built-in functionality to help analysis. For example,
@@ -14,11 +18,10 @@ derivative at each timestep `du` or the spatial discretization `x`, `y`, etc.
1418

1519
## Array Interface
1620

17-
Instead of working on the `Vector{uType}` directly, we can use the provided
18-
array interface.
21+
The general operations are as follows. Use
1922

2023
```julia
21-
sol[j]
24+
sol.u[j]
2225
```
2326

2427
to access the value at timestep `j` (if the timeseries was saved), and
@@ -34,7 +37,8 @@ will address first by component and lastly by time, and thus
3437
sol[i, j]
3538
```
3639

37-
will be the `i`th component at timestep `j`. Hence, `sol[j][i] == sol[i, j]`. This is done because Julia is column-major, so the leading dimension should be contiguous in memory. If the independent variables had shape
40+
will be the `i`th component at timestep `j`. Hence, `sol[j][i] == sol[i, j]`. This is done because Julia is column-major,
41+
so the leading dimension should be contiguous in memory. If the independent variables had shape
3842
(for example, was a matrix), then `i` is the linear index. We can also access
3943
solutions with shape:
4044

@@ -87,7 +91,12 @@ at a time `t` using the command
8791
sol(t)
8892
```
8993

90-
Note that the interpolating function allows for `t` to be a vector and uses this to speed up the interpolation calculations. The full API for the interpolations is
94+
Note that the interpolating function allows for `t` to be a vector and uses this to speed up the interpolation calculations. If `t` is an `AbstractVector`, then
95+
the returned object is a `RecursiveArrayTools.DiffEqArray`, [see RecursiveArrayTools.jl for more information](https://docs.sciml.ai/RecursiveArrayTools/stable/).
96+
Note that the differential equation solution object itself is an `AbstractDiffEqArray`, and this means that the returned object will have the same indexing
97+
behavior as a solution type itself, thus see the indexing description above.
98+
99+
The full API for the interpolations is:
91100

92101
```julia
93102
sol(t, deriv = Val{0}; idxs = nothing, continuity = :left)
@@ -117,14 +126,6 @@ which will write the output to `out`. This allows one to use pre-allocated vecto
117126

118127
## Comprehensions
119128

120-
The solver interface also gives tools for using comprehensions over the solution.
121-
Using the `tuples(sol)` function, we can get a tuple for the output at each
122-
timestep. This allows one to do the following:
123-
124-
```julia
125-
[t + 2u for (u, t) in tuples(sol)]
126-
```
127-
128129
One can use the extra components of the solution object as well as using `zip`. For
129130
example, say the solution type holds `du`, the derivative at each timestep. One
130131
can comprehend over the values using:

0 commit comments

Comments
 (0)