511 questions
1
vote
0
answers
73
views
Why does cusolverDnDsytri not find the inverse of a matrix in Fortran?
I have recently been trying to use CUDA in Fortran for a project which requires finding the inverse of symmetric matrices. The matrices I am working with are not positive definite so I cannot use a ...
0
votes
1
answer
77
views
Sympy matrix inverse only works with method='LU'
I'm doing some prework for a control design of a system, and have started using SymPy.
In my system I have a matrix A, with these parameters:
s= symbols('s')
V = 20000 #[m^3 volume in tank]
K_qo = ...
3
votes
2
answers
97
views
makeCacheMatrix R tutorial from Coursera
I have been trying to complete the 2nd assignment for the R Programming course from Coursera. This assignment consists of writing the function makeCacheMatrix() which returns the inverse of a matrix. ...
1
vote
1
answer
88
views
Why does ⎕DIV not affect Matrix divide (⌹)?
With ⎕DIV←1, dividing by 0 does not give an error but gives a 0 every time.
When dividing by 0, ⌹ (quad divide) seems to always throw a domain error even with ⎕DIV←1.
Is there a reason why the value ...
0
votes
0
answers
143
views
Efficiently compute the diagonal of the inverse of a sparse matrix
In Python have a large NxN sparse matrix representing the precision matrix Q (inverse covariance matrix) of a multivariate Gaussian distribution. I am interested in obtaining the marginal variances of ...
2
votes
1
answer
235
views
Is there a better way to write SIMD code to invert a transformation matrix? [closed]
I am writing a maths library for a raytracer project, and so I'm trying to make my heavy operations (like matrix inverse) more optimised.
After doing some research, I discovered this trick to invert a ...
0
votes
1
answer
104
views
Jupyter Notebook error: Unable to allocate / Too large work array required, when calculating inverse matrix
I want to calculate the (generalized) inverse of a 30807 x 30807 matrix.
I tried to use np.linalg.pinv(matrix), and the error "MemoryError: Unable to allocate 7.07 GiB for an array with shape (...
-1
votes
1
answer
134
views
How to reduce matrix inversion time?
I am writing a program which requires me to find inverse of a complex 21*21 symmetric matrix several times(approx 35 million times).I initially do this with inv() from scipy.linalg. It works. Now I ...
0
votes
2
answers
66
views
How to fix matrix with high cond number?
Here is my code:
A = [+0.00, -2.34, -2.25, -2.16, -2.07, -1.98, -1.89, -1.80, -0.72, +0.09, +1.16;
+2.34, +0.00, -3.15, -3.06, -2.97, -2.88, -2.79, -2.70, -1.26, -0.18, +0.98;
+2.25, +3.15, +0.00, -3....
0
votes
0
answers
136
views
numpy.array_equal returns False for matching np arrays
I'm having trouble getting the correct output from numpy.array_equal. The identity array is created using np.eye(size), and the result_ab array I'm comparing it with was built with np.array([]).
I ...
0
votes
1
answer
62
views
Speeding up sparse inversion, element-wise multiplication and addition in python
I am trying to invert a 10000x10000 sparse matrices that are tri-diagonal, but the problem I have is that scipy.sparse.linalg.inv() is too slow, so I have tried to use spsolve() instead. The main ...
1
vote
1
answer
83
views
Triangular linear system with triangular right hand side in python
I have to solve a linear system of equations with multiple right hand sides, A*X=B, where both, A and B are (upper) triangular, real, square matrices. The size is about 200 by 200. Is there a fast ...
1
vote
0
answers
40
views
Do CPXbinvcol and CPXbinvrow in CPLEX's C API calculate the inverse matrix or retrieve a precalculated inverse?
It is indicated that: "The routine CPXXbinvcol/CPXbinvcol computes the j-th column of the basis inverse." in the documentation on this link: https://www.ibm.com/docs/en/icos/22.1.1?topic=b-...
1
vote
1
answer
92
views
Why is my Python code 3x slower than my Matlab code? (matrix multiplication and inversion)
My python code is a lot slower than my matlab code.
My python code is:
import time
from scipy import linalg
import numpy as np
N=1521
dt=0.1
thet=0.5
A0 = (np.linspace(1,N,N)).reshape(N,1)
A0 = np....
0
votes
1
answer
58
views
Simultaneous Inverse Matrix Computations in TensorFlow for Orthogonal Matching Pursuit
I am currently working on creating a version of Orthogonal Matching Pursuit (OMP) that can be performed simultaneously on different patches, utilizing the power of TensorFlow for optimization through ...
2
votes
0
answers
185
views
Optimise matrix inversion in Python for impedance calculation
To get the impedance profile for a circuit, I am using its admittance (G) and capacitance (C) matrices.
I am using Python to compute impedance profile at different frequencies but the issue is that I ...
1
vote
1
answer
145
views
Recover a matrix after matrix multiplication
I am given two matrices (A and B), where the second has rows with unit length. For example in R:
k <- 1000
m <- 10
n <- 100
A <- matrix(rnorm(m*k), m, k) # m x k
B <- matrix(rnorm(k*n),...
0
votes
1
answer
217
views
Why is my gaussian elimination algorithm failing?
In gaussian elimination, we take our matrix A and another matrix I.
We proceed to convert the matrix A into an identity matrix. Once that's done, we apply the same steps that we did on A on the ...
0
votes
0
answers
97
views
Python version of matlab code is very slow
I have the following Matlab code (my production code array size is of order of 8766 x 8766):
% Define z1 and z2
z1 = rand(6, 6); % Random 6x6 matrix - real life size 8766 x 8766
z2 = rand(6, 7); % ...
2
votes
1
answer
413
views
Haskell implementation of Determinant, Rank and Inverse Matrix calculation- input matrix size limitation
I'm new to Haskell.
As a part of an academic course, I was requested to implement a function in Haskell that calculates the determinant, rank and inverse matrix of a given matrix.
I use gaussian ...
0
votes
0
answers
291
views
Calculate the inverse of an n x n matrix
I want to find the inverse of an n-order matrix using the method of finding the adjugate matrix and determinant, and then deducing the inverse. I'm using C++ language, and for calculating the ...
1
vote
2
answers
224
views
How to apply the pseudo-inverse of a matrix to N arrays with Cupy?
I want to apply the cupy.linalg.pinv function to 100k arrays, but I see a drop in performance compared to the Numpy equivalent.
My 100k arrays are two dimensions arrays. The main array shape is: (...
1
vote
1
answer
229
views
Why is this simple Fortran matrix inversion code not returning the expected value with LAPACK?
I'm trying to use the LAPACK package to compute the inverse of a matrix. For this end, I've employed the routines sgetrf and sgetri. However, when testing the code, it doesn't return the expected ...
1
vote
0
answers
454
views
Maximum size to inverse a matrix?
I want to inverse a 401x401 (upper triangular square) matrix in python but run into issues when the matrix size exceeds 153x153. For all sizes below this, everything works like a charm but then the ...
1
vote
1
answer
1k
views
CUDA: Matrix inversion slower on GPU than on CPU
I have a stable, simple Gauss-Jordan algorithm for calculating the matrix inversion on the CPU. I tried to transfer this algorithm to the GPU, it works fine, but the speed has dropped significantly, ...
0
votes
0
answers
83
views
Numpy inverse function does not work for version 1.16.4 and 1.24.x but works for 1.21.6
For a matrix A, when using numpy version 1.16.4 to run numpy.linalg.inv(A.T.dot(A)) will result in:
numpy.linalg.LinAlgError: Singular matrix.
When using numpy version 1.21.6, no error raised. So I ...
0
votes
0
answers
35
views
plot_surface with inverse matrix
I am trying to plot a 3D surface using matplotlib's plot_surface function. My f(x, y) function is complicated. I'm using inverse matrix which causes an error "Last 2 dimensions of the array must ...
1
vote
0
answers
338
views
Why does numpy not raise an error when inverting a singular matrix?
I am writing a tutorial, as part of which I wanted to show some of the issues that occur when analyzing data that has a singular covariance matrix.
I came across some odd behavior in numpy.
The ...
0
votes
0
answers
128
views
Compute matrix inverse with decimal object
There's a related questions Matrix inverse with Decimal type NumPy 2015 a while ago which did not have a definite answer. There's a second question from me Is there a way for python to perform a ...
-1
votes
1
answer
383
views
inverse of a 2D array (matrix)
I've made a function to calculate the inverse of a matrix, but I'm having an issue getting the correct result when I run my program.
For example, when I insert the following matrix:
A1 A2 A3
(2 1 ...
0
votes
2
answers
289
views
How to accelerate the matrix inversion in Python?
In my code, each runtime takes about 40sec, and most of the time (38sec) is spent matrix inversion, i.e., numpy.linalg.inv. Here, the matrix dimension generally is 100-1000.
Thus, I want to reduce the ...
-2
votes
1
answer
564
views
Solve function in R doesn't match inverse calculation
There seem to be a ton of questions about inverse functions, but they're not what I'm after (neither are many of the results in the matrix-inverse tag). I'm trying to use a function that gets the ...
0
votes
1
answer
1k
views
Why is `sympy.Matrix.inv` slow?
Here is a small example. It surprised me at how slow it is.
import numpy as np
import sympy as sp
X = np.empty(shape=(10,3), dtype=object)
for i in range(10):
for j in range(3):
X[i,j] = ...
0
votes
0
answers
45
views
Difference in outputs between ```pinv``` and ```cg``` in Python
I have two arrays A and B. I am trying to solve for X in AX=B. I am using scipy.sparse.linalg.cg and np.linalg.pinv. Both present different outputs which I have shown below. From physics, I know that ...
0
votes
2
answers
209
views
Optimization Loop unrolling to find the inverse of a matrix by the gauss jordan method
I am trying to apply the loop unrolling to find the inverse of a matrix by the Gauss Jorda method, to reduce the number of memory accesses (bottleneck) when the size of the matrices is very large and ...
0
votes
0
answers
45
views
How to make non iterative code faster than the iterative when using line by line backslash inverse?
This code creats a matrix B contains the product of the each line of A by the backslash inverse of a aline of x
A = [1,2,3,8,1;10,45,7,3,1;9,8,15,75,65,];
x = [14,5,11,15,33;7,1,9,1,1;87,45,11,0,65];
...
3
votes
1
answer
285
views
Speed-up a variable-dependent matrix inverse computation in Python
I have an iterative problem where at each iteration I need to perform a series of matrix operations, which I want to speed up. The majority of the calculation involves constant variables, except for a ...
0
votes
0
answers
72
views
loop not iterating in c
I have recently started coding and was trying to write a program to find the inverse of a matrix using Gauss Jordan method. I try to transform the given matrix to an identity matrix by using ro ...
1
vote
1
answer
569
views
Why my matrix inverse implementation is less accurate? C++
I have a transformation matrix of type Eigen::Matrix4d. And I would like to get its inverse. I write a function my self to compute it by the following formular.
.
And here is my code:
Eigen::Matrix4d ...
0
votes
1
answer
132
views
How to calculate the matrix's inverse using tflite
as far as i known, the matrix's inverse is a common operator.
while tf.raw_ops.MatrixInverse is not supported in tflite and BatchMatrixInverse is not available in GraphDef version 1205.
How can i ...
0
votes
1
answer
3k
views
Large sparse matrix inversion on Python
I'm currently working with a least-square algorithm on Python, regarding some geodetic calculations.
I chose Python (which is not the fastest) and it works pretty well. However, in my code, I have ...
-1
votes
1
answer
1k
views
Adjoint of Matrix in C++. (Inverse of Matrix)
I am Implementing a Inverse Matrix by using the following formula
Inverse of A = (Adj of A) / (Determinant of A)
I am implementing Adjoint Matrix, But When I printing the result of adjoint function , ...
0
votes
0
answers
77
views
Python - Problem multiplying the inverse of a matrix with a vector - Structural Engineering (FEM)
I´m developing a code to analyse portal frames with the finite element method.
However I´m encountering a problem, when I try to multiply the inverse of specic positions of a matrix with an array, ...
0
votes
0
answers
195
views
Can I get the inverse of an LP basis from a GUROBI model object in Python API?
Is it possible to get the inverse of an LP basis the model is solved?
For example, I can get the names of the variables that are in the basis with the following code. I am looking for something ...
1
vote
2
answers
503
views
How to inverse a matrix in CODESYS?
Is it possible to calculate the inverse of a matrix in CODEYS?
I am trying to write the code for the following equation.
-1
votes
1
answer
62
views
Pivot/inverse Pandas Dataframe using key pairs [duplicate]
I have this dataframe that I would like to flip
M1 M2 M3
John 0.10 0.74 0.25
Alex 0.80 0.15 0.05
I would like to convert it to this format:
M ...
2
votes
1
answer
200
views
Parallelise backslash matrix inversion using @distributed
I'm solving a PDE using an implicit scheme, which I can divide into two matrices at every time step, that are then connected by a boundary condition (also at every time step). I'm trying to speed up ...
0
votes
1
answer
1k
views
Inverting a triangular matrix in python/numpy/scipy
I am looking to invert a (lower) triangular matrix that comes from the Cholesky decomposition of A, as A = L @ L.T. There are a few potential solutions, including numpy: inverting an upper triangular ...
0
votes
0
answers
295
views
Inverse matrix in python (numpy/sympy)
I have a matrix (A) of order 8*8 which contains complex numbers.
I would like to calculate the inverse of that matrix, so I used np.linalg.inv(b) command but I got an error:
UFuncTypeError: Cannot ...
0
votes
0
answers
685
views
Fortran inverse matrix Gauss Jordan Metod
I am somewhat new to programming in fortran and I have been doing small activities, one of them is a subroutine to solve a system of equations with the Gauss Jordan Method:
PROGRAM Program2
...