Skip to content

Commit eafe231

Browse files
committed
Fix interfaces
1 parent 9358970 commit eafe231

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/qr.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ _thin_must_hold(thin) =
33
import Base.qr
44

55

6+
"""
7+
qr(A::StaticMatrix, pivot=Val{false}; thin=true) -> Q, R, [p]
8+
9+
Compute the QR factorization of `A` such that `A = Q*R` or `A[:,p] = Q*R`, see [`qr`](@ref).
10+
This function is not support `thin=false` keyword option due to type inference instability.
11+
To use this option call `StaticArrays._qr(Size(A), A, pivot, Val{false})` instead.
12+
"""
613
@inline function qr(A::StaticMatrix, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{false}; thin::Bool=true)
714
_thin_must_hold(thin)
8-
return qr(Size(A), A, pivot, Val{true})
15+
return _qr(Size(A), A, pivot, Val{true})
916
end
1017

1118

12-
"""
13-
qr(Size(A), A::StaticMatrix, pivot=Val{false}, thin=Val{true}) -> Q, R, [p]
14-
15-
Compute the QR factorization of `A` such that `A = Q*R` or `A[:,p] = Q*R`, see [`qr`](@ref).
16-
This function is exported to allow bypass the type instability problem in base `qr` function
17-
with keyword `thin` parameter in the interface.
18-
"""
19-
@generated function qr(::Size{sA}, A::StaticMatrix{<:Any, <:Any, TA}, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{false}, thin::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) where {sA, TA}
19+
@generated function _qr(::Size{sA}, A::StaticMatrix{<:Any, <:Any, TA}, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{false}, thin::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) where {sA, TA}
2020

2121
isthin = thin <: Type{Val{true}}
2222

@@ -36,7 +36,7 @@ with keyword `thin` parameter in the interface.
3636
if (sA[1]*sA[1] + sA[1]*sA[2])÷2 * diagsize(Size(A)) < 17*17*17
3737
return quote
3838
@_inline_meta
39-
return qr_unrolled(Size(A), A, thin)
39+
return qr_unrolled(Size(A), A, pivot, thin)
4040
end
4141
else
4242
return quote
@@ -58,7 +58,7 @@ end
5858
# in the case of `thin=false` Q is full, but R is still reduced, see [`qr`](@ref).
5959
#
6060
# For original source code see below.
61-
@generated function qr_unrolled(::Size{sA}, A::StaticMatrix{<:Any, <:Any, TA}, thin::Union{Type{Val{false}},Type{Val{true}}} = Val{true}) where {sA, TA}
61+
@generated function qr_unrolled(::Size{sA}, A::StaticMatrix{<:Any, <:Any, TA}, pivot::Type{Val{false}}, thin::Union{Type{Val{false}},Type{Val{true}}} = Val{true}) where {sA, TA}
6262
m, n = sA[1], sA[2]
6363

6464
Q = [Symbol("Q_$(i)_$(j)") for i = 1:m, j = 1:m]

test/qr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ srand(42)
2727
@test istriu(R)
2828

2929
# fat (thin=false) case
30-
QR = @inferred qr(Size(arr), arr, Val{false}, Val{false})
30+
QR = @inferred StaticArrays._qr(Size(arr), arr, Val{false}, Val{false})
3131
@test QR isa Tuple
3232
@test length(QR) == 2
3333
Q, R = QR

0 commit comments

Comments
 (0)