QuanGuru (pronounced Kangaroo) is a Python library for numerical modelling of quantum systems. It is still under-development, and it consists of tools for numerical simulations of Quantum systems.
BSD 3-Clause "New" or "Revised" License
5
stars
7
forks
source link
change the way define defalut values for seedNum #239
except: # pylint: disable=bare-except # noqa: E722
opPow = _matPower(op(sparse), power)
return opPow
def randomH(dimension: int, sparse: bool = True, seedNum: list = [np.random.randint(0,63), np.random.randint(0,63)],
mean: float = 0.0, SD: float = 1.0, normalise: bool = True, symmetric: bool = True):
# TODO change the way define defalut values for seedNum
r"""
Creates a matrix with random complex number elements from normal (Gaussian) distribution
Parameters
----------
dimension : int
dimension of the Hilbert space
sparse : bool
if True(False), the returned Matrix type will be sparse(array)
seedNum: list[int, int]
set seedNum for random real and imaginary parts
if None, seedNum for both real and imaginary parts is randomly chosen
mean: float
mean of the normal distribution
SD: float
standard deviation of the normal distribution
norm: bool
if True(False), the returned matrix will be normalised(unnormalised)
symm: bool
if True(False), the returned matrix will be symmetrised(non-symmetrised)
Returns
-------
Matrix
random matrix operator
"""
# if seedNum==None:
# seedNum = [np.random.randint(0,63), np.random.randint(0,63)]
np.random.seed(seed=seedNum[0])
real = np.random.normal(loc=mean, scale=SD, size=[dimension,dimension])
np.random.seed(seed=seedNum[1])
imag = np.random.normal(loc=mean, scale=SD, size=[dimension,dimension])
val = real + 1j*imag
Hamiltonian = sp.csc_matrix(val, (dimension, dimension), dtype=complex)
if symmetric==True:
HT = Hamiltonian.transpose()
Hamiltonian = Hamiltonian + HT
if normalise==True:
Hamiltonian = Hamiltonian/norm(Hamiltonian)
return Hamiltonian if sparse else Hamiltonian.toarray()
seedNum = [np.random.randint(0,63), np.random.randint(0,63)]
https://github.com/CirQuS-UTS/QuanGuru/blob/b8b28072cce6b5de53b87e3346955e561c5adb9b/src/quanguru/QuantumToolbox/operators.py#L1015