Ejemplo n.º 1
0
 def test_scaled_expm_multiply_single_timepoint(self):
     np.random.seed(1234)
     t = 0.1
     n = 5
     k = 2
     A = np.random.randn(n, n)
     B = np.random.randn(n, k)
     observed = _expm_multiply_simple(A, B, t=t)
     expected = scipy.linalg.expm(t*A).dot(B)
     assert_allclose(observed, expected)
 def test_scaled_expm_multiply_single_timepoint(self):
     np.random.seed(1234)
     t = 0.1
     n = 5
     k = 2
     A = np.random.randn(n, n)
     B = np.random.randn(n, k)
     observed = _expm_multiply_simple(A, B, t=t)
     expected = scipy.linalg.expm(t * A).dot(B)
     assert_allclose(observed, expected)
Ejemplo n.º 3
0
 def test_scaled_expm_multiply(self):
     np.random.seed(1234)
     n = 40
     k = 3
     nsamples = 10
     for i in range(nsamples):
         for t in (0.2, 1.0, 1.5):
             A = scipy.linalg.inv(np.random.randn(n, n))
             B = np.random.randn(n, k)
             observed = _expm_multiply_simple(A, B, t=t)
             expected = np.dot(scipy.linalg.expm(t*A), B)
             assert_allclose(observed, expected)
Ejemplo n.º 4
0
 def test_scaled_expm_multiply(self):
     np.random.seed(1234)
     n = 40
     k = 3
     nsamples = 10
     for i in range(nsamples):
         for t in (0.2, 1.0, 1.5):
             A = scipy.linalg.inv(np.random.randn(n, n))
             B = np.random.randn(n, k)
             observed = _expm_multiply_simple(A, B, t=t)
             expected = np.dot(scipy.linalg.expm(t*A), B)
             assert_allclose(observed, expected)
Ejemplo n.º 5
0
 def test_scaled_expm_multiply_single_timepoint(self):
     np.random.seed(1234)
     t = 0.1
     n = 5
     k = 2
     A = np.random.randn(n, n)
     B = np.random.randn(n, k)
     observed = _expm_multiply_simple(A, B, t=t)
     expected = sp_expm(t * A).dot(B)
     assert_allclose(observed, expected)
     observed = estimated(_expm_multiply_simple)(aslinearoperator(A),
                                                 B,
                                                 t=t)
     assert_allclose(observed, expected)
Ejemplo n.º 6
0
 def test_scaled_expm_multiply(self):
     np.random.seed(1234)
     n = 40
     k = 3
     nsamples = 10
     for i, t in product(range(nsamples), [0.2, 1.0, 1.5]):
         with np.errstate(invalid='ignore'):
             A = scipy.linalg.inv(np.random.randn(n, n))
             B = np.random.randn(n, k)
             observed = _expm_multiply_simple(A, B, t=t)
             expected = np.dot(sp_expm(t * A), B)
             assert_allclose(observed, expected)
             observed = estimated(_expm_multiply_simple)(
                 aslinearoperator(A), B, t=t)
             assert_allclose(observed, expected)