From 7a3cc319c53ef9a747fc926025331100c2220e11 Mon Sep 17 00:00:00 2001 From: Patrick Kofod Mogensen Date: Tue, 23 Feb 2016 00:05:45 +0100 Subject: [PATCH] Changed issym to issymmetric. Updated docs, NEWS.md, and deprecated issym. --- NEWS.md | 2 ++ base/deprecated.jl | 3 +++ base/docs/helpdb/Base.jl | 6 +++--- base/exports.jl | 2 +- base/linalg.jl | 2 +- base/linalg/arnoldi.jl | 4 ++-- base/linalg/bitarray.jl | 4 ++-- base/linalg/bunchkaufman.jl | 20 ++++++++++---------- base/linalg/dense.jl | 2 +- base/linalg/diagonal.jl | 2 +- base/linalg/eigen.jl | 8 ++++---- base/linalg/generic.jl | 4 ++-- base/linalg/symmetric.jl | 10 +++++----- base/sparse.jl | 8 ++++---- base/sparse/cholmod.jl | 6 +++--- base/sparse/sparsematrix.jl | 2 +- doc/stdlib/linalg.rst | 4 ++-- test/arrayops.jl | 2 +- test/bitarray.jl | 2 +- test/blas.jl | 2 +- test/linalg/arnoldi.jl | 4 ++-- test/linalg/bunchkaufman.jl | 4 ++-- test/linalg/diagonal.jl | 4 ++-- test/linalg/generic.jl | 4 ++-- test/linalg/symmetric.jl | 4 ++-- test/sparsedir/cholmod.jl | 10 +++++----- test/sparsedir/sparse.jl | 22 +++++++++++----------- 27 files changed, 76 insertions(+), 71 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0151582f97f2c..429b063162805 100644 --- a/NEWS.md +++ b/NEWS.md @@ -126,6 +126,8 @@ Deprecated or removed * Deprecate `chol(A,Val{:U/:L})` in favor of `chol(A)` ([#13680]). + * `issym` is deprecated in favor of `issymmetric` to match similar functions (`ishermitian`, ...) ([#15192]) + Julia v0.4.0 Release Notes ========================== diff --git a/base/deprecated.jl b/base/deprecated.jl index fcfd76be6749a..2aea580bfa700 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -990,3 +990,6 @@ end export call @deprecate_binding LambdaStaticData LambdaInfo + +# Changed issym to issymmetric. #15192 +@deprecate issym issymmetric diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 57b0e326e5295..19a393f83d248 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -6698,11 +6698,11 @@ The arguments to a function or constructor are outside the valid domain. DomainError """ - issym(A) -> Bool + issymmetric(A) -> Bool Test whether a matrix is symmetric. """ -issym +issymmetric """ acosh(x) @@ -8427,7 +8427,7 @@ rand! Compute the Bunch-Kaufman [^Bunch1977] factorization of a real symmetric or complex Hermitian matrix `A` and return a `BunchKaufman` object. The following functions are available for -`BunchKaufman` objects: `size`, `\\`, `inv`, `issym`, `ishermitian`. +`BunchKaufman` objects: `size`, `\\`, `inv`, `issymmetric`, `ishermitian`. [^Bunch1977]: J R Bunch and L Kaufman, Some stable methods for calculating inertia and solving symmetric linear systems, Mathematics of Computation 31:137 (1977), 163-179. [url](http://www.ams.org/journals/mcom/1977-31-137/S0025-5718-1977-0428694-0). diff --git a/base/exports.jl b/base/exports.jl index ff3f510bdba22..2b7e3349b8452 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -664,7 +664,7 @@ export ishermitian, isposdef!, isposdef, - issym, + issymmetric, istril, istriu, kron, diff --git a/base/linalg.jl b/base/linalg.jl index 938be5437c28d..cec964f13830d 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -82,7 +82,7 @@ export ishermitian, isposdef, isposdef!, - issym, + issymmetric, istril, istriu, kron, diff --git a/base/linalg/arnoldi.jl b/base/linalg/arnoldi.jl index 213128e35874c..ca0fd1075cbf1 100644 --- a/base/linalg/arnoldi.jl +++ b/base/linalg/arnoldi.jl @@ -154,7 +154,7 @@ function _eigs(A, B; T = eltype(A) iscmplx = T <: Complex isgeneral = B !== I - sym = issym(A) && !iscmplx + sym = issymmetric(A) && !iscmplx nevmax=sym ? n-1 : n-2 if nevmax <= 0 throw(ArgumentError("Input matrix A is too small. Use eigfact instead.")) @@ -297,7 +297,7 @@ end ## v = [ left_singular_vector; right_singular_vector ] *{T,S}(s::SVDOperator{T,S}, v::Vector{T}) = [s.X * v[s.m+1:end]; s.X' * v[1:s.m]] size(s::SVDOperator) = s.m + s.n, s.m + s.n -issym(s::SVDOperator) = true +issymmetric(s::SVDOperator) = true svds{T<:BlasFloat}(A::AbstractMatrix{T}; kwargs...) = _svds(A; kwargs...) svds(A::AbstractMatrix{BigFloat}; kwargs...) = throw(MethodError(svds, Any[A, kwargs...])) diff --git a/base/linalg/bitarray.jl b/base/linalg/bitarray.jl index eee50e259145b..992f55f03231d 100644 --- a/base/linalg/bitarray.jl +++ b/base/linalg/bitarray.jl @@ -134,8 +134,8 @@ end ## Structure query functions -issym(A::BitMatrix) = size(A, 1)==size(A, 2) && countnz(A - A.')==0 -ishermitian(A::BitMatrix) = issym(A) +issymmetric(A::BitMatrix) = size(A, 1)==size(A, 2) && countnz(A - A.')==0 +ishermitian(A::BitMatrix) = issymmetric(A) function nonzero_chunks(chunks::Vector{UInt64}, pos0::Int, pos1::Int) k0, l0 = Base.get_chunks_id(pos0) diff --git a/base/linalg/bunchkaufman.jl b/base/linalg/bunchkaufman.jl index cf5f76b0e1817..9f18af795604d 100644 --- a/base/linalg/bunchkaufman.jl +++ b/base/linalg/bunchkaufman.jl @@ -14,14 +14,14 @@ immutable BunchKaufman{T,S<:AbstractMatrix} <: Factorization{T} end BunchKaufman{T}(LD::AbstractMatrix{T}, ipiv::Vector{BlasInt}, uplo::Char, symmetric::Bool, rook::Bool) = BunchKaufman{T,typeof(LD)}(LD, ipiv, uplo, symmetric, rook) -function bkfact!{T<:BlasReal}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issym(A), rook::Bool=false) +function bkfact!{T<:BlasReal}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issymmetric(A), rook::Bool=false) if !symmetric throw(ArgumentError("Bunch-Kaufman decomposition is only valid for symmetric matrices")) end LD, ipiv = rook ? LAPACK.sytrf_rook!(char_uplo(uplo) , A) : LAPACK.sytrf!(char_uplo(uplo) , A) BunchKaufman(LD, ipiv, char_uplo(uplo), symmetric, rook) end -function bkfact!{T<:BlasComplex}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issym(A), rook::Bool=false) +function bkfact!{T<:BlasComplex}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issymmetric(A), rook::Bool=false) if rook LD, ipiv = (symmetric ? LAPACK.sytrf_rook! : LAPACK.hetrf_rook!)(char_uplo(uplo) , A) else @@ -29,15 +29,15 @@ function bkfact!{T<:BlasComplex}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric end BunchKaufman(LD, ipiv, char_uplo(uplo), symmetric, rook) end -bkfact{T<:BlasFloat}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issym(A), rook::Bool=false) = bkfact!(copy(A), uplo, symmetric, rook) -bkfact{T}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issym(A), rook::Bool=false) = bkfact!(convert(Matrix{promote_type(Float32,typeof(sqrt(one(T))))},A),uplo,symmetric,rook) +bkfact{T<:BlasFloat}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issymmetric(A), rook::Bool=false) = bkfact!(copy(A), uplo, symmetric, rook) +bkfact{T}(A::StridedMatrix{T}, uplo::Symbol=:U, symmetric::Bool=issymmetric(A), rook::Bool=false) = bkfact!(convert(Matrix{promote_type(Float32,typeof(sqrt(one(T))))},A),uplo,symmetric,rook) convert{T}(::Type{BunchKaufman{T}},B::BunchKaufman) = BunchKaufman(convert(Matrix{T},B.LD),B.ipiv,B.uplo,B.symmetric,B.rook) convert{T}(::Type{Factorization{T}}, B::BunchKaufman) = convert(BunchKaufman{T}, B) size(B::BunchKaufman) = size(B.LD) size(B::BunchKaufman,d::Integer) = size(B.LD,d) -issym(B::BunchKaufman) = B.symmetric +issymmetric(B::BunchKaufman) = B.symmetric ishermitian(B::BunchKaufman) = !B.symmetric function inv{T<:BlasReal}(B::BunchKaufman{T}) @@ -49,7 +49,7 @@ function inv{T<:BlasReal}(B::BunchKaufman{T}) end function inv{T<:BlasComplex}(B::BunchKaufman{T}) - if issym(B) + if issymmetric(B) if B.rook copytri!(LAPACK.sytri_rook!(B.uplo, copy(B.LD), B.ipiv), B.uplo) else @@ -73,9 +73,9 @@ function A_ldiv_B!{T<:BlasReal}(B::BunchKaufman{T}, R::StridedVecOrMat{T}) end function A_ldiv_B!{T<:BlasComplex}(B::BunchKaufman{T}, R::StridedVecOrMat{T}) if B.rook - (issym(B) ? LAPACK.sytrs_rook! : LAPACK.hetrs_rook!)(B.uplo, B.LD, B.ipiv, R) + (issymmetric(B) ? LAPACK.sytrs_rook! : LAPACK.hetrs_rook!)(B.uplo, B.LD, B.ipiv, R) else - (issym(B) ? LAPACK.sytrs! : LAPACK.hetrs!)(B.uplo, B.LD, B.ipiv, R) + (issymmetric(B) ? LAPACK.sytrs! : LAPACK.hetrs!)(B.uplo, B.LD, B.ipiv, R) end end @@ -94,9 +94,9 @@ function det(F::BunchKaufman) else # 2x2 pivot case. Make sure not to square before the subtraction by scaling with the off-diagonal element. This is safe because the off diagonal is always large for 2x2 pivots. if F.uplo == 'U' - d *= M[i, i + 1]*(M[i,i]/M[i, i + 1]*M[i + 1, i + 1] - (issym(F) ? M[i, i + 1] : conj(M[i, i + 1]))) + d *= M[i, i + 1]*(M[i,i]/M[i, i + 1]*M[i + 1, i + 1] - (issymmetric(F) ? M[i, i + 1] : conj(M[i, i + 1]))) else - d *= M[i + 1,i]*(M[i, i]/M[i + 1, i]*M[i + 1, i + 1] - (issym(F) ? M[i + 1, i] : conj(M[i + 1, i]))) + d *= M[i + 1,i]*(M[i, i]/M[i + 1, i]*M[i + 1, i + 1] - (issymmetric(F) ? M[i + 1, i] : conj(M[i + 1, i]))) end i += 2 end diff --git a/base/linalg/dense.jl b/base/linalg/dense.jl index f4b1485427faa..f1919bda8e654 100644 --- a/base/linalg/dense.jl +++ b/base/linalg/dense.jl @@ -340,7 +340,7 @@ end logm(a::Complex) = log(a) function sqrtm{T<:Real}(A::StridedMatrix{T}) - if issym(A) + if issymmetric(A) return full(sqrtm(Symmetric(A))) end n = checksquare(A) diff --git a/base/linalg/diagonal.jl b/base/linalg/diagonal.jl index c6dc778dc202e..69679ea9d07d8 100644 --- a/base/linalg/diagonal.jl +++ b/base/linalg/diagonal.jl @@ -65,7 +65,7 @@ parent(D::Diagonal) = D.diag ishermitian{T<:Real}(D::Diagonal{T}) = true ishermitian(D::Diagonal) = all(D.diag .== real(D.diag)) -issym(D::Diagonal) = true +issymmetric(D::Diagonal) = true isposdef(D::Diagonal) = all(D.diag .> 0) factorize(D::Diagonal) = D diff --git a/base/linalg/eigen.jl b/base/linalg/eigen.jl index b4d205260dab3..1c16526567ed1 100644 --- a/base/linalg/eigen.jl +++ b/base/linalg/eigen.jl @@ -28,7 +28,7 @@ isposdef(A::Union{Eigen,GeneralizedEigen}) = isreal(A.values) && all(A.values .> function eigfact!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) n = size(A, 2) n==0 && return Eigen(zeros(T, 0), zeros(T, 0, 0)) - issym(A) && return eigfact!(Symmetric(A)) + issymmetric(A) && return eigfact!(Symmetric(A)) A, WR, WI, VL, VR, _ = LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'V', 'N', A) all(WI .== 0.) && return Eigen(WR, VR) evec = zeros(Complex{T}, n, n) @@ -81,7 +81,7 @@ eigvals{T,V,S,U}(F::Union{Eigen{T,V,S,U}, GeneralizedEigen{T,V,S,U}}) = F[:value Same as `eigvals`, but saves space by overwriting the input `A` (and `B`), instead of creating a copy. """ function eigvals!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) - issym(A) && return eigvals!(Symmetric(A)) + issymmetric(A) && return eigvals!(Symmetric(A)) _, valsre, valsim, _ = LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'N', 'N', A) return all(valsim .== 0) ? valsre : complex(valsre, valsim) end @@ -120,7 +120,7 @@ det(A::Eigen) = prod(A.values) # Generalized eigenproblem function eigfact!{T<:BlasReal}(A::StridedMatrix{T}, B::StridedMatrix{T}) - issym(A) && isposdef(B) && return eigfact!(Symmetric(A), Symmetric(B)) + issymmetric(A) && isposdef(B) && return eigfact!(Symmetric(A), Symmetric(B)) n = size(A, 1) alphar, alphai, beta, _, vr = LAPACK.ggev!('N', 'V', A, B) all(alphai .== 0) && return GeneralizedEigen(alphar ./ beta, vr) @@ -160,7 +160,7 @@ function eig(A::Number, B::Number) end function eigvals!{T<:BlasReal}(A::StridedMatrix{T}, B::StridedMatrix{T}) - issym(A) && isposdef(B) && return eigvals!(Symmetric(A), Symmetric(B)) + issymmetric(A) && isposdef(B) && return eigvals!(Symmetric(A), Symmetric(B)) alphar, alphai, beta, vl, vr = LAPACK.ggev!('N', 'N', A, B) return (all(alphai .== 0) ? alphar : complex(alphar, alphai))./beta end diff --git a/base/linalg/generic.jl b/base/linalg/generic.jl index 6b1f68d730e17..ae0d89e3ac61f 100644 --- a/base/linalg/generic.jl +++ b/base/linalg/generic.jl @@ -382,7 +382,7 @@ condskeel{T<:Integer}(A::AbstractMatrix{T}, p::Real=Inf) = norm(abs(inv(float(A) condskeel(A::AbstractMatrix, x::AbstractVector, p::Real=Inf) = norm(abs(inv(A))*abs(A)*abs(x), p) condskeel{T<:Integer}(A::AbstractMatrix{T}, x::AbstractVector, p::Real=Inf) = norm(abs(inv(float(A)))*abs(A)*abs(x), p) -function issym(A::AbstractMatrix) +function issymmetric(A::AbstractMatrix) m, n = size(A) if m != n return false @@ -395,7 +395,7 @@ function issym(A::AbstractMatrix) return true end -issym(x::Number) = true +issymmetric(x::Number) = true function ishermitian(A::AbstractMatrix) m, n = size(A) diff --git a/base/linalg/symmetric.jl b/base/linalg/symmetric.jl index 5a8ba6a9c5faa..d7227b70932bb 100644 --- a/base/linalg/symmetric.jl +++ b/base/linalg/symmetric.jl @@ -59,9 +59,9 @@ copy{T,S}(A::Hermitian{T,S}) = Hermitian{T,S}(copy(A.data),A.uplo) ishermitian(A::Hermitian) = true ishermitian{T<:Real,S}(A::Symmetric{T,S}) = true ishermitian{T<:Complex,S}(A::Symmetric{T,S}) = all(imag(A.data) .== 0) -issym{T<:Real,S}(A::Hermitian{T,S}) = true -issym{T<:Complex,S}(A::Hermitian{T,S}) = all(imag(A.data) .== 0) -issym(A::Symmetric) = true +issymmetric{T<:Real,S}(A::Hermitian{T,S}) = true +issymmetric{T<:Complex,S}(A::Hermitian{T,S}) = all(imag(A.data) .== 0) +issymmetric(A::Symmetric) = true transpose(A::Symmetric) = A ctranspose{T<:Real}(A::Symmetric{T}) = A function ctranspose(A::Symmetric) @@ -138,7 +138,7 @@ A_mul_B!{T<:BlasComplex,S<:StridedMatrix}(C::StridedMatrix{T}, A::StridedMatrix{ *(A::HermOrSym, B::HermOrSym) = full(A)*full(B) *(A::StridedMatrix, B::HermOrSym) = A*full(B) -bkfact(A::HermOrSym) = bkfact(A.data, symbol(A.uplo), issym(A)) +bkfact(A::HermOrSym) = bkfact(A.data, symbol(A.uplo), issymmetric(A)) factorize(A::HermOrSym) = bkfact(A) # Is just RealHermSymComplexHerm, but type alias seems to be broken @@ -146,7 +146,7 @@ det{T<:Real,S}(A::Union{Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S}} det{T<:Real}(A::Symmetric{T}) = det(bkfact(A)) det(A::Symmetric) = det(bkfact(A)) -\{T,S<:StridedMatrix}(A::HermOrSym{T,S}, B::StridedVecOrMat) = \(bkfact(A.data, symbol(A.uplo), issym(A)), B) +\{T,S<:StridedMatrix}(A::HermOrSym{T,S}, B::StridedVecOrMat) = \(bkfact(A.data, symbol(A.uplo), issymmetric(A)), B) inv{T<:BlasFloat,S<:StridedMatrix}(A::Hermitian{T,S}) = Hermitian{T,S}(inv(bkfact(A.data, symbol(A.uplo))), A.uplo) inv{T<:BlasFloat,S<:StridedMatrix}(A::Symmetric{T,S}) = Symmetric{T,S}(inv(bkfact(A.data, symbol(A.uplo), true)), A.uplo) diff --git a/base/sparse.jl b/base/sparse.jl index d45eb0004a3e7..56ca4cdaf5a6c 100644 --- a/base/sparse.jl +++ b/base/sparse.jl @@ -13,10 +13,10 @@ import Base.LinAlg: At_ldiv_B!, Ac_ldiv_B! import Base: @get!, acos, acosd, acot, acotd, acsch, asech, asin, asind, asinh, atan, atand, atanh, broadcast!, chol, conj!, cos, cosc, cosd, cosh, cospi, cot, cotd, coth, countnz, csc, cscd, csch, ctranspose!, diag, diff, done, dot, eig, - exp10, exp2, eye, findn, floor, hash, indmin, inv, issym, istril, istriu, log10, - log2, lu, maxabs, minabs, next, sec, secd, sech, show, showarray, sin, sinc, - sind, sinh, sinpi, squeeze, start, sum, sumabs, sumabs2, summary, tan, tand, - tanh, trace, transpose!, tril!, triu!, trunc, vecnorm, writemime, abs, abs2, + exp10, exp2, eye, findn, floor, hash, indmin, inv, issymmetric, istril, istriu, + log10, log2, lu, maxabs, minabs, next, sec, secd, sech, show, showarray, sin, + sinc, sind, sinh, sinpi, squeeze, start, sum, sumabs, sumabs2, summary, tan, + tand, tanh, trace, transpose!, tril!, triu!, trunc, vecnorm, writemime, abs, abs2, broadcast, ceil, complex, cond, conj, convert, copy, copy!, ctranspose, diagm, exp, expm1, factorize, find, findmax, findmin, findnz, float, full, getindex, hcat, hvcat, imag, indmax, ishermitian, kron, length, log, log1p, max, min, diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index ee49a388fbbbc..8388c351d866c 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -7,7 +7,7 @@ import Base: (*), convert, copy, eltype, get, getindex, show, showarray, size, import Base.LinAlg: (\), A_mul_Bc, A_mul_Bt, Ac_ldiv_B, Ac_mul_B, At_ldiv_B, At_mul_B, cholfact, cholfact!, det, diag, ishermitian, isposdef, - issym, ldltfact, ldltfact!, logdet + issymmetric, ldltfact, ldltfact!, logdet importall ..SparseArrays @@ -986,7 +986,7 @@ function convert{Tv}(::Type{SparseMatrixCSC{Tv,SuiteSparse_long}}, A::Sparse{Tv} end function convert(::Type{Symmetric{Float64,SparseMatrixCSC{Float64,SuiteSparse_long}}}, A::Sparse{Float64}) s = unsafe_load(A.p) - if !issym(A) + if !issymmetric(A) throw(ArgumentError("matrix is not symmetric")) end return Symmetric(SparseMatrixCSC(s.nrow, s.ncol, increment(pointer_to_array(s.p, (s.ncol + 1,), false)), increment(pointer_to_array(s.i, (s.nzmax,), false)), copy(pointer_to_array(s.x, (s.nzmax,), false))), s.stype > 0 ? :U : :L) @@ -1536,7 +1536,7 @@ function isposdef{Tv<:VTypes}(A::SparseMatrixCSC{Tv,SuiteSparse_long}) true end -function issym(A::Sparse) +function issymmetric(A::Sparse) s = unsafe_load(A.p) if s.stype != 0 return isreal(A) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index eb16f9443b7df..1286a584cc7df 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -2911,7 +2911,7 @@ function blkdiag(X::SparseMatrixCSC...) end ## Structure query functions -issym(A::SparseMatrixCSC) = is_hermsym(A, IdFun()) +issymmetric(A::SparseMatrixCSC) = is_hermsym(A, IdFun()) ishermitian(A::SparseMatrixCSC) = is_hermsym(A, ConjFun()) diff --git a/doc/stdlib/linalg.rst b/doc/stdlib/linalg.rst index 411b6b526177f..f38976a82823b 100644 --- a/doc/stdlib/linalg.rst +++ b/doc/stdlib/linalg.rst @@ -423,7 +423,7 @@ Linear algebra functions in Julia are largely implemented by calling functions f .. Docstring generated from Julia source - Compute the Bunch-Kaufman [Bunch1977]_ factorization of a real symmetric or complex Hermitian matrix ``A`` and return a ``BunchKaufman`` object. The following functions are available for ``BunchKaufman`` objects: ``size``\ , ``\``\ , ``inv``\ , ``issym``\ , ``ishermitian``\ . + Compute the Bunch-Kaufman [Bunch1977]_ factorization of a real symmetric or complex Hermitian matrix ``A`` and return a ``BunchKaufman`` object. The following functions are available for ``BunchKaufman`` objects: ``size``\ , ``\``\ , ``inv``\ , ``issymmetric``\ , ``ishermitian``\ . .. [Bunch1977] J R Bunch and L Kaufman, Some stable methods for calculating inertia and solving symmetric linear systems, Mathematics of Computation 31:137 (1977), 163-179. `url `_\ . @@ -1093,7 +1093,7 @@ Linear algebra functions in Julia are largely implemented by calling functions f Computes the solution ``X`` to the Sylvester equation ``AX + XB + C = 0``\ , where ``A``\ , ``B`` and ``C`` have compatible dimensions and ``A`` and ``-B`` have no eigenvalues with equal real part. -.. function:: issym(A) -> Bool +.. function:: issymmetric(A) -> Bool .. Docstring generated from Julia source diff --git a/test/arrayops.jl b/test/arrayops.jl index 47593953bf694..edff1668b653d 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -964,7 +964,7 @@ end # Handle block matrices A = [randn(2,2) for i = 1:2, j = 1:2] -@test issym(A.'A) +@test issymmetric(A.'A) A = [complex(randn(2,2), randn(2,2)) for i = 1:2, j = 1:2] @test ishermitian(A'A) diff --git a/test/bitarray.jl b/test/bitarray.jl index de2f715db8f72..d57ec2b7fc221 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -1201,7 +1201,7 @@ b1 = triu(bitrand(n2, n1)) b1 = bitrand(n1,n1) b1 |= b1.' -@check_bit_operation issym(b1) Bool +@check_bit_operation issymmetric(b1) Bool @check_bit_operation ishermitian(b1) Bool b1 = bitrand(n1) diff --git a/test/blas.jl b/test/blas.jl index 2bf10b1b3d874..8b7d0d1680c3e 100644 --- a/test/blas.jl +++ b/test/blas.jl @@ -132,7 +132,7 @@ for elty in [Float32, Float64, Complex64, Complex128] A = rand(elty,n,n) A = A + A.' - @test issym(A) + @test issymmetric(A) @test_approx_eq triu(BLAS.syr!('U',α,x,copy(A))) triu(A + α*x*x.') @test_throws DimensionMismatch BLAS.syr!('U',α,ones(elty,n+1),copy(A)) diff --git a/test/linalg/arnoldi.jl b/test/linalg/arnoldi.jl index 89382dbb52e4c..4ce632206cc47 100644 --- a/test/linalg/arnoldi.jl +++ b/test/linalg/arnoldi.jl @@ -102,13 +102,13 @@ let A6965 = [ end # Example from Quantum Information Theory -import Base: size, issym, ishermitian +import Base: size, issymmetric, ishermitian type CPM{T<:Base.LinAlg.BlasFloat}<:AbstractMatrix{T} # completely positive map kraus::Array{T,3} # kraus operator representation end size(Phi::CPM)=(size(Phi.kraus,1)^2,size(Phi.kraus,3)^2) -issym(Phi::CPM)=false +issymmetric(Phi::CPM)=false ishermitian(Phi::CPM)=false import Base: * function *{T<:Base.LinAlg.BlasFloat}(Phi::CPM{T},rho::Vector{T}) diff --git a/test/linalg/bunchkaufman.jl b/test/linalg/bunchkaufman.jl index 2f94166ca1068..715b280e9d73c 100644 --- a/test/linalg/bunchkaufman.jl +++ b/test/linalg/bunchkaufman.jl @@ -49,10 +49,10 @@ debug && println("(Automatic) Bunch-Kaufman factor of indefinite matrix") end debug && println("Bunch-Kaufman factors of a pos-def matrix") for rook in (false, true) - bc2 = bkfact(apd, :U, issym(apd), rook) + bc2 = bkfact(apd, :U, issymmetric(apd), rook) @test_approx_eq inv(bc2) * apd eye(n) @test_approx_eq_eps apd * (bc2\b) b 150000ε - @test ishermitian(bc2) == !issym(bc2) + @test ishermitian(bc2) == !issymmetric(bc2) end end diff --git a/test/linalg/diagonal.jl b/test/linalg/diagonal.jl index 5288214d16c65..c97693c809162 100644 --- a/test/linalg/diagonal.jl +++ b/test/linalg/diagonal.jl @@ -164,12 +164,12 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty}) @test isa(similar(D, Int, (3,2)), Matrix{Int}) #10036 - @test issym(D2) + @test issymmetric(D2) @test ishermitian(D2) if elty <: Complex dc = d + im*convert(Vector{elty}, ones(n)) D3 = Diagonal(dc) - @test issym(D3) + @test issymmetric(D3) @test !ishermitian(D3) end diff --git a/test/linalg/generic.jl b/test/linalg/generic.jl index 5f4bcb3d84c29..3b33f222d7725 100644 --- a/test/linalg/generic.jl +++ b/test/linalg/generic.jl @@ -89,7 +89,7 @@ y = ['a','b','c','d','e'] @test_throws DimensionMismatch Base.LinAlg.axpy!(α,x,collect(1:2),['a','b'],collect(1:2)) @test_throws ArgumentError diag(rand(10)) -@test !issym(ones(5,3)) +@test !issymmetric(ones(5,3)) @test !ishermitian(ones(5,3)) @test cross(ones(3),ones(3)) == zeros(3) @@ -193,7 +193,7 @@ for elty in [Float32,Float64,Complex64,Complex128] @test !isfinite(cond(zero(elty))) @test cond(a) == one(elty) @test cond(a,1) == one(elty) - @test issym(a) + @test issymmetric(a) @test ishermitian(one(elty)) @test det(a) == a end diff --git a/test/linalg/symmetric.jl b/test/linalg/symmetric.jl index ed8df55e10970..473af1b4b8985 100644 --- a/test/linalg/symmetric.jl +++ b/test/linalg/symmetric.jl @@ -62,9 +62,9 @@ let n=10 #trace @test trace(asym) == trace(Hermitian(asym)) - # issym, ishermitian + # issymmetric, ishermitian if eltya <: Real - @test issym(Symmetric(asym)) + @test issymmetric(Symmetric(asym)) @test ishermitian(Symmetric(asym)) end if eltya <: Complex diff --git a/test/sparsedir/cholmod.jl b/test/sparsedir/cholmod.jl index 494bfe0d81d22..bc21d912b7591 100644 --- a/test/sparsedir/cholmod.jl +++ b/test/sparsedir/cholmod.jl @@ -182,10 +182,10 @@ end @test eltype(A) == Float64 @test eltype(chma) == Float64 -# test Sparse constructor Symmetric and Hermitian input (and issym and ishermitian) +# test Sparse constructor Symmetric and Hermitian input (and issymmetric and ishermitian) ACSC = sprandn(10, 10, 0.3) + I -@test issym(Sparse(Symmetric(ACSC, :L))) -@test issym(Sparse(Symmetric(ACSC, :U))) +@test issymmetric(Sparse(Symmetric(ACSC, :L))) +@test issymmetric(Sparse(Symmetric(ACSC, :U))) @test ishermitian(Sparse(Hermitian(complex(ACSC), :L))) @test ishermitian(Sparse(Hermitian(complex(ACSC), :U))) @@ -387,7 +387,7 @@ for elty in (Float64, Complex{Float64}) @test !isposdef(A1 + A1' |> t -> t - 2eigmax(full(t))*I) if elty <: Real - @test CHOLMOD.issym(Sparse(A1pd, 0)) + @test CHOLMOD.issymmetric(Sparse(A1pd, 0)) @test CHOLMOD.Sparse(cholfact(Symmetric(A1pd, :L))) == CHOLMOD.Sparse(cholfact(A1pd)) F1 = CHOLMOD.Sparse(cholfact(Symmetric(A1pd, :L), shift=2)) F2 = CHOLMOD.Sparse(cholfact(A1pd, shift=2)) @@ -397,7 +397,7 @@ for elty in (Float64, Complex{Float64}) F2 = CHOLMOD.Sparse(ldltfact(A1pd, shift=2)) @test F1 == F2 else - @test !CHOLMOD.issym(Sparse(A1pd, 0)) + @test !CHOLMOD.issymmetric(Sparse(A1pd, 0)) @test CHOLMOD.ishermitian(Sparse(A1pd, 0)) @test CHOLMOD.Sparse(cholfact(Hermitian(A1pd, :L))) == CHOLMOD.Sparse(cholfact(A1pd)) F1 = CHOLMOD.Sparse(cholfact(Hermitian(A1pd, :L), shift=2)) diff --git a/test/sparsedir/sparse.jl b/test/sparsedir/sparse.jl index 38a132b3944e7..0d26331d1cccb 100644 --- a/test/sparsedir/sparse.jl +++ b/test/sparsedir/sparse.jl @@ -1048,43 +1048,43 @@ A = sparse([1.0]) @test_throws ArgumentError norm(sprand(5,5,0.2),3) @test_throws ArgumentError norm(sprand(5,5,0.2),2) -# test ishermitian and issym real matrices +# test ishermitian and issymmetric real matrices A = speye(5,5) @test ishermitian(A) == true -@test issym(A) == true +@test issymmetric(A) == true A[1,3] = 1.0 @test ishermitian(A) == false -@test issym(A) == false +@test issymmetric(A) == false A[3,1] = 1.0 @test ishermitian(A) == true -@test issym(A) == true +@test issymmetric(A) == true -# test ishermitian and issym complex matrices +# test ishermitian and issymmetric complex matrices A = speye(5,5) + im*speye(5,5) @test ishermitian(A) == false -@test issym(A) == true +@test issymmetric(A) == true A[1,4] = 1.0 + im @test ishermitian(A) == false -@test issym(A) == false +@test issymmetric(A) == false A = speye(Complex128, 5,5) A[3,2] = 1.0 + im @test ishermitian(A) == false -@test issym(A) == false +@test issymmetric(A) == false A[2,3] = 1.0 - im @test ishermitian(A) == true -@test issym(A) == false +@test issymmetric(A) == false A = sparse(zeros(5,5)) @test ishermitian(A) == true -@test issym(A) == true +@test issymmetric(A) == true # Test with explicit zeros A = speye(Complex128, 5,5) A[3,1] = 2 A.nzval[2] = 0.0 @test ishermitian(A) == true -@test issym(A) == true +@test issymmetric(A) == true # equality == A1 = speye(10)