예제 #1
0
def test_norm_correctness():
    from math import sqrt
    from proteus.LinearAlgebraTools import Mat
    from proteus.LinearAlgebraTools import l2Norm, l1Norm, lInfNorm, rmsNorm
    from proteus.LinearAlgebraTools import wl2Norm, wl1Norm, wlInfNorm
    from proteus.LinearAlgebraTools import energyNorm

    x = np.ones(2)
    h = np.ones(2)
    A = Mat(2, 2)
    A[0, 0] = 1
    A[1, 1] = 1

    test = npt.assert_almost_equal
    test.description = 'test_correctness_l1Norm'
    yield test, l1Norm(x), 2
    test.description = 'test_correctness_l2Norm'
    yield test, l2Norm(x), sqrt(2)
    test.description = 'test_correctness_lInfNorm'
    yield test, lInfNorm(x), 1
    test.description = 'test_correctness_rmsNorm'
    yield test, rmsNorm(x), 1
    test.description = 'test_correctness_wl1Norm'
    yield test, wl1Norm(x, h), 2
    test.description = 'test_correctness_wl2Norm'
    yield test, wl2Norm(x, h), sqrt(2)
    test.description = 'test_correctness_wlInfNorm'
    yield test, wlInfNorm(x, h), 1
    test.description = 'test_correctness_energyNorm'
    yield test, energyNorm(x, A), sqrt(2)
예제 #2
0
def test_norm_correctness():
    from math import sqrt
    from proteus.LinearAlgebraTools import Mat
    from proteus.LinearAlgebraTools import l2Norm, l1Norm, lInfNorm, rmsNorm
    from proteus.LinearAlgebraTools import wl2Norm, wl1Norm, wlInfNorm
    from proteus.LinearAlgebraTools import energyNorm

    x = np.ones(2)
    h = np.ones(2)
    A = Mat(2, 2)
    A[0, 0] = 1
    A[1, 1] = 1

    assert l1Norm(x) == 2
    assert l2Norm(x) == sqrt(2)
    assert lInfNorm(x) == 1
    assert rmsNorm(x) == 1
    assert wl1Norm(x, h) == 2
    assert wl2Norm(x, h) == sqrt(2)
    assert wlInfNorm(x, h) == 1
    assert energyNorm(x, A) == sqrt(2)
예제 #3
0
def test_norm_correctness():
    from math import sqrt
    from proteus.LinearAlgebraTools import Mat
    from proteus.LinearAlgebraTools import l2Norm, l1Norm, lInfNorm, rmsNorm
    from proteus.LinearAlgebraTools import wl2Norm, wl1Norm, wlInfNorm
    from proteus.LinearAlgebraTools import energyNorm

    x = np.ones(2)
    h = np.ones(2)
    A = Mat(2, 2)
    A[0, 0] = 1
    A[1, 1] = 1

    assert l1Norm(x)==2
    assert l2Norm(x)==sqrt(2)
    assert lInfNorm(x)==1
    assert rmsNorm(x)==1
    assert wl1Norm(x,h)==2
    assert wl2Norm(x,h)==sqrt(2)
    assert wlInfNorm(x,h)==1
    assert energyNorm(x,A)==sqrt(2)
def test_norm_correctness():
    from math import sqrt
    from proteus.LinearAlgebraTools import Mat
    from proteus.LinearAlgebraTools import l2Norm, l1Norm, lInfNorm, rmsNorm
    from proteus.LinearAlgebraTools import wl2Norm, wl1Norm, wlInfNorm
    from proteus.LinearAlgebraTools import energyNorm

    x = np.ones(2)
    h = np.ones(2)
    A = Mat(2, 2)
    A[0, 0] = 1
    A[1, 1] = 1

    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_l1Norm'
    yield test, l1Norm(x), 2
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_l2Norm'
    yield test, l2Norm(x), sqrt(2)
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_lInfNorm'
    yield test, lInfNorm(x), 1
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_rmsNorm'
    yield test, rmsNorm(x), 1
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_wl1Norm'
    yield test, wl1Norm(x, h), 2
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_wl2Norm'
    yield test, wl2Norm(x, h), sqrt(2)
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_wlInfNorm'
    yield test, wlInfNorm(x, h), 1
    test = lambda a,b: npt.assert_almost_equal(a,b)
    test.description = 'test_correctness_energyNorm'
    yield test, energyNorm(x, A), sqrt(2)