init
This commit is contained in:
45
worker/src/main/java/com/example/matrix/model/Matrix.java
Normal file
45
worker/src/main/java/com/example/matrix/model/Matrix.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.example.matrix.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Matrix {
|
||||
private int[][] data;
|
||||
private int rows;
|
||||
private int cols;
|
||||
|
||||
public Matrix(int rows, int cols) {
|
||||
this.rows = rows;
|
||||
this.cols = cols;
|
||||
this.data = new int[rows][cols];
|
||||
}
|
||||
|
||||
// Метод для заполнения матрицы случайными значениями
|
||||
public void fillRandom(int min, int max) {
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < cols; j++) {
|
||||
data[i][j] = min + (int) (Math.random() * (max - min + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Получение подматрицы (части матрицы)
|
||||
public Matrix getSubMatrix(int startRow, int endRow) {
|
||||
if (startRow < 0 || endRow > rows || startRow >= endRow) {
|
||||
throw new IllegalArgumentException("Invalid row range");
|
||||
}
|
||||
|
||||
int subRows = endRow - startRow;
|
||||
Matrix subMatrix = new Matrix(subRows, cols);
|
||||
|
||||
for (int i = 0; i < subRows; i++) {
|
||||
System.arraycopy(data[startRow + i], 0, subMatrix.data[i], 0, cols);
|
||||
}
|
||||
|
||||
return subMatrix;
|
||||
}
|
||||
}
|
||||
22
worker/src/main/java/com/example/matrix/model/MinResult.java
Normal file
22
worker/src/main/java/com/example/matrix/model/MinResult.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.example.matrix.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MinResult {
|
||||
private int minValue;
|
||||
private int row;
|
||||
private int col;
|
||||
private long processingTimeMs;
|
||||
|
||||
public MinResult(int minValue) {
|
||||
this.minValue = minValue;
|
||||
this.row = -1;
|
||||
this.col = -1;
|
||||
this.processingTimeMs = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user