diff --git a/Project.toml b/Project.toml index fe5d67f..970264d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PosDefManifold" uuid = "f45a3650-5c51-11e9-1e9a-133aa5e309cf" authors = ["Marco Congedo "] -version = "0.4.4" +version = "0.4.5" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/docs/Project.toml b/docs/Project.toml index 9edf4e9..f6f9d54 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,5 @@ authors = ["Marco Congedo "] -version = "0.4.4" +version = "0.4.5" [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" diff --git a/src/PosDefManifold.jl b/src/PosDefManifold.jl index bb93204..e97beac 100644 --- a/src/PosDefManifold.jl +++ b/src/PosDefManifold.jl @@ -1,5 +1,5 @@ # Main Module of the PosDefManifold Package for julia language -# v0.4.3 last update 1st of December 2020 +# v0.4.5 last update 8th of January 2020 # MIT License # Copyright (c) 2019, Marco Congedo, CNRS, Grenobe, France: diff --git a/src/linearAlgebra.jl b/src/linearAlgebra.jl index fbb4b00..bbc477e 100644 --- a/src/linearAlgebra.jl +++ b/src/linearAlgebra.jl @@ -268,7 +268,7 @@ dim(vector₂::AnyMatrixVector₂) = ``X`` can be a real or complex `Diagonal`, `LowerTriangular`, `Matrix`, or `Hermitian` matrix. (see [AnyMatrix type](@ref)) - If the determinant is not greater to `tol` (which defalts to zero) + If the determinant is not greater than `tol` (which defalts to zero) a warning is printed and ``X`` is returned. !!! note "Nota Bene" @@ -303,9 +303,11 @@ det1Msg="function det1 in LinearAlgebra.jl of PosDefMaifold package: the determi ``X`` can be a real or complex `Diagonal`, `LowerTriangular`, `Matrix` or `Hermitian` matrix (see [AnyMatrix type](@ref)). - - If the trace is not greater to `tol` - (which defalts to zero) a warning is printed and ``X`` is returned. + Its trace must be real. If the absolute value of its imaginary part + is greater than `tol` (which defalts to zero) a warning is printed + and ``X`` is returned. + Also, if the trace is not greater than `tol` + a warning is printed and ``X`` is returned. **See**: [Julia trace function](https://bit.ly/2HoOLiM). @@ -313,19 +315,38 @@ det1Msg="function det1 in LinearAlgebra.jl of PosDefMaifold package: the determi ## Examples using LinearAlgebra, PosDefManifold + P=randP(5) # generate a random real positive definite matrix 5x5 Q=tr1(P) tr(Q) # must be 1 # using a tolerance Q=tr1(P; tol=1e-12) + Pc=randP(ComplexF64, 5) # generate a random real positive definite matrix 5x5 + Qc=tr1(Pc) + tr(Qc) # must be 1 + + """ function tr1(X::AnyMatrix; tol::Real=0.) tol>=0. ? tolerance=tol : tolerance = 0. trace = tr(X) - if trace>tolerance X/trace else @warn tr1Msg trace tolerance; X end + imagtr = imag(trace) + if abs(imagtr)>tolerance + @warn tr1Msg2 imagtr tolerance + return X + else + trace=real(trace) + end + if trace>tolerance + return X/trace + else + @warn tr1Msg1 trace tolerance + return X + end end -tr1Msg="function tr1 in LinearAlgebra.jl of PosDefMaifold package: the trace of the input matrix is not greater than the tolerance." +tr1Msg1="function tr1 in LinearAlgebra.jl of PosDefMaifold package: the trace of the input matrix is not greater than the tolerance." +tr1Msg2="function tr1 in LinearAlgebra.jl of PosDefMaifold package: the imaginary part of the trace of the input matrix is greater than the tolerance." """ @@ -385,11 +406,11 @@ end (see [AnyMatrix type](@ref)). This is given by - ``UV^T``, + ``UV^H``, where - ``\\textrm(SVD)=UΛV^T``. + ``\\textrm(SVD)=UΛV^H``. If `X` is `Diagonal`, return `X`. diff --git a/src/signalProcessing.jl b/src/signalProcessing.jl index 419383e..b2d9965 100644 --- a/src/signalProcessing.jl +++ b/src/signalProcessing.jl @@ -266,7 +266,7 @@ randPosDefMat(n::Int; randPosDefMat(::Type{Complex{T}}, n::Int; df::Int=2, - eigvalsSNR::Real=10e3) where {T<:AbstractFloat} = + eigvalsSNR::Real=10e3) where {T<:AbstractFloat} = congruence(randU(ComplexF64, n), randΛ(n, df=df, eigvalsSNR=eigvalsSNR), ℍ)