Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #8
0
 def __rpow__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c._data = b**c._data
     return c
Example #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
Example #10
0
 def __rdiv__(a, b):
     c = b.copy(dtype=get_dtype(a, other=b.dtype))
     c /= a
     return c
Example #11
0
 def __div__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c /= b
     return c
Example #12
0
 def __sub__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c -= b
     return c
Example #13
0
 def __add__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c += b
     return c
Example #14
0
def test_get_dtype1():
    assert np.int32 == get_dtype(1)
    assert np.int64 == get_dtype(1, int=np.int64)
Example #15
0
 def __pow__(a, b):
     c = a.copy(dtype=get_dtype(b, other=a.dtype))
     c **= b
     return c
Example #16
0
 def test_get_dtype1(self):
     assert_equal(np.int32, get_dtype(1))
     assert_equal(np.int64, get_dtype(1, int=np.int64))
Example #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