Open mzy2240 opened 1 year ago
The function
solve_system
includes creating the identity matrix, so almost takes the same time.
I don't understand your question. What do you mean by "an allocated space B"? You can allocate B just once and simply reuse B in multiple solvings.
Allocating alone is fine, but allocating and creating a huge identity matrix together is relatively time-consuming (see the benchmark above). And such an identity matrix may not be re-usable, cause if in-place operation is preferred (reuse the B matrix allocation) then the identity matrix will be gone.
We already have CKTSO_L_SolveMV
which is very handy, and I would like to see if we can have something like CKTSO_L_InverseMV
which solves Ax = I
underneath (I imagine the API would be similar).
I see. You want a function to solve the inverse of the matrix, without explicitly inputing the identity matrix, because creating the identity matrix is costly.
Exactly
Do you really need to solve the inversion of a sparse matrix? This problem has better native solutions. Using LU factorization and solving N linear systems is a bad solution and it is not adopted in practice, as it will make the inversion fully dense and the performance is not good.
Yeah I fully understand, however, the formula requires to have row-wise operation (zero out a row) on the inverse of the matrix, which seems to be inevitable to have an explicit inversion.
When the system is relatively large(e.g. B is 20000 * 20000), creating (and allocating) such an identity matrix takes almost the same time as factoring and solving the system(benchmarked in Julia). Is it possible to provide a helper function, so that we could simply pass the sparse matrix A and an allocated space B? I feel like this scenario is quite common in the numerical computation.