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

  • SEARCH
  • Home
  • 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 7922525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:59:16+00:00 2026-06-03T16:59:16+00:00

I am working on an FEM project using Scipy. Now my problem is, that

  • 0

I am working on an FEM project using Scipy. Now my problem is, that
the assembly of the sparse matrices is too slow. I compute the
contribution of every element in dense small matrices (one for each
element). For the assembly of the global matrices I loop over all
small dense matrices and set the matrice entries the following way:

[i,j] = someList[k][l]
Mglobal[i,j] = Mglobal[i,j] + Mlocal[k,l]

Mglobal is a lil_matrice of appropriate size, someList maps the
indexing variables.

Of course this is rather slow and consumes most of the matrice
assembly time. Is there a better way to assemble a large sparse matrix
from many small dense matrices? I tried scipy.weave but it doesn’t
seem to work with sparse matrices

  • 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-03T16:59:18+00:00Added an answer on June 3, 2026 at 4:59 pm

    I posted my response to the scipy mailing list; stack overflow is a bit easier
    to access so I will post it here as well, albeit a slightly improved version.

    The trick is to use the IJV storage format. This is a trio of three arrays
    where the first one contains row indicies, the second has column indicies, and
    the third has the values of the matrix at that location. This is the best way
    to build finite element matricies (or any sparse matrix in my opinion) as access
    to this format is really fast (just filling an an array).

    In scipy this is called coo_matrix; the class takes the three arrays as an
    argument. It is really only useful for converting to another format (CSR os
    CSC) for fast linear algebra.

    For finite elements, you can estimate the size of the three arrays by something
    like

    size = number_of_elements * number_of_basis_functions**2
    

    so if you have 2D quadratics you would do number_of_elements * 36, for example.
    This approach is convenient because if you have local matricies you definitely
    have the global numbers and entry values: exactly what you need for building
    the three IJV arrays. Scipy is smart enough to throw out zero entries, so
    overestimating is fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a project that parses a log of events, and then updates a
I am working on some software that does a sparse matrix-vector multiply. The matrix
Working on a console application using Delphi 7, and have run into a problem.
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion
Working on calling a C function from my asm project. I'm trying to push
Working on an extension that use the new experimental devtools apis. How do you
Working on an old Kohana 2 project and I want to link two models.
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,

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.