File Exchange

image thumbnail

Rank-Revealing QR factorization

version (206 KB) by Ivo Houtzager
Rank-Revealing QR factorization of an array


Updated 07 Apr 2021

From GitHub

View Version History

View license on GitHub

Rank-Revealing QR factorization of an array. The mex-functions are using the rank-revealing QR routines xGEQPX and xGEQPY from ACM Algorithm 782. Can also handle complex and single precision array's.

Cite As

Ivo Houtzager (2021). Rank-Revealing QR factorization (, GitHub. Retrieved .

Comments and Ratings (5)

Ivo Houtzager

According to the xerbla definition in the header file Matlab\R2020b\extern\include\blas.h, the xerbla function expects 2 input arguments. Are you using a different BLAS library then the libmwblas.lib provided in Matlab? I checked VS C++ 2019 with R2020b and get no compilation errors for xerbla.

Jared Barber

Seems ok except it does not compile with VS C++ 2019. This seems to be because of deprecated/fortran-based calls to xerbla. Fortran version of xerbla needs 2 inputs while the c version needs 3. The c-code in the AMS 782 folder calls xerbla with 2 inputs and mex did not like that. I switched out the calls and it compiled, but it was a bit of work. I realize the author may have just copied and pasted AMS 782 files from somewhere else and so had no reason to expect them not to work. Nonetheless, fixing this issue would make the code better/more useable.

Piotr Sypek

Jeshua Bratman

Here's how I managed to compile librrqr.a

# first download the package (it is actually a shell script that creates a bunch of files)
wget -O

# remove the top 3 lines with the ACM info
sed -i '1,3d'

# replace all $( and $?in the cat areas for makefiles with \$( and \$?to work with newer versions of sh
sed -i 's/\$[\(]/\\$\(/g'
sed -i 's/\$[\?]/\\$?/g'

# now extract the rrqr_acm directory

To compile go into rrqr_acm/lib and run make. You will probably need to first edit the Makefile and change the fortran compiler from f77 to gfortran and add -fPIC to the OPTS. After running make, there should be a file rrqr.a in the rrqr_acm directory. Move this to librrqr.a in the directory with the matlab and c files and now you should be able to compile the mex file.

Tim Davis

I had difficulty in compiling the ACM 782 algorithm on Linux (the "make" instructions seem to be out of date).

You should create an m-file called rrqr_install.m that compiles this code and the RRQR algorithm from the ACM - all using the "mex" command from inside MATLAB. That way, your installation should work on any MATLAB. The one-line instructions you give using rrqr.lib assume you're on Windows (there would be an rrqr.a on Linux/Unix, or a, not a Windows rrqr.lib).

You should also provide instructions on where to find the ACM algorithm (I found it here:


but that detail should be in your installation instructions.

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!