/*---------------------------------------------------------------------------* * IT++ * *---------------------------------------------------------------------------* * Copyright (c) 1995-2004 by Tony Ottosson, Thomas Eriksson, Pål Frenger, * * Tobias Ringström, and Jonas Samuelsson. * * * * Permission to use, copy, modify, and distribute this software and its * * documentation under the terms of the GNU General Public License is hereby * * granted. No representations are made about the suitability of this * * software for any purpose. It is provided "as is" without expressed or * * implied warranty. See the GNU General Public License for more details. * *---------------------------------------------------------------------------*/ /*! \file \brief Implementation of QR factorisation functions. \author Tony Ottosson 1.2 2004/09/02 11:29:15 */ #include "base/qr.h" #include "base/matfunc.h" #include "../src/base/lapack.h" namespace itpp { #ifndef NO_LAPACK bool qr(const mat &A, mat &Q, mat &R) { int m, n, k, info, lwork, i, j; m = A.rows(); n = A.cols(); lwork = 16*n; k = std::min(m,n); vec tau(k); vec work(lwork); R = A; dgeqrf_(&m, &n, R._data(), &m, tau._data(), work._data(), &lwork, &info); Q = R; // construct R for (i=0; i