def check_elements(shapein):
    N = criterions.Norm2()
    I = pyoperators.IdentityOperator(shapein=shapein)
    C0 = criterions.CriterionElement(N, I)
    assert C0(np.ones(shapein)) == np.prod(shapein)
def check_dnorm2_mul(a, value):
    N = criterions.Norm2()
    N2 = a * N
    vec = value * np.ones(1)
    testing.assert_array_equal(a * N.diff(vec), N2.diff(vec))
def check_dnorm2(size, value):
    N = criterions.Norm2()
    testing.assert_array_equal(N.diff(value * np.ones(size)),
                               2 * value * np.ones(size))
def check_norm2_mul(a, value):
    N = criterions.Norm2()
    N2 = a * N
    vec = value * np.ones(1)
    assert a * N(vec) == N2(vec)
def check_norm2(size, value):
    N = criterions.Norm2()
    assert N(value * np.ones(size)) == size * value**2