Skip to content

Commit 06e1d95

Browse files
authored
Change the argument order in rankUpdate!. Fixes #36 (#38)
1 parent 8969f6c commit 06e1d95

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
jobs:
77
- job: Linux
8-
8+
99
pool:
1010
vmImage: 'Ubuntu 16.04'
1111

@@ -26,7 +26,7 @@ jobs:
2626
displayName: 'Run the tests'
2727
2828
- job: macOS
29-
29+
3030
pool:
3131
vmImage: 'macOS-10.13'
3232

@@ -49,7 +49,7 @@ jobs:
4949
displayName: 'Run the tests'
5050
5151
- job: Windows
52-
52+
5353
pool:
5454
vmImage: 'VS2017-Win2016'
5555

src/cholesky.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function cholUnblocked!(A::AbstractMatrix{T}, ::Type{Val{:L}}) where T<:Number
88
rmul!(a21, inv(real(A[1,1])))
99

1010
A22 = view(A, 2:n, 2:n)
11-
rankUpdate!(-one(real(T)), a21, Hermitian(A22, :L))
11+
rankUpdate!(Hermitian(A22, :L), a21, -1)
1212
cholUnblocked!(A22, Val{:L})
1313
end
1414
A
@@ -24,7 +24,7 @@ function cholBlocked!(A::AbstractMatrix{T}, ::Type{Val{:L}}, blocksize::Integer)
2424
rdiv!(A21, LowerTriangular(A11)')
2525

2626
A22 = view(A, (blocksize + 1):n, (blocksize + 1):n)
27-
rankUpdate!(-one(real(T)), A21, Hermitian(A22, :L))
27+
rankUpdate!(Hermitian(A22, :L), A21, -1)
2828
cholBlocked!(A22, Val{:L}, blocksize)
2929
end
3030
A
@@ -44,7 +44,7 @@ function cholRecursive!(A::StridedMatrix{T}, ::Type{Val{:L}}, cutoff = 1) where
4444
rdiv!(A21, LowerTriangular(A11)')
4545

4646
A22 = view(A, n2 + 1:n, n2 + 1:n)
47-
rankUpdate!(-real(one(T)), A21, Hermitian(A22, :L))
47+
rankUpdate!(Hermitian(A22, :L), A21, -1)
4848
cholRecursive!(A22, Val{:L}, cutoff)
4949
end
5050
return LowerTriangular(A)

src/householder.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function rmul!(A::StridedMatrix, H::Householder)
4545
x = A1*v
4646
axpy!(one(τ), a1, x)
4747
axpy!(-τ, x, a1)
48-
rankUpdate!(-τ, x, v, A1)
48+
rankUpdate!(A1, x, v, -τ)
4949
A
5050
end
5151

src/juliaBLAS.jl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export rankUpdate!
99

1010
## General
1111
### BLAS
12-
rankUpdate!(α::T, x::StridedVector{T}, y::StridedVector{T}, A::StridedMatrix{T}) where {T<:BlasReal} = BLAS.ger!(α, x, y, A)
12+
rankUpdate!(A::StridedMatrix{T}, x::StridedVector{T}, y::StridedVector{T}, α::T) where {T<:BlasReal} = BLAS.ger!(α, x, y, A)
1313

1414
### Generic
15-
function rankUpdate!(α::Number, x::StridedVector, y::StridedVector, A::StridedMatrix)
15+
function rankUpdate!(A::StridedMatrix, x::StridedVector, y::StridedVector, α::Number)
1616
m, n = size(A, 1), size(A, 2)
1717
m == length(x) || throw(DimensionMismatch("x vector has wrong length"))
1818
n == length(y) || throw(DimensionMismatch("y vector has wrong length"))
@@ -24,12 +24,15 @@ function rankUpdate!(α::Number, x::StridedVector, y::StridedVector, A::StridedM
2424
end
2525
end
2626

27+
# Deprecated 11 October 2018
28+
Base.@deprecate rankUpdate!::Number, x::StridedVector, y::StridedVector, A::StridedMatrix) rankUpdate!(A, x, y, α)
29+
2730
## Hermitian
28-
rankUpdate!(α::T, a::StridedVector{T}, A::HermOrSym{T,S}) where {T<:BlasReal,S<:StridedMatrix} = BLAS.syr!(A.uplo, α, a, A.data)
29-
rankUpdate!(a::StridedVector{T}, A::HermOrSym{T,S}) where {T<:BlasReal,S<:StridedMatrix} = rankUpdate!(one(T), a, A)
31+
rankUpdate!(A::HermOrSym{T,S}, a::StridedVector{T}, α::T) where {T<:BlasReal,S<:StridedMatrix} = BLAS.syr!(A.uplo, α, a, A.data)
32+
rankUpdate!(A::HermOrSym{T,S}, a::StridedVector{T}) where {T<:BlasReal,S<:StridedMatrix} = rankUpdate!(one(T), a, A)
3033

3134
### Generic
32-
function rankUpdate!(α::Real, a::StridedVector, A::Hermitian)
35+
function rankUpdate!(A::Hermitian, a::StridedVector, α::Real)
3336
n = size(A, 1)
3437
n == length(a) || throw(DimensionMismatch("a vector has wrong length"))
3538
@inbounds for j in 1:n
@@ -41,15 +44,18 @@ function rankUpdate!(α::Real, a::StridedVector, A::Hermitian)
4144
return A
4245
end
4346

47+
# Deprecated 11 October 2018
48+
Base.@deprecate rankUpdate!::Real, a::StridedVector, A::Hermitian) rankUpdate!(A, a, α)
49+
4450
# Rank k update
4551
## Real
46-
rankUpdate!(α::T, A::StridedMatrix{T}, β::T, C::HermOrSym{T,S}) where {T<:BlasReal,S<:StridedMatrix} = syrk!(C.uplo, 'N', α, A, β, C.data)
52+
rankUpdate!(C::HermOrSym{T,S}, A::StridedMatrix{T}, α::T, β::T) where {T<:BlasReal,S<:StridedMatrix} = syrk!(C.uplo, 'N', α, A, β, C.data)
4753

4854
## Complex
49-
rankUpdate!(α::T, A::StridedMatrix{Complex{T}}, β::T, C::Hermitian{T,S}) where {T<:BlasReal,S<:StridedMatrix} = herk!(C.uplo, 'N', α, A, β, C.data)
55+
rankUpdate!(C::Hermitian{T,S}, A::StridedMatrix{Complex{T}}, α::T, β::T) where {T<:BlasReal,S<:StridedMatrix} = herk!(C.uplo, 'N', α, A, β, C.data)
5056

5157
### Generic
52-
function rankUpdate!(α::Real, A::StridedVecOrMat, C::Hermitian)
58+
function rankUpdate!(C::Hermitian, A::StridedVecOrMat, α::Real)
5359
n = size(C, 1)
5460
n == size(A, 1) || throw(DimensionMismatch("first dimension of A has wrong size"))
5561
@inbounds if C.uplo == 'L' # branch outside the loop to have larger loop to optimize
@@ -74,6 +80,10 @@ function rankUpdate!(α::Real, A::StridedVecOrMat, C::Hermitian)
7480
return C
7581
end
7682

83+
# Deprecated 11 October 2018
84+
Base.@deprecate rankUpdate!::Real, A::StridedVecOrMat, C::Hermitian) rankUpdate!(C, A, α)
85+
Base.@deprecate rankUpdate!::Real, A::StridedVecOrMat, β::Real, C::Hermitian) rankUpdate!(C, A, α, β)
86+
7787
# BLAS style mul!
7888
## gemv
7989
mul!(y::StridedVector{T}, A::StridedMatrix{T}, x::StridedVector{T}, α::T, β::T) where {T<:BlasFloat} = gemv!('N', α, A, x, β, y)

0 commit comments

Comments
 (0)