We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
isreal
1 parent 0a253be commit ae5385bCopy full SHA for ae5385b
src/LinearAlgebra.jl
@@ -13,7 +13,7 @@ import Base: USE_BLAS64, abs, acos, acosh, acot, acoth, acsc, acsch, adjoint, as
13
copy, copyto!, copymutable, cos, cosh, cot, coth, csc, csch, eltype, exp, fill!, floor,
14
getindex, hcat, getproperty, imag, inv, invpermuterows!, isapprox, isequal, isone, iszero,
15
IndexStyle, kron, kron!, length, log, map, ndims, one, oneunit, parent, permutecols!,
16
- permutedims, permuterows!, power_by_squaring, promote_rule, real, sec, sech, setindex!,
+ permutedims, permuterows!, power_by_squaring, promote_rule, real, isreal, sec, sech, setindex!,
17
show, similar, sin, sincos, sinh, size, sqrt, strides, stride, tan, tanh, transpose, trunc,
18
typed_hcat, vec, view, zero
19
import Base: AbstractArray, AbstractMatrix, Array, Matrix
src/bidiag.jl
@@ -286,6 +286,7 @@ axes(M::Bidiagonal) = (ax = axes(M.dv, 1); (ax, ax))
286
for func in (:conj, :copy, :real, :imag)
287
@eval ($func)(M::Bidiagonal) = Bidiagonal(($func)(M.dv), ($func)(M.ev), M.uplo)
288
end
289
+isreal(M::Bidiagonal) = isreal(M.dv) && isreal(M.ev)
290
291
adjoint(B::Bidiagonal{<:Number}) = Bidiagonal(vec(adjoint(B.dv)), vec(adjoint(B.ev)), B.uplo == 'U' ? :L : :U)
292
adjoint(B::Bidiagonal{<:Number, <:Base.ReshapedArray{<:Number,1,<:Adjoint}}) =
src/diagonal.jl
@@ -256,6 +256,8 @@ factorize(D::Diagonal) = D
256
real(D::Diagonal) = Diagonal(real(D.diag))
257
imag(D::Diagonal) = Diagonal(imag(D.diag))
258
259
+isreal(D::Diagonal) = isreal(D.diag)
260
+
261
iszero(D::Diagonal) = all(iszero, D.diag)
262
isone(D::Diagonal) = all(isone, D.diag)
263
isdiag(D::Diagonal) = all(isdiag, D.diag)
src/tridiag.jl
@@ -173,6 +173,7 @@ _copyto_banded!(dest::SymTridiagonal, src::SymTridiagonal) =
173
174
@eval ($func)(M::SymTridiagonal) = SymTridiagonal(($func)(M.dv), ($func)(M.ev))
175
176
+isreal(S::SymTridiagonal) = isreal(S.dv) && isreal(S.ev)
177
178
transpose(S::SymTridiagonal) = S
179
adjoint(S::SymTridiagonal{<:Number}) = SymTridiagonal(vec(adjoint(S.dv)), vec(adjoint(S.ev)))
@@ -667,6 +668,7 @@ for func in (:conj, :copy, :real, :imag)
667
668
Tridiagonal(($func)(M.dl), ($func)(M.d), ($func)(M.du))
669
670
671
+isreal(T::Tridiagonal) = isreal(T.dl) && isreal(T.d) && isreal(T.du)
672
673
adjoint(S::Tridiagonal{<:Number}) = Tridiagonal(vec(adjoint(S.du)), vec(adjoint(S.d)), vec(adjoint(S.dl)))
674
adjoint(S::Tridiagonal{<:Number, <:Base.ReshapedArray{<:Number,1,<:Adjoint}}) =
test/bidiag.jl
@@ -1172,4 +1172,12 @@ end
1172
@test_throws InexactError convert(Bidiagonal, M)
1173
1174
1175
+@testset "isreal" begin
1176
+ M = Bidiagonal(ones(2), ones(1), :U)
1177
+ @test @inferred((M -> Val(isreal(M)))(M)) == Val(true)
1178
+ M = complex.(M)
1179
+ @test isreal(M)
1180
+ @test !isreal(im*M)
1181
+end
1182
1183
end # module TestBidiagonal
test/diagonal.jl
@@ -1481,4 +1481,12 @@ end
1481
@test ishermitian(D) == ishermitian(A)
1482
1483
1484
1485
+ D = Diagonal(ones(2))
1486
+ @test @inferred((D -> Val(isreal(D)))(D)) == Val(true)
1487
+ D = complex.(D)
1488
+ @test isreal(D)
1489
+ @test !isreal(im*D)
1490
1491
1492
end # module TestDiagonal
test/tridiag.jl
@@ -1162,4 +1162,14 @@ end
1162
1163
1164
1165
1166
+ for M in (SymTridiagonal(ones(2), ones(1)),
1167
+ Tridiagonal(ones(2), ones(3), ones(2)))
1168
1169
1170
1171
+ end
end # module TestTridiagonal
0 commit comments