Skip to main content
Share Your Experience: Take the 2024 Developer Survey
35 votes
Accepted

How to start using LAPACK in c++?

I'm going to disagree with some of the other answers and say that I believe that figuring out how to use LAPACK is important in the field of scientific computing. However, there is a large learning ...
LedHead's user avatar
  • 1,253
16 votes
Accepted

Why is it that SVD routines on nearly square matrices run significantly faster than if the matrix was highly non square?

You are asking for a full (dense) SVD, which also needs to generate the unitary components of $U$ and $V$ which correspond with the null space of your input. for the $1000 \times 800$ case, your input ...
helloworld922's user avatar
10 votes

How to start using LAPACK in c++?

I usually resist telling people what I think they should do rather than answering their question but in this case I'm going to make an exception. Lapack is written in FORTRAN and the API is very ...
Bill Greene's user avatar
  • 6,094
9 votes

How to start using LAPACK in c++?

Here's another answer in the same vein as the above. You should look into the Armadillo C++ linear algebra library. Pros: The function syntax is high-level (similar to that of MATLAB). So no <...
GoHokies's user avatar
  • 2,216
9 votes

Is LAPACK behind the cutting edge of dense linear algebra?

When one says an algorithm is of order $O(n)$, that may mean that the complexity is given by: $c + b*n$. With every new element you add you increase in runtime (effectively). What mathematically ...
MPIchael's user avatar
  • 2,935
8 votes

Rapidly determining whether or not a dense matrix is of low rank

The problem, of course, is that computing the true rank (e.g., via a QR decomposition) is not really any cheaper than computing a low-rank representation of the matrix. The best you can probably do ...
Wolfgang Bangerth's user avatar
8 votes

Is LAPACK behind the cutting edge of dense linear algebra?

LAPACK has been on the cutting edge for just about three decades, and probably still is for its niche. However, given given recent developments in libraries for the simpler BLAS-type matrix operations ...
cbk's user avatar
  • 181
8 votes
Accepted

Python scipy eigh(Arpack) giving wrong eigenvalues for generalized eigenvalue problem

The matrix B (M in the documentation) needs to positive definite according to the documentation: "If sigma is None, M is positive definite", this is in addition to the first requirement &...
user3209427's user avatar
7 votes

What's the fastest implementation of elementwise vector multiplication in Fortran?

The cost of the multiplication is almost insignificant compared to the cost of loading the data from memory (and writing it back). If you're worried about performance, you should be thinking about ...
David Ketcheson's user avatar
7 votes
Accepted

Matrix Balancing Algorithm

Took me quite a while to figure this out and as usual it becomes obvious after you find the culprit. After checking the problematic cases reported in David S. Watkins. A case where balancing is ...
percusse's user avatar
  • 393
7 votes

Rapidly determining whether or not a dense matrix is of low rank

