Permalink
Browse files

[RFC] Matrix trigonometry (#23679)

* Define (some) trigonometric functions for matrices, also fix exp

* Make log(::Array) more type stable

* Add remaining matrix trigonometric functions

* Fix sincos and add tests

* Remove functions from deprecated.jl

* Update tests to not fail when running the suite

* Fix and add a few tests

* Replace `exp`->`exp!` and related changes suggested by fredrikekre

* Missing diagonal optim

* Add missing doc entries to stdlib/linalg

* Make `log(::UpperTriangular)` accept any `BlasFloat`

* Add inverse trigonometric functions

* Add tests for inverse trig matrix functions

* Add inverse matrix trig functions to stdlib/linalg.md

* Fix docs

* Remove duplicate linalg entries from `stdlib/math.md`

* Do not special-case real-valued matrices for symmetric

* Generalise to HermOrSym{<:Real} when appropriate

* Make inverse trig functions use Schur and ensure correct branches

* Add tests for principal values of inverse trigonometric functions

* Return Symmetric/Hermitian when in real domain for inverse trig

* Add reference to Aprahamian and Higham

* StridedMatrix -> AbstractMatrix

* Remove remaining matrix trig functions from deprecated.jl

* Comment out acosh principal value test due to CI fail

* Change back to `exp!(-A)` and add back in acosh test

* Absolute Tolerance and the Return of Fewer Allocations

* Bandaid fix for footnotes

* Absolute Tolerance vol. 2

* Increase absolute tolerance levels in test by 1e2

* Fix Documenter error

* Fix wrong indentation
1 parent 0eab069 commit 361ceb0508c8223b123818c5768342f480edf403 @eveydee eveydee committed with andreasnoack Oct 17, 2017
Showing with 692 additions and 93 deletions.
  1. +10 −19 base/deprecated.jl
  2. +359 −11 base/linalg/dense.jl
  3. +6 −5 base/linalg/linalg.jl
  4. +87 −16 base/linalg/symmetric.jl
  5. +1 −1 base/linalg/triangular.jl
  6. +13 −13 base/math.jl
  7. +28 −0 doc/src/stdlib/linalg.md
  8. +28 −28 doc/src/stdlib/math.md
  9. +160 −0 test/linalg/dense.jl
View
@@ -218,15 +218,9 @@ end
@deprecate SubArray(parent::AbstractArray, indexes::Tuple, dims::Tuple) SubArray(parent, indexes)
# Deprecate vectorized unary functions over sparse matrices in favor of compact broadcast syntax (#17265).
-for f in (:sin, :sinh, :sind, :asin, :asinh, :asind,
- :tan, :tanh, :tand, :atan, :atanh, :atand,
- :sinpi, :cosc, :ceil, :floor, :trunc, :round,
- :log1p, :expm1, :abs, :abs2,
- :log2, :log10, :exp2, :exp10, :sinc, :cospi,
- :cos, :cosh, :cosd, :acos, :acosd,
- :cot, :coth, :cotd, :acot, :acotd,
- :sec, :sech, :secd, :asech,
- :csc, :csch, :cscd, :acsch)
+for f in (:sind, :asind, :tand, :atand, :sinpi, :cosc, :ceil, :floor, :trunc,
+ :round, :log1p, :expm1, :abs, :abs2, :log2, :log10, :exp2, :exp10,
+ :sinc, :cospi, :cosd, :acosd, :cotd, :acotd, :secd, :cscd)
@eval import .Math: $f
@eval @deprecate $f(A::SparseMatrixCSC) $f.(A)
end
@@ -254,9 +248,7 @@ for f in (
# base/special/gamma.jl
:gamma, :lfact,
# base/math.jl
- :cbrt, :sinh, :cosh, :tanh, :atan, :asinh, :exp2,
- :expm1, :exp10, :sin, :cos, :tan, :asin, :acos, :acosh, :atanh,
- :log2, :log10, :lgamma, #=:log1p,=#
+ :cbrt, :exp2, :expm1, :exp10, :log2, :log10, :lgamma, #=:log1p,=#
# base/floatfuncs.jl
:abs, :abs2, :angle, :isnan, :isinf, :isfinite,
# base/complex.jl
@@ -742,9 +734,7 @@ end
@deprecate sign(A::AbstractArray) sign.(A)
# Deprecate manually vectorized trigonometric and hyperbolic functions in favor of compact broadcast syntax
-for f in (:sec, :sech, :secd, :asec, :asech,
- :csc, :csch, :cscd, :acsc, :acsch,
- :cot, :coth, :cotd, :acot, :acoth)
+for f in (:secd, :cscd, :cotd)
@eval import .Math: $f
@eval @deprecate $f(A::AbstractArray{<:Number}) $f.(A)
end
@@ -1480,10 +1470,11 @@ for op in (:floor, :ceil, :trunc, :round,
end
# deprecate remaining vectorized methods over SparseVectors (not-zero-preserving)
for op in (:exp, :exp2, :exp10, :log, :log2, :log10,
- :cos, :cosd, :acos, :cosh, :cospi,
- :csc, :cscd, :acot, :csch, :acsch,
- :cot, :cotd, :acosd, :coth,
- :sec, :secd, :acotd, :sech, :asech)
+ :cos, :cosd, :acos, :cosh, :cospi,
+ :csc, :cscd, :acot, :csch, :acsch,
+ :cot, :cotd, :acosd, :coth,
+ :sec, :secd, :acotd, :sech, :asech)
+ @eval import .Math: $op
@eval @deprecate ($op)(x::AbstractSparseVector{<:Number,<:Integer}) ($op).(x)
end
Oops, something went wrong.

0 comments on commit 361ceb0

Please sign in to comment.