import numpy as np
# 假设我们有一个一维数组x1
x1 = np.array([1, 2, 3])
# 使用np.tile函数
xt = np.tile(x1, 4) # 将x1重复4次
print("使用np.tile:")
print(xt)
# 输出: 使用np.tile:
# [1 2 3 1 2 3 1 2 3 1 2 3]
# 使用.repeat方法
xr = x1.repeat(4) # 将x1中的每个元素重复4次
print("\n使用.repeat:")
print(xr)
# 输出: 使用.repeat:
# [1 1 1 1 2 2 2 2 3 3 3 3]