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
Suppose we have a position vector `r = [:x, :y, :z]` which is naturally one-based, ie. `r[1] == :x`, `r[2] == :y`, `r[3] == :z` and we also want to construct a relativistic position vector which includes time as the 0th component. This can be done with OffsetArrays like
69
+
Suppose we have a position vector `r = [:x, :y, :z]` which is naturally one-based, ie. `r[1] == :x`, `r[2] == :y`, `r[3] == :z` and we also want to construct a relativistic position vector which includes time as the 0th component. This can be done with OffsetArrays like
70
+
25
71
```julia
26
72
julia>using OffsetArrays
27
73
@@ -49,7 +95,7 @@ Suppose one wants to represent the Laurent polynomial
49
95
```
50
96
6/x + 5 - 2*x + 3*x^2 + x^3
51
97
```
52
-
in julia. The coefficients of this polynomial are a naturally `-1` based list, since the `n`th element of the list
98
+
in julia. The coefficients of this polynomial are a naturally `-1` based list, since the `n`th element of the list
53
99
(counting from `-1`) `6, 5, -2, 3, 1` is the coefficient corresponding to the `n`th power of `x`. This Laurent polynomial can be evaluated at say `x = 2` as follows.
54
100
```julia
55
101
julia>using OffsetArrays
@@ -72,4 +118,8 @@ Notice our use of the `eachindex` function which does not assume that the given
72
118
73
119
## Notes on supporting OffsetArrays
74
120
75
-
Julia supports generic programming with arrays that doesn't require you to assume that indices start with 1, see the [documentation](http://docs.julialang.org/en/latest/devdocs/offset-arrays/).
121
+
There are several "tricks" that make it easier to support arrays with general indexes, see the [documentation](http://docs.julialang.org/en/latest/devdocs/offset-arrays/).
0 commit comments