Spaces:
Sleeping
Sleeping
File size: 722 Bytes
97abee9 846d284 52e1813 846d284 0cccd06 52e1813 846d284 0cccd06 52e1813 846d284 0cccd06 52e1813 bc5bc31 97abee9 | 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 | from algorithms import brute_submatrix_max, fft_submatrix_max, kidane_max_submatrix
import numpy as np
from typing import Tuple, Any
# Define type aliases for clarity
SlicePair = Tuple[slice, slice]
Numeric = Any # Matches algorithms.py
# Set matrix dimensions (rows, columns)
M: int = 64
N: int = 64
# Generate MxN matrix of random integers
A: np.ndarray = np.random.randint(-100, 100, size=(M, N))
# Test each algorithm
# output format: maximizing subarray slice specification, maximum sum
# value, running time
print()
print("Running brute force algorithm:")
print(brute_submatrix_max(A))
print("Running FFT algorithm:")
print(fft_submatrix_max(A))
print("Running Kidane algorithm:")
print(kidane_max_submatrix(A))
|