-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No generic exp
, sin
, cos
, sinh
, cosh
#51008
Comments
It doesn't seem so easy to write a generic implementation that is also accurate and reasonably efficient. What algorithm could be used? (Taylor series don't work here.) |
Once you have |
Yes, but computing |
First, the I think that a slow and slightly inaccurate implementation is more useful than nonexistence. In many cases it's impossible to provide a definition without pirating or patching every package out there. Should every package defining I don't see anything conceptually horrifying (though I'm no expert) about applying the algorithm used by The balancing is not strictly required (as far as I understand). However, it could probably be re-implemented generically with some minor or moderate effort. That would not be required for an initial implementation. As for I could settle for leaving |
I think that probably makes sense. For new number types, the efficient operations and desired accuracy .are hard to know generically. For Matrices, on the other hand, multiplication is a common interface, and the tolerances come down more to how long you want to spend rather than the number type precision. |
The (We could apply the current |
Some basic math functions are missing generic implementations. Among these are
exp
,sin
,cos
,sinh
, andcosh
, although likely there are several others that should be included. From this list, all the functions can be evaluated in terms ofexp
. Functions liketan
andtanh
should be re-assessed once these others are fixed. Functions likeacos
,asin
, etc, are a bit more complicated but should probably get a look eventually.exp(::T)
should work for any type for whichevalpoly
can be made to work, which requires*(::T,::T)
and+(::UniformScaling{<:Number},::T)
(in place of theUniformScaling
method,oneunit(::T)
,*(::Number,::T)
, and+(::T,::T)
can serve). Accurate results are much easier to achieve ifopnorm(::T)
is defined, although a different implementation of the polynomial evaluation could continue the Taylor series until convergence (at a potentially-significant computational cost).For example, these functions cannot be used with matrices of dual numbers or quaternions:
The listed functions do have methods with
::AbstractMatrix
signatures, but they fail like here when the elements do not promote toLinearAlgebra.BlasFloat
types. In any case, a suitable fallback should work for types other than matrices, too.It's not critical that these functions be fast, but they should exist and be mostly accurate (to the extent that we can predict what inputs might occur).
The text was updated successfully, but these errors were encountered: