Beispiel #1
0
def allclose(a, b, rtol=1.0e-5, atol=1.0e-8):
    if isinstance(a, Matrix):
        a = a.array
    else:
        a = np.asarray(a)
    if isinstance(b, Matrix):
        b = b.array
    else:
        b = np.asarray(b)
    return np.allclose(a, b, rtol=rtol, atol=atol)
Beispiel #2
0
 def __init__(self, array, dtype=None):
     assert array is not None
     array = asnumpy(array)
     if dtype == backend.real_dtype:
         # forbid unchecked casting
         assert not np.iscomplexobj(array)
     if dtype is None:
         if np.iscomplexobj(array):
             dtype = backend.complex_dtype
         else:
             dtype = backend.real_dtype
     self.array: np.ndarray = np.asarray(array, dtype=dtype)
     self.original_shape = self.array.shape
     self.sigmaqn = None
     backend.running = True
Beispiel #3
0
 def astype(self, dtype):
     assert not (self.dtype == backend.complex_dtype
                 and dtype == backend.real_dtype)
     self.array = np.asarray(self.array, dtype=dtype)
     return self