Questions tagged [matrix]

Matrix is a rectangular array of elements (e.q. numbers, symbols, or expressions), arranged in columns and rows.

Filter by
Sorted by
Tagged with
7
votes
5answers
454 views

Checking singularity of a matrix

Suppose that we don't know $n \times n$ matrix $A$ explicitly but we are only able to compute products $Ax$ where $x$ is a column vector with $n$ elements. Is there an algorithm to determine whether $...
0
votes
0answers
31 views

Explanation of Givens rotation in Jacobi Rotation SVD

I'm trying to implement Singular Value Decomposition (homework of sorts) via the Jacobi Rotation method (more info here, pages 11 and 12). I am stuck at the bullet saying (sorry for the picture, but I'...
26
votes
11answers
8k views

Robust algorithm for $2 \times 2$ SVD

What is a simple algorithm for computing the SVD of $2 \times 2$ matrices? Ideally, I'd like a numerically robust algorithm, but I'll like to see both simple and not-so-simple implementations. C code ...
11
votes
2answers
29k views

What is the fastest algorithm for computing the inverse matrix and its determinant for positive definite symmetric matrices?

Given a positive definite symmetric matrix, what is the fastest algorithm for computing the inverse matrix and its determinant? For problems I am interested in, the matrix dimension is 30 or less. ...
11
votes
3answers
1k views

Rule of thumb for sparse vs dense matrix storage

Suppose I know the expected sparsity of a matrix (i.e. the number of non-zeros / total possible number of non-zeros). Is there a rule of thumb (perhaps approximate) for deciding whether to use sparse ...
3
votes
1answer
68 views

Solve two-player game - minimize the l-infinity norm of a matrix-vector product

I have a matrix $M$ with non-negative real entries, and I would like to minimize the objective function $$\Phi(v) = \|Mv\|_\infty,$$ where $v$ is constrained to be a probability vector, i.e., $v_1+\...
11
votes
2answers
8k views

In FEM, why is the stiffness matrix positive definite?

In FEM classes, it's usually taken for granted that the stiffness matrix is positive definite, but I just can't understand why. Could anyone give some explanation? For instance, we can consider the ...
4
votes
3answers
4k views

debugging a rotation matrix for elastic constants

I have a transformation matrix which takes in the elastic constants from the local $rtl$ coordinates and then converts the elastic constants to the global $xyz$ coordinates via a rotation about the $z$...
2
votes
1answer
81 views

Efficient projection of a vector onto matrix kernel

Given an $m \times n$ matrix $A$ and a vector $x\in\mathbb R^n$, with $m<n$, what's an efficient way of computing the projection of $x$ onto the kernel of $A$?
2
votes
1answer
78 views

Dense decomposition of very non-square matrices

I have inherited code that solves Eigen::Matrix problems using the code shown on this page: ...
1
vote
2answers
79 views

Rewriting matrix multiplication

I have a matrix multiplication in Matlab that goes as follows $$\hat{W} = N W N^{T},$$ where $^T$ means a transposition. $N$ is an incidence matrix with the dimensions m x n and W = diag(G), where G ...
5
votes
1answer
146 views

Algorithm to factorize matrix whose many rows are already of upper triangular form?

