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
15
votes
4 answers

Why is the output of inv() and pinv() not equal in Matlab and Octave?

I have noticed that if A is a NxN matrix and it has the inverse matrix. But what the inv() and pinv() function output is different. - My environment is Win7x64 SP1, Matlab R2012a, Cygwin Octave 3.6.4, FreeMat 4.2 Have a look at the examples from…
13
votes
3 answers

Is there a fast way to invert a matrix in Matlab?

I have lots of large (around 5000 x 5000) matrices that I need to invert in Matlab. I actually need the inverse, so I can't use mldivide instead, which is a lot faster for solving Ax=b for just one b. My matrices are coming from a problem that means…
Daniel
  • 944
  • 1
  • 7
  • 24
13
votes
6 answers

Invert 4x4 matrix - Numerical most stable solution needed

I want to invert a 4x4 matrix. My numbers are stored in fixed-point format (1.15.16 to be exact). With floating-point arithmetic I usually just build the adjoint matrix and divide by the determinant (e.g. brute force the solution). That worked for…
12
votes
4 answers

How to check if a matrix has an inverse in the R language

How do you determine if a matrix has an inverse in R? So is there in R a function that with a matrix input, will return somethin like: "TRUE" (this matrix has inverse)/"FALSE"(it hasn't ...).
hamsternik
  • 1,376
  • 3
  • 18
  • 26
11
votes
1 answer

More efficient and fast way of inverting matrices in c++ (big and small)

EDIT. Since this question was asked, I got a PhD on solving linear system of equations for tomography. As this question still gets a lot of traffic, I want to stress out the first sentence from the answer by @sellibitze: There is not simple answer.…
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
10
votes
2 answers

Eigen efficient inverse of symmetric positive definite matrix

In Eigen, if we have symmetric positive definite matrix A then we can calculate the inverse of A by A.inverse(); or A.llt().solve(I); where I is an identity matrix of the same size as A. But is there a more efficient way to calculate the inverse…
dpritch
  • 1,149
  • 13
  • 15
10
votes
4 answers

Fast method to check if a Matrix is singular? (non-invertible, det = 0)

What is the fastest algorithm (a link to C or C++ example would be cool) to check if a small square matrix (<16*16 elements) is singular (non-invertible, det = 0) ?
Vincent
  • 57,703
  • 61
  • 205
  • 388
10
votes
5 answers

Calculating inverse of a very large matrix

I am trying to calculate inverse of a very large matrix (11300x21500) in C++. So far I have tried Eigen and Armadillo libraries but both failed at initialization stage, saying that there is not enough memory. Can there be any way to overcome this…
Osman Darin
  • 101
  • 1
  • 2
  • 6
9
votes
2 answers

Efficient way to calculate diagonal of the inverse of a matrix

What is the best way of calculating the diagonal of the inverse of a symmetric dense matrix (2000 * 2000)? Currently I calculate the inverse first using solve(x) and then extract the diagonal (diag(y)). Even though it works but I'm wondering whether…
Katherine
  • 111
  • 4
8
votes
2 answers

pseudo inverse of sparse matrix in python

I am working with data from neuroimaging and because of the large amount of data, I would like to use sparse matrices for my code (scipy.sparse.lil_matrix or csr_matrix). In particular, I will need to compute the pseudo-inverse of my matrix to solve…
7
votes
2 answers

How to calculate the inverse key matrix in Hill Cipher algorithm?

I am finding it very hard to understand the way the inverse of the matrix is calculated in the Hill Cipher algorithm. I get the idea of it all being done in modulo arithmetic, but somehow things are not adding up. I would really appreciate a simple…
user59634
7
votes
5 answers

numerically stable inverse of a 2x2 matrix

In a numerical solver I am working on in C, I need to invert a 2x2 matrix and it then gets multiplied on the right side by another matrix: C = B . inv(A) I have been using the following definition of an inverted 2x2 matrix: a = A[0][0]; b =…
Steve
  • 8,153
  • 9
  • 44
  • 91
7
votes
3 answers

det of a matrix returns 0 in matlab

I have been give a very large matrix (I cannot change the values of the matrix) and I need to calculate the inverse of a (covariance) matrix. Sometimes I get the error saying Matrix is close to singular or badly scaled. Results may be…
bhavs
  • 2,091
  • 8
  • 36
  • 66
7
votes
1 answer

Computing `AB⁻¹` with `np.linalg.solve()`

I need to compute AB⁻¹ in Python / Numpy for two matrices A and B (B being square, of course). I know that np.linalg.inv() would allow me to compute B⁻¹, which I can then multiply with A. I also know that B⁻¹A is actually better computed with…
norok2
  • 25,683
  • 4
  • 73
  • 99
7
votes
4 answers

Most efficient matrix inversion in MATLAB

When computing the inverse for some square matrix A in MATLAB, using Ai = inv(A) % should be the same as: Ai = A^-1 MATLAB usually notifies me that this is not the most efficient way of inverting. So what's more efficient? If I have an equation…
ptikobj
  • 2,690
  • 7
  • 39
  • 64
1
2
3
33 34