-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Implement cbrt(A::AbstractMatrix{<:Real})
#50661
Conversation
Algorithm overview: Cube root of a quasi triangular matrixCube root of a quasi triangular matrix is the crucial part of this PR. The implementation consists of three functions in
julia> A = randn(1000,1000) ;
julia> T = schur(A).T ;
julia> U = LinearAlgebra._cbrt_quasi_triu!(copy(T)) ;
julia> typeof(U)
Matrix{Float64} (alias for Array{Float64, 2})
julia> norm(U*U*U-T)
1.9153193181259216e-11
julia> @btime LinearAlgebra._cbrt_quasi_triu!(copy(T)) ;
289.430 ms (205971 allocations: 22.91 MiB)
julia> V = T^(1/3) ;
julia> typeof(V)
Matrix{ComplexF64} (alias for Array{Complex{Float64}, 2})
julia> norm(V*V*V-T)
2.787726919534373e-10
julia> @btime V = T^(1/3) evals=1 samples=100 ;
4.754 s (155 allocations: 900.61 MiB) Implementation Notes:
|
…etting rid of BLAS.gemm! dependence.
…valence of the inputs and outputs.
…ge improvements: ID, S₁, S₂
A = zeros(T, 4, 4)
S₁ = zeros(T,s₁,s₁)
S₂ = zeros(T,s₂,s₂)
Bᵢⱼ⁽⁰⁾ = zeros(T,s₁,s₂)
Bᵢⱼ⁽¹⁾ = zeros(T,s₁,s₂)
Update: I used the following. Comments and suggestions are welcome. @views S₁ = reshape(M_S₁, s₁, :)[:, 1:s₁]
@views S₂ = reshape(M_S₂, s₂, :)[:, 1:s₂]
@views L₀ = reshape(M_L₀, s₁*s₂, :)[:,1:s₁*s₂]
@views L₁ = reshape(M_L₁, s₁*s₂, :)[:,1:s₁*s₂]
@views Bᵢⱼ⁽⁰⁾ = reshape(M_Bᵢⱼ⁽⁰⁾, s₁, :)[:, 1:s₂]
@views Bᵢⱼ⁽¹⁾ = reshape(M_Bᵢⱼ⁽¹⁾, s₁, :)[:, 1:s₂] |
Hello @barucden, kindly let me know if you feel I should copy the format from |
I've been under the impression that a documentation is (or should be) an integral part of any exported functionality. So I'd say it should be part of this PR. BUT I am not a maintainer! I just noticed that the documentation is missing here, so I thought I should point it out. In any case, there is no special team working on the documentation. |
Ok. Thank you. Then, I'll wait for the opinion of one of the members before making any change. |
Line 161 in 2c45e3b
Base.Math.cbrt(::Number) so it only documents the scalar version, similar to sqrt a few lines above.
And a reference to julia/stdlib/LinearAlgebra/docs/src/index.md Line 518 in 2c45e3b
|
…d re-link the documentation of method to the scalar version in .
Thank you for the tip. This is now done and the docs build well on my PC. |
cbrt(A::AbstractMatrix{T})
cbrt(A::AbstractMatrix{<:Real})
…s it will always be zero since sizes[i+k] /= 0.
@stevengj Please let me know if anything more is required for this PR from my side. Is this PR good to merge? I was just wondering if I missed something as this was still hanging around and unmerged since a few months... |
@dkarrasch, I think this is ready to merge? |
This PR resolves JuliaLang/LinearAlgebra.jl#966.
Baseline: 1.10.0-alpha1(rebased tomaster
)Summary of the Implementation
(Method removed.)cbrt(A::AbstractMatrix)
is delegated toA^(1//3)
.Diagonal
andSymmetric
matrices, straightforward implementations based on scalarcbrt
andeigen
are provided.schur
decomposition and [1, Algorithm 4.3]-based algorithm (_cbrt_quasi_triu!
) is provided._cbrt_quasi_triu!
are provided.Note: See comment below for details on the algorithm.
References
Pending Items
Memory and MIPS optimisations (trade-off) for_cbrt_quasi_triu!
.Tests
File:
stdlib/LinearAlgebra/test/dense.jl
Testset:
@testset "cbrt(A::AbstractMatrix{T})"
Memory and MIPS
sqrt
wrt MIPS and memory consumption for large