Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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
11 votes

What algorithm(s) do numpy and scipy use to calculate matrix inverses?

Documentation to numpy.linalg.inv and scipy.linalg.inv does not mention the algorithm used. Judging from the source, ...
Vladimir Lysikov's user avatar
5 votes

Overlap matrix and its inverse matrix

There are several improvements you can make to the computation of $S_{n,m}^{-1}$ to make it more stable. Avoid the explicit inverse As the comments say, this is the first thing to look into. You ...
Federico Poloni's user avatar
5 votes

Confusion about matrix differentiation in a nonlinear matrix equation

If a matrix is differentiated with respect to itself, the result should be a fourth order tensor. The easist way to see this is to work with components. $$ \frac{ \partial K_{ij}}{\partial {K_{kl}}} = ...
NNN's user avatar
  • 760
5 votes
Accepted

Apply 3D Operator to Matrix and get new Matrix

I am not sure why you call $H$ a "3D operator", so I am not completely sure that I understood the question right, but here is my attempt at explanation. Consider the space $\mathbb{R}^{n \...
Vladimir Lysikov's user avatar
5 votes
Accepted

Measuring the extent to which two sets of vectors span the same space

The classical tool for this job is canonical angles. The canonical angles between $\operatorname{Im} A$ and $\operatorname{Im} B$ can be computed as $\arccos \sigma_i$, where $\sigma_i$ are the ...
Federico Poloni's user avatar
4 votes
Accepted

How can we calculate mixed derivatives numerically using the Chebyshev derivative matrix?

Note: Your nomenclature is only valid on Cartesian elements. If you want to calculate derivatives on arbitrary shapes you also have to consider spatial metric terms. Answer: To keep it simple, we ...
ConvexHull's user avatar
  • 1,335
4 votes

Reordering eigenvalues in Schur factorization - MATLAB ordschur and LAPACK dtrsen not producing the same results

You should use COMPQ = 'V'; instead of COMPQ = 'N'; accroding to the official documentation of LAPACK ...
138 Aspen's user avatar
  • 153
4 votes

Reordering eigenvalues in Schur factorization - MATLAB ordschur and LAPACK dtrsen not producing the same results

First of all, please include a definition of Z in your minimal example so that we can reproduce your output. The bug clearly seems to be in the Fortran code. Have you verified that $Z \approx UTU^*$ ...
Federico Poloni's user avatar
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

Is it possible to express an arbitrary tensor contraction in terms of BLAS routines?

You can use reshape and pointwise multiply to reduce the operation to a matmul in terms of two temporary tensors $c_1,c_2$. Consider following transformations: pointwise mul to turn $a_i * b_i$ into $...
Yaroslav Bulatov's user avatar
4 votes

Weird runtime behavior of `scipy.linalg.solve_triangular` and `trtrs`

Thanks to Federico Poloni's comment, I have revised the script as below. It looks like scipy.linalg.solve_triangular has time complexity $O(p^2)$, because the ...
nalzok's user avatar
  • 181
3 votes

How do BLAS libraries implement support for transposed matrices?

Blas kernels typically don't deal with transposed matrices. Instead, they will repack matrices (transposed or not) outside of the kernel. See https://www.cs.utexas.edu/users/flame/pubs/blis3_ipdps14....
Oscar Smith's user avatar
3 votes

Automatic differentiation (AD) of a loss function which maps unitary matrix onto number

Your analytic derivative expression doesn't look right. Let's calculate the gradient (in the Wirtinger sense) $$\eqalign{ \def\l{L} \def\o{{\tt1}} \def\p{\partial} \def\grad#1#2{\frac{\p #1}{\p #2}} \...
greg's user avatar
  • 604
2 votes

Tools to compare two matrices with same dimensions

Welcome to Scicomp! You might be interested in the field of (multimodal) medical image registration. In medical contexts one often wants to register a CT image with an MR or PET-Scan. The amplitudes ...
MPIchael's user avatar
  • 2,935
2 votes
Accepted

Calculating camera calibration matrix with Scilab

I found the answer. The videos I was looking at didn't mention a very important detail. The QR factorization needs to be applied to the inverse of the first three columns of P. The resulting K is also ...
Vaahterasiirappi's user avatar
2 votes

What algorithm(s) do numpy and scipy use to calculate matrix inverses?

First of all, they don't take matrix inverses. They perform linear solves. Typically this is done via LU factorization.
Oscar Smith's user avatar
1 vote

Confusion about matrix differentiation in a nonlinear matrix equation

$ \def\R#1{{\mathbb R}^{#1}} \def\o{{\large\tt1}} \def\D{{\cal D}} \def\k{\otimes} \def\h{\odot} \def\bR#1{\big(#1\big)} \def\BR#1{\Big(#1\Big)} \def\LR#1{\left(#1\right)} \def\op#1{\operatorname{#1}} ...
greg's user avatar
  • 604
1 vote
Accepted

Finding the Vector $v$ for a Given Householder Matrix Transformation of Non-Collinear Vectors $a$ and $b$

$v$ is one of the bisectors $\|b\|a\pm\|a\|b$ between the rays in directions $a$ and $b$. One of them is the larger one, which gives a more accurate reflection, usually the difference is small, ...
Lutz Lehmann's user avatar
  • 6,109

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