function printMatrix(a) {
let n = a.length;
let m = a[0].length;
for (let i = 0; i < n; i++) {
let row = '';
for (let j = 0; j < m; j++)
row += a[i][j].toFixed(2) + '\t';
console.log(row);
}
}
function gorizont(a) {
let matrix = new Array(8).fill(0).map(() => new Array(8).fill(0));
for (let i = 0; i < 8; i++) {
for (let f = 0; f < 4; f++) {
matrix[i][f] = (a[i][2 * f] + a[i][2 * f + 1]) / Math.sqrt(2);
matrix[i][f + 4] = (a[i][2 * f] - a[i][2 * f + 1]) / Math.sqrt(2);
}
}
return matrix;
}
function vertikal(a) {
let matrix = new Array(8).fill(0).map(() => new Array(8).fill(0));
for (let i = 0; i < 4; i++) {
for (let f = 0; f < 8; f++)
matrix[i][f] = (a[2 * i][f] + a[2 * i + 1][f]) / Math.sqrt(2);
}
for (let i = 0; i < 4; i++) {
for (let f = 0; f < 8; f++)
matrix[i + 4][f] = (a[2 * i][f] - a[2 * i + 1][f]) / Math.sqrt(2);
}
return matrix;
}
function r_vertikal(a) {
let matrix = new Array(8).fill(0).map(() => new Array(8).fill(0));
for (let f = 0; f < 8; f++) {
for (let i = 0; i < 4; i++) {
matrix[2 * i][f] = (a[i][f] + a[i + 4][f]) / Math.sqrt(2);
matrix[2 * i + 1][f] = (a[i][f] - a[i + 4][f]) / Math.sqrt(2);
}
}
return matrix;
}
function r_gorizont(a) {
let matrix = new Array(8).fill(0).map(() => new Array(8).fill(0));
for (let i = 0; i < 8; i++) {
for (let f = 0; f < 4; f++) {
matrix[i][2 * f] = (a[i][f] + a[i][f + 4]) / Math.sqrt(2);
matrix[i][2 * f + 1] = (a[i][f] - a[i][f + 4]) / Math.sqrt(2);
}
}
return matrix;
}
function qisqartirish(a) {
let matrix = new Array(8).fill(0).map(() => new Array(8).fill(0));
for (let i = 0; i < 8; i++) {
for (let f = 0; f < 8; f++) {
if (a[i][f] < 1 && a[i][f] > -1)
matrix[i][f] = 0;
else
matrix[i][f] = a[i][f];
}
}
return matrix;
}