Just a follow up, I think I've fixed bug 2, the following patch should work:
+++ SparseQR.h 2017-01-10 09:31:56.600356224 +0100
@@ -609,7 +609,7 @@
// Get the references
SparseQR_QProduct(const SparseQRType& qr, const Derived& other, bool transpose) :
m_qr(qr),m_other(other),m_transpose(transpose) {}
- inline Index rows() const { return m_transpose ? m_qr.rows() : m_qr.cols(); }
+ inline Index rows() const { return m_transpose ? m_qr.cols() : m_qr.rows(); }
inline Index cols() const { return m_other.cols(); }
// Assign to a vector
@@ -619,7 +619,12 @@
Index m = m_qr.rows();
Index n = m_qr.cols();
Index diagSize = (std::min)(m,n);
- res = m_other;
+ res.topLeftCorner(m_other.rows(), m_other.cols()) = m_other;
+
+ //set the rest to 0
+ res.topRightCorner(m_other.rows(), res.cols() - m_other.cols()).fill(0);
+ res.bottomLeftCorner(res.rows() - m_other.rows(), m_other.cols()).fill(0);
+ res.bottomRightCorner(res.rows() - m_other.rows(), res.cols() - m_other.cols()).fill(0);
if (m_transpose)
{
eigen_assert(m_qr.m_Q.rows() == m_other.rows() && "Non conforming object sizes");
@@ -637,7 +642,7 @@
}
else
{
- eigen_assert(m_qr.m_Q.rows() == m_other.rows() && "Non conforming object sizes");
+ eigen_assert(m_qr.m_Q.cols() == m_other.rows() && "Non conforming object sizes");
// Compute res = Q * other column by column
for(Index j = 0; j < res.cols(); j++)
{
This solution should work when &res == &m_other as well, since the topRight/bottomLeft/bottomRight corner fills should go to no-ops, since one or both of the width/height of the block will be 0.
I'm not sure whether the repeated fill(0) calls are the best way to do this, basically we need to set everything not in the top left corner to 0. If there was some kind of invertSelection() it would be much easier to read.
For bug 1) I am just taking the matrixR().topRows(n) manually in other code. I'm not sure where would be best to put a conservativeResize(n, n) - at the end of factorize(...) maybe?
Anyway, combining these two fixes gives me the correct results.