# What is the most efficient way of obtaining the orthogonal column space of a matrix?

**URL:** <https://discourse.julialang.org/t/what-is-the-most-efficient-way-of-obtaining-the-orthogonal-column-space-of-a-matrix/72212>\
**Category:** General Usage\
**Tags:** linearalgebra\
**Created:** [November 28, 2021, 9:44pm UTC](https://discourse.julialang.org/t/what-is-the-most-efficient-way-of-obtaining-the-orthogonal-column-space-of-a-matrix/72212 "2021-11-28T21:44:21Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 29, 2021, 2:21am UTC](https://discourse.julialang.org/t/what-is-the-most-efficient-way-of-obtaining-the-orthogonal-column-space-of-a-matrix/72212/13 "2021-11-29T02:21:13Z")

</div>

> [@stevengj](#):
>
> QR factors are stored in an implicit form that makes indexing slow, but they can be quickly multiplied by vectors. To get the first n columns, try multiplying Q by the first n columns of the identity matrix.

In particular, try `qr(X).Q * Matrix(I, size(X)...)`, and you should find that it is much faster than an SVD.

> [@Oscar\_Smith](#):
>
> I think I have a PR that fixes this, but it stalled out. I really should revive it though because it’s a dumb performance cliff.

Yes, it’s pretty common to want to slice a Q matrix and we really should provide a fast algorithm for it.

---

_[View the full topic](https://discourse.julialang.org/t/what-is-the-most-efficient-way-of-obtaining-the-orthogonal-column-space-of-a-matrix/72212)._
