Skip to content

Commit

Permalink
Docstring for the tensor_product macro
Browse files Browse the repository at this point in the history
  • Loading branch information
KnutAM committed Jan 1, 2024
1 parent c6c0755 commit 62d0fc7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,20 @@ function tensor_product!(expr, args...)
return expr
end

"""
@tensor_product(expr, args...)
Generate a function to evaluate a tensor product based on an index expression.
```julia
@tensor_product function my_op(A::Tensor{2,3}, B::Tensor{1,3})
C[i] = A[i,j]*B[j]
end
```
The type specification of `A` and `B` should contain at least the type of tensor, order, and dim.
Additional type parameters can optionally be given to dispatch on e.g. the `eltype`.
The return type of `C`, i.e. `Tensor` or `SymmetricTensor` is inferred from the index
expression and the input tensors.
"""
macro tensor_product(expr, args...)
tensor_product!(expr, args...)
end
Expand Down

0 comments on commit 62d0fc7

Please sign in to comment.