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
2 votes
1 answer
132 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. ...
4 votes
5 answers
612 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$ ...
  • 436
3 votes
1 answer
80 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 ...
  • 31
0 votes
1 answer
97 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 ...
3 votes
1 answer
119 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{\...
1 vote
0 answers
80 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. ...
  • 111
0 votes
3 answers
142 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 ...
  • 11
1 vote
1 answer
77 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 ...
  • 111
3 votes
1 answer
148 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 ...
  • 354
2 votes
1 answer
195 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 ...
2 votes
0 answers
43 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 ...
  • 717
5 votes
2 answers
308 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=...
  • 436
5 votes
0 answers
43 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 ...
  • 151
3 votes
1 answer
110 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 ...
  • 219
1 vote
1 answer
112 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 $...
  • 217
0 votes
1 answer
925 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.
1 vote
2 answers
109 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 ...
  • 165
1 vote
1 answer
91 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. ...
  • 123
1 vote
1 answer
73 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, ...
5 votes
1 answer
280 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 ...
  • 165
4 votes
2 answers
192 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 ...
  • 41
1 vote
0 answers
478 views

Symmetric Matrix in Eigen C++

I am aware of a symmetric matrix type in uBLAS as ublas::symmetric_matrix matrix. Is there an equivalent for this in Eigen library that can be used to construct one or do we need to explicitly check ...
1 vote
0 answers
147 views

Trouble inverting complex matrix with numpy and scipy

I have some matrix-valued, complex data $Z(f)$ with $f\in\{f_0,f_1,\dots\}$ and $Z(f_i)$ being a 3x3 matrix. I require the inverse $Z^{-1}(f)$ in my workflow. After encountering some problems with my ...
5 votes
0 answers
88 views

Is this a legit way to sample a random matrix spectrum?

In order to undergird a theoretical model concerning many body physics, I want to have exponentially large eigenvalue spectra from the random matrix GOE ensemble. its properties are mainly (i) a ...
0 votes
2 answers
130 views

Implementation of $[X, \cdot]$ as an $n^2 \times n^2$ matrix, where $X$ is an $n \times n$ matrix

Let $M_n(\mathbb{R})$ denote the set of $n\times n$ matrices with real entries. I have an $n\times n$ matrix $X\in M_n(\mathbb{R})$, and I would like to implement the linear operator $[X, \cdot] : M_n(...
6 votes
1 answer
217 views

Algorithm for solving systems which are nearly symmetric/adjoint?

I am familiar with Cholesky decomposition and LU factorization for solving systems of linear equations. I have a problem where I have large sparse matrices (say, 1000x1000 or larger) where only one or ...
18 votes
3 answers
3k views

Why do we usually not want the eigenvalues of non-symmetric matrices?

I came across this line in a class note I am reading where it discusses finding eigenvalues of matrices. In reality we don't go all the way with Arnoldi. We stop at a decent value of 𝑘. Then the 𝑘 ...
1 vote
1 answer
436 views

Efficiency of scipy.sparse.linalg.expm_multiply with sparse vs unsparse vectors

From the package scipy.sparse.linalg in Python, calling expm_multiply(X, v) allows you to compute the vector ...
1 vote
1 answer
255 views

2-norm and infinty norm of a system in controls

How to compute 2-norm or infinity norm of following system? i am confused whether to calculate using simple matrix theory "where it don't regard for s domain" or H2 and H-infinty norm. ...
1 vote
1 answer
2k views

What is difference between L2 norm and H2 Norm?

When someone refers 2-norm of system,L2 and H2 are used interchangeably by author and is rather confusing. Even the matlab has different functions for H-infinity norm and L-infinity norm. as shown in ...
1 vote
0 answers
89 views

Matlab - Equality between 2 Fisher matrices constructed in a different way

I want to know if, on a Fisher matrix, the projection operation (with a Jacobian matrix) commutes with a matricial inversion operation. The 2 ways to build these 2 matrices are: 1) First method: 1.1) ...
0 votes
0 answers
83 views

Can a symmetric matrix be found using matrix-vector operation while maintaining matrix-vector operatin?

Consider $A\in\mathbb{R}^{n\times n}$ its not a special matrix and in the worst case all of its entries are non-zero. I am looking for a way to compute $AA^{T}$ using matrix-vector operation. The ...
  • 101
0 votes
0 answers
155 views

Do the projection (with Jacobian) and marginalisation (inversion of matrix and remove a row/column and reinversion) commute?

