Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
 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
Beispiel #5
0
 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
Beispiel #6
0
 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
Beispiel #7
0
 def __pow__(a, b):
     if isinstance(b, Hamiltonian):
         raise NotImplementedError
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c **= b
     return c
Beispiel #8
0
 def __rpow__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c._data = b**c._data
     return c
Beispiel #9
0
 def __truediv__(a, b):
     if isinstance(b, Hamiltonian):
         raise NotImplementedError
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c /= b
     return c
Beispiel #10
0
 def __rdiv__(a, b):
     c = b.copy(dtype=get_dtype(a, other=b.dtype))
     c /= a
     return c
Beispiel #11
0
 def __div__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c /= b
     return c
Beispiel #12
0
 def __sub__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c -= b
     return c
Beispiel #13
0
 def __add__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c += b
     return c
Beispiel #14
0
def test_get_dtype1():
    assert np.int32 == get_dtype(1)
    assert np.int64 == get_dtype(1, int=np.int64)
Beispiel #15
0
 def __pow__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c **= b
     return c
Beispiel #16
0
 def test_get_dtype1(self):
     assert_equal(np.int32, get_dtype(1))
     assert_equal(np.int64, get_dtype(1, int=np.int64))
Beispiel #17
0
 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