Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #61

Merged
merged 8 commits into from
Dec 11, 2018
Merged

Update README.md #61

merged 8 commits into from
Dec 11, 2018

Conversation

MasonProtter
Copy link
Contributor

@MasonProtter MasonProtter commented Dec 10, 2018

I know there's not anything particularly new here, but I thought it'd be good to show an example where you construct an OffsetArray from a preexisting array instead of an undef. This might be redundant for experienced users but I think it's helpful for newcomers. The relativistic notation was just the first example that came to mind where 0 based indexing was natural.

It can be changed to something more natural or accessible if needed.

@timholy
Copy link
Member

timholy commented Dec 10, 2018

Hmm, yes, the current README is indeed pretty anemic. 👍

Why do you insert :t in the constructor instead of prior? (Just thinking we might as well make this pretty simple.) Also, since I imagine most people will be interested in numeric arrays, what about something like

η = 0.1
v1 = [sinh(η), cosh(η), 0, 0]
v0 = OffsetArray(v1, 0:3)

just to separate the values of the array from setting the indexing?

I don't feel attached to these suggestions, just wondering. And your version might have some advantages, so I'd be happy to merge this as-is.

@MasonProtter
Copy link
Contributor Author

MasonProtter commented Dec 10, 2018

I did [:t, [:x, :y, :z]...] because I thought might highlight that I’m interested in a spatial, one-based vector r = [:x, :y, :z] and a zero-based spacetime vector x. I like this because it emphasizes that 0-based and 1-based arrays might be useful for two related quantities in one problem.

Perhaps it’d e good to have the symbolic example as well as the numeric example? Or I can just switch to your numeric example.

Would you still prefer that it be something like OffsetVector([:t, :x, :y, :z], 0:3) instead?

@MasonProtter
Copy link
Contributor Author

MasonProtter commented Dec 10, 2018

I've added an exmple where one may want to express the coefficients of the Laurent polynomial

6/x + 5 - 2*x + 3*x^2 + x^3

as a -1-based array, since if one counts from -1, the nth coefficient corresponds to the nth power of x. This also introduces the eachindex function which is very useful when working with any AbstractArray and should be advertised to potential users of OffsetArrays.jl

README.md Outdated Show resolved Hide resolved
@timholy
Copy link
Member

timholy commented Dec 11, 2018

Test failures addressed in #62

@timholy timholy merged commit 39a16a3 into JuliaArrays:master Dec 11, 2018
@timholy
Copy link
Member

timholy commented Dec 11, 2018

Thanks for an excellent and much-needed enhancement!

@MasonProtter MasonProtter deleted the patch-1 branch December 11, 2018 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants