Skip to content

Commit

Permalink
generalized dispatch for symbolic computation
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Nov 28, 2019
1 parent e7fd9e0 commit c829d3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ function ^(v::T,i::Integer) where T<:TensorTerm
for k 1:(i-1)%4
out *= basis(v)
end
return typeof(v)<:Basis ? out : out*value(v)^i
return typeof(v)<:Basis ? out : out*DirectSum.:^(value(v),i)
end

function Base.:^(v::T,i::S) where {T<:TensorAlgebra{V},S<:Integer} where V
Expand Down
8 changes: 4 additions & 4 deletions src/composite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export exph, log_fast, logh_fast
## exponential & logarithm function

@inline Base.expm1(t::Basis{V,0}) where V = Simplex{V}(ℯ-1)
@inline Base.expm1(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}(expm1(value(t)))
@inline Base.expm1(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}(DirectSum.expm1(value(t)))

function Base.expm1(t::T) where T<:TensorAlgebra{V} where V
S,term,f = t,(t^2)/2,norm(t)
Expand Down Expand Up @@ -108,7 +108,7 @@ end
for (qrt,n) ((:sqrt,2),(:cbrt,3))
@eval begin
@inline Base.$qrt(t::Basis{V,0} where V) = t
@inline Base.$qrt(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}($qrt(value(t)))
@inline Base.$qrt(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}($Sym.$qrt(value(t)))
@inline function Base.$qrt(t::T) where T<:TensorAlgebra
isscalar(t) ? $qrt(scalar(t)) : exp(log(t)/$n)
end
Expand All @@ -117,7 +117,7 @@ end

## trigonometric

@inline Base.cosh(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}(cosh(value(t)))
@inline Base.cosh(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}(DirectSum.cosh(value(t)))

function Base.cosh(t::T) where T<:TensorAlgebra{V} where V
τ = t^2
Expand Down Expand Up @@ -166,7 +166,7 @@ end
end
end

@inline Base.sinh(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}(sinh(value(t)))
@inline Base.sinh(t::T) where T<:TensorTerm{V,0} where V = Simplex{V}(DirectSum.sinh(value(t)))

function Base.sinh(t::T) where T<:TensorAlgebra{V} where V
τ,f = t^2,norm(t)
Expand Down

0 comments on commit c829d3f

Please sign in to comment.