Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8321593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:04:23+00:00 2026-06-08T23:04:23+00:00

I have two large square sparse matrices, A & B, and need to compute

  • 0

I have two large square sparse matrices, A & B, and need to compute the following: A * B^-1 in the most efficient way. I have a feeling that the answer involves using scipy.sparse, but can’t for the life of me figure it out.

After extensive searching, I have run across the following thread: Efficient numpy / lapack routine for product of inverse and sparse matrix? but can’t figure out what the most efficient way would be.

Someone suggested using LU decomposition which is built into the sparse module of scipy, but when I try and do LU on sample matrix is says the result is singular (although when I just do a * B^-1 i get an answer). I have also heard someone suggest using linalg.spsolve(), but i can’t figure out how to implement this as it requires a vector as the second argument.

If it helps, once I have the solution s.t. A * B^-1 = C, i only need to know the value for one row of the matrix C. The matrices will be roughly 1000×1000 to 1500×1500.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:04:26+00:00Added an answer on June 8, 2026 at 11:04 pm

    Actually 1000×1000 matrices are not that large. You can compute the inverse of such a matrix using numpy.linalg.inv(B) in less than 1 second on a modern desktop computer.

    But you can be much more efficient if you rewrite your problem taking into account the fact that you only need one row of C (this is actually very often the case).

    Let us write d_i = [0 0 0 … 0 1 0 … 0 ], a vector with only one one on the i-th element.
    You can write, if ^t denotes the transpose :

    AB^-1 = C <=> A = CB <=> A^t = B^t C^t
    

    For the i-th row :

    A^t d_i = B^t C^t d_i <=> a_i = B^t c_i
    

    So you have a linear inverse problem which can be solved using numpy.linalg.solve

    ci = np.linalg.solve(B.T, a[i])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the most efficient (fastest) way to simultaneously read in two large files
I have two very large matrices (60x25000) and I'd like to compute the correlation
I have two large (~100 GB) text files that must be iterated through simultaneously.
1) My question is that, when i have two large table which cannot be
I have two databases in SQL2k5: one that holds a large amount of static
I have two T-SQL scalar functions that both perform calculations over large sums of
I face the following problem. I have two large tables with about 80.000 records
I have two large MySQL databases with identical schemas that I want to merge.
We have two large solution files that we would like to merge into a
I have a varray full of triangles that make a large square. I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.