Example #1
0
 def test_superlu_dlamch_i386_nan(self):
     # SuperLU 4.3 calls some functions returning floats without
     # declaring them. On i386@linux call convention, this fails to
     # clear floating point registers after call. As a result, NaN
     # can appear in the next floating point operation made.
     #
     # Here's a test case that triggered the issue.
     n = 8
     d = np.arange(n) + 1
     A = spdiags((d, 2 * d, d[::-1]), (-3, 0, 5), n, n)
     A = A.astype(np.float32)
     spilu(A)
     A = A + 1j * A
     B = A.A
     assert_(not np.isnan(B).any())
Example #2
0
 def test_superlu_dlamch_i386_nan(self):
     # SuperLU 4.3 calls some functions returning floats without
     # declaring them. On i386@linux call convention, this fails to
     # clear floating point registers after call. As a result, NaN
     # can appear in the next floating point operation made.
     #
     # Here's a test case that triggered the issue.
     n = 8
     d = np.arange(n) + 1
     A = spdiags((d, 2*d, d[::-1]), (-3, 0, 5), n, n)
     A = A.astype(np.float32)
     spilu(A)
     A = A + 1j*A
     B = A.A
     assert_(not np.isnan(B).any())
Example #3
0
 def test_spilu_smoketest(self):
     # Check that spilu works at all
     x = random.rand(self.n)
     lu = spilu(self.A, drop_tol=1e-2, fill_factor=5)
     r = self.A * lu.solve(x)
     assert_(abs(x - r).max() < 1e-2)
     assert_(abs(x - r).max() > 1e-5)
 def test_spilu_smoketest(self):
     # Check that spilu works at all
     x = random.rand(self.n)
     lu = spilu(self.A, drop_tol=1e-2, fill_factor=5)
     r = self.A*lu.solve(x)
     assert_(abs(x - r).max() < 1e-2)
     assert_(abs(x - r).max() > 1e-5)
 def test_spilu_smoketest(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore", category=SparseEfficiencyWarning)
         # Check that spilu works at all
         x = random.rand(self.n)
         lu = spilu(self.A, drop_tol=1e-2, fill_factor=5)
         r = self.A * lu.solve(x)
         assert_(abs(x - r).max() < 1e-2)
         assert_(abs(x - r).max() > 1e-5)
 def test_spilu_smoketest(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore", category=SparseEfficiencyWarning)
         # Check that spilu works at all
         x = random.rand(self.n)
         lu = spilu(self.A, drop_tol=1e-2, fill_factor=5)
         r = self.A * lu.solve(x)
         assert_(abs(x - r).max() < 1e-2)
         assert_(abs(x - r).max() > 1e-5)
Example #7
0
    def test_spilu_drop_rule(self):
        # Test passing in the drop_rule argument to spilu.
        A = identity(2)

        rules = [
            b'basic,area'.decode('ascii'),  # unicode
            b'basic,area',  # ascii
            [b'basic', b'area'.decode('ascii')]
        ]
        for rule in rules:
            # Argument should be accepted
            assert_(isinstance(spilu(A, drop_rule=rule), SuperLU))
Example #8
0
    def test_spilu_drop_rule(self):
        # Test passing in the drop_rule argument to spilu.
        A = identity(2)

        rules = [
            b'basic,area'.decode('ascii'),  # unicode
            b'basic,area',  # ascii
            [b'basic', b'area'.decode('ascii')]
        ]
        for rule in rules:
            # Argument should be accepted
            assert_(isinstance(spilu(A, drop_rule=rule), SuperLU))
Example #9
0
    def test_bad_inputs(self):
        A = self.A.tocsc()

        assert_raises(ValueError, splu, A[:, :4])
        assert_raises(ValueError, spilu, A[:, :4])

        for lu in [splu(A), spilu(A)]:
            b = random.rand(42)
            B = random.rand(42, 3)
            BB = random.rand(self.n, 3, 9)
            assert_raises(ValueError, lu.solve, b)
            assert_raises(ValueError, lu.solve, B)
            assert_raises(ValueError, lu.solve, BB)
            assert_raises(TypeError, lu.solve, b.astype(np.complex64))
            assert_raises(TypeError, lu.solve, b.astype(np.complex128))
Example #10
0
    def test_bad_inputs(self):
        A = self.A.tocsc()

        assert_raises(ValueError, splu, A[:,:4])
        assert_raises(ValueError, spilu, A[:,:4])

        for lu in [splu(A), spilu(A)]:
            b = random.rand(42)
            B = random.rand(42, 3)
            BB = random.rand(self.n, 3, 9)
            assert_raises(ValueError, lu.solve, b)
            assert_raises(ValueError, lu.solve, B)
            assert_raises(ValueError, lu.solve, BB)
            assert_raises(TypeError, lu.solve,
                          b.astype(np.complex64))
            assert_raises(TypeError, lu.solve,
                          b.astype(np.complex128))