Skip to content
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

Matrix functions for UniformScaling #695

Open
7 of 17 tasks
jagot opened this issue Feb 18, 2020 · 11 comments
Open
7 of 17 tasks

Matrix functions for UniformScaling #695

jagot opened this issue Feb 18, 2020 · 11 comments

Comments

@jagot
Copy link
Contributor

jagot commented Feb 18, 2020

I was surprised by this:

julia> sqrt(5.0I)
ERROR: MethodError: no method matching sqrt(::UniformScaling{Float64})
Closest candidates are:
  sqrt(::Float16) at math.jl:1085
  sqrt(::Complex{Float16}) at math.jl:1086
  sqrt(::Missing) at math.jl:1138
  ...
Stacktrace:
 [1] top-level scope at REPL[25]:1

julia> sqrt(Matrix(5I, 5, 5))
5×5 Array{Float64,2}:
 2.23607  0.0      0.0      0.0      0.0
 0.0      2.23607  0.0      0.0      0.0
 0.0      0.0      2.23607  0.0      0.0
 0.0      0.0      0.0      2.23607  0.0
 0.0      0.0      0.0      0.0      2.23607

Since we already have a few matrix functions defined, such as
https://github.com/JuliaLang/julia/blob/e36fe95a639c6956aa39367bef8e727b174e52b2/stdlib/LinearAlgebra/src/dense.jl#L702-L759
it would seem reasonable to expect at least these elementary functions to be defined for UniformScaling as well:

All of the above have been added in JuliaLang/julia#28872, the question is now which additional functions are of interest, i.e. which are used for matrices? Candidates are

  • abs - one could argue that the matrix generalization is det
    (which yields a scalar), but you can compute abs(A) as
    Q*abs.(λ)*Q', which is something different.
  • abs2
  • log10, log2
  • exp2, exp10
  • sinc, cosc

I am unsure if the functions below are sensible for matrices, possibly
with the exception of sinpi and cospi.

  • sinpi, cospi
  • sind, cosd, tand, secd, cscd, cotd
  • asind, acosd, atand, asecd, acscd, acotd
  • deg2rad, rad2deg
  • mod2pi

From JuliaLang/julia#28872 remains also the idea of matrix decompositions.

@jagot
Copy link
Contributor Author

jagot commented Feb 18, 2020

@dkarrasch
Copy link
Member

There was some initial effort made in JuliaLang/julia#28872, but then got stale.

@jagot
Copy link
Contributor Author

jagot commented Feb 18, 2020

Good to know! Maybe that PR should be revived instead?

@dkarrasch
Copy link
Member

Yes. Actually, that PR had all that you are asking for here. So we could resolve merge conflicts there, merge, and open a new issue to track the ambitious unresolved broadcasting aspects.

@JeffreySarnoff
Copy link

sqrt
exp, log
sin, cos, tan + asin, acos, atan
sinh, cosh, tanh + asinh, acosh, atanh

other similar from Base.Math: cbrt , expm1, log1p

@jagot
Copy link
Contributor Author

jagot commented Feb 19, 2020

I've rebased JuliaLang/julia#28872 and pushed to my fork. Just need to build and test and then make a new PR?

@dkarrasch
Copy link
Member

I've just resolved the merge conflicts there and one qualification issue, tests are running. If they pass, I'd suggest to merge JuliaLang/julia#28872, and then continue from there.

@jagot
Copy link
Contributor Author

jagot commented Feb 19, 2020

Hmm, double work double the fun?

@dkarrasch
Copy link
Member

@antoine-levitt suggested this list of functions:
...
supplemented by
...

Sounds good. Maybe update the OP to reflect the missing parts now that JuliaLang/julia#28872 is merged? One open issue there were matrix decompositions.

@jagot
Copy link
Contributor Author

jagot commented Feb 19, 2020

Updated!

@KristofferC KristofferC transferred this issue from JuliaLang/julia Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants