-
Notifications
You must be signed in to change notification settings - Fork 0
/
f1.js
41 lines (34 loc) · 934 Bytes
/
f1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// імпортуємо клас для отримання данних (не використовуємо) та для відправки даних
const { workerData, parentPort } = require("worker_threads");
// імпортуємо бібліотеку для обчислювання
const { multiply, add } = require("mathjs");
// задаємо та обчислюємо матриці та вектори
const mo = [
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1],
];
const me = [
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1],
];
const a = [
[1, 1],
[1, 1],
[1, 1],
[1, 1],
];
const b = [
[1, 1],
[1, 1],
[1, 1],
[1, 1],
];
firstMove = multiply(mo, me);
secondMove = multiply(firstMove, b);
thirdMove = add(a, secondMove);
// відправляємо ім'я та дані у головну функцію
parentPort.postMessage({ name: "F1 (C)", value: thirdMove });