2025-04-03 01:48:49 +08:00

18 lines
572 B
Python

"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/45966
"""
import numpy as np
import time
n_array = np.concatenate((np.arange(100, 1000, 100),
np.arange(1000, 10000, 1000),
np.arange(10000, 60000, 10000)))
for n in n_array:
A = np.random.rand(n, n)
start_time = time.time()
inv_A = np.linalg.inv(A)
inv_time = time.time() - start_time
print(f"n = {n} 的计算时间: {inv_time:.6f}")