miércoles, 27 de diciembre de 2023

row sorting

import numpy as np

matrix = np.array([
    [0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0],
    [0, 0, 1, 0, 0],
    [0, 0, 0, 0, 1]
])

num_rows = matrix.shape[0]

identity = np.eye(num_rows)

for i in range(len(matrix)):
    for j in range(len(identity)):
        product = matrix[i] * identity[j]
        if np.any(product > 0):
            print(f"{i+1} > {j+1}")


No hay comentarios:

Publicar un comentario