|
19 | 19 | @inline qr(A::StaticMatrix, pivot::Union{Type{Val{false}}, Type{Val{true}}}, thin::Union{Type{Val{false}}, Type{Val{true}}}) = _qr(Size(A), A, pivot, thin)
|
20 | 20 |
|
21 | 21 |
|
| 22 | +_qreltype(::Type{T}) where T = typeof(zero(T)/sqrt(abs2(one(T)))) |
| 23 | + |
| 24 | + |
22 | 25 | @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}
|
23 | 26 |
|
24 | 27 | isthin = thin == Type{Val{true}}
|
|
30 | 33 | return quote
|
31 | 34 | @_inline_meta
|
32 | 35 | Q0, R0, p0 = Base.qr(Matrix(A), pivot, thin=$isthin)
|
33 |
| - T = arithmetic_closure(TA) |
| 36 | + T = _qreltype(TA) |
34 | 37 | return similar_type(A, T, $(SizeQ))(Q0),
|
35 | 38 | similar_type(A, T, $(SizeR))(R0),
|
36 | 39 | similar_type(A, Int, $(Size(sA[2])))(p0)
|
|
45 | 48 | return quote
|
46 | 49 | @_inline_meta
|
47 | 50 | Q0, R0 = Base.qr(Matrix(A), pivot, thin=$isthin)
|
48 |
| - T = arithmetic_closure(TA) |
| 51 | + T = _qreltype(TA) |
49 | 52 | return similar_type(A, T, $(SizeQ))(Q0),
|
50 | 53 | similar_type(A, T, $(SizeR))(R0)
|
51 | 54 | end
|
|
130 | 133 |
|
131 | 134 | return quote
|
132 | 135 | @_inline_meta
|
133 |
| - T = arithmetic_closure(TA) |
| 136 | + T = _qreltype(TA) |
134 | 137 | @inbounds $(Expr(:block, initQ...))
|
135 | 138 | @inbounds $(Expr(:block, initR...))
|
136 | 139 | @inbounds $code
|
|
146 | 149 | ## thin=true version of QR
|
147 | 150 | #function qr_unrolled(A::StaticMatrix{<:Any, <:Any, TA}) where {TA}
|
148 | 151 | # m, n = size(A)
|
149 |
| -# T = arithmetic_closure(TA) |
| 152 | +# T = _qreltype(TA) |
150 | 153 | # Q = eye(MMatrix{m,m,T,m*m})
|
151 | 154 | # R = MMatrix{m,n,T,m*n}(A)
|
152 | 155 | # for k = 1:min(m - 1 + !(TA<:Real), n)
|
|
0 commit comments