Ferrite-FEM / Ferrite-FEM/Tensors.jl
Support power with integer?
- Dominant language
- Julia
- Stars
- 182
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
Currently, we allow `x^2` or `x^10`, as long as the exponent is a literal `Base.literal_pow`, but non-literal exponentiation is not supported, i.e.
```julia
julia> bar(x, n) = x^n
bar (generic function with 1 method)
julia> bar(rand(Tensor{2,2}), 3)
ERROR: use `⋅` (`\cdot`) for single contraction and `⊡` (`\boxdot`) for double contraction instead of `*`
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:44
[2] *(S1::Tensor{2, 2, Float64, 4}, S2::Tensor{2, 2, Float64, 4})
@ Tensors ~/.julia/dev/Tensors/src/tensor_ops_errors.jl:3
[3] power_by_squaring(x_::Tensor{2, 2, Float64, 4}, p::Int64; mul::typeof(*))
@ Base ./intfuncs.jl:365
[4] power_by_squaring(x_::Tensor{2, 2, Float64, 4}, p::Int64)
@ Base ./intfuncs.jl:364
[5] ^(A::Tensor{2, 2, Float64, 4}, p::Int64)
@ LinearAlgebra ~/.julia/juliaup/julia-1.12.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.12/LinearAlgebra/src/dense.jl:560
[6] bar(x::Tensor{2, 2, Float64, 4}, n::Int64)
@ Main ./REPL[43]:1
[7] top-level scope
@ REPL[44]:1
```
as this calls the generic `^` from `LinearAlgebra/src/dense.jl`
Didn't really need this but figured it is good to document this behavior so that if somebody needs it, they can find this issue and know that it needs to be implemented and that they didn't do anything wrong.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.