-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make it more like StaticArrays.jl #222
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #222 +/- ##
==========================================
+ Coverage 93.68% 93.73% +0.05%
==========================================
Files 18 18
Lines 1583 1581 -2
==========================================
- Hits 1483 1482 -1
+ Misses 100 99 -1 ☔ View full report in Codecov by Sentry. |
Hello, @ExpandingMan. Based on your comment in #210, I’m experimentally considering changing the package to be more consistent with StaticArrays.jl, making it easier to switch from StaticArrays.jl to Tensorial.jl. To do this, I plan to:
However, (3) is difficult because similar-looking operators, like |
Cool! This is an exciting development, I think this is very worth doing. StaticArrays.jl has a lot of its own problems, so I think it's possible to go too far in emulating it, but on the other hand I think maintaining consistency with standard conventions of the Julia Let me re-familiarize myself with the API here and see if I can make an educated suggestion. |
I'm not entirely clear on all the changes that are implicit in this PR, but I'll give an outline of where the current version is incompatible with standard conventions of First, and perhaps most importantly, as well as for scalars (which Tensorial already does). As far as I know,
As for single contractions, I'm a bit surprised that there aren't already methods for contracting individual indices apart from
this would mean that |
Thanks for your comments.
Yes, this PR simply restores the multiplication as follows: julia> A = rand(Mat{3,2})
3×2 Mat{3, 2, Float64, 6}:
0.265676 0.383535
0.525552 0.664998
0.27495 0.77021
julia> B = rand(Mat{2,3})
2×3 Mat{2, 3, Float64, 6}:
0.66506 0.275736 0.206113
0.145932 0.279541 0.616196
julia> A * B
3×3 Tensor{Tuple{3, 3}, Float64, 2, 9}:
0.23266 0.18047 0.291092
0.446568 0.330808 0.518092
0.295257 0.291119 0.531271
julia> a = rand(Vec{2})
2-element Vec{2, Float64}:
0.24376793178856293
0.8046192769558261
julia> A * a
3-element Vec{3, Float64}:
0.3733630609973071
0.6631827209074246
0.6867495652822495 I also think that defining
In my field,
The lower-level interface has already been implemented to achieve the functionality of |
0d65f2b
to
9bcbe8d
Compare
9bcbe8d
to
2a7a3f7
Compare
That's a good point. Anyway, I think it's fine, it's clearly absolutely required for matrix-vector and matrix-matrix to satisfy the interface, but if you leave the rest undefined, it's fine, I don't think any other package defines any other cases.
I seem to remember having this conversation when I opened the initial issue, and at first I thought it was strange when you said that, but then I remembered this convention sometimes being used in literature I'm familiar with. I'm most familiar with tensors from general relativity and quantum field theory, which tend to use either component or abstract index notation nearly 100% of the time, so when I see If you'd like, I can text out the changes you made here and verify that StaticArray (or indeed Array) can now be swapped for Tensorial tensors without breaking, but it might take me a day or two to get to it. |
I've gone in and checked out this branch. I have done various tests of compatibility with This package is really great, by the way, I'm excited for this. StaticArrays uses a horrible hack called |
Thank you very much for checking the compatibility with |
No description provided.