def _addition_invariance(self):
        """Verify ``A(x+y) = A(x) + A(y)``."""
        with FailCounter(
                test_name='Verifying distributivity under vector addition',
                err_msg='error = ||A(x+y) - A(x) - A(y)|| / '
                        '||A||(||x|| + ||y||)',
                logger=self.log) as counter:
            for [name_x, x], [name_y, y] in samples(self.operator.domain,
                                                    self.operator.domain):
                opx = self.operator(x)
                opy = self.operator(y)
                opxy = self.operator(x + y)

                denom = self.operator_norm * (x.norm() + y.norm())
                error = (0 if denom == 0
                         else (opxy - opx - opy).norm() / denom)

                if error > self.tol:
                    counter.fail('x={:25s} y={:25s} error={:6.5f}'
                                 ''.format(name_x, name_y, error))
def _addition_invariance ( self ) : with FailCounter ( test_name = 'Verifying distributivity under vector addition' , err_msg = 'error = ||A(x+y) - A(x) - A(y)|| / ' '||A||(||x|| + ||y||)' , logger = self . log ) as counter : for [ name_x , x ] , [ name_y , y ] in samples ( self . operator . domain , self . operator . domain ) : opx = self . operator ( x ) opy = self . operator ( y ) opxy = self . operator ( x + y ) denom = self . operator_norm * ( x . norm ( ) + y . norm ( ) ) error = ( 0 if denom == 0 else ( opxy - opx - opy ) . norm ( ) / denom ) if error > self . tol : counter . fail ( 'x={:25s} y={:25s} error={:6.5f}' '' . format ( name_x , name_y , error ) )
Verify ``A(x+y) = A(x) + A(y)``.