Exemple #1
0
 def test_padecases_dtype_sparse_float(self):
     # float32 and complex64 lead to errors in spsolve/UMFpack
     dtype = np.float64
     with warnings.catch_warnings():
         warnings.simplefilter("ignore", category=SparseEfficiencyWarning)
         for scale in [1e-2, 1e-1, 5e-1, 1, 10]:
             a = scale * speye(3, 3, dtype=dtype, format='csc')
             e = exp(scale) * eye(3, dtype=dtype)
             exact_onenorm = _expm(a, use_exact_onenorm=True).toarray()
             inexact_onenorm = _expm(a, use_exact_onenorm=False).toarray()
             assert_array_almost_equal_nulp(exact_onenorm, e, nulp=100)
             assert_array_almost_equal_nulp(inexact_onenorm, e, nulp=100)
Exemple #2
0
 def test_padecases_dtype_sparse_float(self):
     # float32 and complex64 lead to errors in spsolve/UMFpack
     dtype = np.float64
     with warnings.catch_warnings():
         warnings.simplefilter("ignore", category=SparseEfficiencyWarning)
         for scale in [1e-2, 1e-1, 5e-1, 1, 10]:
             a = scale * speye(3, 3, dtype=dtype, format='csc')
             e = exp(scale) * eye(3, dtype=dtype)
             exact_onenorm = _expm(a, use_exact_onenorm=True).toarray()
             inexact_onenorm = _expm(a, use_exact_onenorm=False).toarray()
             assert_array_almost_equal_nulp(exact_onenorm, e, nulp=100)
             assert_array_almost_equal_nulp(inexact_onenorm, e, nulp=100)
 def test_padecases_dtype_sparse_float(self):
     # float32 and complex64 lead to errors in spsolve/UMFpack
     dtype = np.float64
     for scale in [1e-2, 1e-1, 5e-1, 1, 10]:
         a = scale * speye(3, 3, dtype=dtype, format='csc')
         e = exp(scale) * eye(3, dtype=dtype)
         with suppress_warnings() as sup:
             sup.filter(SparseEfficiencyWarning,
                        "Changing the sparsity structure of a csc_matrix is expensive.")
             exact_onenorm = _expm(a, use_exact_onenorm=True).toarray()
             inexact_onenorm = _expm(a, use_exact_onenorm=False).toarray()
         assert_array_almost_equal_nulp(exact_onenorm, e, nulp=100)
         assert_array_almost_equal_nulp(inexact_onenorm, e, nulp=100)
Exemple #4
0
 def test_padecases_dtype_sparse_float(self):
     # float32 and complex64 lead to errors in spsolve/UMFpack
     dtype = np.float64
     for scale in [1e-2, 1e-1, 5e-1, 1, 10]:
         a = scale * speye(3, 3, dtype=dtype, format='csc')
         e = exp(scale) * eye(3, dtype=dtype)
         with suppress_warnings() as sup:
             sup.filter(SparseEfficiencyWarning,
                        "Changing the sparsity structure of a csc_matrix is expensive.")
             exact_onenorm = _expm(a, use_exact_onenorm=True).toarray()
             inexact_onenorm = _expm(a, use_exact_onenorm=False).toarray()
         assert_array_almost_equal_nulp(exact_onenorm, e, nulp=100)
         assert_array_almost_equal_nulp(inexact_onenorm, e, nulp=100)
Exemple #5
0
def matrix_exp(A, use_exact_onenorm):
    k = 5
    import scipy.sparse.linalg.matfuncs as mf
    return mf._expm(k*A, use_exact_onenorm)**(1/k)