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
2
votes
1 answer

Fastest way in R to compute the inverse for large matrices

I need to compute a hat matrix (as from linear regression). Standard R code would be: H <- tcrossprod(tcrossprod(X, solve(crossprod(X))), X) with X being a relatively large matrix (i.e 1e5*100), and this line has to run thousands of times. I…
DGMartin
  • 67
  • 7
2
votes
1 answer

Fast and efficient upper diagonal matrix inverse

I compute the multinomial Gaussian density for some huge number of times in a project where I update the covariance matrix by rank-1. Instead of computing the covariance from scratch, I used the cholupdate function to add a new sample to the…
petrichor
  • 6,459
  • 4
  • 36
  • 48
2
votes
1 answer

How do I find the pseudo-inverse from Apache Commons Math - Java library

According to this code. It can finding the pseudo-inverse by using Apache Commons Math library. RealMatrix Swinv = new LUDecomposition(Sw).getSolver().getInverse(); // MATLAB: Swinv = pinv(Sw) But even if Sw is square, I can get the exception…
euraad
  • 2,467
  • 5
  • 30
  • 51
2
votes
4 answers

Scala Matrix Inversion

Uh, yeah, I'd really need a quick input from someone without creator's eyes. Something's wrong in here, according to my scalacheck tests... but I don't really know enough about it to know where it's wrong. case class Matrix(_1: (Float, Float, Float,…
Lanbo
  • 15,118
  • 16
  • 70
  • 147
2
votes
1 answer

Wrong matrix inverse results in R

I calculated the inverse of a matrix (I-Q) (I is the identity matrix) in both R and Mathematica, but R gives me wrong results compared with the theoretical results. I have attached the code in R and Mathematica, and you can see the results are…
T. J.
  • 90
  • 1
  • 6
2
votes
1 answer

Pseudo-inverse matrix different in Julia and Python

I am trying to transcribe a python code in Julia. I have a matrix test = [2.0 3.0 4.0 3.0 4.0 5.0 4.0 5.0 6.0] I am computing the (Moore-Penrose) pseudo-inverse of a matrix in Python using numpy.linalg.pinv and the result is…
Suyama87
  • 85
  • 10
2
votes
0 answers

Can someone assist with speeding up my Woodbury matrix inversion code in r?

I have code for inverting large matrices and finding the log determinant in R. I really would like this code to run quicker but am struggling for anymore ideas. I have used the Cholesky decomposition and removed unwanted variables for memory. Please…
2
votes
1 answer

Matrix inverse from PLU decomposition

I am trying to compute the matrix inverse from plu decomposition, but the results I get are wrong. Using the debugger, I couldn't find a single step I could blame, so here is the code for the inversion function : template Matrix
Magix
  • 4,989
  • 7
  • 26
  • 50
2
votes
2 answers

Issue with code for NxN determinant function (C++)

I'm trying to write a matrix inverse calculator (been doing stuff to do with matrices for my maths module in uni so I figured it would be a good way to get practice with recursive functions). At the moment I'm working on functions for working out…
2
votes
1 answer

OpenGL How to calculate worldspace coordinates from frustum aligned vectors?

I am a graphics programming beginner working on my own engine and tried to implement frustum-aligned volume rendering. The idea was to render multiple planes as vertical slices across the view frustum and then use the world coordinates of those…
2
votes
2 answers

R Inconsistent product of matrix inversions

I have a matrix emat generated by taking the sum of outer products of vectors. It should be symmetric and positive definite. I am finding that solve(emat) %*% solve(emat) generates a different result from bmat <- solve(emat) bmat %*% t(bmat) In…
2
votes
1 answer

Radial Basis Function in 3D (facing Singularity Matrix)

I am writing a code for 2D RBF Interpolation but facing singularity issue: `raise LinAlgError('Matrix is singular.') LinAlgError: Matrix is singular.` I have an idea of QR decomposition to resolve this issue but I don't know at which place of code…
2
votes
1 answer

Inverting matrix in python slightly off

I'm trying to use this http://www.irma-international.org/viewtitle/41011/ algorithm to invert a nxn matrix. I ran the function on this matrix [[1.0, -0.5], [-0.4444444444444444, 1.0]] and got the output [[ 1.36734694, 0.64285714] […
huddie96
  • 1,240
  • 2
  • 13
  • 26
2
votes
1 answer

`tf.reciprocal` vs `tf.inv`: is there any difference?

tf.reciprocal and tf.inv seem to be equivalent. Is there any difference? They are implemented as separate TF ops and also have separate gradient implementations, which also seem equivalent.
Albert
  • 65,406
  • 61
  • 242
  • 386
2
votes
1 answer

Python matrix inverse

I have a camera matrix k which I have computed. The value of k is: [[ 1.92160183e+08 0.00000000e+00 3.06056985e+02] [ 0.00000000e+00 1.92160183e+08 1.57709172e+02] [ 0.00000000e+00 0.00000000e+00 1.00000000e+00]] Now, I have tried…
RaviTej310
  • 1,635
  • 6
  • 25
  • 51