I try to check the equality or the inequality between 2 Fisher matrices. The goal is too see if the projection (with Jacobian) and marginalisation (inversion of matrix and remove a row/column and ...
1 vote
2 answers
434 views

Dyadic operations, fourth order tensors and Tensor algebra

I am trying to understand the dyadic operation for a while since I am interested in Elasticity problems. I believe an intuitive understanding (rather than assuming) will give me good problem solving ...
2 votes
1 answer
121 views

Vectorization Matlab/Octave of Markov Matrix Powers

I have just created a code snippet in Octave/Matlab that aims to create a plot which shows the accuracy of an initial probability vector $\vec{\pi}$ derived from the transition probability matrix $\...
1 vote
1 answer
107 views

RCM better than Nested dissection? (For FEM discretizations in 2D and 3D)

I realize this might be a too general question but here goes nothing: I am trying different re-ordering strategies and checking the fill-in of $A=LU$. I have 2D ($p=1$, $h=1/40$ on $\Omega = [-1,1]^2$)...
  • 91
2 votes
0 answers
149 views

Jacobian matrix cutoff in ODE solver

I am studying an implementation of a 3rd semi-implicit Runge Kutta method (siRK3) from the book by Villadsen & Michelsen (1978), Solution of differential equation models by polynomial ...
  • 342
4 votes
1 answer
130 views

How are Matrices Stored in MATLAB?

I have this simple question but I am trying to figure out why: Are matrices stored column-wise in MATLAB? If so then why? I theorize that they are stored column-wise because the memory does not have ...
  • 297
3 votes
1 answer
137 views

Forming a particular (averaged) block matrix with numpy

Say I have a set of $n \times n$ matrices $A_1, ..., A_m$ as numpy arrays. I'd like to create the block matrix defined below. I'm looking for a clean, elegant, and easy-to-interpret way of doing this ...
  • 203
1 vote
1 answer
409 views

MATLAB : find an algorithm to inverse quickly a large matrix of symbolic variables

I have to solve the equality between 2 matrixes 12x12 containing a lot of symbolic variables and with which I perform inversion of matrix. There is only one unknown called "...
0 votes
1 answer
260 views

Pseudospectrum of non square Matrix in Python

I have a rectangular matrix $A \in \mathbb{R}^{m \times n}$ ...
user avatar
8 votes
3 answers
924 views

Accurate Way to Calculate Matrix Powers and Matrix Exponential for Sparse Positive Semidefinite Matrices

I do need to numerically calculate the following forms for any $x\in\mathbb{R}^n$, possibly in python: $x^T M^k x$, where $M\in\mathbb{R^{n\times n}}$ is a PSD sparse matrix, $n$ can be quite large ...
  • 183
2 votes
0 answers
64 views

How to solve this boundary value problem which has more unknown than equation on MATLAB

I need your helps about solving the problem below with MATLAB. I am trying to solve 2D Stress Wave Propagation problem by using FDTD(Finite difference time domain) method on the cylindrical coord. I ...
2 votes
1 answer
697 views

How to Invert a Poorly Conditioned Matrix

In my research, I need to invert a Fisher matrix in order to get a covariance matrix for me to do parameter estimation. Unfortunately, the values of Fisher matrix vary by many orders of magnitude, and ...
3 votes
1 answer
308 views

Quick way to find a common basis of eigenvectors between 2 matrices : valid or not?

Following the advise of @Federico Polonion a previous post, one suggested, to find a basis of common eigen vectors between 2 matrices, to simply do : Generate 2 ...
2 votes
2 answers
248 views

Matlab - Compute approximative common eigenvectors basis between two matrices as a function of tolerance

I am looking for finding or rather building common eigenvectors matrix X between 2 matrices A and B such as : ...
11 votes
1 answer
5k views

How to compute Singular value decomposition of a large matrix with Python

Language: Python3 Problem: I have a matrix Q of shape [51200 rows x 51200 cols] stored in a binary file, each of the element in this matrix has a data type of complex64. To load the data into memory I ...
  • 111
6 votes
1 answer
434 views

Efficiently computing $e^{tX}$ for many different values of $t$

Given an anti-Hermitian and sparse matrix $X$, I am using Python (NumPy and SciPy) to compute the matrix exponential $f(t) := e^{tX}$ for many values of $t$. The method I am currently using is to ...
1 vote
0 answers
36 views

What's the best way to implement a least-squares estimation of a motor system in MATLAB?

Basically, I'm trying to use Least-Squares to estimate the parameters of a DC motor. My system can be modeled by the following matrix equation: $$\begin{bmatrix}V_{input}(t)\\0\end{bmatrix}=\begin{...
  • 109
1 vote
0 answers
45 views

updating the matrix Adjugate/Cofactor

I would like to calculate the Adjugate matrix of a given matrix $A$, and its updates in the diagonal: $B=A-\lambda I$, where $I$ is the identity matrix, $\lambda$ is a scalar. To this end, I am using ...

1
2 3 4 5
12