Skip to main content

Questions tagged [matrix]

For questions about using and representing matrices on a computer in order to solve computational problems. Should generally also include a tag about the specific property/problem you are solving (e.g. [tag:linear-algebra], [tag:eigenvalues], [tag:inverse].

Filter by
Sorted by
Tagged with
0 votes
0 answers
31 views

Lumped (diagonal) vs. consistent (non-diagonal, symmetric) mass matrix in Nastran

I've been tinkering with DMAP to explore the procedure followed by Nastran when solving a complex modes analysis. I've reached a passage I cannot understand: at some point Nastran formulated what it ...
temporary_pigeon's user avatar
0 votes
1 answer
73 views

What do diagonal (DOF-to-self) terms of stiffness matrix physically mean?

I am used to interpreting each entry of a solid mechanic system's stiffness matrix as a 1D (linear or angular) spring joining one DOF (column index) to another (row index). But this interpretation ...
temporary_pigeon's user avatar
4 votes
1 answer
111 views

Optimized Lanczos method for finding eigenvalues of $A \otimes B$

Recently my supervisor told me about an efficient way to calculate eigenvalues and eigenvectors of matrix $A \otimes B$ with $a_{1} \times a_{2}$ as dimensions of $A$ and $b_{1} \times b_{2}$ is of $B$...
Mohammad. Reza. Moghtader's user avatar
1 vote
0 answers
57 views

Orthogonal Transformation of Hessenberg Matrices

$H\in\mathbb{R}^{n\times n}$ is an upper Hessenberg matrix. Suppose $\lambda$ is an eigenvalue of $H$ and $x$ is an eigenvector w.r.t. $\lambda$. Is there any fast algorithm that can find an ...
MakaBaka's user avatar
  • 111
2 votes
2 answers
170 views

Confusion about matrix differentiation in a nonlinear matrix equation

I am trying to solve a matrix equation in the following discrete form: $$ \frac{K^{n+1}-K^n}{\Delta t} = [(K^{n+1} (V^{n})^T).^3 - K^{n+1} (V^{n})^T]V^n. $$ where $K^{n+1} \in \mathbb{R}^{m \times r}, ...
Owen Jun's user avatar
  • 141
0 votes
1 answer
68 views

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

I want to understand the time complexity of scipy.linalg.solve_triangular, which calls trtrs from LAPACK under the hood, so I ...
nalzok's user avatar
  • 181
1 vote
0 answers
107 views

How to implement boundary conditions for the Thomas algorithm

For my variable $U(t,x)$, I have implemented the thomas algorithm with $U_j^i$: $$ a(x)U_{j-1}^{i+1}+ b(x)U_j^{i+1} + c(x)U_{j+1}^{i+1} = d(x)U_j^{i} $$ Then $\textbf{A}$ is a tridiagonal vector with ...
THATS MY QUANT MY QUANTITATIVE's user avatar
1 vote
1 answer
185 views

How do BLAS libraries implement support for transposed matrices?

I'm trying to understand how BLAS libraries implement fast GEMM with support for transposed matrices. Say, I'm only operating on square matrixes (with dimensions n ...
ilya's user avatar
  • 121
1 vote
0 answers
124 views

How to vectorise numerical differentiation

I have a 2-D matrix with 2 spatial coordinates and I want to be able to vectorise the process of numerically differentiating with respect to its 2 coordinates, rather than just looping along the rows ...
THATS MY QUANT MY QUANTITATIVE's user avatar
11 votes
1 answer
340 views

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

I noticed that libraries like numpy and pytorch are able to perform arbitrary tensor contractions at speeds similar to comparably sized matrix multiplications. This leads me to believe that underneath ...
ilya's user avatar
  • 121
3 votes
1 answer
92 views

Apply 3D Operator to Matrix and get new Matrix

Hopefully this question makes sense. I know I can formulate an operator for a vector as a matrix, then apply that matrix to my vector to get a new vector. For example, if I define a left shift ...
Nukesub's user avatar
  • 163
0 votes
0 answers
69 views

Singular Matrix Error in Incomplete LU Decomposition

I’m currently working on solving the following PDE: $$\begin{equation} -(\mu_x \frac{\partial^2 u}{\partial x^2} + \mu_y \frac{\partial^2 u}{\partial y^2}) = f(x, y)\end{equation}$$ Where a right hand ...
blov's user avatar
  • 43
5 votes
2 answers
2k views

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

I am solving differential equations that require inverting dense square matrices, and I wanted to know what algorithm(s) do numpy and scipy use to calculate matrix inverses?
kamy rez's user avatar
3 votes
1 answer
147 views

Overlap matrix and its inverse matrix

Now, we consider a non-orthonormal basis: $$\mathcal{S}_N=\{|\alpha\rangle,a^\dagger|\alpha\rangle,a^{\dagger 2}|\alpha\rangle,\ldots,a^{\dagger N}|\alpha\rangle\},$$ where $|\alpha\rangle$ is the ...
Young Q's user avatar
  • 31
0 votes
1 answer
106 views

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

Consider a vector $v$ in $\mathbb{R}^{n\times1}$. The Householder matrix is defined as follows: $$H(v)=I-\dfrac{2vv^T}{v^Tv}.$$ It can be demonstrated that $H(v)$ is symmetric and orthonormal. The ...
Ferran Gonzalez's user avatar
2 votes
0 answers
67 views

Efficient Algorithm for LU-Factorization of Modified Matrix with Last Column Alteration If We Have Its Not-Modified LU-Factorization

Suppose that we have a $n\times n$ matrix $A$. We have its LU-factorization as $A=LU$ (or $PA=LU$ that $P$ is a permutation matrix). Now assume we change the last column of matrix $A$ and denote the ...
Ferran Gonzalez's user avatar
9 votes
1 answer
1k views

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

In Python / Matlab, if you run a routine for SVD on a significantly non-square matrix, X, such as X.shape = (2,15000) you will ...
tisPrimeTime's user avatar
3 votes
1 answer
173 views

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

Using the Chebyshev derivative matrix $D$, we can numerically approximate the first and second derivative of a function by doing matrix multiplication: $${df(x) \over dx} = Df(x) \tag 1$$ $${d^2f(x) \...
FriendlyNeighborhoodEngineer's user avatar
2 votes
0 answers
73 views

Complex matrix logarithm discontinuity by solving inverse Fourier integral by alternative method to FFT

NOTE: This code is a piece of code I am using for a master's thesis, so I do not expect someone to do the work for me, but I gladly accept suggestions of any kind. However, I am trying to get the ...
SimoPape's user avatar
1 vote
0 answers
78 views

numerical calculation of haldane model arm chair edge states

hello I am trying to numerical simulate the band structure of the one-dimensional periodic arm chair edge states, I use the pybinding model to construct and ...
yangxing844's user avatar
1 vote
0 answers
36 views

Sums of sparse matrices modulo 2

I have a set of sparse matrices modulo 2 (i.e systems of equations in the format "a XOR b XOR ... XOR c = 0 or 1" compressed by me into reduced row echelon form). This is a rather large set (...
unknown's user avatar
  • 111
4 votes
2 answers
249 views

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

Disclaimer: I previously posted this on SO, but though it would be more relevant for scicomp. The original post has been deleted. I have been trying to recreate the functionality provided by MATLABs <...
two_Thomas's user avatar
2 votes
1 answer
133 views

Tools to compare two matrices with same dimensions

Context: I have two 3D non-random matrices that have the same dimensions. These matrices represent satellite images with 1 band, so their values are strictly positive. They both present areas that ...
Nihilum's user avatar
  • 121
2 votes
1 answer
177 views

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

I have a set of measurements $y_i$, $1 \leq i \leq N$, and I want to model these measurements with a linear model. I have two possible models I can use, $$ y \approx A c $$ and $$ y \approx B d $$ ...
vibe's user avatar
  • 1,058
1 vote
1 answer
127 views

Calculating camera calibration matrix with Scilab

I'm not entirely sure whether this question belongs here or in DSP but I think this is the proper site. I'm following these videos (first video, second video) to calibrate a camera for photogrammetry ...
Vaahterasiirappi's user avatar
1 vote
1 answer
95 views

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

Is it possible to estimate whether automatic differentiation (AD) techniques could enable a more efficient way to repeatedly compute the derivative $\delta L / \delta u^*_{ij}$ of a specific loss ...
thyme's user avatar
  • 111
1 vote
1 answer
84 views

Reshaping a matrix and rearranging the elements lexicographically into a vector

Let us say that I have a $3 \times 3$ matrix $\bf X$, that has to be reshaped into a vector and rearranged as follows: $$ {\bf v} ({\bf X}) = \begin{bmatrix} x_{22} & (x_{23}+x_{32}) & (x_{21}+...
Neuling's user avatar
  • 23
2 votes
0 answers
73 views

When is Lanczos tridiagonalization accurate?

Suppose that we are given a random, symmetric matrix $A$, and a random vector $q$. For concreteness, assume the dimensions of $q$ and $A$ are both $1,000$. I would like to use the Lanczos algorithm to ...
miggle's user avatar
  • 41
1 vote
1 answer
190 views

QR algorithm for eigenvalues and eigenvectors of large symmetric matrices

I am trying to write a QR algorithm in Python for eigenvectors and eigenvalues finding for large symmetric matrices, My initial thought was to use Householder transformation with a Wilkinson shift on ...
Daniel's user avatar
  • 11
2 votes
1 answer
224 views

Parallelize pseudo inverse of a matrix using Lapacke

I am currently using the protocol described in https://stackoverflow.com/questions/55599950/computation-of-pseidoinverse-with-svd-in-c-using-blas-and-lapacke to compute the pseudo inverse of a matrix. ...
Filippo Caleca's user avatar
4 votes
5 answers
654 views

Matrix derivative

I am looking to compute the derivative of the following expression: $$\frac{\partial}{\partial X}\mathrm{tr}\left[A\exp(X)\right]$$ where $A$ is both a symmetrical and positive-definite matrix and $X$ ...
PC1's user avatar
  • 436
3 votes
1 answer
123 views

Scipy solve_ivp sensitivity to random phase shifts

I am trying to solve a coupled system of ODE's using the solve_ivp function from scipy. The general form of the equation is given via $$\dot{y}(t) = M(t)y(t).$$ The time dependence of matrix is ...
raeel's user avatar
  • 31
0 votes
1 answer
202 views

How to efficiently transpose distributed matrix in Scalapack?

I have a distributed matrix in block cyclic layout. Is there an efficient way to out/in place transpose a distributed matrix with scalapack? Context: I am trying to diagonalize the transpose of a ...
Aditya Kurrodu's user avatar
3 votes
1 answer
141 views

Rewriting quadratically-constrained optimization problem as a semidefinite program

Suppose $A,H$ are positive definite matrices and $\alpha,t$ are scalars. Is there a way to massage the following problem into a form suitable for a specialized solver? $$\begin{array}{ll} \underset{\...
Yaroslav Bulatov's user avatar
1 vote
0 answers
135 views

Does cblas_dgemm mutate my input matrices?

I have written a matrix class Matrix<T> for which I have implemented a wrapper function for cblas_dgemm. ...
Urwald's user avatar
  • 111
0 votes
3 answers
290 views

How do we compute a matrix-vector product without using the standard matrix multiplication?

I am a bit confused right now. I am taking a class on numerical linear algebra and as I have understood sometimes one doesn't compute the Matrix-Vector product $Av$ normally but uses other techniques ...
Josh.K's user avatar
  • 11
1 vote
1 answer
142 views

QR decomposition with only diagonal elements changing

I have to compute the QR decomposition of a matrix A repeatedly, each time with ONLY diagonal elements changing. Is there an efficient way to accomplish this ...
Madhurjya's user avatar
  • 111
3 votes
1 answer
272 views

BiCGSTAB convergence

So I need a fast converging solver for SysLinEq as a subroutine in fortran, decided to test BiCGStab in Matlab. Thank God I decided to test it out on first before implementing in Fortran as a ...
2Napasa's user avatar
  • 362
2 votes
1 answer
512 views

Matrix regularisation for ill-conditioned problems

I have read that matrix regularisation can improve the stability of LU or Cholesky decomposition of ill conditioned problems. The idea is to add a value to the diagonals of a matrix: $B=A+cI$ In the ...
vydesaster's user avatar
2 votes
0 answers
57 views

Is there a permutation used in sparse QR factorizations that better locates small elements on the diagonal of R?

Is there a permutation used in sparse QR factorizations that better locates small elements on the diagonal of R to the end of the diagonal? As an example, consider the following snippet of MATLAB ...
wyer33's user avatar
  • 767
5 votes
2 answers
454 views

Recurrence relation for matrices

I have matrices ($S_0$ thought $S_N$) and I have a recurrence relation that link successive matrices together. $$S_i + S_i(aS_{i-1}^{-1})S_i=C_i+aS_{i+1}$$ We can assume for this problem that $S_0=S_N=...
PC1's user avatar
  • 436
5 votes
0 answers
45 views

Lowest eigenvalues of a matrix with divergent entries

In high energy physics we oftentimes encounter the following problem. For a given parametrized matrix $\{H_{ij}(\Lambda)\}$, we know that in the limit $\Lambda\to\infty$ some of its entries become ...
mavzolej's user avatar
  • 151
3 votes
1 answer
192 views

Using submatrices of matrix decomposition for solving a large number least-squares problems

I want to decrease the computational time for solving a large number (>1000) of least-squares problems. Given a matrix, the system matrix for each least-squares problem is a submatrix of the given ...
Raibyo's user avatar
  • 219
1 vote
1 answer
245 views

constructing a symmetric matrix for finite difference

I come across the following operator in a paper $\mathcal{I}\psi = \psi_{xxxx} + (r~\psi_x)_x$, where $\psi=\psi(x)$ and $r=r(x)$. Periodic boundary condition is employed. It claims that the operator $...
Physicist's user avatar
  • 217
0 votes
1 answer
4k views

Dynamic Sized Identity Matrix in Eigen

I am aware of creating an identity matrix in Eigen if the number of rows and columns are known. How do we create them dynamically when the size is not known? An example would be useful. Thanks.
user1408865's user avatar
1 vote
2 answers
479 views

Calculate average distance between pairs of points without computing full distance matrix

Suppose I have a set of $N$ points of shape $N \times D$, where $D$ is the dimensionality. I want to compute the average Euclidean distance between all points, as well as additional moments such as ...
wil3's user avatar
  • 165
1 vote
1 answer
108 views

Fast algorithm to compute chi-square

I would like to evaluate the chi-square of the form $\chi^2=v^{T}C^{-1}v$ where $v$ is a column vector and $C$ is a covariance matrix. Both $v$ and $C$ are known and $C$ is a $740\times740$ matrix. ...
user7896's user avatar
  • 123
1 vote
1 answer
109 views

Converting a 4 rank matrix to 2 rank matrix after using tensorproduct

Let's say I have a 2x2 matrix (with symbols) called 'A'. Now, if do B = sympy.tensorproduct(A,A) print(sympy.shape(B)) I get, ...
Shashank Saumya's user avatar
5 votes
1 answer
542 views

Converting distance matrix back into original data

Suppose that we have $N$ points, and a distance matrix $D \in \mathbb{R}^{N \times N}$ describing the Euclidean distance among those points. For now, assume that we do not necessarily know how many ...
wil3's user avatar
  • 165
4 votes
2 answers
235 views

nnz-preserving sparse matrix multiplication

Let A and B be sparse matrices in $ \mathbb{R}^{m\times m}$ with (roughly) the same density $p$. I want to efficiently compute a matrix $C$ that in some sense is "closest" to $AB$ while ...
nonagon's user avatar
  • 41

1
2 3 4 5
13