![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
程序学习
文章平均质量分 58
DeepLe_NN
凡是以往,皆成序章
展开
-
Python 的输出矩阵的一些常用设置
1. 矩阵的运算 矩阵的幂 import numpy as np from scipy.linalg import expm print(expm(H)) 矩阵的乘法 np.dot(a,b) 求解矩阵的行列式 numpy.linalg.eig() 2. 矩阵输出 np.set_printoptions(linewidth=300) #输出在屏幕中宽度为 300 np.set_printoptions(suppress=True) #抑制数值科学计数法表达 np.set_print原创 2022-01-12 12:05:02 · 2797 阅读 · 0 评论 -
【程序学习篇】Python yield 使用
1. 背景 在看量子线路的简单示例时(用 Python 写个玩具级量子计算机 (1) - 知乎),发现生成希尔伯特空间的简单代码, def hilbert_space(nbit=5): nspace = 2**nbit for i in range(nspace): #bin(7) = 0b100 binary = bin(i)[2:] nzeros = nbit - len(binary) yield '0'*nzero原创 2021-12-26 13:04:25 · 385 阅读 · 0 评论