Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [1.3.0] - 2026-03-20

### Added

- Matrix multiplication report

### Fixed

- `md` report generation - images and code blocks

## [1.2.0] - 2026-03-19

### Added
Expand Down
7 changes: 5 additions & 2 deletions generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def md_to_pdf(md_path: Path, pdf_path: Path):
with open(md_path, encoding="utf-8") as f:
md_text = f.read()

html = markdown.markdown(md_text)
HTML(string=html).write_pdf(str(pdf_path))
html = markdown.markdown(
md_text,
extensions=["fenced_code", "codehilite"],
)
HTML(string=html, base_url=md_path.parent).write_pdf(str(pdf_path))


def resolve_module_path(module_name):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "matrix_calculus"
version = "1.2.0"
version = "1.3.0"
description = "Matrix calculus toolkit"
requires-python = ">=3.10"
dependencies = ["numpy", "seaborn", "matplotlib", "weasyprint", "markdown"]
Expand Down
Binary file added reports/imgs/execution_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reports/imgs/image_time_logx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reports/imgs/time_benchmark.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 123 additions & 0 deletions reports/matrix_multiplication_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Mnożenie Macierzy

*Autorzy: Maja Byrecka, Michał Kowalczyk*

## Tradycyjne mnożenie macierzy

### Pseudokod

Mnożenie macierzy kwadratowych o rozmiarach `SIZE x SIZE`

```
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
for (k = 0; k < SIZE; k++) {
s = s + m_1[i][k]*m_2[k][j];
}
res[i][j] = s;
s = 0;
}
}
return res;
```

### Złożoność

Tradycyjne mnożenie macierzy posiada ogólną złożoność n^3

Ilość operacji podczas mnożenia macierzy k x k:

* Mnożenia: k^3
* Dodawania: k^2 * (k-1)
* Dzielenia: 0
* Odejmowania: 0

Algorytm nie wymaga alokacji dodatkowej pamięci (poza pamięcią na macierz wynikową), w trakcie wykonywania operacji.

## Algorytm Strassena

### Pseudokod

```
Strassen – funkcja główna z dopełnieniem do potęgi 2
Input: A ∈ Rn×n, B ∈ Rn×n
Output: C = A · B ∈ Rn×n

1 if (A i B nie są kwadratowe lub dim(A)̸ = dim(B)) then
2 return błąd
3 n ← dim(A)
4 if n = 1 then
5 return [[A11 · B11]]
6 m ← NextPowerOf2(n)
7 if m = n then
8 return StrassenRec(A, B, n)
9 A′ ← Pad(A, m)
10 B′ ← Pad(B, m)
11 C′ ← StrassenRec(A′, B′, m)
12 return Unpad(C′, n)
```

## Połączenie metod

### Pseudokod

```
if SIZE<=2 {
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
for (k = 0; k < SIZE; k++) {
s = s + m_1[i][k]*m_2[k][j];
}
res[i][j] = s;
s = 0;
}
}
return res;
} else {
k = SIZE / 2

# Podział macierzy na bloki
podziel m_1 na: A11, A12, A21, A22 (każda k x k)
podziel m_2 na: B11, B12, B21, B22 (każda k x k)

# Rekurencyjne obliczenie 7 iloczynów
M1 = Strassen(A11 + A22, B11 + B22)
M2 = Strassen(A21 + A22, B11)
M3 = Strassen(A11, B12 - B22)
M4 = Strassen(A22, B21 - B11)
M5 = Strassen(A11 + A12, B22)
M6 = Strassen(A21 - A11, B11 + B12)
M7 = Strassen(A12 - A22, B21 + B22)

# Obliczenie bloków wynikowych
C11 = M1 + M4 - M5 + M7
C12 = M3 + M5
C21 = M2 + M4
C22 = M1 - M2 + M3 + M6

# Złożenie macierzy wynikowej
wstaw C11, C12, C21, C22 do odpowiednich ćwiartek macierzy res

return res;
}
```

## Porównanie Metod

<img src="imgs/time_benchmark.jpeg" style="max-width:100%; height:auto;" />

<img src="imgs/image_time_logx.png" style="max-width:100%; height:auto;" />

<img src="imgs/execution_time.png" style="max-width:100%; height:auto;" />


Na podstawie przedstawionych wykresów można zauważyć, że dla badanych rozmiarów macierzy szybsze jest mnożenie tradycyjne. Jednocześnie widoczna jest tendencja wskazująca, że wraz ze wzrostem n algorytm Strassena powinien stać się korzystniejszy, a dla bardzo dużych n może wykonywać się szybciej od podejścia klasycznego. Oba algorytmy posiadają zbliżoną złożoność obliczeniową.

---

Wykonanie:

* Język: Python3
* Podział zadań:
* Tradycyjne mnożenie macierzy, testy, analizy - Maja Byrecka
* Metoda Strassena, wykresy, analizy - Michał Kowalczyk
Loading
Loading