def _represent_NumberOp(self, basis, **options):
ndim_info = options.get('ndim', 4)
format = options.get('format', 'sympy')
options['spmatrix'] = 'lil'
vector = matrix_zeros(1, ndim_info, **options)
if isinstance(self.n, Integer):
if self.n >= ndim_info:
return ValueError("N-Dimension too small")
if format == 'scipy.sparse':
vector[0, int(self.n)] = 1.0
vector = vector.tocsr()
elif format == 'numpy':
vector[0, int(self.n)] = 1.0
else:
vector[0, self.n] = Integer(1)
return vector
else:
return ValueError("Not Numerical State")
评论列表
文章目录