File tree 6 files changed +47
-24
lines changed
6 files changed +47
-24
lines changed Original file line number Diff line number Diff line change 1
1
name = " PDMats"
2
2
uuid = " 90014a1f-27ba-587c-ab20-58faa44d9150"
3
- version = " 0.11.17 "
3
+ version = " 0.11.18 "
4
4
5
5
[deps ]
6
6
LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Original file line number Diff line number Diff line change @@ -58,8 +58,12 @@ function \(a::PDiagMat, x::AbstractVecOrMat)
58
58
end
59
59
function / (x:: AbstractVecOrMat , a:: PDiagMat )
60
60
@check_argdims a. dim == size (x, 2 )
61
- # return matrix for 1-element vectors `x`, consistent with LinearAlgebra
62
- return reshape (x, Val (2 )) ./ permutedims (a. diag) # = (a' \ x')'
61
+ if VERSION < v " 1.9-"
62
+ # return matrix for 1-element vectors `x`, consistent with LinearAlgebra < 1.9
63
+ return reshape (x, Val (2 )) ./ permutedims (a. diag) # = (a' \ x')'
64
+ else
65
+ return x ./ (x isa AbstractVector ? a. diag : a. diag' )
66
+ end
63
67
end
64
68
Base. kron (A:: PDiagMat , B:: PDiagMat ) = PDiagMat (vec (permutedims (A. diag) .* B. diag))
65
69
Original file line number Diff line number Diff line change 49
49
* (a:: PDMat , x:: AbstractVector ) = a. mat * x
50
50
* (a:: PDMat , x:: AbstractMatrix ) = a. mat * x
51
51
\ (a:: PDMat , x:: AbstractVecOrMat ) = a. chol \ x
52
- # return matrix for 1-element vectors `x`, consistent with LinearAlgebra
53
- / (x:: AbstractVecOrMat , a:: PDMat ) = reshape (x, Val (2 )) / a. chol
52
+ function / (x:: AbstractVecOrMat , a:: PDMat )
53
+ # /(::AbstractVector, ::Cholesky) is not defined
54
+ if VERSION < v " 1.9-"
55
+ # return matrix for 1-element vectors `x`, consistent with LinearAlgebra
56
+ return reshape (x, Val (2 )) / a. chol
57
+ else
58
+ if x isa AbstractVector
59
+ return vec (reshape (x, Val (2 )) / a. chol)
60
+ else
61
+ return x / a. chol
62
+ end
63
+ end
64
+ end
54
65
55
66
# ## Algebra
56
67
Original file line number Diff line number Diff line change @@ -53,8 +53,12 @@ function \(a::ScalMat, x::AbstractVecOrMat)
53
53
end
54
54
function / (x:: AbstractVecOrMat , a:: ScalMat )
55
55
@check_argdims a. dim == size (x, 2 )
56
- # return matrix for 1-element vectors `x`, consistent with LinearAlgebra
57
- return reshape (x, Val (2 )) / a. value
56
+ if VERSION < v " 1.9-"
57
+ # return matrix for 1-element vectors `x`, consistent with LinearAlgebra < 1.9
58
+ return reshape (x, Val (2 )) / a. value
59
+ else
60
+ return x / a. value
61
+ end
58
62
end
59
63
Base. kron (A:: ScalMat , B:: ScalMat ) = ScalMat (A. dim * B. dim, A. value * B. value )
60
64
Original file line number Diff line number Diff line change @@ -88,25 +88,29 @@ using Test
88
88
A = rand (1 , 1 )
89
89
x = randn (1 )
90
90
y = x / A
91
- @assert x / A isa Matrix{Float64}
92
- @assert size (y) == (1 , 1 )
93
91
94
92
for M in (PDiagMat (vec (A)), ScalMat (1 , first (A)))
95
- @test x / M isa Matrix{Float64}
96
- @test x / M ≈ y
93
+ z = x / M
94
+ @test typeof (z) === typeof (y)
95
+ @test size (z) == size (y)
96
+ @test z ≈ y
97
97
end
98
98
99
99
# requires https://github.com/JuliaLang/julia/pull/32594
100
100
if VERSION >= v " 1.3.0-DEV.562"
101
- @test x / PDMat (A) isa Matrix{Float64}
102
- @test x / PDMat (A) ≈ y
101
+ z = x / PDMat (A)
102
+ @test typeof (z) === typeof (y)
103
+ @test size (z) == size (y)
104
+ @test z ≈ y
103
105
end
104
106
105
107
# right division not defined for CHOLMOD:
106
108
# `rdiv!(::Matrix{Float64}, ::SuiteSparse.CHOLMOD.Factor{Float64})` not defined
107
109
if ! HAVE_CHOLMOD
108
- @test x / PDSparseMat (sparse (first (A), 1 , 1 )) isa Matrix{Float64}
109
- @test x / PDSparseMat (sparse (first (A), 1 , 1 )) ≈ y
110
+ z = x / PDSparseMat (sparse (first (A), 1 , 1 ))
111
+ @test typeof (z) === typeof (y)
112
+ @test size (z) == size (y)
113
+ @test z ≈ y
110
114
end
111
115
end
112
116
Original file line number Diff line number Diff line change @@ -63,17 +63,17 @@ using StaticArrays
63
63
x = rand (5 )
64
64
X = rand (2 , 5 )
65
65
Y = rand (5 , 2 )
66
- @test P * x ≈ A * x
67
- @test P * Y ≈ A * Y
66
+ @test P * x ≈ x
67
+ @test P * Y ≈ Y
68
68
# Right division with Cholesky requires https://github.com/JuliaLang/julia/pull/32594
69
69
if VERSION >= v " 1.3.0-DEV.562"
70
- @test X / P ≈ X / A
70
+ @test X / P ≈ X
71
71
end
72
- @test P \ x ≈ A \ x
73
- @test P \ Y ≈ A \ Y
74
- @test X_A_Xt (P, X) ≈ X * A * X'
75
- @test X_invA_Xt (P, X) ≈ X * (A \ X ' )
76
- @test Xt_A_X (P, Y) ≈ Y' * A * Y
77
- @test Xt_invA_X (P, Y) ≈ Y' * (A \ Y)
72
+ @test P \ x ≈ x
73
+ @test P \ Y ≈ Y
74
+ @test X_A_Xt (P, X) ≈ X * X'
75
+ @test X_invA_Xt (P, X) ≈ X * X '
76
+ @test Xt_A_X (P, Y) ≈ Y' * Y
77
+ @test Xt_invA_X (P, Y) ≈ Y' * Y
78
78
end
79
79
end
You can’t perform that action at this time.
0 commit comments