# Why is qr! not available for a view?

**URL:** <https://discourse.julialang.org/t/why-is-qr-not-available-for-a-view/90563>\
**Category:** General Usage\
**Created:** [November 20, 2022, 11:54pm UTC](https://discourse.julialang.org/t/why-is-qr-not-available-for-a-view/90563 "2022-11-20T23:54:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 20, 2022, 11:54pm UTC](https://discourse.julialang.org/t/why-is-qr-not-available-for-a-view/90563/1 "2022-11-20T23:54:54Z")

</div>

I tried to use `qr!` on a view of a dense matrix, but apparently there is no method for that:

```julia
  LoadError: MethodError: no method matching qr!(::SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true})                                                
  Closest candidates are:                                                                                                                                                                   
    qr!(::StridedMatrix{var"#s882"} where var"#s882"<:Union{Float32, Float64, ComplexF32, ComplexF64}, ::LinearAlgebra.NoPivot; blocksize) at C:\Users\pkonl\SublimeJulia_1.8\assets\julia-1.8.2\share\julia\stdlib\v1.8\LinearAlgebra\src\qr.jl:292                                                                                                                                    
    qr!(::StridedMatrix{var"#s885"} where var"#s885"<:Union{Float32, Float64, ComplexF32, ComplexF64}, ::LinearAlgebra.ColumnNorm) at C:\Users\pkonl\SublimeJulia_1.8\assets\julia-1.8.2\share\julia\stdlib\v1.8\LinearAlgebra\src\qr.jl:294                                                                                                                                            
    qr!(::AbstractMatrix) at C:\Users\pkonl\SublimeJulia_1.8\assets\julia-1.8.2\share\julia\stdlib\v1.8\LinearAlgebra\src\qr.jl:340                                                         
    ...        

```

Is that something that I could rectify?

---

<div class="post-metadata">

**Author:** ![cgeoga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgeoga/32/216186_2.png) [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Post date:** [November 21, 2022, 3:12am UTC](https://discourse.julialang.org/t/why-is-qr-not-available-for-a-view/90563/2 "2022-11-21T03:12:43Z")

</div>

I’m not an expert on reading subarray types, but it looks to me like you accidentally passed in a 1D view, or something like that. The following works fine in my REPL:

```julia
julia> A = randn(10,10);
julia> B = view(A, 1:9, 1:9);
julia> Bf = qr!(B);

```

The reason I mention the 1D view is because the `typeof` of my view is

```julia
julia> typeof(B)
SubArray{Float64, 2, Matrix{Float64}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}

```

which is different from what your method error gave.

Or am I misunderstanding some part of your post?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 21, 2022, 3:24am UTC](https://discourse.julialang.org/t/why-is-qr-not-available-for-a-view/90563/3 "2022-11-21T03:24:24Z")

</div>

You are right, I had a mistake there passing the array. It was received as a vector.
