Welcome to the Matrix Multiplication repository! This repository contains three implementations of matrix multiplication algorithms in C. Each file showcases a different approach: using BLAS, a standard matrix multiplication, and Strassen's algorithm. Explore each implementation to understand the differences and efficiencies in matrix multiplication techniques.
- BLAS Implementation (
blas.c
) - Standard Matrix Multiplication (
mat_mul.c
) - Strassen's Algorithm (
stressen.c
)
The blas.c
file demonstrates matrix multiplication using the BLAS (Basic Linear Algebra Subprograms) library.
-
Matrix Size: 1000 x 1000
-
Library Used: BLAS for optimized matrix operations.
-
Function: Uses
cblas_dgemm
to perform matrix multiplication. -
- Execution:
gcc -o blas blas.c -lcblas -llapacke ./blas
A classic approach to matrix multiplication using a straightforward triple nested loop.
-
Key Features:
- Implements standard matrix multiplication.
- Handles matrix size of 1000 x 1000.
- Measures and prints computation time.
-
Execution:
gcc -o mat_mul mat_mul.c ./mat_mul
An advanced implementation using Strassen's algorithm for matrix multiplication, which is more efficient for larger matrices.
-
Key Features:
- Uses Strassen's divide-and-conquer approach.
- Includes helper functions for matrix operations: add_matrices, subtract_matrices, split_matrix, join_matrices.
- Handles matrix size of 1000 x 1000.
- Measures and prints computation time.
-
Execution:
gcc -o stressen stressen.c ./stressen
Feel free to customize this further based on your needs!