There is a neat trick I have recently learned from this paper. You start doing rank-revealing QR, and stop after the first $k$ Householder reflections, when you have a matrix of the form $$ \begin{...
Federico Poloni's user avatar
7 votes

Matlab, Mathematica & LAPACK returning 3 different eigenvectors

Seems that you have a duplicate eigenvalue. Thus, you have two eigenpairs $(\lambda_1, x_1)$ and $(\lambda_2, x_2)$ where $\lambda_1 = \lambda_2$. Denote $\lambda = \lambda_1 = \lambda_2$. Let $\alpha$...
knl's user avatar
  • 2,104
7 votes

What is the reason that LAPACK uses $\tau$ in QR decomposition (instead of normalizing the reflection vector)?

It's the blocked variant of Householder-QR that is driving this design. If you look in Golub and Van Loan's book (Ch 5.2 or so) they talk about how k-iterations of the algorithm can be blocked ...
rchilton1980's user avatar
  • 4,906
7 votes
Accepted

Do most statistical packages and libraries in high-level programming languages rely on LAPACK for their matrix inversion operations?

tl;dr Yes. But your question doesn't make it clear that you understand what LAPACK is about. LAPACK is both a software as well as an interface. That is, the operations that LAPACK defines are standard ...
Richard's user avatar
  • 3,971
7 votes
Accepted

Functions from Scipy, Blas, or Lapack that compute only upper triangular matrix

I think you are overestimating the overhead of computing L. There are zero extra operations needed; the only additional cost is writing to RAM some numbers that you ...
Federico Poloni's user avatar
7 votes
Accepted

Eigenvalues of diagonal plus rank-one

Thanks to Brian Borchers for suggesting dlaed9; this mostly solves my problem. Unfortunately, dlaed9 does not include deflation ...
eepperly16's user avatar
6 votes
Accepted

Fast c++ library to solve very big sparse systems

I second the idea of using Eigen, which is pretty efficient, but also very simple to include. If you need a lot more performance, you could try to use PETSc or Trilinos. They are very powerful ...
BlaB's user avatar
  • 1,157
6 votes
Accepted

Faster eigenvector routine for non-symmetric matrices with real eigensystem?

The trick is trying to find out why that matrix has real eigenvalues in the first place. Usually it is because a suitable set of conjugations turns it into a symmetric matrix, and then you can reduce ...
Federico Poloni's user avatar
5 votes

Rapidly determining whether or not a dense matrix is of low rank

Another approach, which might be of interest to you is randomized sampling. This is of particular interest if you can quickly compute matrix-vector products $x\rightarrow Ax$ and $x\rightarrow A^* x$. ...
bobo's user avatar
  • 91
5 votes
Accepted

How many operations are needed for LAPACK's zgesv to solve a linear system?

The LAPACK routine zgesv first computes the LU factorization, and then solves the system making use of the factorization. It is a simple driver for calling the two ...
Will P.'s user avatar
  • 831
5 votes

A misunderstanding or a bug in LAPACK's solver for generalized eigenvalue problems?

The other answers already tell you what went wrong, but I will add a terminology note: the term for what is happening is that the pencil $A - \lambda B$ is a singular matrix pencil, i.e., $\det (A - \...
Federico Poloni's user avatar
5 votes
Accepted

Does LAPACK offer routines for Krylov sub-space based solvers and nonlinear solvers?

As far as I know, there are no such methods in LAPACK. Since LAPACK is the linear algebra package, no nonlinear solvers are included. However, you can use the underlying BLAS for implementing ...
cos_theta's user avatar
  • 451
4 votes

Rapidly determining whether or not a dense matrix is of low rank

Another approach worth trying is to use Adaptive Cross Approximation (ACA). It is a pretty popular algorithm that has many implementations available online. For the reference, you can see the original ...
Anton Menshov's user avatar
  • 8,672
4 votes
Accepted

Efficient computation of AX=B where B has special structure (block-diagonal)

Supposing you already have an LU factorization, you can save a half of a forward substitution step. In the system $Lx=b$, you would have $$ \begin{pmatrix} l_{11}&0&&&&\cdots&0\...
Kirill's user avatar
  • 11.4k
4 votes
Accepted

$\mathbf{UDU}^\top$ decomposition routines in LAPACK/Eigen?

Short Answer: LAPACK's dsytf2 (for symmetric full) and dsptrf (for symmetric packed, which is the same layout that Bierman uses ...
tantuni's user avatar
  • 156
4 votes
Accepted

LAPACK sorting eigenvalues differently each time

You write, that you are computing the eigenvalues of a symmetric matrix. Does the matrix have real entries? In this case all eigenvalues are real, and you can use a symmetric eigenvalue solver, which ...
H. Rittich's user avatar
4 votes

Are there any packaged routines (in lapack or elsewhere) for inverting a banded matrix?

Well, other than the usual "don't invert your matrices unless you need the inverse itself" you can still use the banded routines ?gbtrf and then use ...
percusse's user avatar
  • 393
4 votes

LAPACK non-convergent eigenvalue algorithm for complex but not double matrix

Your matrix is not diagonalizable, in the Jordan decomposition of it there is a block for the eigenvalue $0$ of the form $$\begin{pmatrix}0&0&0\\0&0&1\\0&0&0\end{pmatrix},$$ ...
Kirill's user avatar
  • 11.4k
4 votes
Accepted

Does armadillo library slow down the execution of matrix operations?

You're comparing statically-defined arrays which live on the stack: double a[100][100]; double b[100][100]; double c[100][100]; to heap allocated ...
Chris Rackauckas's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible