def __div__(a, b): if isinstance(a, Hamiltonian): if isinstance(b, Hamiltonian): raise NotImplementedError c = a.copy(dtype=get_dtype(b, other=a.dtype)) c /= b elif isinstance(b, Hamiltonian): c = b.copy(dtype=get_dtype(a, other=b.dtype)) c._data = a / c._data return c
def __rsub__(a, b): if isinstance(b, Hamiltonian): c = b.copy(dtype=get_dtype(a, other=b.dtype)) c._data += -1 * a._data else: c = b + (-1) * a return c
def __rpow__(a, b): if isinstance(b, SparseCSR): raise NotImplementedError c = a.copy(dtype=get_dtype(b, other=a.dtype)) c._D[...] = b**c._D[...] return c
def __truediv__(a, b): if isinstance(b, SparseCSR): raise NotImplementedError c = a.copy(dtype=get_dtype(b, other=a.dtype)) c._D /= b return c
def __rpow__(a, b): if isinstance(b, SparseCSR): raise NotImplementedError c = a.copy(dtype=get_dtype(b, other=a.dtype)) c._data = b ** c._data return c
def __pow__(a, b): if isinstance(b, Hamiltonian): raise NotImplementedError c = a.copy(dtype=get_dtype(b, other=a.dtype)) c **= b return c
def __rpow__(a, b): c = a.copy(dtype=get_dtype(b, other=a.dtype)) c._data = b**c._data return c
def __truediv__(a, b): if isinstance(b, Hamiltonian): raise NotImplementedError c = a.copy(dtype=get_dtype(b, other=a.dtype)) c /= b return c
def __rdiv__(a, b): c = b.copy(dtype=get_dtype(a, other=b.dtype)) c /= a return c
def __div__(a, b): c = a.copy(dtype=get_dtype(b, other=a.dtype)) c /= b return c
def __sub__(a, b): c = a.copy(dtype=get_dtype(b, other=a.dtype)) c -= b return c
def __add__(a, b): c = a.copy(dtype=get_dtype(b, other=a.dtype)) c += b return c
def test_get_dtype1(): assert np.int32 == get_dtype(1) assert np.int64 == get_dtype(1, int=np.int64)
def __pow__(a, b): c = a.copy(dtype=get_dtype(b, other=a.dtype)) c **= b return c
def test_get_dtype1(self): assert_equal(np.int32, get_dtype(1)) assert_equal(np.int64, get_dtype(1, int=np.int64))