Tensors.jl
Tensors.jl copied to clipboard
tensor_product macro
Make it easy to define new unrolled tensor expressions based on an index expression, xref: https://github.com/Ferrite-FEM/Tensors.jl/pull/205#discussion_r1359951108
Examples
Tensors.@tensor_product(@inline @inbounds function dcontract(A::Tensor{4,3}, B::Tensor{4,3})
C[i,j,k,l] = A[i,j,m,n]*B[m,n,k,l]
end, muladd)
Tensors.@tensor_product(@inline @inbounds function otimes(A::Tensor{2,3}, B::Tensor{2,3})
C[i,j,k,l] = A[i,j]*B[k,l]
end)
TODO
- [x] Support
SymmetricTensoroutput (need to automatically figure out when based on the input and expression) - [x] Replace current functions with the generated functions where that makes sense (e.g.
otimesalready use index expression, and that approach seems faster than manually unrolling) - [x] Document the macro such that users can create their special functions (not public API yet)
Codecov Report
Attention: 16 lines in your changes are missing coverage. Please review.
Comparison is base (
ce37b01) 96.91% compared to head (62d0fc7) 93.69%. Report is 3 commits behind head on master.
| Files | Patch % | Lines |
|---|---|---|
| src/utilities.jl | 92.48% | 16 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## master #211 +/- ##
==========================================
- Coverage 96.91% 93.69% -3.23%
==========================================
Files 17 17
Lines 1490 1522 +32
==========================================
- Hits 1444 1426 -18
- Misses 46 96 +50
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think this can also really help users getting https://github.com/Ferrite-FEM/Tensors.jl/pull/188 functional for their corner cases
@fredrikekre or @KristofferC - would any of you have time to review?
Feels like there is too much code for "parsing" the user input, but didn't find a way to reduce it...