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)
def compute_norms(h, A, vecs): from proteus.LinearAlgebraTools import l2Norm, l1Norm, lInfNorm, rmsNorm from proteus.LinearAlgebraTools import wl2Norm, wl1Norm, wlInfNorm from proteus.LinearAlgebraTools import energyNorm for norm in [l2Norm, l1Norm, lInfNorm, rmsNorm]: yield norm.__name__, [norm(x) for x in vecs] for norm in [wl2Norm, wl1Norm, wlInfNorm]: yield norm.__name__, [norm(x, h) for x in vecs] for norm in [energyNorm]: yield norm.__name__, [energyNorm(x, A) for x in vecs]
def compute_norms(h,A,vecs): from proteus.LinearAlgebraTools import l2Norm, l1Norm, lInfNorm, rmsNorm from proteus.LinearAlgebraTools import wl2Norm, wl1Norm, wlInfNorm from proteus.LinearAlgebraTools import energyNorm for norm in [l2Norm, l1Norm, lInfNorm, rmsNorm]: yield norm.__name__, [norm(x) for x in vecs] for norm in [wl2Norm, wl1Norm, wlInfNorm]: yield norm.__name__, [norm(x, h) for x in vecs] for norm in [energyNorm]: yield norm.__name__, [energyNorm(x, A) for x in vecs]
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 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)