# Inverting the columns of \`LinearAlgebra.QRCompactWYQ\`

**URL:** <https://discourse.julialang.org/t/inverting-the-columns-of-linearalgebra-qrcompactwyq/90003>\
**Category:** General Usage\
**Tags:** matrices, qr, factorization\
**Created:** [November 9, 2022, 7:24pm UTC](https://discourse.julialang.org/t/inverting-the-columns-of-linearalgebra-qrcompactwyq/90003 "2022-11-09T19:24:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brainandforce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brainandforce/32/211054_2.png) [@brainandforce](https://discourse.julialang.org/u/brainandforce)\
**Post date:** [November 9, 2022, 7:24pm UTC](https://discourse.julialang.org/t/inverting-the-columns-of-linearalgebra-qrcompactwyq/90003/1 "2022-11-09T19:24:53Z")

</div>

I need to perform a QR decomposition with all of the diagonal elements of R to be positive. I’d like to do this by multiplying relevant columns of Q and rows of R by -1, but the issue that comes up is that `qr!()` returns `LinearAlgebra.QRCompactWY`, which stores the Q factors as a `LinearAlgebra.QRCompactWYQ`. Is there a nice way to multiply the columns of the matrix represented by this struct by -1? This would prevent me from having to convert Q to a matrix and then somehow rebuild a new QR struct.

I know [this paper](https://epubs.siam.org/doi/epdf/10.1137/0908009) exists describing the compact WY format the Q matrix is stored in, but I am no expert in implementations of fast linear algebra.
