def test_functional_left_vector_mult(): r3 = odl.Rn(3) r4 = odl.Rn(4) Aop = SumFunctional(r3) x = r3.element([1, 2, 3]) y = r4.element([3, 2, 1, 5]) # Test a range of scalars (scalar multiplication could implement # optimizations for (-1, 0, 1). C = FunctionalLeftVectorMult(Aop, y) assert C.is_linear assert C.adjoint.is_linear assert all_almost_equal(C(x), y * np.sum(x)) assert all_almost_equal(C.adjoint(y), y.inner(y) * np.ones(3)) assert all_almost_equal(C.adjoint.adjoint(x), C(x)) # Using operator overloading assert all_almost_equal((y * Aop)(x), y * np.sum(x)) assert all_almost_equal((y * Aop).adjoint(y), y.inner(y) * np.ones(3))