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

Rotate matrix confusion in Java

public int[][] Solution(int[][] matrix, int flag) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) return matrix; //int m = matrix.length, n = matrix[0].length; int[][] rvalue; rvalue = transpose(matrix); …
KKKK
  • 347
  • 7
  • 18
0
votes
1 answer

Invert 20X20 matrix with math.net numerics

I need to invert a 20X20 matrix, but I am getting incorrect results. I have created a test program using some values from my application: using System; using System.Diagnostics; using MathNet.Numerics.LinearAlgebra; using…
Phil Jollans
  • 3,605
  • 2
  • 37
  • 50
0
votes
0 answers

Inverse probability matrix with solve function

I want to take the inverse of a matrix i.p with the solve function. This i.p matrix is the result of an identity matrix subtracting p. Here's the code to get i.p: p<-rbind(c(0,0,0,0,0,0,3), c(0,0,7,9,0,0,0), c(3,6,0,75,0,0,0), c(0,0,20,0,1,35,34),…
Silu Wang
  • 9
  • 1
0
votes
1 answer

Complex inverse and complex pseudo-inverse in Scala?

I'm considering to learn Scala for my algorithm development, but first need to know if the language has implemented (or is implementing) complex inverse and pseudo-inverse functions. I looked at the documentation (here, here), and although it states…
zanbri
  • 5,958
  • 2
  • 31
  • 41
0
votes
1 answer

OpenSceneGraph: Trying to extract far and near points from mouse screen coordinates for ray casting

I'm trying to do ray casting using OpenSceneGraph. The context of the problem is that I need to draw a line segment on a virtual plane by mouse. I cannot use LineIntersector because the plane does not contain any drawables (I use osg::Plane to…
vicrucann
  • 1,703
  • 1
  • 24
  • 34
0
votes
1 answer

broadcasting linalg.pinv on a 3D theano tensor

in the example below, there is a 3d numpy matrix of size (4, 3, 3)+ a solution about how to calculate pinv of each of 4 of those 3*3 matrices in numpy. I also tried to use the same function worked in numpy, in theano hoping that it is implemented…
PickleRick
  • 419
  • 1
  • 5
  • 13
0
votes
1 answer

Omitting zeroes from matrix calculation in Octave

I'm performing input-output calculations in Octave. I have several matrices/vectors in the formula: F = f' * (I-A)^-1 * Y All vectors probably contain zeroes. I would like to omit them from the calculation and just return 0 instead. Any help would…
0
votes
0 answers

How can I use numpy.linalg correctly in doing matrix calculations in Python

I am Stuggling with using the numpy.linalg.inv() function in Python. I populate 4 matrices by fetching certain elements in a nested for loop from a larger ZMatrix. As follows #populating arrays for Zp for k1 in range(3): for m1 in range(3): …
Robey Beswick
  • 31
  • 1
  • 5
0
votes
1 answer

Symbolically calculate the inverse of a 4 x 4 matrix in MATLAB

I am trying to find the general formula of an inverse matrix of size 4 x 4. What I wrote is simply this: A = [a b c d ; e f g h ; i l m n; o p q r]; inv(A) However, the MATLAB console returns the following: undefined function or variable 'a'. How…
0
votes
1 answer

Stata inverse matrix function

I'm trying to get inverse matrix with inv() function. Excel function is working fine but I can't get it from Stata 11 and Stata 12 version matrix A =…
Nurlan
  • 505
  • 1
  • 4
  • 11
0
votes
2 answers

Square Matrix Inversion in C

I wrote a inversion function for an n*n square matrix. void inverseMatrix(int n, float **matrix) { float ratio,a; int i, j, k; for(i = 0; i < n; i++) { for(j = n; j < 2*n; j++) { if(i==(j-n)) …
re3el
  • 735
  • 2
  • 12
  • 28
0
votes
1 answer

Java: Inverse of a matrix using EJML not working as expected

Within a java project I've developed I need to calculate the inverse of a matrix. In order to align with other projects and other developers I'm using the Efficient Java Matrix Library (orj.ejml). For inverting the Matrix I'm using invert from…
Julian
  • 192
  • 1
  • 12
0
votes
0 answers

CUDA cublas getrf and getri, for a matrix inversion, cause nvprof errors with one dimensional memory

I am attempting to use the cuBlas functions cublasSgetrf and cublasSgetri to find the inversion of a square matrix. This portion of code is part of a larger program where I am attempting to minimize any unnecessary memory allocations or copies. As…
cshea
  • 82
  • 1
  • 7
0
votes
2 answers

Runtime error, NxN Matrix Inverse in C

I am trying to write a function which gets a matrix and the dimension (square), and returns the inverse matrix in C. Further, I will use it in solving a least square matrix solution function! I have got most of the ideas and algorithms from online…
MRM
  • 1
  • 6
0
votes
2 answers

python-inverse-of-a-matrix failure to import

I thought that the code in the python-inverse-of-a-matrix was extremely interesting, particularly since I have used numpy for several years in computations that involve matrices. I was disappointed as the 2 imports from numpy failed. Here are the…
user377367
  • 119
  • 1
  • 2