Skip to content

Commit

Permalink
Remove vdots, use contract3 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
KeitaNakamura committed Sep 4, 2024
1 parent 1a9f51c commit 941dc06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tensorial"
uuid = "98f94333-fa9f-48a9-ad80-1c66397b2b38"
authors = ["Keita Nakamura <[email protected]>"]
version = "0.16.0"
version = "0.16.1"

[deps]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand Down
6 changes: 4 additions & 2 deletions src/Tensorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ export
levicivita,
# operations
contract,
contract1,
contract2,
contract3,
otimes,
dotdot,
symmetric,
minorsymmetric,
skew,
,
,
,
rotmat,
rotmatx,
rotmaty,
Expand All @@ -80,6 +82,7 @@ export
quaternion,
angleaxis

const contract1 = dot

include("utils.jl")
include("Symmetry.jl")
Expand All @@ -102,7 +105,6 @@ include("quaternion.jl")

const = otimes
const = contract2
const = contract3

@deprecate contraction contract true
@deprecate double_contraction contract2 true
Expand Down
10 changes: 5 additions & 5 deletions src/ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ end
@inline Base.:-(x::AbstractTensor, y::UniformScaling) = _add_uniform( x, -y.λ)
@inline Base.:+(x::UniformScaling, y::AbstractTensor) = _add_uniform( y, x.λ)
@inline Base.:-(x::UniformScaling, y::AbstractTensor) = _add_uniform(-y, x.λ)
@inline dot(x::Union{AbstractVec, AbstractMat, AbstractSquareTensor}, y::UniformScaling) = x * y.λ
@inline dot(x::UniformScaling, y::Union{AbstractVec, AbstractMat, AbstractSquareTensor}) = x.λ * y
@inline contract1(x::Union{AbstractVec, AbstractMat, AbstractSquareTensor}, y::UniformScaling) = x * y.λ
@inline contract1(x::UniformScaling, y::Union{AbstractVec, AbstractMat, AbstractSquareTensor}) = x.λ * y
@inline contract2(x::AbstractSquareTensor, y::UniformScaling) = tr(x) * y.λ
@inline contract2(x::UniformScaling, y::AbstractSquareTensor) = x.λ * tr(y)

Expand All @@ -58,7 +58,7 @@ end
Conduct contraction of `N` inner indices.
For example, `N=2` contraction for third-order tensors ``A_{ij} = B_{ikl} C_{klj}``
can be computed in Tensorial.jl as
can be computed as follows:
```jldoctest
julia> B = rand(Tensor{Tuple{3,3,3}});
Expand Down Expand Up @@ -178,8 +178,8 @@ julia> a = x ⋅ y
0.5715585109976284
```
"""
@inline dot(x1::AbstractTensor, x2::AbstractTensor) = contract(x1, x2, Val(1))
@inline contract2(x1::AbstractTensor, x2::AbstractTensor) = contract(x1, x2, Val(2))
@inline dot(x1::AbstractTensor, x2::AbstractTensor) = contract(x1, x2, Val(1)) # dot, ⋅
@inline contract2(x1::AbstractTensor, x2::AbstractTensor) = contract(x1, x2, Val(2)) #
@inline contract3(x1::AbstractTensor, x2::AbstractTensor) = contract(x1, x2, Val(3))

"""
Expand Down

2 comments on commit 941dc06

@KeitaNakamura
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/114571

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.16.1 -m "<description of version>" 941dc06468f8b24e22102897d30636638613cd70
git push origin v0.16.1

Please sign in to comment.