I have a matrix whose many rows are already in the upper triangular form. $$\begin{bmatrix} x_{11} & x_{12} & x_{13} & x_{14} & x_{5} \\ 0 & x_{22} & x_{23} & x_{...
0
votes
0answers
61 views

Calculating the exponential of a complex matrix

I am trying to calculate the exponent of a 3 x 3 matrix using the formula $\sum_{i=0}^\infty\frac {A^n}{n!}$ I believe that my error may lay in the scalar division with a factorial or the member ...
1
vote
0answers
49 views

Assume $AX = C$. How to determine which entry of $BX - D$ is non-negative?

Let $A,B$ be $n \times n$ matrices and $C,D$ be $n \times 1$ matrices. Moreover, all entries of $A,B,C,D$ are non-negative. Assume that there is a unique matrix $X$ that solves $AX = C$. My goal is ...
1
vote
1answer
93 views

Composite matrices in Numpy

Lets say I have four matrices A, B, C and D, and I want to combine them together into one new matrix for computation: $$ \left( \begin{matrix} A & B\\ C & D \end{matrix}\right) $$ How can I ...
0
votes
0answers
40 views

Gradient of dot product of two tensors

Through obtaining an alternative form for force balance equation in a fluid mechanics problem, I stopped at a point where I have to prove this identity where $A$ and $B$ are second-order matrices:$$\...
2
votes
1answer
43 views

Find index for submatrix with maximum sum

Given an N-dimensional matrix A, I want to find an M<N dimensional index array I such ...
0
votes
0answers
63 views

How can I optimize that loop?

I need to populate a matrix $A_{kl}$, where $$ k = (m-1)J+n$$ $$ l = (p-1)J+q$$ And $$m,p = 1, 2, ..., I$$ $$n,q = 1, 2, ..., J$$ Its components are (mnpq). For ...
0
votes
0answers
25 views

Computing square root of rank-1 correction

In the post Computing square root of diag(u)-uu'?, both @YaroslavBulatov and @NickAlger suggested the factor $\frac{\sqrt{u^{T}D^{-1}u+1}-1}{u^{T}D^{-1}u}$ for their approximation. Can somebody ...
0
votes
1answer
28 views

Norm of operator in finite element discretization of Heat equation

I am solving the heat equation discretized spatially via FEM and temporally via backward Euler. I get the system $$M \dot{u} = K u +f$$ where $u$ is a vector representing the solution at spatial ...
1
vote
0answers
31 views

Choosing the pivot for the rotation matrix in similarity transformation

I have arrived at an equation in the similarity transformation - $M_r$ = $T. M_{r-1}. T^t$ ,where $T$ is the rotation matrix and $M_r$ ,$M_{r-1}$ are similar matrices. My aim is to find the rotation ...
4
votes
1answer
129 views

An optimization method for bounding the eigenvalues of a unknown non symmetric matrix

Given a positive objective function $f$ that acts on a real-valued matrix $A$, I am interested in the following problem $$\underset{A \in \mathbb{R}^{n \times n}}{\text{minimize}} \quad f(A) \quad \...
3
votes
0answers
61 views

Fastest matrix library for Android (with GPU is possible)

I was working on an Android app that requires some linear algebra with matrices. The matrices will be somewhat medium-sized as they are not too small or too big. I was originally using jBlas because ...
2
votes
0answers
51 views

Random Orthogonal Matrix Generation

This post is inspired by N. Higham post "What is Random Orthogonal matrix?". In this post, N. Higham links to the two papers: G. W. Stewart, The efficient generation of random orthogonal matrices ...
-1
votes
1answer
47 views

Find mass matrix in a system of linear equations

Given $z_t=\sum_{i=1}^t \theta_iz_{t-i}+v_t $, where $t=1,...,N$ where $N=1024$. I need to write this in matrix form (a system of linear equations) as $\mathsf{A}\mathsf{z} = \mathsf{z} - \mathsf{v}$. ...
3
votes
3answers
226 views

Using matrix exponential to solve linear system

Consider the system of linear equations: $$ Ax=b \tag{1} \label{eq1} $$ where $A\in\mathbb F^{n\times n}$, diagonalizable dense matrix, over the field $\mathbb F$ of real or complex numbers, $x\...
3
votes
1answer
584 views

Efficient ways to numerically evaluate matrix exponentials

What are some computationally efficient ways to solve matrix exponentials, i.e. functions of the form : $f(X)=e^{X}$, where $X$ is a square matrix? So far I have been able to diagonalise some ...
2
votes
0answers
42 views

How to determine the finite difference coefficient matrix in 2D with periodic BC?

I'm solving a PDE in matlab using ode15s, and since the spatial dimension is 2, and number of variables grow large very quickly, I need to supply the structure of ...
1
vote
1answer
177 views

How to compute all the eigenvalues of a large sparse matrix using matlab?

In matlab, there are 2 commands named "eig" for full matrices and "eigs" for sparse matrices to compute eigenvalues of a matrix. And eig(A) computes all the eigenvalues of a full matrix and eigs(A) ...
5
votes
0answers
73 views

Efficient way to find eigenvalues of complex symmetric matrix with real off-diagonal elements

My goal is to find all eigenvalues (and eigenvectors) in a given range of magnitudes of a complex symmetric matrix with real off-diagonal elements (only diagonal elements are complex). Currently I'm ...
-1
votes
2answers
61 views

2d Schrodinger Equation via matrix diagonalization in C

I am trying to solve the time-independent Schrodinger equation in two dimensions via discrete matrix diagonalization. I want the energy eigenvalues and the corresponding eigenfunctions for a given ...
2
votes
0answers
36 views

Lexicographically order matrix into a vector

I am trying to implement the algorithm contained in this article here. It is about solving a 2 and 2.5D Fredholm integral, focused on bidimensional NMR experiments. I've made significant progress, ...
1
vote
1answer
42 views

How to properly compute weights for Weighted Least Squares (WLS)?

I want to apply the weighted least squares method in order to identify parameters of a dynamic process. The process is described by a second order differential equation of the form: $$ \ddot{y}+a_1\...
2
votes
1answer
112 views

Bareiss algorithm vs. LU-decomposition

I at the moment try to fully understand the Bareiss algorithm for calculating determinants. One question that came to my mind is the following: Why is LU-decomposition much more often used than the ...
4
votes
1answer
209 views

Fast algorithm for computing cofactor matrix

I wonder if there is a fast algorithm, say ($\mathcal O(n^3)$) for computing the cofactor matrix (or conjugate matrix) of an $N\times N$ square matrix. And yes, one could first compute its determinant ...
1
vote
2answers
99 views

Calculate cofactor-matrix efficiently [duplicate]

I've implemented an algorithm that can calculate the cofactor-matrix of a matrix in $\mathcal{O}(n^5)$. The algorithm just step-by-step iterates over the whole matrix ($\mathcal{O}(n^2)$) and for ...
4
votes
2answers
204 views

Fastest Way to Mutiply $10^4$ 2x2 Matrices

In a code that I work with (written in python, but also tagging as matlab because numpy is so close and I could use it if need be), we use a transfer matrix method to compute the properties of a ...
1
vote
0answers
56 views

When does reduced integration lead to artificial zero energy modes in stiffness matrix?

This question relates to the topic of locking free finite element development. In the case of application of reduced integration to global stiffness matrix for the Timoshenko beam element with ...
5
votes
0answers
184 views

Polynomial rooting - fast root finding

I need to solve a rooting problem of a polynomial (the order of which is 2(N-1), where N=48). So far I'm using Python Numpy algorithm (that relies on computing the eigenvalues of the companion matrix)...
4
votes
1answer
116 views

Comparing Two Matrix Notation

I have two matrix A and B, I want to find pattern B in matrix A. So I get 2 pattern similar like pattern B. What the name of this operation? and How I write this in mathematics notation? Thank you in ...
2
votes
2answers
236 views

Inverting really big symmetric block diagonal matrix

I have a really big symmetric 7.000.000 X 7.000.000 matrix that i would like to invert. The matrix is extremely sparse and it can be rearranged as to become a block diagonal matrix. The biggest blocks ...
33
votes
2answers
12k views

why is A*v+B*v faster than (A+B)*v?

$A$ and $B$ are $n \times n$ matrices and $v$ is a vector with $n$ elements. $Av$ has $\approx 2n^2$ flops and $A+B$ has $n^2$ flops. Following this logic, $(A+B)v$ should be faster than $Av+Bv$. Yet,...
5
votes
1answer
185 views

How to know which LAPACK's function is used by Scipy's eig function?

As far as I understood, scipy.linalg.eig use wrappers from scipy.lapack to compute the eigenvalues and eigenvectors of a matrix. ...
5
votes
1answer
161 views

Fastest way to calculate the $2$-norm (or an upper bound for the $2$-norm) of the inverse of a matrix $A\in \mathbb{C}^{N\times N}$

I have a matrix $A\in \mathbb{C}^{N\times N}$ and I need to calculate $||A^{-1}||_{2}$ efficiently. Can it be done without having to evaluate the inverse explicitly? In general, I am looking for ...
3
votes
0answers
109 views

What is the fastest algorithm for computing log determinant of a PSD matrix? (All possible PSD matrices)

I am diving into some literature to understand which is the best algorithm for computing the log-determinant of a PSD matrix. More generally, I am interested in a list of resources to read, which ...
2
votes
1answer
120 views

Numerical stability in the product of many matrices

I have to calculate in numpy the matrix-product of many matrices (~400). Are there common practices to increase numerical stability? If this is relevant, the matrices are $300\times 300$ orthogonal ...
3
votes
1answer
80 views

Calculate Transformation Matrix between two sensors

My question is if I can calculate the transformation matrix between two sensors. Each sensor provides a $4\times 4$ matrix for every timestep recorded. The sensors are moving and have some noise in ...
0
votes
2answers
9k views

How to prove the 2-norm of an invertible matrix is exactly the reciprocal of its minimum singular value?

If a matrix $A_{n\times n}$ is invertible, then $\left\|A^{-1}\right\|_2 = \dfrac{1}{\min\limits_{i} \sigma_i}$ where $\sigma_i$ is the $i$-th singular value of $A$
2
votes
1answer
152 views

A Bound for the inverse of the sum of identity and triangular matrix

I wonder if there are any theorems which can help me to calculate an upper bound for the spectral norm of: $$\left\| \left[ I + \sum_{i=1}^{\overline{n}\in\mathbb{N}} \big( C_i - I\big)\right]^{-1}\...
7
votes
3answers
384 views

Does a symmetric positive definite matrix also have $\mathbf{A} = \mathbf{L}^T\mathbf{L}$ (where $\mathbf{L}$ is a lower triangular matrix)?

As we know, for a symmetric positive definite (SPD) matrix $\mathbf{A}$, there is a theorem about the Cholesky factorization $\mathbf{A}= \mathbf{L}\mathbf{L}^T$, where $\mathbf{L}$ is a lower ...

1
2 3 4 5
11