def _assert_self_adjoint(self): # Check the diagonal has non-zero imaginary, and the super and subdiagonals # are conjugate. asserts = [] diag_message = ( 'This tridiagonal operator contained non-zero ' 'imaginary values on the diagonal.') off_diag_message = ( 'This tridiagonal operator has non-conjugate ' 'subdiagonal and superdiagonal.') if self.diagonals_format == _MATRIX: asserts += [check_ops.assert_equal( self.diagonals, linalg.adjoint(self.diagonals), message='Matrix was not equal to its adjoint.')] elif self.diagonals_format == _COMPACT: diagonals = ops.convert_to_tensor_v2_with_dispatch(self.diagonals) asserts += [linear_operator_util.assert_zero_imag_part( diagonals[..., 1, :], message=diag_message)] # Roll the subdiagonal so the shifted argument is at the end. subdiag = manip_ops.roll(diagonals[..., 2, :], shift=-1, axis=-1) asserts += [check_ops.assert_equal( math_ops.conj(subdiag[..., :-1]), diagonals[..., 0, :-1], message=off_diag_message)] else: asserts += [linear_operator_util.assert_zero_imag_part( self.diagonals[1], message=diag_message)] subdiag = manip_ops.roll(self.diagonals[2], shift=-1, axis=-1) asserts += [check_ops.assert_equal( math_ops.conj(subdiag[..., :-1]), self.diagonals[0][..., :-1], message=off_diag_message)] return control_flow_ops.group(asserts)
def test_complex_tensor_with_nonzero_imag_raises(self): x = ops.convert_to_tensor([1., 2, 0]) y = ops.convert_to_tensor([1., 2, 0]) z = math_ops.complex(x, y) with self.cached_session(): with self.assertRaisesOpError("ABC123"): linear_operator_util.assert_zero_imag_part(z, message="ABC123").run()
def test_complex_tensor_with_imag_zero_doesnt_raise(self): x = ops.convert_to_tensor([1., 0, 3]) y = ops.convert_to_tensor([0., 0, 0]) z = math_ops.complex(x, y) with self.cached_session(): # Should not raise. linear_operator_util.assert_zero_imag_part(z, message="ABC123").run()
def _assert_self_adjoint(self): # Recall correspondence between symmetry and real transforms. See docstring return linear_operator_util.assert_zero_imag_part( self.spectrum, message= ("Not self-adjoint: The spectrum contained non-zero imaginary part." ))
def test_complex_tensor_with_imag_zero_doesnt_raise(self): x = ops.convert_to_tensor([1., 0, 3]) y = ops.convert_to_tensor([0., 0, 0]) z = math_ops.complex(x, y) # Should not raise. self.evaluate( linear_operator_util.assert_zero_imag_part(z, message="ABC123"))
def _assert_self_adjoint(self): # Recall correspondence between symmetry and real transforms. See docstring return linear_operator_util.assert_zero_imag_part( self.spectrum, message=( "Not self-adjoint: The spectrum contained non-zero imaginary part." ))
def test_real_tensor_doesnt_raise(self): x = ops.convert_to_tensor([0., 2, 3]) with self.cached_session(): # Should not raise. linear_operator_util.assert_zero_imag_part(x, message="ABC123").run()
def test_real_tensor_doesnt_raise(self): x = ops.convert_to_tensor([0., 2, 3]) with self.cached_session(): # Should not raise. linear_operator_util.assert_zero_imag_part(x, message="ABC123").run()
def _assert_self_adjoint(self): return linear_operator_util.assert_zero_imag_part( self._diag, message=( "This diagonal operator contained non-zero imaginary values. " " Thus it was not self-adjoint."))
def _assert_self_adjoint(self): return linear_operator_util.assert_zero_imag_part( self._diag, message=( "This diagonal operator contained non-zero imaginary values. " " Thus it was not self-adjoint."))
def test_real_tensor_doesnt_raise(self): x = ops.convert_to_tensor([0., 2, 3]) # Should not raise. self.evaluate( linear_operator_util.assert_zero_imag_part(x, message="ABC123"))