Git Product home page Git Product logo

matrix_multiplication_python's Introduction

Matrix Multiplication Algorithms with Python from scratch

Jaeho Kim [email protected]

This is an implementation of matrix multiplication algorithm with python. The repository contains a report, code, and a jupyter file. All codes are in python

  1. Schoolbook Matrix multiplication
  2. Naive Divide and Conquer multiplication
  3. Strassen
  4. Strassen Optimized

Usage

To run the algorithm you should have a "input.txt" file in the directory where you are running the python scripts.

# Standard matrix multiplication
python schoolbook_multiplication.py
# Standard naive divide and conquer multiplication
python divide_and_conquer.py
# Standard Strassen 
python strassen_base.py
# Standard Strassen leaf size 4
python strassen_optimized_leaf4.py
# To compare everything and get time_comparison.csv
python all.py

There is also a Jupyter file to draw graphs.

Results

Time complexity for algorithms Time complexity for Strassens

Acknowledgement

It took me so long to figure out why Strassen takes longer implementation time than standard matrix multiplication even though it has a lower algorithm complexity. To answer this check stackoverflow.

Another article you can check out is here

For those who are just to lazy to check out, here is a simple answer. Our standard Strassen makes a recursive call until n equals to 1. This increases the constant time which in theory shouldn't be a problem. But you know, this isn't theory. Its real shiit! So it does matter in reality. We can opimize the time by calling the recusive call until n equals to 2,4,8 ~. Hope someone finds this useful.If I got it wrong please leave a comment on issue! would love to know

Please press star if this was helpful. Thank you

matrix_multiplication_python's People

Contributors

jaeho3690 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.