/* ************************************************************ PROCEDURE qtxq - computes tril(Qb' * X * Qb) Here, Qb = Q_1*Q_2*..*Q_{m-1}, where each Q_i is a Householder reflection. (Qb is from a Qb * R decomposition.) INPUT beta - length m vector c - m x m matrix, lower triangular gives Householder reflections m - order UPDATED x - m x m. On output, Xnew = Qb' * X * Qb This means: start with order m reflection, up to order 2 reflection. WORK fwork - length m working vector. ************************************************************ */ void qtxq(double *x, const double *beta, const double *c, const int m, double *fwork) { int k, inz; inz = 0; /* ------------------------------------------------------------ For each k, c[inz] = c(k,k), the top of the lower-right block, x[k] is start of k-th row in k. ------------------------------------------------------------ */ for(k = 0; k < m-1; k++, inz += m+1) elqxq(x + k, -beta[k], c + inz, k, m, fwork); }
/* ************************************************************ PROCEDURE qxqt - computes tril(Qb * X * Qb') Here, Qb = Q_1*Q_2*..*Q_{m-1}, where each Q_i is a Householder reflection. (Qb is from a Qb * R decomposition.) INPUT beta - length m vector c - m x m matrix, lower triangular gives Householder reflections m - order UPDATED x - m x m. On output, Xnew = Qb * X * Qb' This means: start with order 2 reflection, up to order m reflection. WORK fwork - length m working vector. ************************************************************ */ void qxqt(double *x, const double *beta, const double *c, const int m, double *fwork) { int k, inz; inz = SQR(m) - (m+2); /* ------------------------------------------------------------ For each k, c[inz] = c(k,k), the top of the lower-right block, x[k] is start of k-th row in k. ------------------------------------------------------------ */ for(k = m-2; k >= 0; k--, inz -= m+1) elqxq(x + k, -beta[k], c + inz, k, m, fwork); }
/* ************************************************************ PROCEDURE qxqt - computes tril(Qb * X * Qb') Here, Qb = Q_1*Q_2*..*Q_{m-1}, where each Q_i is a Householder reflection. (Qb is from a Qb * R decomposition.) INPUT beta - length m vector c - m x m matrix, lower triangular gives Householder reflections m - order UPDATED x - m x m. On output, Xnew = Qb * X * Qb' This means: start with order 2 reflection, up to order m reflection. WORK fwork - length m working vector. ************************************************************ */ void qxqt(double *x, const double *beta, const double *c, const mwIndex m, double *fwork) { mwIndex k, inz; mxAssert(m>1,""); inz = SQR(m) - (m+2); /* ------------------------------------------------------------ For each k, c[inz] = c(k,k), the top of the lower-right block, x[k] is start of k-th row in k. ------------------------------------------------------------ */ for(k = m-1; k > 0; k--, inz -= m+1) { elqxq(x + k-1, -beta[k-1], c + inz, k-1, m, fwork); } /*elqxq(x , -beta[0], c , 0, m, fwork);*/ }