Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freddiehaddad/matrix
Multithreaded Matrix Rotator written in Go.
https://github.com/freddiehaddad/matrix
concurrency concurrent-programming go golang leetcode leetcode-go leetcode-golang leetcode-solution multithreading
Last synced: 16 days ago
JSON representation
Multithreaded Matrix Rotator written in Go.
- Host: GitHub
- URL: https://github.com/freddiehaddad/matrix
- Owner: freddiehaddad
- Created: 2024-02-13T04:14:22.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-02-16T03:48:18.000Z (12 months ago)
- Last Synced: 2025-01-03T03:48:42.407Z (24 days ago)
- Topics: concurrency, concurrent-programming, go, golang, leetcode, leetcode-go, leetcode-golang, leetcode-solution, multithreading
- Language: Go
- Homepage: https://leetcode.com/problems/rotate-image/?envType=study-plan-v2&envId=top-interview-150
- Size: 2.93 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Multithreaded Matrix Rotation
Program that performs a matrix rotation using multithreading.
The rotation works by evaluating the matrix as a set of squares with one
surrounding the other such that the inner square is the smallest and the outer
square is the largest. For each of the squares a thread is created that will
create additional threads for performing the rotation of sets of four values
equidistant from each other.Consider the following matrix:
```text
1 2 3
4 5 6
7 8 9
```The matrix is made up of two squares. The inner square is a 1x1 matrix with the
single value 5 and the outer square is the remaining numbers. The outer square
thread will spawn two threads. One will rotate the corner values *{1, 3, 9, 7}*
and the other will rotate *{2, 6, 8, 4}*. For each square the number of rotation
sets is equal to one less than the length of one side. In other words, for a
square of length three, only two rotations are needed.For another example, consider the following matrix:
```text
A B C D E F
T a b c d G
S l 0 1 e H
R k 3 2 f I
Q j i h g J
P O N M L K
```Here, imagine three nested squares. One Go routine will spawn per square. For
each square of length *n*, *n-1* threads are spawned to handle the rotation of
four equidistant points. Example rotation sets include *{A, F, K, P}*, *{C, H,
M, R}*, *{c, f, i, l}*, and *{0, 1, 2, 3}*.