使用Numpy生成大小为100的二进制非对称矩阵的代码如下:
import numpy as np
size = 100
# Generate a random binary matrix of size (size, size)
binary_matrix = np.random.randint(2, size=(size, size))
# Generate a random permutation of integers from 0 to size-1
perm = np.random.permutation(size)
# Create an empty matrix of size (size, size)
matrix = np.zeros((size, size))
# Fill in the matrix with values from the binary matrix using the permutation
for i in range(size):
matrix[i,:] = binary_matrix[perm[i],:]
print(matrix)
该代码使用Numpy生成大小为100的随机二进制矩阵。然后,它生成0到99的随机排列,并使用此排列从二进制矩阵中提取行,并将其放入结果矩阵中。这样可以得到一个大小为100的二进制非对称矩阵。