Questions tagged [qr-decomposition]

QR factorization is an important type of matrix factorization in scientific computing. It is commonly used for generating orthonormal basis and solving least squares problem.

The standard scientific library supports Householder QR factorization with or without pivoting via dgeqrf and dgeqp3.

The scientific software for statistical computing and graphics has a built-in function qr(, LAPACK = TRUE) that interfaces dgeqp3. Note that if LAPACK = FALSE (default), the factorization is implemented with a modified LINPACK routine that can detect numerical rank. This is used for lm and glm functions that fits linear models and generalized linear models.

69 questions
3
votes
2 answers

Thin QR decomposition in c++

Is there an easy to use c++ library for "thin" QR decomposition of a rectangular matrix? Eigen seems to only support full Q matrices. I can take a full Q and discard some columns, but would it be more efficient to not compute them to begin with?
Abhishek Anand
  • 3,789
  • 2
  • 21
  • 29
3
votes
1 answer

Fast QR Factorization in R

I have a large number of matrices for which I need to perform a QR factorization and store the resulting Q matrices (normalized such that the R matrix has positive number in its diagonal). Is there another method than using the qr() function? Here…
Adrien
  • 461
  • 5
  • 19
3
votes
0 answers

Modify/Shrink Eigen Permutation Matrix

I'm having trouble solving what I think should be a fairly simple problem. The basic problem is I want to modify an Eigen PermutationMatrix but I don't know how. I'm doing a QR decomposition of some matrix X using the C++ Eigen library. I'm doing…
luke.sonnet
  • 475
  • 2
  • 11
3
votes
1 answer

Writing a Householder QR factorization function in R code

I am working on a piece of code to find the QR factorization of a matrix in R. X <- structure(c(0.8147, 0.9058, 0.127, 0.9134, 0.6324, 0.0975, 0.2785, 0.5469, 0.9575, 0.9649, 0.1576, 0.9706, 0.9572, 0.4854, 0.8003 ), .Dim = c(5L, 3L)) myqr <-…
user3483060
  • 337
  • 2
  • 13
3
votes
3 answers

My example shows SVD is less numerically stable than QR decomposition

I asked this question in Math Stackexchange, but it seems it didn't get enough attention there so I am asking it here.…
daydayup
  • 2,049
  • 5
  • 22
  • 47
3
votes
1 answer

QR decomposition and Choleski decomposition in R

I recently read about how the R matrix of QR decomposition can be calculated using the Choleski decomposition. The relation is: R = Choleski-decomposition(A^TA) Example: > A=matrix(c(1,2,3,2,3,5,1,3,2), nrow=3) > A [,1] [,2] [,3] [1,] 1 …
Prateek Kulkarni
  • 481
  • 2
  • 5
  • 12
3
votes
1 answer

QR decomposition different in lm and biglm?

I'm trying to recover the R matrix from the QR decomposition used in biglm. For this I am using a portion of the code in vcov.biglm and put it into a function like so: qr.R.biglm <- function (object, ...) { # Return the qr.R matrix from a biglm…
J4y
  • 639
  • 6
  • 21
2
votes
0 answers

Low-memory QR factorization

I am trying to numerically determine the rank of large matrices (around 50000 x 50000 64-bit floating point) using QR factorization with column pivoting. Even when the matrix is somewhat sparse (density ~0.05), I am having trouble completing the…
Ying
  • 163
  • 4
2
votes
1 answer

QR factorization in R not giving correct answer with large sparse matrix

I have a sparse matrix of type dgTMatrix built with the Matrix package in R and I'm trying to solve for the vector x in Ax=b using QR decomposition, but it is not working correctly. For example below I am solving for a random A, b and you can see…
Frank
  • 952
  • 1
  • 9
  • 23
2
votes
0 answers

Get base::qr pivoting in Matrix::qr method

I have a situation where I have a rank deficient X matrix and still want regression coefficients. Specifically, I want the well behaved coefficients provided by base::qr require(Matrix) y <- c(230, 192, 195, 180, 200, 185, 0) X <- new("dgCMatrix", i…
pdb
  • 1,574
  • 12
  • 26
2
votes
1 answer

QR decomposition Fortran error

I have a problem with QR decomposition method. I use dgeqrf subroutine for decomposition but there is no error in the compiler but it gives a problem after that. I haven't found where is the mistake. Another question is, A=Q*R=> if A matrix has…
2
votes
1 answer

Implementing QR decomposition in C

Problem solved It seems I accidently wrote j where it should be 0 on the line matrix_column_subtract(Q,i,matrix_column_multiply(T,0,r),j); Which should be matrix_column_subtract(Q,i,matrix_column_multiply(T,0,r),0); I'm implementing QR…
Nubcake
  • 449
  • 1
  • 8
  • 21
2
votes
1 answer

How base R `qr` creates the QR decomposition compact form?

I was wondering how to return the 'compact' form from QR decomposition using RcppArmadillo. It is relatively simple to run a QR decomposition on a matrix using RcppArmadillo with the following: library(inline) src <- ' using namespace Rcpp; using…
cdeterman
  • 19,630
  • 7
  • 76
  • 100
2
votes
1 answer

Using QR decomposition to solve least squares in Matlab

I am using Matlab to estimate a regression model with ordinary least squares (OLS). The model is y = xB, where x is a very sparse matrix with dimension 500000 x 2500. I'm using a QR decomposition: [C,R] = qr(x,y,0) and then estimating b with b =…
itzy
  • 11,275
  • 15
  • 63
  • 96
2
votes
1 answer

Extract face rotation from homography in a video

I'm trying to determine the orientation of a face in a video. The video starts with the frontal image of the face, so it has no rotation. In the following frames the head rotates and i'm trying to determine the rotation, which will lead me to…
powder
  • 1,163
  • 2
  • 16
  • 32