Skip to content

Commit

Permalink
extended algebra compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Apr 24, 2024
1 parent 2ea23b1 commit 309579e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TensorFields"
uuid = "86e2b4fd-d9c8-44dc-a03f-e0a387f3b4e6"
authors = ["Michael Reed"]
version = "0.1.5"
version = "0.1.6"

[deps]
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Expand Down
18 changes: 9 additions & 9 deletions src/TensorFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module TensorFields
# \/ \___|_| |_|___/\___/|_| \/ |_|\___|_|\__,_|___/

using SparseArrays, LinearAlgebra, Base.Threads, Grassmann, Requires
import Grassmann: value, vector, valuetype, tangent, Derivation, radius,
import Grassmann: value, vector, valuetype, tangent, istangent, Derivation, radius,
import Grassmann: Values, Variables, FixedVector
import Grassmann: Scalar, GradedVector, Bivector, Trivector
import Base: @pure, OneTo
Expand Down Expand Up @@ -145,14 +145,14 @@ function show_pairtyped(io::IO, s::Section{B,F}) where {B,F}
show(io, (base(s), fiber(s)))
end

for fun (:-,:!,:~,:inv,:exp,:log,:sinh,:cosh,:abs,:sqrt,:real,:imag,:cos,:sin,:tan,:cot,:sec,:csc,:asec,:acsc,:sech,:csch,:asech,:tanh,:coth,:asinh,:acosh,:atanh,:acoth,:asin,:acos,:atan,:acot,:sinc,:cosc,:abs2,:conj)
for fun (:-,:!,:~,:inv,:exp,:log,:sinh,:cosh,:abs,:sqrt,:cbrt,:real,:imag,:cos,:sin,:tan,:cot,:sec,:csc,:asec,:acsc,:sech,:csch,:asech,:tanh,:coth,:asinh,:acosh,:atanh,:acoth,:asin,:acos,:atan,:acot,:sinc,:cosc,:abs2,:conj,:deg2rad)
@eval Base.$fun(s::Section) = base(s) $fun(fiber(s))
end
for fun (:reverse,:involute,:clifford,:even,:odd,:scalar,:vector,:bivector,:volume,:value,:curl,:∂,:d,:,:angle,:radius)
for fun (:reverse,:involute,:clifford,:even,:odd,:scalar,:vector,:bivector,:volume,:value,:curl,:∂,:d,:,:angle,:radius,:complementleft,:complementlefthodge,:pseudoabs,:pseudoabs2,:pseudoexp,:pseudolog,:pseudoinv,:pseudosqrt,:pseudocbrt,:pseudocos,:pseudosin,:pseudotan,:pseudocosh,:pseudosinh,:pseudotanh)
@eval Grassmann.$fun(s::Section) = base(s) $fun(fiber(s))
end
for op (:+,:-,:*,:/,:^,:<,:>,:<<,:>>,:&,:,:)
let bop = op (:,:) ? :(Grassmann.$op) : :(Base.$op)
for op (:+,:-,:*,:/,:^,:<,:>,:<<,:>>,:&,:,:,:,:>>>,:,:veedot)
let bop = op (:,:,:,:,:veedot) ? :(Grassmann.$op) : :(Base.$op)
@eval begin
$bop(a::Section{R},b::Section{R}) where R = base(a)==base(b) ? Section(base(a),$op(fiber(a),fiber(b))) : error("Section $(base(a))$(base(b))")
$bop(a::Number,b::Section) = base(b) $op(a,fiber(b))
Expand Down Expand Up @@ -344,19 +344,19 @@ function Grassmann.Chain(t::TensorField{B,T,<:Chain{V,G}} where {B,T}) where {V,
Chain{V,G}((base(t) getindex.(fiber(t),j) for j 1:binomial(mdims(V),G))...)
end
Base.:^(t::TensorField,n::Int) = domain(t) codomain(t).^n
for op (:*,:/,:+,:-,:^,:>,:<,:>>,:<<,:&,:,:,:)
let bop = op (:,:,:) ? :(Grassmann.$op) : :(Base.$op)
for op (:*,:/,:+,:-,:^,:>,:<,:>>,:<<,:&,:,:,:,:,:>>>,:,:veedot)
let bop = op (:,:,:,:,:,:veedot) ? :(Grassmann.$op) : :(Base.$op)
@eval begin
$bop(a::TensorField,b::TensorField) = checkdomain(a,b) && (domain(a) $op.(codomain(a),codomain(b)))
$bop(a::TensorField,b::Number) = domain(a) $op.(codomain(a),Ref(b))
$bop(a::Number,b::TensorField) = domain(b) $op.(Ref(a),codomain(b))
end
end
end
for fun (:-,:!,:~,:exp,:log,:sinh,:cosh,:abs,:sqrt,:real,:imag,:cos,:sin,:tan,:cot,:sec,:csc,:asec,:acsc,:sech,:csch,:asech,:tanh,:coth,:asinh,:acosh,:atanh,:acoth,:asin,:acos,:atan,:acot,:sinc,:cosc,:abs2,:conj)
for fun (:-,:!,:~,:exp,:log,:sinh,:cosh,:abs,:sqrt,:cbrt,:real,:imag,:cos,:sin,:tan,:cot,:sec,:csc,:asec,:acsc,:sech,:csch,:asech,:tanh,:coth,:asinh,:acosh,:atanh,:acoth,:asin,:acos,:atan,:acot,:sinc,:cosc,:abs2,:conj,:deg2rad)
@eval Base.$fun(t::TensorField) = domain(t) $fun.(codomain(t))
end
for fun (:reverse,:involute,:clifford,:even,:odd,:scalar,:vector,:bivector,:volume,:value,:,:angle,:radius)
for fun (:reverse,:involute,:clifford,:even,:odd,:scalar,:vector,:bivector,:volume,:value,:,:angle,:radius,:complementleft,:complementlefthodge,:pseudoabs,:pseudoabs2,:pseudoexp,:pseudolog,:pseudoinv,:pseudosqrt,:pseudocbrt,:pseudocos,:pseudosin,:pseudotan,:pseudocosh,:pseudosinh,:pseudotanh)
@eval Grassmann.$fun(t::TensorField) = domain(t) $fun.(codomain(t))
end
for fun (:sum,:prod)
Expand Down

2 comments on commit 309579e

@chakravala
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 register()

@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/105894

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.1.6 -m "<description of version>" 309579e97c81afefbc57a37d036dab8220f5d9a3
git push origin v0.1.6

Please sign in to comment.