11
votes
Accepted
Computational method to compute both the (log) determinant and inverse of a matrix
The LU decomposition will give you what you want with only $\tfrac{2}{3}n^3 + \mathcal{O}(n^2)$ FLOPs. The linear system is solved by solving two triangular systems. The determinant is the product ...
9
votes
Robust algorithm for $2 \times 2$ SVD
I needed an algorithm that has
little branching (hopefully CMOVs)
no trigonometric function calls
high numerical accuracy even with 32 bit floats
We want to calculate $c_1, s_1, c_2, s_2, \sigma_1$ ...
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 ...
8
votes
Accepted
Solving $A=B+AB$ without matrix inverse
If $A$ and $B$ are real symmetric, then $A=B+AB$ if and only if the product $AB$ is also real symmetric. In turn, $AB=BA$ holds if any only if $A$ and $B$ share a common eigendecomposition. This ...
8
votes
Accepted
Cholesky for ill-conditioned/singular covariance matrices
If your covariance matrix is singular, then you really should consider why the matrix is singular and come up with a higher-level approach that avoids the singularity.
However, if you insist on ...
8
votes
Accepted
Does a symmetric positive definite matrix also have $\mathbf{A} = \mathbf{L}^T\mathbf{L}$ (where $\mathbf{L}$ is a lower triangular matrix)?
Let $P$ be the anti-diagonal permutation matrix,
$$P = \begin{bmatrix}
& & & 1 \\
& & 1 \\
& 1 \\
1
\end{bmatrix}$$
so that $PAP$ is the version of $A$ with rows and columns ...
8
votes
Accepted
Bareiss algorithm vs. LU-decomposition
Bareiss' algorithm is a better choice if you have to compute exactly determinants of integer matrices, as noted in the comments.
When it comes to real (floating-point) or complex matrices, the main ...
7
votes
Accepted
Clever ways to update LU factorization for ridge regression
What is the size of your $A$ matrix? Is $A$ sparse? Does $A$ have some other special structure? How many values of $\lambda$ do you want to try?
Normally, you'd use the Cholesky factorization of $...
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{...
7
votes
Supernodal vs multifrontal factorizations
The scopes of these terms are (in my opinion) somewhat different.
I'd use "supernodal" as a broad term, to describe any sparse direct solver that applies sufficient intelligence during the symbolic ...
7
votes
Accepted
Term for the typical "linear in the larger dimension, quadratic in the smaller" cost for linear algebra
The book "Introduction to Applied Linear Algebra" by Boyd and Vandenberghe has an appendix about complexity of basic operations in linear algebra and they call this case
big-times-small-...
7
votes
Accepted
Numerically find the nearest positive semi definite matrix to a symmetric matrix
After you compute $Q$ and $D$, form $D'=\max(D,0)$, and compute $A'=QD'Q^\top$, the algorithms involved in multiplying those matrices do not promise that $A'$ will be exactly $QD'Q^\top$. Most ...
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 ...
7
votes
Accepted
Algorithm to factorize matrix whose many rows are already of upper triangular form?
I believe you can accomplish what you want efficiently using the recursive LU algorithm. In brief, recursive LU on a $M \times N$ matrix $A$ proceeds by partitioning the matrix into 4 blocks:
\begin{...
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 ...
7
votes
Accepted
Accurate Way to Calculate Matrix Powers and Matrix Exponential for Sparse Positive Semidefinite Matrices
This is a slightly modified version of my response on math.stackexchange. One standard approach to computing matrix functions times a vector $f(M)x$ or quadratic forms $x^Tf(M)x$ when $M$ is symmetric ...
6
votes
Accepted
Fastest way to solve a sparse unsymmetric system many times
Generally speaking, for many right-hand side (RHS) problems, a direct solver is a more feasible solution for several reasons:
Major computations are performed during the factorization step (which is ...
6
votes
Accepted
Ways to solve $Ax=b$ for a sparse (banded) $A$ with updates
If the only non-zero entries of $A_{ij}$ have $j$ in $\{i - 1, i, i + 1\}$, then $A$ is a banded matrix with bandwidth 1.
More generally, you can talk about matrices of bandwidth $k$ where $k$ is any ...
6
votes
Does a symmetric positive definite matrix also have $\mathbf{A} = \mathbf{L}^T\mathbf{L}$ (where $\mathbf{L}$ is a lower triangular matrix)?
Yes, for an SPD matrix $\mathbf A$ there are a variety of Cholesky-like decompositions, you can derive the $\mathbf A = \mathbf L^T \mathbf L$ variant by first writing down an educated/structured ...
6
votes
Accepted
Block-matrix: optimal fill-in reduction for LU factorization
Unfortunately, optimal reordering is NP-complete, so all the algorithms in this space are kinda heuristic. At first glance my instinct would be to try some variant of minimum degree, mainly because ...
6
votes
Accepted
Numerical Linear Algebra: When to use Direct methods versus iterative methods to solve a linear system - for PDEs in particular
It's a complicated question, which is why I've recorded a whole bunch of video lectures on the topic :-) Take a look at lectures 34 and following here:
https://www.math.colostate.edu/~bangerth/videos....
6
votes
Accepted
Algorithm for solving systems which are nearly symmetric/adjoint?
Let's express the matrix $A \in \mathbb{R}^{n \times n}$ with which we want to solve linear systems as
$$
A = S + U V
$$
where $S$ is a symmetric matrix, $U \in \mathbb{R}^{n \times r}$, and $V \in \...
6
votes
QR decomposition with only diagonal elements changing
Variants of this question get asked regularly on [scicomp.se], but unfortunately the answer is always no: one cannot update easily any matrix factorizations after a full-rank diagonal update. Some ...
6
votes
Is there a way to generate a matrix-free decomposition for a matrix-free operator?
This is not efficient, primarily because (i) the factors of sparse matrices are, in general, not sparse themselves, and (ii) when computing matrix factorizations, you don't just need $A_{ij}$ but you ...
5
votes
Accepted
Does $\log(\det(A))$ equals sum of log of diagonal elements of D in LDLT decomposition?
Yes, it is possible. By construction, the $L$ matrix is lower triangular with all its diagonal entries equal to one. Therefore, $\det(L) = \det(L^T) = 1$ and, consequently, $\det(L D L^T) = \det(L) \,...
5
votes
The fast, and The Backward-Stable (left) $3\times 3$ matrix inverse
I will try to give my thought on the first question regarding fast $3\times 3$ inverse. Consider
$$
A=\left[
\begin{array}{ccc}
a & d & g\\
b & e & h\\
c & f & i
\end{array}\...
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$. ...
5
votes
inertia count sparse matrix with dense low-rank perturbation
Upon further examination, I do think the Woodbury identity can be used to solve this problem. With it we can write:
$\left( \mathbf K - \sigma \mathbf Z \mathbf Z^T \right)^{-1} = \mathbf K^{-1} - \...
5
votes
Factorize laplacian in terms of first derivative matrix
It is enough if you consider a $D$ that uses forward or backward differences with reflecting boundaries:
\begin{equation}
D_f = \frac{1}{h}\begin{bmatrix}
-1 & 1 & & \\
& \ddots &\...
5
votes
Accepted
Why is 'scipy.sparse.linalg.spilu' less efficient than 'scipy.linalg.lu' for sparse matrix?
This particular effect is highly likely to come from parallelization.
In many setups, numpy will use multiple threads for invoked BLAS/LAPACK calls.
In the default setting on my laptop (Mac OS, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
matrix-factorization × 122linear-algebra × 46
sparse-matrix × 27
matrix × 26
linear-solver × 11
lapack × 10
matlab × 8
iterative-method × 8
least-squares × 8
python × 7
numerics × 7
eigenvalues × 6
scipy × 6
preconditioning × 6
svd × 5
finite-element × 3
optimization × 3
algorithms × 3
linear-system × 3
efficiency × 3
inverse × 3
matrix-equations × 3
banded-matrix × 3
complex-arithmetic × 3
update × 3