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 8225125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:18:33+00:00 2026-06-07T15:18:33+00:00

I have written programs in C++, Python and Java for matrix multiplication and tested

  • 0

I have written programs in C++, Python and Java for matrix multiplication and tested their speed for multiplying two 2000 x 2000 matrices (see post). The standard ikj-implentation – which is in enter image description here – took:

  • C++: 15 seconds (Source)
  • Python: 6 minutes 13 seconds (Source)

Now I have implemented the Strassen algorithm for matrix multiplication – which is in enter image description here – in Python and C++ as it was on wikipedia. These are the times I’ve got:

  • C++: 45 minutes (Source)
  • Python: Killed after 10 hours (Source)

Why is Strassen matrix multiplication so much slower than standard matrix multiplication?


Ideas:

  • Some cache effects
  • Implementation:
    • error (the resulting 2000 x 2000 matrix is correct)
    • null-multiplication (shouldn’t be that important for 2000 x 2000 -> 2048 x 2048)

This is especially astonishing, as it seems to contradict the experiences of others:

  • Why is my Strassen Matrix multiplier so fast?
  • Matrix multiplication: Strassen vs. Standard – Strassen was also slower for him, but it was at least in the same order of magnitude.

edit: The reason why Strassen matrix multiplication was slower in my case, were:

  • I made it fully recursive (see tam)
  • I had two functions strassen and strassenRecursive. The first one resized the matrix to a power of two, if required and called the second one. But strassenRecursive didn’t recursively call itself, but strassen.
  • 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-07T15:18:35+00:00Added an answer on June 7, 2026 at 3:18 pm

    The basic problem is that you’re recursing down to a leaf size of 1 with your strassen implementaiton. Strassen’s algorithm has a better Big O complexity, but constants do matter in reality, which means in reality you’re better off with a standard n^3 matrix multiplication for smaller problem sizes.

    So to greatly improve your program instead of doing:

    if (tam == 1) {
            C[0][0] = A[0][0] * B[0][0];
            return;
        }
    

    use if (tam == LEAF_SIZE) // iterative solution here. LEAF_SIZE should be a constant that you have to experimentally determine for your given architecture. Depending on the architecture it may be larger or smaller – there are architectures where the constant factors for strassen are so large that it’s basically always worse than a simpler n^3 implementation for sensible matrix sizes. It all depends.

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

Sidebar

Related Questions

I'm using Python 3. I've written two programs. One loops through a csv file
I'm kinda' new to python, but I have already written many programs including some
I have written my program in python. It is written across seven files and
I have written a Python program to find the carrier of a cell phone
Well, i have written a simple python program that parses HTML with HTMLParser. Here
I have written quite a few Ruby programs, but if I need to show
I have written a small makefile for a few simple C programs that compiles
I have written a small Python application where I use PyGame for displaying some
I have to read a binary file in python. This is first written by
I have written a program in Tkinter (Python 2.7), a scrabblehelper in Norwegian which

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.