Questions tagged [matrix-inverse]

The matrix inverse, A^{-1}, is a mathematical relationship such that given a square n x n matrix A, A*A^{-1} = A^{-1}*A = I, where I is the identity matrix. Use this tag with regards to any numerical methods or computations that require the use or calculation of the matrix inverse.

Computation of the inverse of a square matrix, provided it is invertible (i.e., full-rank), is often via LU factorization. When the matrix is positive-definite, Cholesky factorization is often used. In standard numerical linear algebra library , dgesv and dpotrf respectively performs LU and Cholesky factorization.

In reality it is rare that a matrix inverse needs be explicitly formed, and matrix multiplications involving a matrix inverse is done by one of the factorizations above, and a triangular system solving.

509 questions
7
votes
1 answer

Fast matrix inversion without a package

Assume that I have a square matrix M. Assume that I would like to invert the matrix M. I am trying to use the the fractions mpq class within gmpy2 as members of my matrix M. If you are not familiar with these fractions, they are functionally…
Paul Terwilliger
  • 1,596
  • 1
  • 20
  • 45
7
votes
2 answers

Is numpy.linalg.inv() giving the correct matrix inverse? EDIT: Why does inv() gives numerical errors?

I have a matrix shaped (4000, 4000) and I would like to take the inverse. (My intuition of the inverting matrices breaks down with such large matrices.) The beginning matrix has values of the magnitude e-10, with the following values: print matrix…
ShanZhengYang
  • 16,511
  • 49
  • 132
  • 234
6
votes
1 answer

Woodbury identity for fast matrix inversion—slower than expected

The Woodbury matrix identity states that the inverse of a rank-k correction of some matrix can be computed by doing a rank-k correction to the inverse of the original matrix. If A is a p × p full rank matrix that is rank corrected by UCV where U is…
jds
  • 7,910
  • 11
  • 63
  • 101
6
votes
2 answers

numpy.linalg.inv returns inverse for a singular matrix

The matrix below is singular, and AFAIK attempting to invert it should result in numpy.linalg.linalg.LinAlgError: Singular matrix but instead, I do get some output matrix. Note that output matrix is a non-sensical result, because it has a row of…
niklas
  • 81
  • 1
  • 4
6
votes
1 answer

efficiency of inverting a matrix in numpy with Cholesky decomposition

I have a symmetric positive-definite matrix (e.g. Covariance matrix), and I want to calculate its inverse. In math, I know that it is more efficient to use Cholesky decomposition to invert the matrix, especially if your matrix is big. But I was not…
Babak
  • 497
  • 1
  • 7
  • 15
6
votes
1 answer

How to compute diag(X %*% solve(A) %*% t(X)) efficiently without taking matrix inverse?

I need the following diagonal: diag(X %*% solve(A) %*% t(X)) where A is a full rank square matrix, X is a rectangular matrix. Both A and X are sparse. I know finding the inverse of a matrix is bad unless you really need it. However, I can't see how…
Coolwater
  • 703
  • 8
  • 15
6
votes
1 answer

R ginv and Matlab pinv produce different results

ginv() function from MASS package in R produce totally different values compared to MATLAB pinv() function. They both claim to produce Moore-Penrose generalized inverse of a matrix. I tried to set the same tolerance for the R implementation but the…
Farid Cheraghi
  • 847
  • 2
  • 12
  • 23
6
votes
1 answer

Huge symmetric matrix - how to store and use it cleverly - Python

I have a symmetric matrix. Now,the problem is that I need to fill such a matrix of dimensions (32**3) x (32**3). The reason why I need to fill the matrix is because in my program I am then using it for various calculations: I am inverting it, I am…
johnhenry
  • 1,293
  • 5
  • 21
  • 43
6
votes
4 answers

Efficient way to solve for X in AX=B in MATLAB when both A and B are big matrices

I have this problem which requires solving for X in AX=B. A is of the order 15000 x 15000 and is sparse and symmetric. B is 15000 X 7500 and is NOT sparse. What is the fastest way to solve for X? I can think of 2 ways. Simplest possible way, X =…
6
votes
1 answer

Inverse Matrix OpenCV. Matrix.inv() not working properly

I have one problem for which I could not find any solution. I have to make some calculations with the inverse of one known matrix. Matrix homography= 1.1688, 0.23, 62.2, -0.013,1.225, -6.29, 0, 0, 1, and then: Mat homoInv=homography.inv(); The…
Ivánovick
  • 267
  • 1
  • 5
  • 17
5
votes
4 answers

Statistics and matrix algebra in Ruby

I need to inverse a variance-covariance matrix in Ruby and vector by matrix multiplication. Which numerical Ruby library/Gem should I use?
Hekje
  • 441
  • 3
  • 12
5
votes
1 answer

Best performance method when solving 7000x7000 linear system with python

I’m in the need of an efficient method to inverse a 7000x7000 aerodynamic influence coefficient (dense) matrix in python. I had started before a FORTRAN routine to handle the problem using the LU decompostition routines from LAPACK, which I had seen…
Pedro Secchi
  • 109
  • 5
5
votes
3 answers

Why is inverting a positive definite matrix via Cholesky decomposition slower than regular inversion with numpy?

It's mathematically known that inverting a positive definite matrix via Cholesky decomposition is faster than just using np.linalg.inv(X). However, when I experimented with both and it turns out Cholesky decomposition's performance is worse! #…
Daeyoung
  • 194
  • 7
5
votes
3 answers

Is 3x3 Matrix inverse possible using SIMD instructions?

I'm making use of an ARM Cortex-A8 based processor and I have several places where I calculate 3x3 Matrix inverse operations. As the Cortex-a8 processor has a NEON SIMD processor I'm interested to use this co-processor for 3x3 matrix inverse, I saw…
HaggarTheHorrible
  • 7,083
  • 20
  • 70
  • 81
5
votes
5 answers

Fast inverse and transpose matrix in Python

I have a large matrix A of shape (n, n, 3, 3) with n is about 5000. Now I want find the inverse and transpose of matrix A: import numpy as np A = np.random.rand(1000, 1000, 3, 3) identity = np.identity(3, dtype=A.dtype) Ainv =…
user2863620
  • 635
  • 3
  • 10
  • 17
1 2
3
33 34